Merge ~lihuiguo/charm-homer-dashboard:bug/1975562 into charm-homer-dashboard:master

Proposed by Linda Guo
Status: Merged
Approved by: Alvaro Uria
Approved revision: 4541489ba449118772128b2a53673537c6a155cd
Merged at revision: 48bda7508c1796108fb096265f36803e5880df7d
Proposed branch: ~lihuiguo/charm-homer-dashboard:bug/1975562
Merge into: charm-homer-dashboard:master
Diff against target: 61 lines (+9/-6)
1 file modified
src/charm.py (+9/-6)
Reviewer Review Type Date Requested Status
Alvaro Uria (community) Approve
prod-jenkaas-bootstack (community) continuous-integration Approve
BootStack Reviewers Pending
Review via email: mp+423521@code.launchpad.net

Commit message

allow multiple source models with same applications name , for example, multiple LMA models have graylog, nagios, etc. belongs to different group to be added to homer-dashboard

To post a comment you must log in.
Revision history for this message
prod-jenkaas-bootstack (prod-jenkaas-bootstack) wrote :

A CI job is currently in progress. A follow up comment will be added when it completes.

Revision history for this message
Canonical IS Merge Bot (canonical-is-mergebot) wrote :

This merge proposal is being monitored by mergebot. Change the status to Approved to merge.

Revision history for this message
prod-jenkaas-bootstack (prod-jenkaas-bootstack) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
prod-jenkaas-bootstack (prod-jenkaas-bootstack) wrote :

A CI job is currently in progress. A follow up comment will be added when it completes.

Revision history for this message
prod-jenkaas-bootstack (prod-jenkaas-bootstack) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
prod-jenkaas-bootstack (prod-jenkaas-bootstack) wrote :

A CI job is currently in progress. A follow up comment will be added when it completes.

Revision history for this message
prod-jenkaas-bootstack (prod-jenkaas-bootstack) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
prod-jenkaas-bootstack (prod-jenkaas-bootstack) wrote :

A CI job is currently in progress. A follow up comment will be added when it completes.

Revision history for this message
prod-jenkaas-bootstack (prod-jenkaas-bootstack) wrote :
review: Approve (continuous-integration)
Revision history for this message
Alvaro Uria (aluria) wrote :

+1

review: Approve
Revision history for this message
Canonical IS Merge Bot (canonical-is-mergebot) wrote :

Change successfully merged at revision 48bda7508c1796108fb096265f36803e5880df7d

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/src/charm.py b/src/charm.py
2index 478a7f9..87faa3a 100755
3--- a/src/charm.py
4+++ b/src/charm.py
5@@ -77,7 +77,7 @@ class HomerDashboardCharm(CharmBase):
6 with open(icon_filename, "w") as f:
7 f.write(icon_data)
8 logger.info("name: {}, url: {}, rel_id: {}".format(name, url, rel_id))
9- if name and url and rel_id:
10+ if name and url:
11 self._add_application_in_homer(
12 name, url, rel_id=rel_id, subtitle=subtitle, icon=icon, group=group
13 )
14@@ -87,7 +87,7 @@ class HomerDashboardCharm(CharmBase):
15 """Application dashboard departed, delete it from dashboard."""
16 self.unit.status = MaintenanceStatus("Removing service from dashboard")
17 rel_id = event.relation.id
18- if rel_id:
19+ if rel_id is not None:
20 self._delete_application_from_homer(rel_id=rel_id)
21 self.unit.status = ActiveStatus()
22
23@@ -142,7 +142,7 @@ class HomerDashboardCharm(CharmBase):
24 to_add_sites = new_sites - old_sites
25 for site in to_del_sites:
26 name, url, group = site.split("|")
27- self._delete_application_from_homer(name)
28+ self._delete_application_from_homer(name=name, group=group)
29 for site in to_add_sites:
30 name, url, group = site.split("|")
31 self._add_application_in_homer(name, url, group=group)
32@@ -196,7 +196,7 @@ class HomerDashboardCharm(CharmBase):
33 "relation_id": rel_id,
34 }
35 # delete the app from homer config file if it exists.
36- self._delete_application_from_homer(name, rel_id)
37+ self._delete_application_from_homer(name=name, rel_id=rel_id, group=group)
38
39 # then add the app with updated info to homer config file
40 with open(HOMER_CONFIG, "r") as yaml_rfd:
41@@ -233,7 +233,7 @@ class HomerDashboardCharm(CharmBase):
42 yaml_data["services"] = groups
43 self._save_homer_config(yaml_data)
44
45- def _delete_application_from_homer(self, name=None, rel_id=None):
46+ def _delete_application_from_homer(self, name=None, rel_id=None, group=None):
47 """Delete application from Homer dashboard."""
48 with open(HOMER_CONFIG, "r") as yaml_rfd:
49 yaml_data = yaml.safe_load(yaml_rfd)
50@@ -243,7 +243,10 @@ class HomerDashboardCharm(CharmBase):
51 svc[i]["items"] = [
52 item
53 for item in svc[i]["items"]
54- if (rel_id and item.get("relation_id") != rel_id)
55+ if (group and svc[i]["name"] != group)
56+ or ( # noqa: W503
57+ rel_id is not None and item.get("relation_id") != rel_id
58+ )
59 or (name and item.get("name") != name) # noqa: W503
60 ]
61 self._save_homer_config(yaml_data)

Subscribers

People subscribed via source and target branches

to all changes: