Fix bug 1799: Add hostpath mount option in OSM charms 71/11371/4
authorDavid Garcia <david.garcia@canonical.com>
Thu, 18 Nov 2021 15:45:05 +0000 (16:45 +0100)
committerDavid Garcia <david.garcia@canonical.com>
Mon, 22 Nov 2021 12:47:52 +0000 (13:47 +0100)
Change-Id: Ie5ef484759bd37d6cc8dcea0f32573e2a7dd3a11
Signed-off-by: David Garcia <david.garcia@canonical.com>
16 files changed:
installers/charm/bundles/osm-ha/bundle.yaml
installers/charm/bundles/osm/bundle.yaml
installers/charm/lcm/config.yaml
installers/charm/lcm/src/charm.py
installers/charm/mon/config.yaml
installers/charm/mon/src/charm.py
installers/charm/nbi/config.yaml
installers/charm/nbi/src/charm.py
installers/charm/pol/config.yaml
installers/charm/pol/src/charm.py
installers/charm/ro/config.yaml
installers/charm/ro/src/charm.py
installers/charm/update-bundle-revisions.sh [new file with mode: 0755]
tools/debug/charmed/README.md
tools/debug/charmed/generate_ssh_config.sh [new file with mode: 0755]
tools/debug/charmed/prepare_pods.sh [deleted file]

index 36d1b37..752cf56 100644 (file)
@@ -29,7 +29,7 @@ description: |
 bundle: kubernetes
 applications:
   zookeeper:
 bundle: kubernetes
 applications:
   zookeeper:
-    charm: "cs:~charmed-osm/zookeeper-0"
+    charm: "cs:~charmed-osm/zookeeper-1"
     channel: "stable"
     scale: 3
     series: kubernetes
     channel: "stable"
     scale: 3
     series: kubernetes
@@ -56,7 +56,7 @@ applications:
       gui-x: -300
       gui-y: -250
   kafka:
       gui-x: -300
       gui-y: -250
   kafka:
-    charm: "cs:~charmed-osm/kafka-0"
+    charm: "cs:~charmed-osm/kafka-1"
     channel: "stable"
     scale: 3
     series: kubernetes
     channel: "stable"
     scale: 3
     series: kubernetes
@@ -78,7 +78,7 @@ applications:
       gui-x: 0
       gui-y: 0
   nbi:
       gui-x: 0
       gui-y: 0
   nbi:
-    charm: "cs:~charmed-osm/nbi-17"
+    charm: "cs:~charmed-osm/nbi-18"
     scale: 3
     series: kubernetes
     options:
     scale: 3
     series: kubernetes
     options:
@@ -89,7 +89,7 @@ applications:
       gui-x: 0
       gui-y: -250
   ro:
       gui-x: 0
       gui-y: -250
   ro:
-    charm: "cs:~charmed-osm/ro-9"
+    charm: "cs:~charmed-osm/ro-10"
     scale: 3
     series: kubernetes
     options:
     scale: 3
     series: kubernetes
     options:
@@ -98,14 +98,14 @@ applications:
       gui-x: -300
       gui-y: 250
   ng-ui:
       gui-x: -300
       gui-y: 250
   ng-ui:
-    charm: "cs:~charmed-osm/ng-ui-24"
+    charm: "cs:~charmed-osm/ng-ui-25"
     scale: 3
     series: kubernetes
     annotations:
       gui-x: 600
       gui-y: 0
   lcm:
     scale: 3
     series: kubernetes
     annotations:
       gui-x: 600
       gui-y: 0
   lcm:
-    charm: "cs:~charmed-osm/lcm-14"
+    charm: "cs:~charmed-osm/lcm-15"
     scale: 3
     series: kubernetes
     options:
     scale: 3
     series: kubernetes
     options:
@@ -115,7 +115,7 @@ applications:
       gui-x: -300
       gui-y: 0
   mon:
       gui-x: -300
       gui-y: 0
   mon:
-    charm: "cs:~charmed-osm/mon-11"
+    charm: "cs:~charmed-osm/mon-12"
     scale: 1
     series: kubernetes
     options:
     scale: 1
     series: kubernetes
     options:
@@ -126,7 +126,7 @@ applications:
       gui-x: 300
       gui-y: 0
   pol:
       gui-x: 300
       gui-y: 0
   pol:
-    charm: "cs:~charmed-osm/pol-9"
+    charm: "cs:~charmed-osm/pol-10"
     scale: 3
     series: kubernetes
     options:
     scale: 3
     series: kubernetes
     options:
@@ -135,7 +135,7 @@ applications:
       gui-x: -300
       gui-y: 500
   pla:
       gui-x: -300
       gui-y: 500
   pla:
-    charm: "cs:~charmed-osm/pla-12"
+    charm: "cs:~charmed-osm/pla-13"
     scale: 3
     series: kubernetes
     options:
     scale: 3
     series: kubernetes
     options:
@@ -144,7 +144,7 @@ applications:
       gui-x: 600
       gui-y: -250
   prometheus:
       gui-x: 600
       gui-y: -250
   prometheus:
