Fix bug 1800: Add hostpath mount option in OSM charms
Change-Id: Ie5ef484759bd37d6cc8dcea0f32573e2a7dd3a11
Signed-off-by: David Garcia <david.garcia@canonical.com>
diff --git a/installers/charm/bundles/osm-ha/bundle.yaml b/installers/charm/bundles/osm-ha/bundle.yaml
index 36d1b37..752cf56 100644
--- a/installers/charm/bundles/osm-ha/bundle.yaml
+++ b/installers/charm/bundles/osm-ha/bundle.yaml
@@ -29,7 +29,7 @@
bundle: kubernetes
applications:
zookeeper:
- charm: "cs:~charmed-osm/zookeeper-0"
+ charm: "cs:~charmed-osm/zookeeper-1"
channel: "stable"
scale: 3
series: kubernetes
@@ -56,7 +56,7 @@
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
@@ -78,7 +78,7 @@
gui-x: 0
gui-y: 0
nbi:
- charm: "cs:~charmed-osm/nbi-17"
+ charm: "cs:~charmed-osm/nbi-18"
scale: 3
series: kubernetes
options:
@@ -89,7 +89,7 @@
gui-x: 0
gui-y: -250
ro:
- charm: "cs:~charmed-osm/ro-9"
+ charm: "cs:~charmed-osm/ro-10"
scale: 3
series: kubernetes
options:
@@ -98,14 +98,14 @@
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:
- charm: "cs:~charmed-osm/lcm-14"
+ charm: "cs:~charmed-osm/lcm-15"
scale: 3
series: kubernetes
options:
@@ -115,7 +115,7 @@
gui-x: -300
gui-y: 0
mon:
- charm: "cs:~charmed-osm/mon-11"
+ charm: "cs:~charmed-osm/mon-12"
scale: 1
series: kubernetes
options:
@@ -126,7 +126,7 @@
gui-x: 300
gui-y: 0
pol:
- charm: "cs:~charmed-osm/pol-9"
+ charm: "cs:~charmed-osm/pol-10"
scale: 3
series: kubernetes
options:
@@ -135,7 +135,7 @@
gui-x: -300
gui-y: 500
pla:
- charm: "cs:~charmed-osm/pla-12"
+ charm: "cs:~charmed-osm/pla-13"
scale: 3
series: kubernetes
options:
@@ -144,7 +144,7 @@
gui-x: 600
gui-y: -250
prometheus:
- charm: "cs:~charmed-osm/prometheus-8"
+ charm: "cs:~charmed-osm/prometheus-9"
scale: 1
series: kubernetes
storage:
@@ -155,14 +155,14 @@
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:
- charm: "cs:~charmed-osm/keystone-15"
+ charm: "cs:~charmed-osm/keystone-16"
scale: 1
series: kubernetes
annotations:
diff --git a/installers/charm/bundles/osm/bundle.yaml b/installers/charm/bundles/osm/bundle.yaml
index 1325951..9031388 100644
--- a/installers/charm/bundles/osm/bundle.yaml
+++ b/installers/charm/bundles/osm/bundle.yaml
@@ -28,7 +28,7 @@
bundle: kubernetes
applications:
zookeeper:
- charm: "cs:~charmed-osm/zookeeper-0"
+ charm: "cs:~charmed-osm/zookeeper-1"
scale: 1
series: kubernetes
storage:
@@ -51,7 +51,7 @@
gui-x: -300
gui-y: -250
kafka:
- charm: "cs:~charmed-osm/kafka-0"
+ charm: "cs:~charmed-osm/kafka-1"
scale: 1
series: kubernetes
storage:
@@ -69,7 +69,7 @@
gui-x: 0
gui-y: 0
nbi:
- charm: "cs:~charmed-osm/nbi-17"
+ charm: "cs:~charmed-osm/nbi-18"
scale: 1
series: kubernetes
options:
@@ -80,7 +80,7 @@
gui-x: 0
gui-y: -250
ro:
- charm: "cs:~charmed-osm/ro-9"
+ charm: "cs:~charmed-osm/ro-10"
scale: 1
series: kubernetes
options:
@@ -89,14 +89,14 @@
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:
- charm: "cs:~charmed-osm/lcm-14"
+ charm: "cs:~charmed-osm/lcm-15"
scale: 1
series: kubernetes
options:
@@ -106,7 +106,7 @@
gui-x: -300
gui-y: 0
mon:
- charm: "cs:~charmed-osm/mon-11"
+ charm: "cs:~charmed-osm/mon-12"
scale: 1
series: kubernetes
options:
@@ -117,7 +117,7 @@
gui-x: 300
gui-y: 0
pol:
- charm: "cs:~charmed-osm/pol-9"
+ charm: "cs:~charmed-osm/pol-10"
scale: 1
series: kubernetes
options:
@@ -126,7 +126,7 @@
gui-x: -300
gui-y: 500
pla:
- charm: "cs:~charmed-osm/pla-12"
+ charm: "cs:~charmed-osm/pla-13"
scale: 1
series: kubernetes
options:
@@ -135,7 +135,7 @@
gui-x: 600
gui-y: -250
prometheus:
- charm: "cs:~charmed-osm/prometheus-8"
+ charm: "cs:~charmed-osm/prometheus-9"
scale: 1
series: kubernetes
storage:
@@ -146,14 +146,14 @@
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:
- charm: "cs:~charmed-osm/keystone-15"
+ charm: "cs:~charmed-osm/keystone-16"
scale: 1
series: kubernetes
annotations:
diff --git a/installers/charm/lcm/config.yaml b/installers/charm/lcm/config.yaml
index 0f218ea..709a8ca 100644
--- a/installers/charm/lcm/config.yaml
+++ b/installers/charm/lcm/config.yaml
@@ -291,6 +291,27 @@
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
diff --git a/installers/charm/lcm/src/charm.py b/installers/charm/lcm/src/charm.py
index aac1813..4a10f5c 100755
--- a/installers/charm/lcm/src/charm.py
+++ b/installers/charm/lcm/src/charm.py
@@ -144,10 +144,26 @@
super().__init__(
*args,
oci_image="image",
- debug_mode_config_key="debug_mode",
- debug_pubkey_config_key="debug_pubkey",
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)
diff --git a/installers/charm/mon/config.yaml b/installers/charm/mon/config.yaml
index a3394ff..3d90286 100644
--- a/installers/charm/mon/config.yaml
+++ b/installers/charm/mon/config.yaml
@@ -104,6 +104,27 @@
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
diff --git a/installers/charm/mon/src/charm.py b/installers/charm/mon/src/charm.py
index 85d1fa4..7833deb 100755
--- a/installers/charm/mon/src/charm.py
+++ b/installers/charm/mon/src/charm.py
@@ -129,11 +129,26 @@
super().__init__(
*args,
oci_image="image",
- debug_mode_config_key="debug_mode",
- debug_pubkey_config_key="debug_pubkey",
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)
diff --git a/installers/charm/nbi/config.yaml b/installers/charm/nbi/config.yaml
index a85aa70..f10304f 100644
--- a/installers/charm/nbi/config.yaml
+++ b/installers/charm/nbi/config.yaml
@@ -89,6 +89,20 @@
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
diff --git a/installers/charm/nbi/src/charm.py b/installers/charm/nbi/src/charm.py
index c6a7c1e..faba78a 100755
--- a/installers/charm/nbi/src/charm.py
+++ b/installers/charm/nbi/src/charm.py
@@ -122,10 +122,22 @@
super().__init__(
*args,
oci_image="image",
- debug_mode_config_key="debug_mode",
- debug_pubkey_config_key="debug_pubkey",
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)
diff --git a/installers/charm/pol/config.yaml b/installers/charm/pol/config.yaml
index 0279bd5..a2eef47 100644
--- a/installers/charm/pol/config.yaml
+++ b/installers/charm/pol/config.yaml
@@ -49,6 +49,20 @@
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
diff --git a/installers/charm/pol/src/charm.py b/installers/charm/pol/src/charm.py
index 1ac1aa8..e2fcdb3 100755
--- a/installers/charm/pol/src/charm.py
+++ b/installers/charm/pol/src/charm.py
@@ -91,11 +91,22 @@
super().__init__(
*args,
oci_image="image",
- debug_mode_config_key="debug_mode",
- debug_pubkey_config_key="debug_pubkey",
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)
diff --git a/installers/charm/ro/config.yaml b/installers/charm/ro/config.yaml
index ab4cd5d..8c5740a 100644
--- a/installers/charm/ro/config.yaml
+++ b/installers/charm/ro/config.yaml
@@ -87,6 +87,20 @@
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
diff --git a/installers/charm/ro/src/charm.py b/installers/charm/ro/src/charm.py
index e9642d3..099c559 100755
--- a/installers/charm/ro/src/charm.py
+++ b/installers/charm/ro/src/charm.py
@@ -24,7 +24,7 @@
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
@@ -131,11 +131,19 @@
super().__init__(
*args,
oci_image="image",
- debug_mode_config_key="debug_mode",
- debug_pubkey_config_key="debug_pubkey",
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)
@@ -363,5 +371,92 @@
"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)
diff --git a/installers/charm/update-bundle-revisions.sh b/installers/charm/update-bundle-revisions.sh
new file mode 100755
index 0000000..1a8d8cb
--- /dev/null
+++ b/installers/charm/update-bundle-revisions.sh
@@ -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
diff --git a/tools/debug/charmed/README.md b/tools/debug/charmed/README.md
index 1330454..93bf7ee 100644
--- a/tools/debug/charmed/README.md
+++ b/tools/debug/charmed/README.md
@@ -30,6 +30,7 @@
- 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
@@ -56,25 +57,64 @@
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.
-### Prepare pods
+### Mounting local modules
-Preparing the pods includes setting up the ~/.ssh/config so the VSCode can easily discover which ssh hosts are available
+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
+```
+
+### 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
-./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
@@ -92,22 +132,16 @@
### 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
-Go to extensions and install the Python extension. It will be installed in the remote pod.
+Open the `Terminal` tab, and the Python extension will be automatically downloaded. 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`.
+Go to the `Explorer (ctrl + shift + E)` to see the module folders in the charm. You can add breakpoints and start debugging.
-Now you will be asked to select a folder in your workspace. Select the folder of the main component:
+Go to the `Run and Debug (ctrl + shift + D)` and press `F5` to start the main entrypoint of the charm.
-- LCM: select osm_lcm
-- MON: select osm_mon
-- NBI: select osm_nbi
-- RO: select osm_ng_ro
-- POL: select osm_policy_module
-
-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/prepare_pods.sh b/tools/debug/charmed/generate_ssh_config.sh
similarity index 100%
rename from tools/debug/charmed/prepare_pods.sh
rename to tools/debug/charmed/generate_ssh_config.sh