From 354ca211482bd96656590e4ce2bfb307421b2090 Mon Sep 17 00:00:00 2001 From: aticig Date: Wed, 24 Aug 2022 01:27:39 +0300 Subject: [PATCH] Fixing hostpaths of RO side car charm, updating osm_lib library. Updating osm_libs charm library and update the new version of library in osm sidecar charms. Change-Id: If3e526af823d0862e45513bd77dfdae1ef3e2398 Signed-off-by: aticig --- .../charmcraft.yaml | 4 +- .../lib/charms/osm_libs/v0/utils.py | 57 +++++++++++++----- installers/charm/osm-lcm/charmcraft.yaml | 4 +- .../osm-lcm/lib/charms/osm_libs/v0/utils.py | 58 +++++++++++++----- installers/charm/osm-mon/charmcraft.yaml | 6 +- .../osm-mon/lib/charms/osm_libs/v0/utils.py | 57 +++++++++++++----- installers/charm/osm-nbi/charmcraft.yaml | 6 +- .../osm-nbi/lib/charms/osm_libs/v0/utils.py | 57 +++++++++++++----- installers/charm/osm-ng-ui/charmcraft.yaml | 4 +- .../osm-ng-ui/lib/charms/osm_libs/v0/utils.py | 59 ++++++++++++++----- installers/charm/osm-pol/charmcraft.yaml | 2 +- .../osm-pol/lib/charms/osm_libs/v0/utils.py | 57 +++++++++++++----- installers/charm/osm-ro/charmcraft.yaml | 4 +- .../osm-ro/lib/charms/osm_libs/v0/utils.py | 57 +++++++++++++----- installers/charm/osm-ro/src/charm.py | 21 ++++++- installers/charm/osm-ro/tox.ini | 4 +- .../vca-integrator-operator/charmcraft.yaml | 4 +- 17 files changed, 334 insertions(+), 127 deletions(-) diff --git a/installers/charm/juju-simplestreams-operator/charmcraft.yaml b/installers/charm/juju-simplestreams-operator/charmcraft.yaml index eaab6bb1..05960ce4 100644 --- a/installers/charm/juju-simplestreams-operator/charmcraft.yaml +++ b/installers/charm/juju-simplestreams-operator/charmcraft.yaml @@ -30,5 +30,5 @@ bases: parts: charm: - prime: - - files/* \ No newline at end of file + prime: + - files/* diff --git a/installers/charm/juju-simplestreams-operator/lib/charms/osm_libs/v0/utils.py b/installers/charm/juju-simplestreams-operator/lib/charms/osm_libs/v0/utils.py index b7009c4b..df3da94e 100644 --- a/installers/charm/juju-simplestreams-operator/lib/charms/osm_libs/v0/utils.py +++ b/installers/charm/juju-simplestreams-operator/lib/charms/osm_libs/v0/utils.py @@ -107,6 +107,7 @@ class MyCharm(CharmBase): - Get pod IP with `get_pod_ip()` """ +from dataclasses import dataclass import logging import secrets import socket @@ -136,7 +137,7 @@ LIBAPI = 0 # Increment this PATCH version before using `charmcraft publish-lib` or reset # to 0 if you are raising the major API version -LIBPATCH = 2 +LIBPATCH = 3 logger = logging.getLogger(__name__) @@ -231,17 +232,30 @@ wait """ +@dataclass +class SubModule: + """Represent RO Submodules.""" + sub_module_path: str + container_path: str + + class HostPath: """Represents a hostpath.""" - - def __init__(self, config: str, container_path: str) -> None: + def __init__(self, config: str, container_path: str, submodules: dict = None) -> None: mount_path_items = config.split("-") mount_path_items.reverse() self.mount_path = "/" + "/".join(mount_path_items) self.config = config - self.container_path = container_path - self.module_name = container_path.split("/")[-1] - + self.sub_module_dict = {} + if submodules: + for submodule in submodules.keys(): + self.sub_module_dict[submodule] = SubModule( + sub_module_path=self.mount_path + "/" + submodule, + container_path=submodules[submodule], + ) + else: + self.container_path = container_path + self.module_name = container_path.split("/")[-1] class DebugMode(Object): """Class to handle the debug-mode.""" @@ -416,15 +430,28 @@ class DebugMode(Object): # Add symlinks to mounted hostpaths for hostpath in mounted_hostpaths: logger.debug(f"adding symlink for {hostpath.config}") - self.container.exec(["rm", "-rf", hostpath.container_path]).wait_output() - self.container.exec( - [ - "ln", - "-s", - f"{hostpath.mount_path}/{hostpath.module_name}", - hostpath.container_path, - ] - ) + if len(hostpath.sub_module_dict) > 0: + for sub_module in hostpath.sub_module_dict.keys(): + self.container.exec(["rm", "-rf", hostpath.sub_module_dict[sub_module].container_path]).wait_output() + self.container.exec( + [ + "ln", + "-s", + hostpath.sub_module_dict[sub_module].sub_module_path, + hostpath.sub_module_dict[sub_module].container_path, + ] + ) + + else: + self.container.exec(["rm", "-rf", hostpath.container_path]).wait_output() + self.container.exec( + [ + "ln", + "-s", + f"{hostpath.mount_path}/{hostpath.module_name}", + hostpath.container_path, + ] + ) def _configure_hostpaths(self, hostpaths: List[HostPath]): client = Client() diff --git a/installers/charm/osm-lcm/charmcraft.yaml b/installers/charm/osm-lcm/charmcraft.yaml index 2932e584..f5e3ff37 100644 --- a/installers/charm/osm-lcm/charmcraft.yaml +++ b/installers/charm/osm-lcm/charmcraft.yaml @@ -32,5 +32,5 @@ parts: charm: # build-packages: # - git - prime: - - files/* \ No newline at end of file + prime: + - files/* diff --git a/installers/charm/osm-lcm/lib/charms/osm_libs/v0/utils.py b/installers/charm/osm-lcm/lib/charms/osm_libs/v0/utils.py index e686f824..df3da94e 100644 --- a/installers/charm/osm-lcm/lib/charms/osm_libs/v0/utils.py +++ b/installers/charm/osm-lcm/lib/charms/osm_libs/v0/utils.py @@ -107,7 +107,7 @@ class MyCharm(CharmBase): - Get pod IP with `get_pod_ip()` """ - +from dataclasses import dataclass import logging import secrets import socket @@ -137,7 +137,7 @@ LIBAPI = 0 # Increment this PATCH version before using `charmcraft publish-lib` or reset # to 0 if you are raising the major API version -LIBPATCH = 2 +LIBPATCH = 3 logger = logging.getLogger(__name__) @@ -232,17 +232,30 @@ wait """ +@dataclass +class SubModule: + """Represent RO Submodules.""" + sub_module_path: str + container_path: str + + class HostPath: """Represents a hostpath.""" - - def __init__(self, config: str, container_path: str) -> None: + def __init__(self, config: str, container_path: str, submodules: dict = None) -> None: mount_path_items = config.split("-") mount_path_items.reverse() self.mount_path = "/" + "/".join(mount_path_items) self.config = config - self.container_path = container_path - self.module_name = container_path.split("/")[-1] - + self.sub_module_dict = {} + if submodules: + for submodule in submodules.keys(): + self.sub_module_dict[submodule] = SubModule( + sub_module_path=self.mount_path + "/" + submodule, + container_path=submodules[submodule], + ) + else: + self.container_path = container_path + self.module_name = container_path.split("/")[-1] class DebugMode(Object): """Class to handle the debug-mode.""" @@ -417,15 +430,28 @@ class DebugMode(Object): # Add symlinks to mounted hostpaths for hostpath in mounted_hostpaths: logger.debug(f"adding symlink for {hostpath.config}") - self.container.exec(["rm", "-rf", hostpath.container_path]).wait_output() - self.container.exec( - [ - "ln", - "-s", - f"{hostpath.mount_path}/{hostpath.module_name}", - hostpath.container_path, - ] - ) + if len(hostpath.sub_module_dict) > 0: + for sub_module in hostpath.sub_module_dict.keys(): + self.container.exec(["rm", "-rf", hostpath.sub_module_dict[sub_module].container_path]).wait_output() + self.container.exec( + [ + "ln", + "-s", + hostpath.sub_module_dict[sub_module].sub_module_path, + hostpath.sub_module_dict[sub_module].container_path, + ] + ) + + else: + self.container.exec(["rm", "-rf", hostpath.container_path]).wait_output() + self.container.exec( + [ + "ln", + "-s", + f"{hostpath.mount_path}/{hostpath.module_name}", + hostpath.container_path, + ] + ) def _configure_hostpaths(self, hostpaths: List[HostPath]): client = Client() diff --git a/installers/charm/osm-mon/charmcraft.yaml b/installers/charm/osm-mon/charmcraft.yaml index e13cdaf1..f5e3ff37 100644 --- a/installers/charm/osm-mon/charmcraft.yaml +++ b/installers/charm/osm-mon/charmcraft.yaml @@ -23,14 +23,14 @@ type: charm bases: - build-on: - name: "ubuntu" - channel: "20.04" + channel: "22.04" run-on: - name: "ubuntu" - channel: "20.04" + channel: "22.04" parts: charm: # build-packages: # - git prime: - - files/* \ No newline at end of file + - files/* diff --git a/installers/charm/osm-mon/lib/charms/osm_libs/v0/utils.py b/installers/charm/osm-mon/lib/charms/osm_libs/v0/utils.py index b7009c4b..df3da94e 100644 --- a/installers/charm/osm-mon/lib/charms/osm_libs/v0/utils.py +++ b/installers/charm/osm-mon/lib/charms/osm_libs/v0/utils.py @@ -107,6 +107,7 @@ class MyCharm(CharmBase): - Get pod IP with `get_pod_ip()` """ +from dataclasses import dataclass import logging import secrets import socket @@ -136,7 +137,7 @@ LIBAPI = 0 # Increment this PATCH version before using `charmcraft publish-lib` or reset # to 0 if you are raising the major API version -LIBPATCH = 2 +LIBPATCH = 3 logger = logging.getLogger(__name__) @@ -231,17 +232,30 @@ wait """ +@dataclass +class SubModule: + """Represent RO Submodules.""" + sub_module_path: str + container_path: str + + class HostPath: """Represents a hostpath.""" - - def __init__(self, config: str, container_path: str) -> None: + def __init__(self, config: str, container_path: str, submodules: dict = None) -> None: mount_path_items = config.split("-") mount_path_items.reverse() self.mount_path = "/" + "/".join(mount_path_items) self.config = config - self.container_path = container_path - self.module_name = container_path.split("/")[-1] - + self.sub_module_dict = {} + if submodules: + for submodule in submodules.keys(): + self.sub_module_dict[submodule] = SubModule( + sub_module_path=self.mount_path + "/" + submodule, + container_path=submodules[submodule], + ) + else: + self.container_path = container_path + self.module_name = container_path.split("/")[-1] class DebugMode(Object): """Class to handle the debug-mode.""" @@ -416,15 +430,28 @@ class DebugMode(Object): # Add symlinks to mounted hostpaths for hostpath in mounted_hostpaths: logger.debug(f"adding symlink for {hostpath.config}") - self.container.exec(["rm", "-rf", hostpath.container_path]).wait_output() - self.container.exec( - [ - "ln", - "-s", - f"{hostpath.mount_path}/{hostpath.module_name}", - hostpath.container_path, - ] - ) + if len(hostpath.sub_module_dict) > 0: + for sub_module in hostpath.sub_module_dict.keys(): + self.container.exec(["rm", "-rf", hostpath.sub_module_dict[sub_module].container_path]).wait_output() + self.container.exec( + [ + "ln", + "-s", + hostpath.sub_module_dict[sub_module].sub_module_path, + hostpath.sub_module_dict[sub_module].container_path, + ] + ) + + else: + self.container.exec(["rm", "-rf", hostpath.container_path]).wait_output() + self.container.exec( + [ + "ln", + "-s", + f"{hostpath.mount_path}/{hostpath.module_name}", + hostpath.container_path, + ] + ) def _configure_hostpaths(self, hostpaths: List[HostPath]): client = Client() diff --git a/installers/charm/osm-nbi/charmcraft.yaml b/installers/charm/osm-nbi/charmcraft.yaml index aaef73f8..42fb3eca 100644 --- a/installers/charm/osm-nbi/charmcraft.yaml +++ b/installers/charm/osm-nbi/charmcraft.yaml @@ -23,14 +23,14 @@ type: charm bases: - build-on: - name: "ubuntu" - channel: "20.04" + channel: "22.04" run-on: - name: "ubuntu" - channel: "20.04" + channel: "22.04" parts: charm: build-packages: - git - prime: + prime: - files/* \ No newline at end of file diff --git a/installers/charm/osm-nbi/lib/charms/osm_libs/v0/utils.py b/installers/charm/osm-nbi/lib/charms/osm_libs/v0/utils.py index b7009c4b..df3da94e 100644 --- a/installers/charm/osm-nbi/lib/charms/osm_libs/v0/utils.py +++ b/installers/charm/osm-nbi/lib/charms/osm_libs/v0/utils.py @@ -107,6 +107,7 @@ class MyCharm(CharmBase): - Get pod IP with `get_pod_ip()` """ +from dataclasses import dataclass import logging import secrets import socket @@ -136,7 +137,7 @@ LIBAPI = 0 # Increment this PATCH version before using `charmcraft publish-lib` or reset # to 0 if you are raising the major API version -LIBPATCH = 2 +LIBPATCH = 3 logger = logging.getLogger(__name__) @@ -231,17 +232,30 @@ wait """ +@dataclass +class SubModule: + """Represent RO Submodules.""" + sub_module_path: str + container_path: str + + class HostPath: """Represents a hostpath.""" - - def __init__(self, config: str, container_path: str) -> None: + def __init__(self, config: str, container_path: str, submodules: dict = None) -> None: mount_path_items = config.split("-") mount_path_items.reverse() self.mount_path = "/" + "/".join(mount_path_items) self.config = config - self.container_path = container_path - self.module_name = container_path.split("/")[-1] - + self.sub_module_dict = {} + if submodules: + for submodule in submodules.keys(): + self.sub_module_dict[submodule] = SubModule( + sub_module_path=self.mount_path + "/" + submodule, + container_path=submodules[submodule], + ) + else: + self.container_path = container_path + self.module_name = container_path.split("/")[-1] class DebugMode(Object): """Class to handle the debug-mode.""" @@ -416,15 +430,28 @@ class DebugMode(Object): # Add symlinks to mounted hostpaths for hostpath in mounted_hostpaths: logger.debug(f"adding symlink for {hostpath.config}") - self.container.exec(["rm", "-rf", hostpath.container_path]).wait_output() - self.container.exec( - [ - "ln", - "-s", - f"{hostpath.mount_path}/{hostpath.module_name}", - hostpath.container_path, - ] - ) + if len(hostpath.sub_module_dict) > 0: + for sub_module in hostpath.sub_module_dict.keys(): + self.container.exec(["rm", "-rf", hostpath.sub_module_dict[sub_module].container_path]).wait_output() + self.container.exec( + [ + "ln", + "-s", + hostpath.sub_module_dict[sub_module].sub_module_path, + hostpath.sub_module_dict[sub_module].container_path, + ] + ) + + else: + self.container.exec(["rm", "-rf", hostpath.container_path]).wait_output() + self.container.exec( + [ + "ln", + "-s", + f"{hostpath.mount_path}/{hostpath.module_name}", + hostpath.container_path, + ] + ) def _configure_hostpaths(self, hostpaths: List[HostPath]): client = Client() diff --git a/installers/charm/osm-ng-ui/charmcraft.yaml b/installers/charm/osm-ng-ui/charmcraft.yaml index 25ff5906..072529c6 100644 --- a/installers/charm/osm-ng-ui/charmcraft.yaml +++ b/installers/charm/osm-ng-ui/charmcraft.yaml @@ -23,10 +23,10 @@ type: charm bases: - build-on: - name: "ubuntu" - channel: "20.04" + channel: "22.04" run-on: - name: "ubuntu" - channel: "20.04" + channel: "22.04" parts: charm: diff --git a/installers/charm/osm-ng-ui/lib/charms/osm_libs/v0/utils.py b/installers/charm/osm-ng-ui/lib/charms/osm_libs/v0/utils.py index 3feed7d7..df3da94e 100644 --- a/installers/charm/osm-ng-ui/lib/charms/osm_libs/v0/utils.py +++ b/installers/charm/osm-ng-ui/lib/charms/osm_libs/v0/utils.py @@ -107,6 +107,7 @@ class MyCharm(CharmBase): - Get pod IP with `get_pod_ip()` """ +from dataclasses import dataclass import logging import secrets import socket @@ -136,7 +137,7 @@ LIBAPI = 0 # Increment this PATCH version before using `charmcraft publish-lib` or reset # to 0 if you are raising the major API version -LIBPATCH = 1 +LIBPATCH = 3 logger = logging.getLogger(__name__) @@ -231,17 +232,30 @@ wait """ +@dataclass +class SubModule: + """Represent RO Submodules.""" + sub_module_path: str + container_path: str + + class HostPath: """Represents a hostpath.""" - - def __init__(self, config: str, container_path: str) -> None: + def __init__(self, config: str, container_path: str, submodules: dict = None) -> None: mount_path_items = config.split("-") mount_path_items.reverse() self.mount_path = "/" + "/".join(mount_path_items) self.config = config - self.container_path = container_path - self.module_name = container_path.split("/")[-1] - + self.sub_module_dict = {} + if submodules: + for submodule in submodules.keys(): + self.sub_module_dict[submodule] = SubModule( + sub_module_path=self.mount_path + "/" + submodule, + container_path=submodules[submodule], + ) + else: + self.container_path = container_path + self.module_name = container_path.split("/")[-1] class DebugMode(Object): """Class to handle the debug-mode.""" @@ -416,15 +430,28 @@ class DebugMode(Object): # Add symlinks to mounted hostpaths for hostpath in mounted_hostpaths: logger.debug(f"adding symlink for {hostpath.config}") - self.container.exec(["rm", "-rf", hostpath.container_path]).wait_output() - self.container.exec( - [ - "ln", - "-s", - f"{hostpath.mount_path}/{hostpath.module_name}", - hostpath.container_path, - ] - ) + if len(hostpath.sub_module_dict) > 0: + for sub_module in hostpath.sub_module_dict.keys(): + self.container.exec(["rm", "-rf", hostpath.sub_module_dict[sub_module].container_path]).wait_output() + self.container.exec( + [ + "ln", + "-s", + hostpath.sub_module_dict[sub_module].sub_module_path, + hostpath.sub_module_dict[sub_module].container_path, + ] + ) + + else: + self.container.exec(["rm", "-rf", hostpath.container_path]).wait_output() + self.container.exec( + [ + "ln", + "-s", + f"{hostpath.mount_path}/{hostpath.module_name}", + hostpath.container_path, + ] + ) def _configure_hostpaths(self, hostpaths: List[HostPath]): client = Client() @@ -510,7 +537,7 @@ class DebugMode(Object): pod_ip: str, user: str = "root", workspace_path: str = "/debug.code-workspace", - ) -> None: + ) -> str: return f"code --remote ssh-remote+{user}@{pod_ip} {workspace_path}" def _restart(self): diff --git a/installers/charm/osm-pol/charmcraft.yaml b/installers/charm/osm-pol/charmcraft.yaml index 584a8265..f5e3ff37 100644 --- a/installers/charm/osm-pol/charmcraft.yaml +++ b/installers/charm/osm-pol/charmcraft.yaml @@ -32,5 +32,5 @@ parts: charm: # build-packages: # - git - prime: + prime: - files/* diff --git a/installers/charm/osm-pol/lib/charms/osm_libs/v0/utils.py b/installers/charm/osm-pol/lib/charms/osm_libs/v0/utils.py index b7009c4b..df3da94e 100644 --- a/installers/charm/osm-pol/lib/charms/osm_libs/v0/utils.py +++ b/installers/charm/osm-pol/lib/charms/osm_libs/v0/utils.py @@ -107,6 +107,7 @@ class MyCharm(CharmBase): - Get pod IP with `get_pod_ip()` """ +from dataclasses import dataclass import logging import secrets import socket @@ -136,7 +137,7 @@ LIBAPI = 0 # Increment this PATCH version before using `charmcraft publish-lib` or reset # to 0 if you are raising the major API version -LIBPATCH = 2 +LIBPATCH = 3 logger = logging.getLogger(__name__) @@ -231,17 +232,30 @@ wait """ +@dataclass +class SubModule: + """Represent RO Submodules.""" + sub_module_path: str + container_path: str + + class HostPath: """Represents a hostpath.""" - - def __init__(self, config: str, container_path: str) -> None: + def __init__(self, config: str, container_path: str, submodules: dict = None) -> None: mount_path_items = config.split("-") mount_path_items.reverse() self.mount_path = "/" + "/".join(mount_path_items) self.config = config - self.container_path = container_path - self.module_name = container_path.split("/")[-1] - + self.sub_module_dict = {} + if submodules: + for submodule in submodules.keys(): + self.sub_module_dict[submodule] = SubModule( + sub_module_path=self.mount_path + "/" + submodule, + container_path=submodules[submodule], + ) + else: + self.container_path = container_path + self.module_name = container_path.split("/")[-1] class DebugMode(Object): """Class to handle the debug-mode.""" @@ -416,15 +430,28 @@ class DebugMode(Object): # Add symlinks to mounted hostpaths for hostpath in mounted_hostpaths: logger.debug(f"adding symlink for {hostpath.config}") - self.container.exec(["rm", "-rf", hostpath.container_path]).wait_output() - self.container.exec( - [ - "ln", - "-s", - f"{hostpath.mount_path}/{hostpath.module_name}", - hostpath.container_path, - ] - ) + if len(hostpath.sub_module_dict) > 0: + for sub_module in hostpath.sub_module_dict.keys(): + self.container.exec(["rm", "-rf", hostpath.sub_module_dict[sub_module].container_path]).wait_output() + self.container.exec( + [ + "ln", + "-s", + hostpath.sub_module_dict[sub_module].sub_module_path, + hostpath.sub_module_dict[sub_module].container_path, + ] + ) + + else: + self.container.exec(["rm", "-rf", hostpath.container_path]).wait_output() + self.container.exec( + [ + "ln", + "-s", + f"{hostpath.mount_path}/{hostpath.module_name}", + hostpath.container_path, + ] + ) def _configure_hostpaths(self, hostpaths: List[HostPath]): client = Client() diff --git a/installers/charm/osm-ro/charmcraft.yaml b/installers/charm/osm-ro/charmcraft.yaml index 2932e584..f5e3ff37 100644 --- a/installers/charm/osm-ro/charmcraft.yaml +++ b/installers/charm/osm-ro/charmcraft.yaml @@ -32,5 +32,5 @@ parts: charm: # build-packages: # - git - prime: - - files/* \ No newline at end of file + prime: + - files/* diff --git a/installers/charm/osm-ro/lib/charms/osm_libs/v0/utils.py b/installers/charm/osm-ro/lib/charms/osm_libs/v0/utils.py index b7009c4b..df3da94e 100644 --- a/installers/charm/osm-ro/lib/charms/osm_libs/v0/utils.py +++ b/installers/charm/osm-ro/lib/charms/osm_libs/v0/utils.py @@ -107,6 +107,7 @@ class MyCharm(CharmBase): - Get pod IP with `get_pod_ip()` """ +from dataclasses import dataclass import logging import secrets import socket @@ -136,7 +137,7 @@ LIBAPI = 0 # Increment this PATCH version before using `charmcraft publish-lib` or reset # to 0 if you are raising the major API version -LIBPATCH = 2 +LIBPATCH = 3 logger = logging.getLogger(__name__) @@ -231,17 +232,30 @@ wait """ +@dataclass +class SubModule: + """Represent RO Submodules.""" + sub_module_path: str + container_path: str + + class HostPath: """Represents a hostpath.""" - - def __init__(self, config: str, container_path: str) -> None: + def __init__(self, config: str, container_path: str, submodules: dict = None) -> None: mount_path_items = config.split("-") mount_path_items.reverse() self.mount_path = "/" + "/".join(mount_path_items) self.config = config - self.container_path = container_path - self.module_name = container_path.split("/")[-1] - + self.sub_module_dict = {} + if submodules: + for submodule in submodules.keys(): + self.sub_module_dict[submodule] = SubModule( + sub_module_path=self.mount_path + "/" + submodule, + container_path=submodules[submodule], + ) + else: + self.container_path = container_path + self.module_name = container_path.split("/")[-1] class DebugMode(Object): """Class to handle the debug-mode.""" @@ -416,15 +430,28 @@ class DebugMode(Object): # Add symlinks to mounted hostpaths for hostpath in mounted_hostpaths: logger.debug(f"adding symlink for {hostpath.config}") - self.container.exec(["rm", "-rf", hostpath.container_path]).wait_output() - self.container.exec( - [ - "ln", - "-s", - f"{hostpath.mount_path}/{hostpath.module_name}", - hostpath.container_path, - ] - ) + if len(hostpath.sub_module_dict) > 0: + for sub_module in hostpath.sub_module_dict.keys(): + self.container.exec(["rm", "-rf", hostpath.sub_module_dict[sub_module].container_path]).wait_output() + self.container.exec( + [ + "ln", + "-s", + hostpath.sub_module_dict[sub_module].sub_module_path, + hostpath.sub_module_dict[sub_module].container_path, + ] + ) + + else: + self.container.exec(["rm", "-rf", hostpath.container_path]).wait_output() + self.container.exec( + [ + "ln", + "-s", + f"{hostpath.mount_path}/{hostpath.module_name}", + hostpath.container_path, + ] + ) def _configure_hostpaths(self, hostpaths: List[HostPath]): client = Client() diff --git a/installers/charm/osm-ro/src/charm.py b/installers/charm/osm-ro/src/charm.py index 7b8acea7..0c5ab9a3 100755 --- a/installers/charm/osm-ro/src/charm.py +++ b/installers/charm/osm-ro/src/charm.py @@ -49,10 +49,29 @@ from ops.model import ActiveStatus, Container from legacy_interfaces import MongoClient +ro_host_paths = { + "NG-RO": "/usr/lib/python3/dist-packages/osm_ng_ro", + "RO-plugin": "/usr/lib/python3/dist-packages/osm_ro_plugin", + "RO-SDN-arista_cloudvision": "/usr/lib/python3/dist-packages/osm_rosdn_arista_cloudvision", + "RO-SDN-dpb": "/usr/lib/python3/dist-packages/osm_rosdn_dpb", + "RO-SDN-dynpac": "/usr/lib/python3/dist-packages/osm_rosdn_dynpac", + "RO-SDN-floodlight_openflow": "/usr/lib/python3/dist-packages/osm_rosdn_floodlightof", + "RO-SDN-ietfl2vpn": "/usr/lib/python3/dist-packages/osm_rosdn_ietfl2vpn", + "RO-SDN-juniper_contrail": "/usr/lib/python3/dist-packages/osm_rosdn_juniper_contrail", + "RO-SDN-odl_openflow": "/usr/lib/python3/dist-packages/osm_rosdn_odlof", + "RO-SDN-onos_vpls": "/usr/lib/python3/dist-packages/osm_rosdn_onos_vpls", + "RO-VIM-aws": "/usr/lib/python3/dist-packages/osm_rovim_aws", + "RO-VIM-azure": "/usr/lib/python3/dist-packages/osm_rovim_azure", + "RO-VIM-gcp": "/usr/lib/python3/dist-packages/osm_rovim_gcp", + "RO-VIM-openstack": "/usr/lib/python3/dist-packages/osm_rovim_openstack", + "RO-VIM-openvim": "/usr/lib/python3/dist-packages/osm_rovim_openvim", + "RO-VIM-vmware": "/usr/lib/python3/dist-packages/osm_rovim_vmware", +} HOSTPATHS = [ HostPath( config="ro-hostpath", - container_path="/usr/lib/python3/dist-packages/osm_ro", + container_path="/usr/lib/python3/dist-packages/", + submodules=ro_host_paths, ), HostPath( config="common-hostpath", diff --git a/installers/charm/osm-ro/tox.ini b/installers/charm/osm-ro/tox.ini index 90adfe20..e27651da 100644 --- a/installers/charm/osm-ro/tox.ini +++ b/installers/charm/osm-ro/tox.ini @@ -62,10 +62,10 @@ deps = codespell commands = # uncomment the following line if this charm owns a lib - codespell {[vars]lib_path} + codespell {[vars]lib_path} --ignore-words-list=Ro,RO,ro codespell {toxinidir}/. --skip {toxinidir}/.git --skip {toxinidir}/.tox \ --skip {toxinidir}/build --skip {toxinidir}/lib --skip {toxinidir}/venv \ - --skip {toxinidir}/.mypy_cache --skip {toxinidir}/icon.svg + --skip {toxinidir}/.mypy_cache --skip {toxinidir}/icon.svg --ignore-words-list=Ro,RO,ro # pflake8 wrapper supports config from pyproject.toml pflake8 {[vars]all_path} isort --check-only --diff {[vars]all_path} diff --git a/installers/charm/vca-integrator-operator/charmcraft.yaml b/installers/charm/vca-integrator-operator/charmcraft.yaml index 0d7d5ebc..98ffe03b 100644 --- a/installers/charm/vca-integrator-operator/charmcraft.yaml +++ b/installers/charm/vca-integrator-operator/charmcraft.yaml @@ -19,10 +19,10 @@ type: "charm" bases: - build-on: - name: "ubuntu" - channel: "20.04" + channel: "22.04" run-on: - name: "ubuntu" - channel: "20.04" + channel: "22.04" parts: charm: build-environment: -- 2.25.1