-    charm: "cs:~charmed-osm/prometheus-8"
+    charm: "cs:~charmed-osm/prometheus-9"
     scale: 1
     series: kubernetes
     storage:
     scale: 1
     series: kubernetes
     storage:
@@ -155,14 +155,14 @@ applications:
       gui-x: 300
       gui-y: 250
   grafana:
       gui-x: 300
       gui-y: 250
   grafana:
-    charm: "cs:~charmed-osm/grafana-9"
+    charm: "cs:~charmed-osm/grafana-10"
     scale: 3
     series: kubernetes
     annotations:
       gui-x: 300
       gui-y: 500
   keystone:
     scale: 3
     series: kubernetes
     annotations:
       gui-x: 300
       gui-y: 500
   keystone:
-    charm: "cs:~charmed-osm/keystone-15"
+    charm: "cs:~charmed-osm/keystone-16"
     scale: 1
     series: kubernetes
     annotations:
     scale: 1
     series: kubernetes
     annotations:
index 1325951..9031388 100644 (file)
@@ -28,7 +28,7 @@ description: |
 bundle: kubernetes
 applications:
   zookeeper:
 bundle: kubernetes
 applications:
   zookeeper:
-    charm: "cs:~charmed-osm/zookeeper-0"
+    charm: "cs:~charmed-osm/zookeeper-1"
     scale: 1
     series: kubernetes
     storage:
     scale: 1
     series: kubernetes
     storage:
@@ -51,7 +51,7 @@ applications:
       gui-x: -300
       gui-y: -250
   kafka:
       gui-x: -300
       gui-y: -250
   kafka:
-    charm: "cs:~charmed-osm/kafka-0"
+    charm: "cs:~charmed-osm/kafka-1"
     scale: 1
     series: kubernetes
     storage:
     scale: 1
     series: kubernetes
     storage:
@@ -69,7 +69,7 @@ applications:
       gui-x: 0
       gui-y: 0
   nbi:
       gui-x: 0
       gui-y: 0
   nbi:
-    charm: "cs:~charmed-osm/nbi-17"
+    charm: "cs:~charmed-osm/nbi-18"
     scale: 1
     series: kubernetes
     options:
     scale: 1
     series: kubernetes
     options:
@@ -80,7 +80,7 @@ applications:
       gui-x: 0
       gui-y: -250
   ro:
       gui-x: 0
       gui-y: -250
   ro:
-    charm: "cs:~charmed-osm/ro-9"
+    charm: "cs:~charmed-osm/ro-10"
     scale: 1
     series: kubernetes
     options:
     scale: 1
     series: kubernetes
     options:
@@ -89,14 +89,14 @@ applications:
       gui-x: -300
       gui-y: 250
   ng-ui:
       gui-x: -300
       gui-y: 250
   ng-ui:
-    charm: "cs:~charmed-osm/ng-ui-24"
+    charm: "cs:~charmed-osm/ng-ui-25"
     scale: 1
     series: kubernetes
     annotations:
       gui-x: 600
       gui-y: 0
   lcm:
     scale: 1
     series: kubernetes
     annotations:
       gui-x: 600
       gui-y: 0
   lcm:
-    charm: "cs:~charmed-osm/lcm-14"
+    charm: "cs:~charmed-osm/lcm-15"
     scale: 1
     series: kubernetes
     options:
     scale: 1
     series: kubernetes
     options:
@@ -106,7 +106,7 @@ applications:
       gui-x: -300
       gui-y: 0
   mon:
       gui-x: -300
       gui-y: 0
   mon:
-    charm: "cs:~charmed-osm/mon-11"
+    charm: "cs:~charmed-osm/mon-12"
     scale: 1
     series: kubernetes
     options:
     scale: 1
     series: kubernetes
     options:
@@ -117,7 +117,7 @@ applications:
       gui-x: 300
       gui-y: 0
   pol:
       gui-x: 300
       gui-y: 0
   pol:
-    charm: "cs:~charmed-osm/pol-9"
+    charm: "cs:~charmed-osm/pol-10"
     scale: 1
     series: kubernetes
     options:
     scale: 1
     series: kubernetes
     options:
@@ -126,7 +126,7 @@ applications:
       gui-x: -300
       gui-y: 500
   pla:
       gui-x: -300
       gui-y: 500
   pla:
-    charm: "cs:~charmed-osm/pla-12"
+    charm: "cs:~charmed-osm/pla-13"
     scale: 1
     series: kubernetes
     options:
     scale: 1
     series: kubernetes
     options:
@@ -135,7 +135,7 @@ applications:
       gui-x: 600
       gui-y: -250
   prometheus:
       gui-x: 600
       gui-y: -250
   prometheus:
-    charm: "cs:~charmed-osm/prometheus-8"
+    charm: "cs:~charmed-osm/prometheus-9"
     scale: 1
     series: kubernetes
     storage:
     scale: 1
     series: kubernetes
     storage:
@@ -146,14 +146,14 @@ applications:
       gui-x: 300
       gui-y: 250
   grafana:
       gui-x: 300
       gui-y: 250
   grafana:
