From 5c18c44c42604bc903d3bdd13ee702a176200376 Mon Sep 17 00:00:00 2001 From: James Struga Date: Fri, 16 Aug 2024 10:41:14 -0400 Subject: [PATCH] Add missing logic in staging Signed-off-by: James Struga --- manifest.yaml | 2 +- src/main.c | 76 ++++++++++++++++++++++++++++++++++++++++----------- 2 files changed, 61 insertions(+), 17 deletions(-) diff --git a/manifest.yaml b/manifest.yaml index 1a87549..d139705 100644 --- a/manifest.yaml +++ b/manifest.yaml @@ -5,7 +5,7 @@ name: launcher # Component identifier. This identifier matches artifact path in Zowe Artifactory https://zowe.jfrog.io/. id: org.zowe.launcher # Component version -version: 2.19.0 +version: 2.18.0 # Human readable component name title: Zowe Launcher # Human readable component description diff --git a/src/main.c b/src/main.c index 11e37c5..65b3736 100644 --- a/src/main.c +++ b/src/main.c @@ -1575,41 +1575,85 @@ static int get_component_list(char *buf, size_t buf_size,ConfigManager *configmg bool enabled; bool wasMissing = false; + bool checkHaSection = false; + + Json *haInstancesJson = NULL; + int getStatus = cfgGetAnyC(configmgr, ZOWE_CONFIG_NAME, &haInstancesJson, 1, "haInstances"); + if (!getStatus) { + if ((!strcmp(zl_context.ha_instance_id, "__ha_instance_id__")) || (!strcmp(zl_context.ha_instance_id, "{{ha_instance_id}}"))) { + int rc = 0; + int rsn = 0; + char *resolvedName = resolveSymbol("&SYSNAME", &rc, &rsn); + if (!rc) { + //ha instance name is always lowercase if derived from sysname automatically. + int nameLength = strlen(resolvedName); + for(int i = 0; i < nameLength; i++){ + resolvedName[i] = tolower(resolvedName[i]); + } + + // Resolves ha instance id for downstream as well. + snprintf(zl_context.ha_instance_id, 8+1, "%s", resolvedName); + checkHaSection = true; + } else { + ERROR("Could not resolve SYSNAME for HA instance lookup, rc=0x%x, rsn=0x%x\n", rc, rsn); + } + } else { + checkHaSection = true; + } + } + DEBUG("about to get component list\n"); int rc = cfgGetAnyC(configmgr, ZOWE_CONFIG_NAME, &result, 1, "components"); if (jsonIsObject(result)) { JsonObject *resultObj = jsonAsObject(result); JsonProperty *prop = resultObj->firstProperty; - int getStatus = cfgGetStringC(configmgr, ZOWE_CONFIG_NAME, &runtimeDirectory, 2, "zowe", "runtimeDirectory"); - if (getStatus) { + getStatus = cfgGetStringC(configmgr, ZOWE_CONFIG_NAME, &runtimeDirectory, 2, "zowe", "runtimeDirectory"); + if (!getStatus) { getStatus = cfgGetStringC(configmgr, ZOWE_CONFIG_NAME, &extensionDirectory, 2, "zowe", "extensionDirectory"); if (getStatus) { - ERROR(" failed to get runtimeDirectory and extensionDirectory"); + ERROR("failed to get extensionDirectory\n"); return -1; } + } else { + ERROR("failed to get runtimeDirectory\n"); + return -1; } + + while (prop!=NULL) { enabled = false; // check if component is enabled - getStatus = cfgGetBooleanC(configmgr, ZOWE_CONFIG_NAME, &enabled,3, "components", prop->key, "enabled"); + if (checkHaSection) { + getStatus = cfgGetBooleanC(configmgr, ZOWE_CONFIG_NAME, &enabled, 5, "haInstances", zl_context.ha_instance_id, "components", prop->key, "enabled"); + if (getStatus) { + getStatus = cfgGetBooleanC(configmgr, ZOWE_CONFIG_NAME, &enabled,3, "components", prop->key, "enabled"); + } + } else { + getStatus = cfgGetBooleanC(configmgr, ZOWE_CONFIG_NAME, &enabled,3, "components", prop->key, "enabled"); + } + if (getStatus) { // failed to get enabled value of the component DEBUG("failed to get enabled value of the component %s\n", prop->key); prop = prop->next; continue; } - snprintf(manifestPath, PATH_MAX, "%s/components/%s/manifest.yaml", runtimeDirectory, prop->key); - DEBUG("manifest path for component %s is %s\n", prop->key, manifestPath); - - // check if manifest.yaml is in instance/components/component-name/manifest.yaml - yamlExists = true; - if (check_if_yaml_exists(manifestPath, "MANIFEST.YAML")) { - yamlExists = false; - // if not check instance/extensions/component/manifest.yaml - snprintf(manifestPath, PATH_MAX, "%s/components/%s/manifest.yaml", extensionDirectory, prop->key); + + yamlExists = true; //unused if not enabled. otherwise set to false if not found. + if (enabled) { + snprintf(manifestPath, PATH_MAX, "%s/components/%s/manifest.yaml", runtimeDirectory, prop->key); DEBUG("manifest path for component %s is %s\n", prop->key, manifestPath); - if(!check_if_yaml_exists(manifestPath, "MANIFEST.YAML")) - yamlExists = true; + + // check if manifest.yaml is in /components//manifest.yaml + if (check_if_yaml_exists(manifestPath, "MANIFEST.YAML")) { + yamlExists = false; + // if not check //manifest.yaml + snprintf(manifestPath, PATH_MAX, "%s/%s/manifest.yaml", extensionDirectory, prop->key); + DEBUG("manifest path for component %s is %s\n", prop->key, manifestPath); + if(!check_if_yaml_exists(manifestPath, "MANIFEST.YAML")) { + yamlExists = true; + } + } } // read the yaml and check for item 'commands.start', if present then add enabled component to component list @@ -1946,4 +1990,4 @@ int main(int argc, char **argv) { SPDX-License-Identifier: EPL-2.0 Copyright Contributors to the Zowe Project. -*/ +*/ \ No newline at end of file