X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=installers%2Fcharm%2Fng-ui%2Fsrc%2Fcharm.py;h=6f5ca5b50d8f137c0d8070887f1817d9bb17f7d8;hb=0fc2ee1ada11d0608d5890ef6012e5cd27672ab1;hp=ce48927ad1e13b747df90ee7ccfe665daefededa;hpb=838e3fd080fe021ea96e855455d41a5cedd8c62d;p=osm%2Fdevops.git diff --git a/installers/charm/ng-ui/src/charm.py b/installers/charm/ng-ui/src/charm.py index ce48927a..6f5ca5b5 100755 --- a/installers/charm/ng-ui/src/charm.py +++ b/installers/charm/ng-ui/src/charm.py @@ -13,11 +13,12 @@ # See the License for the specific language governing permissions and # limitations under the License. -import sys -import logging import base64 - -sys.path.append("lib") +from glob import glob +import logging +from pathlib import Path +from string import Template +import sys from ops.charm import CharmBase from ops.framework import StoredState, Object @@ -30,9 +31,6 @@ from ops.model import ( WaitingStatus, ) -from glob import glob -from pathlib import Path -from string import Template logger = logging.getLogger(__name__) @@ -129,7 +127,11 @@ class NGUICharm(CharmBase): ] port = config["https_port"] if ssl_enabled else config["port"] ports = [ - {"name": "port", "containerPort": port, "protocol": "TCP", }, + { + "name": "port", + "containerPort": port, + "protocol": "TCP", + }, ] kubernetes = { @@ -157,13 +159,19 @@ class NGUICharm(CharmBase): }, } ) + logger.debug(files) + spec = { "version": 2, "containers": [ { "name": self.framework.model.app.name, - "image": "{}".format(config["image"]), + "imageDetails": { + "imagePath": config["image"], + "username": config["image_username"], + "password": config["image_password"], + }, "ports": ports, "kubernetes": kubernetes, "files": files, @@ -188,11 +196,12 @@ class NGUICharm(CharmBase): self.on_start(event) def on_nbi_relation_changed(self, event): - unit = self.model.unit - if not unit.is_leader(): - return - self.state.nbi_host = event.relation.data[event.unit].get("host") - self.state.nbi_port = event.relation.data[event.unit].get("port") + nbi_host = event.relation.data[event.unit].get("host") + nbi_port = event.relation.data[event.unit].get("port") + if nbi_host and self.state.nbi_host != nbi_host: + self.state.nbi_host = nbi_host + if nbi_port and self.state.nbi_port != nbi_port: + self.state.nbi_port = nbi_port self._apply_spec()