-    charm: "cs:~charmed-osm/grafana-9"
+    charm: "cs:~charmed-osm/grafana-10"
     scale: 1
     series: kubernetes
     annotations:
       gui-x: 300
       gui-y: 500
   keystone:
     scale: 1
     series: kubernetes
     annotations:
       gui-x: 300
       gui-y: 500
   keystone:
-    charm: "cs:~charmed-osm/keystone-15"
+    charm: "cs:~charmed-osm/keystone-16"
     scale: 1
     series: kubernetes
     annotations:
     scale: 1
     series: kubernetes
     annotations:
index 0f218ea..709a8ca 100644 (file)
@@ -291,6 +291,27 @@ options:
     description: |
       Public SSH key that will be injected to the application pod.
     type: string
     description: |
       Public SSH key that will be injected to the application pod.
     type: string
+  debug_lcm_local_path:
+    description: |
+      Local full path to the LCM project.
+
+      The path will be mounted to the docker image,
+      which means changes during the debugging will be saved in your local path.
+    type: string
+  debug_n2vc_local_path:
+    description: |
+      Local full path to the N2VC project.
+
+      The path will be mounted to the docker image,
+      which means changes during the debugging will be saved in your local path.
+    type: string
+  debug_common_local_path:
+    description: |
+      Local full path to the COMMON project.
+
+      The path will be mounted to the docker image,
+      which means changes during the debugging will be saved in your local path.
+    type: string
   security_context:
     description: Enables the security context of the pods
     type: boolean
   security_context:
     description: Enables the security context of the pods
     type: boolean
index aac1813..4a10f5c 100755 (executable)
@@ -144,10 +144,26 @@ class LcmCharm(CharmedOsmBase):
         super().__init__(
             *args,
             oci_image="image",
         super().__init__(
             *args,
             oci_image="image",
-            debug_mode_config_key="debug_mode",
-            debug_pubkey_config_key="debug_pubkey",
             vscode_workspace=VSCODE_WORKSPACE,
         )
             vscode_workspace=VSCODE_WORKSPACE,
         )
+        if self.config.get("debug_mode"):
+            self.enable_debug_mode(
+                pubkey=self.config.get("debug_pubkey"),
+                hostpaths={
+                    "LCM": {
+                        "hostpath": self.config.get("debug_lcm_local_path"),
+                        "container-path": "/usr/lib/python3/dist-packages/osm_lcm",
+                    },
+                    "N2VC": {
+                        "hostpath": self.config.get("debug_n2vc_local_path"),
+                        "container-path": "/usr/lib/python3/dist-packages/n2vc",
+                    },
+                    "osm_common": {
+                        "hostpath": self.config.get("debug_common_local_path"),
+                        "container-path": "/usr/lib/python3/dist-packages/osm_common",
+                    },
+                },
+            )
         self.kafka_client = KafkaClient(self, "kafka")
         self.framework.observe(self.on["kafka"].relation_changed, self.configure_pod)
         self.framework.observe(self.on["kafka"].relation_broken, self.configure_pod)
         self.kafka_client = KafkaClient(self, "kafka")
         self.framework.observe(self.on["kafka"].relation_changed, self.configure_pod)
         self.framework.observe(self.on["kafka"].relation_broken, self.configure_pod)
index a3394ff..3d90286 100644 (file)
@@ -104,6 +104,27 @@ options:
     description: |
       Public SSH key that will be injected to the application pod.
     type: string
     description: |
       Public SSH key that will be injected to the application pod.
     type: string
+  debug_mon_local_path:
+    description: |
+      Local full path to the MON project.
+
+      The path will be mounted to the docker image,
+      which means changes during the debugging will be saved in your local path.
+    type: string
+  debug_n2vc_local_path:
+    description: |
+      Local full path to the N2VC project.
+
+      The path will be mounted to the docker image,
+      which means changes during the debugging will be saved in your local path.
+    type: string
+  debug_common_local_path:
+    description: |
+      Local full path to the COMMON project.
+
+      The path will be mounted to the docker image,
+      which means changes during the debugging will be saved in your local path.
+    type: string
   security_context:
     description: Enables the security context of the pods
     type: boolean
   security_context:
     description: Enables the security context of the pods
     type: boolean
index 85d1fa4..7833deb 100755 (executable)
@@ -129,11 +129,26 @@ class MonCharm(CharmedOsmBase):
         super().__init__(
             *args,
             oci_image="image",
         super().__init__(
             *args,
             oci_image="image",
-            debug_mode_config_key="debug_mode",
-            debug_pubkey_config_key="debug_pubkey",
             vscode_workspace=VSCODE_WORKSPACE,
         )
             vscode_workspace=VSCODE_WORKSPACE,
         )
