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