diff options
Diffstat (limited to 'app/discover/fetchers/cli/cli_fetch_host_vservice.py')
-rw-r--r-- | app/discover/fetchers/cli/cli_fetch_host_vservice.py | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/app/discover/fetchers/cli/cli_fetch_host_vservice.py b/app/discover/fetchers/cli/cli_fetch_host_vservice.py index 9f8173f..ae7c656 100644 --- a/app/discover/fetchers/cli/cli_fetch_host_vservice.py +++ b/app/discover/fetchers/cli/cli_fetch_host_vservice.py @@ -31,35 +31,37 @@ class CliFetchHostVservice(CliAccess, DbAccess): def set_details(self, host_id, r): # keep the index without prefix id_full = r["local_service_id"].strip() - prefix = id_full[1:id_full.index('-')] - id_clean = id_full[id_full.index('-') + 1:] - r["service_type"] = prefix - name = self.get_router_name(r, id_clean) if prefix == "router" \ + prefix = id_full[:id_full.index('-')] + id_clean = id_full[len(prefix)+1:] + r["service_type"] = prefix[1:] + name = self.get_router_name(r, id_clean) \ + if r["service_type"] == "router" \ else self.get_network_name(id_clean) r["name"] = prefix + "-" + name r["host"] = host_id - r["id"] = host_id + "-" + id_full + r["id"] = "{}-{}".format(host_id, id_full) self.set_agent_type(r) - def get_network_name(self, id): + def get_network_name(self, network_id): query = """ SELECT name FROM {}.networks WHERE id = %s """.format(self.neutron_db) - results = self.get_objects_list_for_id(query, "router", id) + results = self.get_objects_list_for_id(query, "router", network_id) if not list(results): - return id + return network_id for db_row in results: return db_row["name"] - def get_router_name(self, r, id): + def get_router_name(self, r, router_id): query = """ SELECT * FROM {}.routers WHERE id = %s """.format(self.neutron_db) - results = self.get_objects_list_for_id(query, "router", id.strip()) + results = self.get_objects_list_for_id(query, "router", + router_id.strip()) for db_row in results: r.update(db_row) return r["name"] |