-
+        if self.config.get("debug_mode"):
+            self.enable_debug_mode(
+                pubkey=self.config.get("debug_pubkey"),
+                hostpaths={
+                    "MON": {
+                        "hostpath": self.config.get("debug_mon_local_path"),
+                        "container-path": "/usr/lib/python3/dist-packages/osm_mon",
+                    },
+                    "N2VC": {
+                        "hostpath": self.config.get("debug_n2vc_local_path"),
+                        "container-path": "/usr/lib/python3/dist-packages/n2vc",
+                    },
+                    "osm_common": {
+                        "hostpath": self.config.get("debug_common_local_path"),
+                        "container-path": "/usr/lib/python3/dist-packages/osm_common",
+                    },
+                },
+            )
         self.kafka_client = KafkaClient(self, "kafka")
         self.framework.observe(self.on["kafka"].relation_changed, self.configure_pod)
         self.framework.observe(self.on["kafka"].relation_broken, self.configure_pod)
         self.kafka_client = KafkaClient(self, "kafka")
         self.framework.observe(self.on["kafka"].relation_changed, self.configure_pod)
         self.framework.observe(self.on["kafka"].relation_broken, self.configure_pod)
index a85aa70..f10304f 100644 (file)
@@ -89,6 +89,20 @@ options:
     description: |
       Public SSH key that will be injected to the application pod.
     type: string
     description: |
       Public SSH key that will be injected to the application pod.
     type: string
+  debug_nbi_local_path:
+    description: |
+      Local full path to the NBI project.
+
+      The path will be mounted to the docker image,
+      which means changes during the debugging will be saved in your local path.
+    type: string
+  debug_common_local_path:
+    description: |
+      Local full path to the COMMON project.
+
+      The path will be mounted to the docker image,
+      which means changes during the debugging will be saved in your local path.
+    type: string
   security_context:
     description: Enables the security context of the pods
     type: boolean
   security_context:
     description: Enables the security context of the pods
     type: boolean
index c6a7c1e..faba78a 100755 (executable)
@@ -122,10 +122,22 @@ class NbiCharm(CharmedOsmBase):
         super().__init__(
             *args,
             oci_image="image",
         super().__init__(
             *args,
             oci_image="image",
-            debug_mode_config_key="debug_mode",
-            debug_pubkey_config_key="debug_pubkey",
             vscode_workspace=VSCODE_WORKSPACE,
         )
             vscode_workspace=VSCODE_WORKSPACE,
         )
+        if self.config.get("debug_mode"):
+            self.enable_debug_mode(
+                pubkey=self.config.get("debug_pubkey"),
+                hostpaths={
+                    "NBI": {
+                        "hostpath": self.config.get("debug_nbi_local_path"),
+                        "container-path": "/usr/lib/python3/dist-packages/osm_nbi",
+                    },
+                    "osm_common": {
+                        "hostpath": self.config.get("debug_common_local_path"),
+                        "container-path": "/usr/lib/python3/dist-packages/osm_common",
+                    },
+                },
+            )
 
         self.kafka_client = KafkaClient(self, "kafka")
         self.framework.observe(self.on["kafka"].relation_changed, self.configure_pod)
 
         self.kafka_client = KafkaClient(self, "kafka")
         self.framework.observe(self.on["kafka"].relation_changed, self.configure_pod)
index 0279bd5..a2eef47 100644 (file)
@@ -49,6 +49,20 @@ options:
     description: |
       Public SSH key that will be injected to the application pod.
     type: string
     description: |
       Public SSH key that will be injected to the application pod.
     type: string
+  debug_pol_local_path:
+    description: |
+      Local full path to the POL project.
+
+      The path will be mounted to the docker image,
+      which means changes during the debugging will be saved in your local path.
+    type: string
+  debug_common_local_path:
+    description: |
+      Local full path to the COMMON project.
+
+      The path will be mounted to the docker image,
+      which means changes during the debugging will be saved in your local path.
+    type: string
   security_context:
     description: Enables the security context of the pods
     type: boolean
   security_context:
     description: Enables the security context of the pods
     type: boolean
index 1ac1aa8..e2fcdb3 100755 (executable)
@@ -91,11 +91,22 @@ class PolCharm(CharmedOsmBase):
         super().__init__(
             *args,
             oci_image="image",
         super().__init__(
             *args,
             oci_image="image",
-            debug_mode_config_key="debug_mode",
-            debug_pubkey_config_key="debug_pubkey",
             vscode_workspace=VSCODE_WORKSPACE,
         )
             vscode_workspace=VSCODE_WORKSPACE,
         )
-
+        if self.config.get("debug_mode"):
+            self.enable_debug_mode(
+                pubkey=self.config.get("debug_pubkey"),
+                hostpaths={
+                    "POL": {
+                        "hostpath": self.config.get("debug_pol_local_path"),
+                        "container-path": "/usr/lib/python3/dist-packages/osm_policy_module",
+                    },
+                    "osm_common": {
+                        "hostpath": self.config.get("debug_common_local_path"),
+                        "container-path": "/usr/lib/python3/dist-packages/osm_common",
+                    },
+                },
+            )
         self.kafka_client = KafkaClient(self, "kafka")
         self.framework.observe(self.on["kafka"].relation_changed, self.configure_pod)
         self.framework.observe(self.on["kafka"].relation_broken, self.configure_pod)
         self.kafka_client = KafkaClient(self, "kafka")
         self.framework.observe(self.on["kafka"].relation_changed, self.configure_pod)
         self.framework.observe(self.on["kafka"].relation_broken, self.configure_pod)
