diff --git a/cdb2api/cdb2api.c b/cdb2api/cdb2api.c index 2c2edecc6d..af95213c53 100644 --- a/cdb2api/cdb2api.c +++ b/cdb2api/cdb2api.c @@ -1664,13 +1664,12 @@ static int read_available_comdb2db_configs(cdb2_hndl_tp *hndl, char comdb2db_hos return 0; } -int cdb2_get_comdb2db(char **comdb2dbname, char **default_type) +int cdb2_get_comdb2db(char **comdb2dbname) { if (!strlen(cdb2_comdb2dbname)) { read_available_comdb2db_configs(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 0); } (*comdb2dbname) = strdup(cdb2_comdb2dbname); - (*default_type) = strdup(cdb2_default_cluster); return 0; } @@ -1687,8 +1686,7 @@ static int get_host_by_name(const char *comdb2db_name, char comdb2db_hosts[][CDB if (cdb2_default_cluster[0] == '\0') { snprintf(dns_name, sizeof(dns_name), "%s.%s", comdb2db_name, cdb2_dnssuffix); } else { - snprintf(dns_name, sizeof(dns_name), "%s-%s.%s", cdb2_default_cluster, comdb2db_name, - cdb2_dnssuffix); + snprintf(dns_name, sizeof(dns_name), "%s-%s.%s", cdb2_default_cluster, comdb2db_name, cdb2_dnssuffix); } #ifdef __APPLE__ hp = gethostbyname(dns_name); diff --git a/cdb2api/cdb2api.h b/cdb2api/cdb2api.h index e5322ce19e..a7edb0062a 100644 --- a/cdb2api/cdb2api.h +++ b/cdb2api/cdb2api.h @@ -200,7 +200,7 @@ typedef struct cdb2_effects_type effects_tp; void cdb2_set_comdb2db_config(const char *cfg_file); void cdb2_set_comdb2db_info(const char *cfg_info); -int cdb2_get_comdb2db(char **comdb2db_name, char **default_type); +int cdb2_get_comdb2db(char **comdb2db_name); int cdb2_open(cdb2_hndl_tp **hndl, const char *dbname, const char *type, int flags); diff --git a/db/phys_rep.c b/db/phys_rep.c index cf00ba7a20..e8a1e65c83 100644 --- a/db/phys_rep.c +++ b/db/phys_rep.c @@ -210,29 +210,20 @@ static int append_quoted_source_hosts(char *buf, int buf_len, int *rc) { static char *comdb2dbname = NULL; if (!comdb2dbname) { - cdb2_get_comdb2db(&comdb2dbname, &comdb2dbclass); - } - - // Also fix the 'source tier' in case it is one of the following - if ((strncasecmp(gbl_physrep_source_host, "test", 4) == 0) || - (strncasecmp(gbl_physrep_source_host, "dev", 3) == 0) || - (strncasecmp(gbl_physrep_source_host, "fuzz", 4) == 0)) { - // test is dev - gbl_physrep_source_host = (strncasecmp(gbl_physrep_source_host, "fuzz", 4) == 0) ? "fuzz" : "dev"; + cdb2_get_comdb2db(&comdb2dbname); + comdb2dbclass = (strcmp(comdb2dbname, "comdb3db") == 0) ? "dev" : "prod"; } *rc = cdb2_open(&comdb2db, comdb2dbname, comdb2dbclass, 0); if (*rc) { - physrep_logmsg(LOGMSG_ERROR, "%s:%d Failed to connect to %s@%s (err: %s rc: %d)\n", - __func__, __LINE__, comdb2dbname, comdb2dbclass, - cdb2_errstr(comdb2db), *rc); + physrep_logmsg(LOGMSG_ERROR, "%s:%d Failed to connect to %s@%s (err: %s rc: %d)\n", __func__, __LINE__, + comdb2dbname, comdb2dbclass, cdb2_errstr(comdb2db), *rc); goto err; } *rc = cdb2_bind_param(comdb2db, "dbname", CDB2_CSTRING, gbl_physrep_source_dbname, strlen(gbl_physrep_source_dbname)); if (*rc) { - physrep_logmsg(LOGMSG_ERROR, "%s:%d Failed to bind dbname (rc: %d)\n", - __func__, __LINE__, *rc); + physrep_logmsg(LOGMSG_ERROR, "%s:%d Failed to bind dbname (rc: %d)\n", __func__, __LINE__, *rc); goto err; }