index ab4cd5d..8c5740a 100644 (file)
@@ -87,6 +87,20 @@ options:
     description: |
       Public SSH key that will be injected to the application pod.
     type: string
     description: |
       Public SSH key that will be injected to the application pod.
     type: string
+  debug_ro_local_path:
+    description: |
+      Local full path to the RO project.
+
+      The path will be mounted to the docker image,
+      which means changes during the debugging will be saved in your local path.
+    type: string
+  debug_common_local_path:
+    description: |
+      Local full path to the COMMON project.
+
+      The path will be mounted to the docker image,
+      which means changes during the debugging will be saved in your local path.
+    type: string
   security_context:
     description: Enables the security context of the pods
     type: boolean
   security_context:
     description: Enables the security context of the pods
     type: boolean
index e9642d3..099c559 100755 (executable)
@@ -24,7 +24,7 @@
 
 import base64
 import logging
 
 import base64
 import logging
-from typing import NoReturn, Optional
+from typing import Dict, NoReturn, Optional
 
 from ops.main import main
 from opslib.osm.charm import CharmedOsmBase, RelationsMissing
 
 from ops.main import main
 from opslib.osm.charm import CharmedOsmBase, RelationsMissing
@@ -131,11 +131,19 @@ class RoCharm(CharmedOsmBase):
         super().__init__(
             *args,
             oci_image="image",
         super().__init__(
             *args,
             oci_image="image",
-            debug_mode_config_key="debug_mode",
-            debug_pubkey_config_key="debug_pubkey",
             vscode_workspace=VSCODE_WORKSPACE,
         )
             vscode_workspace=VSCODE_WORKSPACE,
         )
-
+        if self.config.get("debug_mode"):
+            self.enable_debug_mode(
+                pubkey=self.config.get("debug_pubkey"),
+                hostpaths={
+                    "osm_common": {
+                        "hostpath": self.config.get("debug_common_local_path"),
+                        "container-path": "/usr/lib/python3/dist-packages/osm_common",
+                    },
+                    **_get_ro_host_paths(self.config.get("debug_ro_local_path")),
+                },
+            )
         self.kafka_client = KafkaClient(self, "kafka")
         self.framework.observe(self.on["kafka"].relation_changed, self.configure_pod)
         self.framework.observe(self.on["kafka"].relation_broken, self.configure_pod)
         self.kafka_client = KafkaClient(self, "kafka")
         self.framework.observe(self.on["kafka"].relation_changed, self.configure_pod)
         self.framework.observe(self.on["kafka"].relation_broken, self.configure_pod)
@@ -363,5 +371,92 @@ VSCODE_WORKSPACE = {
     "settings": {},
 }
 
     "settings": {},
 }
 
+
+def _get_ro_host_paths(ro_host_path: str) -> Dict:
+    """Get RO host paths"""
+    return (
+        {
+            "NG-RO": {
+                "hostpath": f"{ro_host_path}/NG-RO",
+                "container-path": "/usr/lib/python3/dist-packages/osm_ng_ro",
+            },
+            "RO-plugin": {
+                "hostpath": f"{ro_host_path}/RO-plugin",
+                "container-path": "/usr/lib/python3/dist-packages/osm_ro_plugin",
+            },
+            "RO-SDN-arista_cloudvision": {
+                "hostpath": f"{ro_host_path}/RO-SDN-arista_cloudvision",
+                "container-path": "/usr/lib/python3/dist-packages/osm_rosdn_arista_cloudvision",
+            },
+            "RO-SDN-dpb": {
+                "hostpath": f"{ro_host_path}/RO-SDN-dpb",
+                "container-path": "/usr/lib/python3/dist-packages/osm_rosdn_dpb",
+            },
+            "RO-SDN-dynpac": {
+                "hostpath": f"{ro_host_path}/RO-SDN-dynpac",
+                "container-path": "/usr/lib/python3/dist-packages/osm_rosdn_dynpac",
+            },
+            "RO-SDN-floodlight_openflow": {
+                "hostpath": f"{ro_host_path}/RO-SDN-floodlight_openflow",
+                "container-path": "/usr/lib/python3/dist-packages/osm_rosdn_floodlightof",
+            },
+            "RO-SDN-ietfl2vpn": {
+                "hostpath": f"{ro_host_path}/RO-SDN-ietfl2vpn",
+                "container-path": "/usr/lib/python3/dist-packages/osm_rosdn_ietfl2vpn",
+            },
+            "RO-SDN-juniper_contrail": {
+                "hostpath": f"{ro_host_path}/RO-SDN-juniper_contrail",
+                "container-path": "/usr/lib/python3/dist-packages/osm_rosdn_juniper_contrail",
+            },
+            "RO-SDN-odl_openflow": {
+                "hostpath": f"{ro_host_path}/RO-SDN-odl_openflow",
+                "container-path": "/usr/lib/python3/dist-packages/osm_rosdn_odlof",
+            },
+            "RO-SDN-onos_openflow": {
+                "hostpath": f"{ro_host_path}/RO-SDN-onos_openflow",
+                "container-path": "/usr/lib/python3/dist-packages/osm_rosdn_onosof",
+            },
+            "RO-SDN-onos_vpls": {
+                "hostpath": f"{ro_host_path}/RO-SDN-onos_vpls",
+                "container-path": "/usr/lib/python3/dist-packages/osm_rosdn_onos_vpls",
+            },
+            "RO-VIM-aws": {
+                "hostpath": f"{ro_host_path}/RO-VIM-aws",
+                "container-path": "/usr/lib/python3/dist-packages/osm_rovim_aws",
+            },
+            "RO-VIM-azure": {
+                "hostpath": f"{ro_host_path}/RO-VIM-azure",
+                "container-path": "/usr/lib/python3/dist-packages/osm_rovim_azure",
+            },
+            "RO-VIM-gcp": {
+                "hostpath": f"{ro_host_path}/RO-VIM-gcp",
+                "container-path": "/usr/lib/python3/dist-packages/osm_rovim_gcp",
+            },
+            "RO-VIM-fos": {
+                "hostpath": f"{ro_host_path}/RO-VIM-fos",
+                "container-path": "/usr/lib/python3/dist-packages/osm_rovim_fos",
+            },
+            "RO-VIM-opennebula": {
+                "hostpath": f"{ro_host_path}/RO-VIM-opennebula",
+                "container-path": "/usr/lib/python3/dist-packages/osm_rovim_opennebula",
+            },
+            "RO-VIM-openstack": {
+                "hostpath": f"{ro_host_path}/RO-VIM-openstack",
+                "container-path": "/usr/lib/python3/dist-packages/osm_rovim_openstack",
+            },
+            "RO-VIM-openvim": {
+                "hostpath": f"{ro_host_path}/RO-VIM-openvim",
+                "container-path": "/usr/lib/python3/dist-packages/osm_rovim_openvim",
+            },
+            "RO-VIM-vmware": {
+                "hostpath": f"{ro_host_path}/RO-VIM-vmware",
+                "container-path": "/usr/lib/python3/dist-packages/osm_rovim_vmware",
+            },
+        }
+        if ro_host_path
+        else {}
+    )
+
+
 if __name__ == "__main__":
     main(RoCharm)
 if __name__ == "__main__":
     main(RoCharm)
diff --git a/installers/charm/update-bundle-revisions.sh b/installers/charm/update-bundle-revisions.sh
new file mode 100755 (executable)
index 0000000..1a8d8cb
--- /dev/null
@@ -0,0 +1,35 @@
+##
+# Copyright 2019 ETSI
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+#         http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+##
+
+charms=`cat bundles/osm/bundle.yaml  | grep cs | grep -v k8s | awk '{print $2}' | tr -d \"`
+for charm_uri in $charms; do
+    charm_without_rev=`echo $charm_uri| rev | cut -d "-" -f 2-5 | rev`
+    latest_revision=`charm show --channel edge $charm_without_rev | grep Revision | awk '{print $2}'`
+    new_charm_uri=$charm_without_rev-$latest_revision
+    old_uri=`echo $charm_uri | sed 's/\//\\\\\//g'`
+    new_uri=`echo $new_charm_uri | sed 's/\//\\\\\//g'`
+    sed -i "s/"$old_uri"/"$new_uri"/g" bundles/osm/bundle.yaml
+done
+
+charms=`cat bundles/osm-ha/bundle.yaml  | grep cs | grep -v k8s | awk '{print $2}' | tr -d \"`
+for charm_uri in $charms; do
+    charm_without_rev=`echo $charm_uri| rev | cut -d "-" -f 2-5 | rev`
+    latest_revision=`charm show --channel edge $charm_without_rev | grep Revision | awk '{print $2}'`
+    new_charm_uri=$charm_without_rev-$latest_revision
+    old_uri=`echo $charm_uri | sed 's/\//\\\\\//g'`
+    new_uri=`echo $new_charm_uri | sed 's/\//\\\\\//g'`
+    sed -i "s/"$old_uri"/"$new_uri"/g" bundles/osm-ha/bundle.yaml
+done
\ No newline at end of file
index 1330454..93bf7ee 100644 (file)
@@ -30,6 +30,7 @@ Benefits:
 - Easily configure modules for debugging_mode: `juju config <module> debug_mode=True debug_pubkey="ssh-rsa ..."`.
 - Debug in K8s: All pods (the debugged ones and the rest) will be running always in K8s.
 - Seemless setup: VSCode will connect through SSH to the pods.
 - Easily configure modules for debugging_mode: `juju config <module> debug_mode=True debug_pubkey="ssh-rsa ..."`.
 - Debug in K8s: All pods (the debugged ones and the rest) will be running always in K8s.
 - Seemless setup: VSCode will connect through SSH to the pods.
+- Keep your changes save: Possibility to mount local module to the container; all the changes will be saved automatically to your local filesystem.
 
 ## Install OSM
 
 
 ## Install OSM
 
@@ -56,25 +57,64 @@ Install OSM from a specific tag:
 
 Once the Charmed OSM installation has finished, you can select which applications you want to run with the debug mode.
 
 
 Once the Charmed OSM installation has finished, you can select which applications you want to run with the debug mode.
 
-- lcm: `juju config lcm debug_mode=True  debug_pubkey="ssh-rsa ..."`
-- mon: `juju config mon debug_mode=True debug_pubkey="ssh-rsa ..."`
-- nbi: `juju config nbi debug_mode=True debug_pubkey="ssh-rsa ..."`
-- ro: `juju config ro debug_mode=True debug_pubkey="ssh-rsa ..."`
-- pol: `juju config pol debug_mode=True debug_pubkey="ssh-rsa ..."`
+```bash
+# LCM
+juju config lcm debug_mode=True  debug_pubkey="`cat ~/.ssh/id_rsa.pub`"
+# MON
+juju config mon debug_mode=True  debug_pubkey="`cat ~/.ssh/id_rsa.pub`"
+# NBI
+juju config nbi debug_mode=True  debug_pubkey="`cat ~/.ssh/id_rsa.pub`"
+# RO
+juju config ro debug_mode=True  debug_pubkey="`cat ~/.ssh/id_rsa.pub`"
+# POL
+juju config pol debug_mode=True  debug_pubkey="`cat ~/.ssh/id_rsa.pub`"
+```
 
 Enabling the debug_mode will put a `sleep infinity` as the entrypoint of the container. That way, we can later connect to the pod through SSH in VSCode, and run the entrypoint of the application from the debugger.
 
 
 Enabling the debug_mode will put a `sleep infinity` as the entrypoint of the container. That way, we can later connect to the pod through SSH in VSCode, and run the entrypoint of the application from the debugger.
 
-### Prepare pods
+### Mounting local modules
+
+The Charmed OSM Debugging mode allows you to mount local modules to the desired charms. The following commands show which modules can be mounted in each charm.
+
+```bash
+LCM_LOCAL_PATH="/path/to/LCM"
+N2VC_LOCAL_PATH="/path/to/N2VC"
+NBI_LOCAL_PATH="/path/to/NBI"
+RO_LOCAL_PATH="/path/to/RO"
+MON_LOCAL_PATH="/path/to/MON"
+POL_LOCAL_PATH="/path/to/POL"
+COMMON_LOCAL_PATH="/path/to/common"
+
+# LCM
+juju config lcm debug_lcm_local_path=$LCM_LOCAL_PATH
+juju config lcm debug_n2vc_local_path=$N2VC_LOCAL_PATH
+juju config lcm debug_common_local_path=$COMMON_LOCAL_PATH
+# MON
+juju config mon debug_mon_local_path=$MON_LOCAL_PATH
+juju config mon debug_n2vc_local_path=$N2VC_LOCAL_PATH
+juju config mon debug_common_local_path=$COMMON_LOCAL_PATH
+# NBI
+juju config nbi debug_nbi_local_path=$LCM_LOCAL_PATH
+juju config nbi debug_common_local_path=$COMMON_LOCAL_PATH
+# RO
+juju config ro debug_ro_local_path=$RO_LOCAL_PATH
+juju config ro debug_common_local_path=$COMMON_LOCAL_PATH
+# POL
+juju config pol debug_pol_local_path=$POL_LOCAL_PATH
+juju config pol debug_common_local_path=$COMMON_LOCAL_PATH
+```
 
 
-Preparing the pods includes setting up the ~/.ssh/config so the VSCode can easily discover which ssh hosts are available
+### Generate SSH config file
+
+Preparing the pods includes setting up the `~/.ssh/config` so the VSCode can easily discover which ssh hosts are available
 
 Just execute:
 
 ```bash
 
 Just execute:
 
 ```bash
-./prepare_pods.sh
+./generate_ssh_config.sh
 ```
 
 ```
 
-> NOTE: The public key that will be used will be `$HOME/.ssh/id_rsa.pub`. If you want to use a different one, add the absolute path to it as a first argument: `./prepare_pods.sh /path/to/key.pub`.
+> NOTE: The public key that will be used will be `$HOME/.ssh/id_rsa.pub`. If you want to use a different one, add the absolute path to it as a first argument: `./generate_ssh_config.sh /path/to/key.pub`.
 
 ### Connect to Pods
 
 
 ### Connect to Pods
 
@@ -92,22 +132,16 @@ Right click on the host, and "Connect to host in a New Window".
 
 ### Add workspace
 
 
 ### Add workspace
 
-The `./prepare_pods.sh` script adds a workspace to the `/root` folder of each pod, with the following name: `<module>.code-workspace`.
+The `./generate_ssh_config.sh` script adds a workspace to the `/root` folder of each pod, with the following name: `debug.code-workspace`.
 
 
-In the window of the connected host, go to `File/Open Workspace...`. Then select the `<module>.code-workspace` file.
+In the window of the connected host, go to `File/Open Workspace from File...`. Then select the `debug.code-workspace` file.
 
 ### Run and Debug
 
 
 ### Run and Debug
 
-Go to extensions and install the Python extension. It will be installed in the remote pod.
-
-Now we need to add a [debug configuration](https://code.visualstudio.com/docs/editor/debugging). For that, go to the Run and Debug tab, and click on `create a launch.json file`.
+Open the `Terminal` tab, and the Python extension will be automatically downloaded. It will be installed in the remote pod.
 
 
-Now you will be asked to select a folder in your workspace. Select the folder of the main component:
+Go to the `Explorer (ctrl + shift + E)` to see the module folders in the charm. You can add breakpoints and start debugging. 
 
 
-- LCM: select osm_lcm
-- MON: select osm_mon
-- NBI: select osm_nbi
-- RO: select osm_ng_ro
-- POL: select osm_policy_module
+Go to the `Run and Debug (ctrl + shift + D)` and press `F5` to start the main entrypoint of the charm.
 
 
-Then select `Python` as the environment. And finally, select `Module` and enter the module of the component you are going to test (LCM example: osm_lcm.lcm)
+Happy debugging!
diff --git a/tools/debug/charmed/generate_ssh_config.sh b/tools/debug/charmed/generate_ssh_config.sh
new file mode 100755 (executable)
index 0000000..6749dd7
--- /dev/null
@@ -0,0 +1,50 @@
+#!/bin/bash
+# Copyright 2021 Canonical Ltd.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+#         http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+#
+# For those usages not covered by the Apache License, Version 2.0 please
+# contact: legal@canonical.com
+#
+# To get in touch with the maintainers, please contact:
+# osm-charmers@lists.launchpad.net
+##
+
+MODULES="lcm pol mon ro nbi"
+
+
+PUBLIC_KEY=${1:-$HOME/.ssh/id_rsa.pub}
+echo "Using $PUBLIC_KEY key."
+[ -f $PUBLIC_KEY ] || (echo "$PUBLIC_KEY file does not exist" && exit 1)
+PUBLIC_KEY_CONTENT=`cat $PUBLIC_KEY`
+
+mkdir -p ~/.ssh/config.d
+echo "" | tee ~/.ssh/config.d/osm
+
+
+for module in $MODULES; do
+    if [[ `juju config -m osm $module debug_mode` == "true" ]]; then
+      pod_name=`microk8s.kubectl -n osm get pods | grep -E "^$module-" | grep -v operator | cut -d " " -f 1`
+      pod_ip=`microk8s.kubectl -n osm get pods $pod_name -o yaml | yq e .status.podIP -`
+      echo "Host $module
+  HostName $pod_ip
+  User root
+  # StrictHostKeyChecking no
+  IdentityFile $PUBLIC_KEY" | tee -a ~/.ssh/config.d/osm
+    fi
+done
+
+
+import_osm_config="Include config.d/osm"
+touch ~/.ssh/config
+grep "$import_osm_config" ~/.ssh/config || ( echo -e "$import_osm_config\n$(cat ~/.ssh/config)" > ~/.ssh/config )
\ No newline at end of file
diff --git a/tools/debug/charmed/prepare_pods.sh b/tools/debug/charmed/prepare_pods.sh
deleted file mode 100755 (executable)
index 6749dd7..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-#!/bin/bash
-# Copyright 2021 Canonical Ltd.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-#         http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-#
-# For those usages not covered by the Apache License, Version 2.0 please
-# contact: legal@canonical.com
-#
-# To get in touch with the maintainers, please contact:
-# osm-charmers@lists.launchpad.net
-##
-
-MODULES="lcm pol mon ro nbi"
-
-
-PUBLIC_KEY=${1:-$HOME/.ssh/id_rsa.pub}
-echo "Using $PUBLIC_KEY key."
-[ -f $PUBLIC_KEY ] || (echo "$PUBLIC_KEY file does not exist" && exit 1)
-PUBLIC_KEY_CONTENT=`cat $PUBLIC_KEY`
-
-mkdir -p ~/.ssh/config.d
-echo "" | tee ~/.ssh/config.d/osm
-
-
-for module in $MODULES; do
-    if [[ `juju config -m osm $module debug_mode` == "true" ]]; then
-      pod_name=`microk8s.kubectl -n osm get pods | grep -E "^$module-" | grep -v operator | cut -d " " -f 1`
-      pod_ip=`microk8s.kubectl -n osm get pods $pod_name -o yaml | yq e .status.podIP -`
-      echo "Host $module
-  HostName $pod_ip
-  User root
-  # StrictHostKeyChecking no
-  IdentityFile $PUBLIC_KEY" | tee -a ~/.ssh/config.d/osm
-    fi
-done
-
-
-import_osm_config="Include config.d/osm"
-touch ~/.ssh/config
-grep "$import_osm_config" ~/.ssh/config || ( echo -e "$import_osm_config\n$(cat ~/.ssh/config)" > ~/.ssh/config )
\ No newline at end of file