Add charmcraft.yaml debug_mode to charmed-osm
- Added a debug_mode option to lcm, mon, nbi, pol, and ro charms
- Added a script to prepare pods for debugging:
- setup .ssh/config to easily ssh from vscode to the pods
- Added a README that explains how to prepare the environment for
testing
Change-Id: Ieb56b565c15e61c68ad000b60897abd27e1eeb0e
Signed-off-by: David Garcia <david.garcia@canonical.com>
diff --git a/installers/charm/build.sh b/installers/charm/build.sh
index 06a6d65..65dd87d 100755
--- a/installers/charm/build.sh
+++ b/installers/charm/build.sh
@@ -14,17 +14,15 @@
# limitations under the License.
function build() {
- cd $1 && tox -e build && cd ..
+ cd $1 && tox -qe build && cd ..
}
-charms="ro nbi pla pol mon lcm ng-ui keystone grafana prometheus keystone mariadb-k8s mongodb-k8s zookeeper-k8s kafka-k8s mongodb-exporter kafka-exporter mysqld-exporter"
+charms="ro nbi pla pol mon lcm ng-ui keystone grafana prometheus mariadb-k8s mongodb-k8s zookeeper-k8s kafka-k8s mongodb-exporter kafka-exporter mysqld-exporter"
if [ -z `which charmcraft` ]; then
sudo snap install charmcraft --edge
fi
for charm_directory in $charms; do
- echo "Building charm $charm_directory..."
- # cd $charm_directory
- build $charm_directory
- # cd ..
+ build $charm_directory &
done
+wait
\ No newline at end of file
diff --git a/installers/charm/bundles/osm-ha/bundle.yaml b/installers/charm/bundles/osm-ha/bundle.yaml
index 88115fa..a7ebc38 100644
--- a/installers/charm/bundles/osm-ha/bundle.yaml
+++ b/installers/charm/bundles/osm-ha/bundle.yaml
@@ -78,7 +78,7 @@
gui-x: 0
gui-y: 0
nbi:
- charm: "cs:~charmed-osm/nbi-13"
+ charm: "cs:~charmed-osm/nbi-16"
scale: 3
series: kubernetes
options:
@@ -89,7 +89,7 @@
gui-x: 0
gui-y: -250
ro:
- charm: "cs:~charmed-osm/ro-5"
+ charm: "cs:~charmed-osm/ro-8"
scale: 3
series: kubernetes
options:
@@ -98,14 +98,14 @@
gui-x: -300
gui-y: 250
ng-ui:
- charm: "cs:~charmed-osm/ng-ui-22"
+ charm: "cs:~charmed-osm/ng-ui-23"
scale: 3
series: kubernetes
annotations:
gui-x: 600
gui-y: 0
lcm:
- charm: "cs:~charmed-osm/lcm-10"
+ charm: "cs:~charmed-osm/lcm-13"
scale: 3
series: kubernetes
options:
@@ -115,7 +115,7 @@
gui-x: -300
gui-y: 0
mon:
- charm: "cs:~charmed-osm/mon-6"
+ charm: "cs:~charmed-osm/mon-9"
scale: 1
series: kubernetes
options:
@@ -126,7 +126,7 @@
gui-x: 300
gui-y: 0
pol:
- charm: "cs:~charmed-osm/pol-5"
+ charm: "cs:~charmed-osm/pol-8"
scale: 3
series: kubernetes
options:
@@ -135,7 +135,7 @@
gui-x: -300
gui-y: 500
pla:
- charm: "cs:~charmed-osm/pla-10"
+ charm: "cs:~charmed-osm/pla-11"
scale: 3
series: kubernetes
options:
@@ -144,7 +144,7 @@
gui-x: 600
gui-y: -250
prometheus:
- charm: "cs:~charmed-osm/prometheus-5"
+ charm: "cs:~charmed-osm/prometheus-6"
scale: 1
series: kubernetes
storage:
@@ -155,14 +155,14 @@
gui-x: 300
gui-y: 250
grafana:
- charm: "cs:~charmed-osm/grafana-5"
+ charm: "cs:~charmed-osm/grafana-6"
scale: 3
series: kubernetes
annotations:
gui-x: 300
gui-y: 500
keystone:
- charm: "cs:~charmed-osm/keystone-11"
+ charm: "cs:~charmed-osm/keystone-12"
scale: 1
series: kubernetes
annotations:
diff --git a/installers/charm/bundles/osm/bundle.yaml b/installers/charm/bundles/osm/bundle.yaml
index d867f1b..36322fe 100644
--- a/installers/charm/bundles/osm/bundle.yaml
+++ b/installers/charm/bundles/osm/bundle.yaml
@@ -71,7 +71,7 @@
gui-x: 0
gui-y: 0
nbi:
- charm: "cs:~charmed-osm/nbi-13"
+ charm: "cs:~charmed-osm/nbi-16"
scale: 1
series: kubernetes
options:
@@ -82,7 +82,7 @@
gui-x: 0
gui-y: -250
ro:
- charm: "cs:~charmed-osm/ro-5"
+ charm: "cs:~charmed-osm/ro-8"
scale: 1
series: kubernetes
options:
@@ -91,14 +91,14 @@
gui-x: -300
gui-y: 250
ng-ui:
- charm: "cs:~charmed-osm/ng-ui-22"
+ charm: "cs:~charmed-osm/ng-ui-23"
scale: 1
series: kubernetes
annotations:
gui-x: 600
gui-y: 0
lcm:
- charm: "cs:~charmed-osm/lcm-10"
+ charm: "cs:~charmed-osm/lcm-13"
scale: 1
series: kubernetes
options:
@@ -108,7 +108,7 @@
gui-x: -300
gui-y: 0
mon:
- charm: "cs:~charmed-osm/mon-6"
+ charm: "cs:~charmed-osm/mon-9"
scale: 1
series: kubernetes
options:
@@ -119,7 +119,7 @@
gui-x: 300
gui-y: 0
pol:
- charm: "cs:~charmed-osm/pol-5"
+ charm: "cs:~charmed-osm/pol-8"
scale: 1
series: kubernetes
options:
@@ -128,7 +128,7 @@
gui-x: -300
gui-y: 500
pla:
- charm: "cs:~charmed-osm/pla-10"
+ charm: "cs:~charmed-osm/pla-11"
scale: 1
series: kubernetes
options:
@@ -137,7 +137,7 @@
gui-x: 600
gui-y: -250
prometheus:
- charm: "cs:~charmed-osm/prometheus-5"
+ charm: "cs:~charmed-osm/prometheus-6"
scale: 1
series: kubernetes
storage:
@@ -148,14 +148,14 @@
gui-x: 300
gui-y: 250
grafana:
- charm: "cs:~charmed-osm/grafana-5"
+ charm: "cs:~charmed-osm/grafana-6"
scale: 1
series: kubernetes
annotations:
gui-x: 300
gui-y: 500
keystone:
- charm: "cs:~charmed-osm/keystone-11"
+ charm: "cs:~charmed-osm/keystone-12"
scale: 1
series: kubernetes
annotations:
diff --git a/installers/charm/grafana/charmcraft.yaml b/installers/charm/grafana/charmcraft.yaml
new file mode 100644
index 0000000..0a285a9
--- /dev/null
+++ b/installers/charm/grafana/charmcraft.yaml
@@ -0,0 +1,37 @@
+# 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
+##
+
+type: charm
+bases:
+ - build-on:
+ - name: ubuntu
+ channel: "20.04"
+ architectures: ["amd64"]
+ run-on:
+ - name: ubuntu
+ channel: "20.04"
+ architectures:
+ - amd64
+ - aarch64
+ - arm64
+parts:
+ charm:
+ build-packages: [git]
diff --git a/installers/charm/grafana/src/charm.py b/installers/charm/grafana/src/charm.py
index 9bc612e..87776aa 100755
--- a/installers/charm/grafana/src/charm.py
+++ b/installers/charm/grafana/src/charm.py
@@ -108,15 +108,15 @@
files_builder = FilesV3Builder()
files_builder.add_file(
"dashboard_osm.yaml",
- Path("files/default_dashboards.yaml").read_text(),
+ Path("templates/default_dashboards.yaml").read_text(),
)
if config.osm_dashboards:
osm_dashboards_mapping = {
- "kafka_exporter_dashboard.json": "files/kafka_exporter_dashboard.json",
- "mongodb_exporter_dashboard.json": "files/mongodb_exporter_dashboard.json",
- "mysql_exporter_dashboard.json": "files/mysql_exporter_dashboard.json",
- "nodes_exporter_dashboard.json": "files/nodes_exporter_dashboard.json",
- "summary_dashboard.json": "files/summary_dashboard.json",
+ "kafka_exporter_dashboard.json": "templates/kafka_exporter_dashboard.json",
+ "mongodb_exporter_dashboard.json": "templates/mongodb_exporter_dashboard.json",
+ "mysql_exporter_dashboard.json": "templates/mysql_exporter_dashboard.json",
+ "nodes_exporter_dashboard.json": "templates/nodes_exporter_dashboard.json",
+ "summary_dashboard.json": "templates/summary_dashboard.json",
}
for file_name, path in osm_dashboards_mapping.items():
files_builder.add_file(file_name, Path(path).read_text())
@@ -126,7 +126,7 @@
files_builder = FilesV3Builder()
files_builder.add_file(
"datasource_prometheus.yaml",
- Template(Path("files/default_datasources.yaml").read_text()).substitute(
+ Template(Path("templates/default_datasources.yaml").read_text()).substitute(
prometheus_host=self.prometheus_client.hostname,
prometheus_port=self.prometheus_client.port,
),
diff --git a/installers/charm/grafana/files/default_dashboards.yaml b/installers/charm/grafana/templates/default_dashboards.yaml
similarity index 100%
rename from installers/charm/grafana/files/default_dashboards.yaml
rename to installers/charm/grafana/templates/default_dashboards.yaml
diff --git a/installers/charm/grafana/files/default_datasources.yaml b/installers/charm/grafana/templates/default_datasources.yaml
similarity index 100%
rename from installers/charm/grafana/files/default_datasources.yaml
rename to installers/charm/grafana/templates/default_datasources.yaml
diff --git a/installers/charm/grafana/files/kafka_exporter_dashboard.json b/installers/charm/grafana/templates/kafka_exporter_dashboard.json
similarity index 100%
rename from installers/charm/grafana/files/kafka_exporter_dashboard.json
rename to installers/charm/grafana/templates/kafka_exporter_dashboard.json
diff --git a/installers/charm/grafana/files/mongodb_exporter_dashboard.json b/installers/charm/grafana/templates/mongodb_exporter_dashboard.json
similarity index 100%
rename from installers/charm/grafana/files/mongodb_exporter_dashboard.json
rename to installers/charm/grafana/templates/mongodb_exporter_dashboard.json
diff --git a/installers/charm/grafana/files/mysql_exporter_dashboard.json b/installers/charm/grafana/templates/mysql_exporter_dashboard.json
similarity index 100%
rename from installers/charm/grafana/files/mysql_exporter_dashboard.json
rename to installers/charm/grafana/templates/mysql_exporter_dashboard.json
diff --git a/installers/charm/grafana/files/nodes_exporter_dashboard.json b/installers/charm/grafana/templates/nodes_exporter_dashboard.json
similarity index 100%
rename from installers/charm/grafana/files/nodes_exporter_dashboard.json
rename to installers/charm/grafana/templates/nodes_exporter_dashboard.json
diff --git a/installers/charm/grafana/files/summary_dashboard.json b/installers/charm/grafana/templates/summary_dashboard.json
similarity index 100%
rename from installers/charm/grafana/files/summary_dashboard.json
rename to installers/charm/grafana/templates/summary_dashboard.json
diff --git a/installers/charm/grafana/tox.ini b/installers/charm/grafana/tox.ini
index dc4074f..d3e139d 100644
--- a/installers/charm/grafana/tox.ini
+++ b/installers/charm/grafana/tox.ini
@@ -95,19 +95,22 @@
#######################################################################################
[testenv:build]
passenv=HTTP_PROXY HTTPS_PROXY NO_PROXY
-deps = charmcraft
whitelist_externals =
charmcraft
- cp
+ sh
commands =
charmcraft build
- cp -r build release
+ sh -c 'ubuntu_version=20.04; \
+ architectures="amd64-aarch64-arm64"; \
+ charm_name=`cat metadata.yaml | grep -E "^name: " | cut -f 2 -d " "`; \
+ mv $charm_name"_ubuntu-"$ubuntu_version-$architectures.charm $charm_name.charm'
#######################################################################################
[flake8]
ignore =
W291,
W293,
+ W503,
E123,
E125,
E226,
diff --git a/installers/charm/kafka-exporter/charmcraft.yaml b/installers/charm/kafka-exporter/charmcraft.yaml
new file mode 100644
index 0000000..0a285a9
--- /dev/null
+++ b/installers/charm/kafka-exporter/charmcraft.yaml
@@ -0,0 +1,37 @@
+# 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
+##
+
+type: charm
+bases:
+ - build-on:
+ - name: ubuntu
+ channel: "20.04"
+ architectures: ["amd64"]
+ run-on:
+ - name: ubuntu
+ channel: "20.04"
+ architectures:
+ - amd64
+ - aarch64
+ - arm64
+parts:
+ charm:
+ build-packages: [git]
diff --git a/installers/charm/kafka-exporter/src/charm.py b/installers/charm/kafka-exporter/src/charm.py
index fd24964..2147781 100755
--- a/installers/charm/kafka-exporter/src/charm.py
+++ b/installers/charm/kafka-exporter/src/charm.py
@@ -137,7 +137,7 @@
if self.unit.is_leader():
self.dashboard_target.publish_info(
name="osm-kafka",
- dashboard=Path("files/kafka_exporter_dashboard.json").read_text(),
+ dashboard=Path("templates/kafka_exporter_dashboard.json").read_text(),
)
def _check_missing_dependencies(self, config: ConfigModel):
diff --git a/installers/charm/kafka-exporter/files/kafka_exporter_dashboard.json b/installers/charm/kafka-exporter/templates/kafka_exporter_dashboard.json
similarity index 100%
rename from installers/charm/kafka-exporter/files/kafka_exporter_dashboard.json
rename to installers/charm/kafka-exporter/templates/kafka_exporter_dashboard.json
diff --git a/installers/charm/kafka-exporter/tox.ini b/installers/charm/kafka-exporter/tox.ini
index f207ac3..c341c8e 100644
--- a/installers/charm/kafka-exporter/tox.ini
+++ b/installers/charm/kafka-exporter/tox.ini
@@ -95,13 +95,15 @@
#######################################################################################
[testenv:build]
passenv=HTTP_PROXY HTTPS_PROXY NO_PROXY
-deps = charmcraft
whitelist_externals =
charmcraft
- cp
+ sh
commands =
charmcraft build
- cp -r build release
+ sh -c 'ubuntu_version=20.04; \
+ architectures="amd64-aarch64-arm64"; \
+ charm_name=`cat metadata.yaml | grep -E "^name: " | cut -f 2 -d " "`; \
+ mv $charm_name"_ubuntu-"$ubuntu_version-$architectures.charm $charm_name.charm'
#######################################################################################
[flake8]
diff --git a/installers/charm/keystone/charmcraft.yaml b/installers/charm/keystone/charmcraft.yaml
new file mode 100644
index 0000000..0a285a9
--- /dev/null
+++ b/installers/charm/keystone/charmcraft.yaml
@@ -0,0 +1,37 @@
+# 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
+##
+
+type: charm
+bases:
+ - build-on:
+ - name: ubuntu
+ channel: "20.04"
+ architectures: ["amd64"]
+ run-on:
+ - name: ubuntu
+ channel: "20.04"
+ architectures:
+ - amd64
+ - aarch64
+ - arm64
+parts:
+ charm:
+ build-packages: [git]
diff --git a/installers/charm/keystone/tox.ini b/installers/charm/keystone/tox.ini
index cb37bc8..6537616 100644
--- a/installers/charm/keystone/tox.ini
+++ b/installers/charm/keystone/tox.ini
@@ -95,13 +95,15 @@
#######################################################################################
[testenv:build]
passenv=HTTP_PROXY HTTPS_PROXY NO_PROXY
-deps = charmcraft
whitelist_externals =
charmcraft
- cp
+ sh
commands =
charmcraft build
- cp -r build release
+ sh -c 'ubuntu_version=20.04; \
+ architectures="amd64-aarch64-arm64"; \
+ charm_name=`cat metadata.yaml | grep -E "^name: " | cut -f 2 -d " "`; \
+ mv $charm_name"_ubuntu-"$ubuntu_version-$architectures.charm $charm_name.charm'
#######################################################################################
[flake8]
diff --git a/installers/charm/lcm/charmcraft.yaml b/installers/charm/lcm/charmcraft.yaml
new file mode 100644
index 0000000..0a285a9
--- /dev/null
+++ b/installers/charm/lcm/charmcraft.yaml
@@ -0,0 +1,37 @@
+# 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
+##
+
+type: charm
+bases:
+ - build-on:
+ - name: ubuntu
+ channel: "20.04"
+ architectures: ["amd64"]
+ run-on:
+ - name: ubuntu
+ channel: "20.04"
+ architectures:
+ - amd64
+ - aarch64
+ - arm64
+parts:
+ charm:
+ build-packages: [git]
diff --git a/installers/charm/lcm/config.yaml b/installers/charm/lcm/config.yaml
index 27c43e5..becbc4a 100644
--- a/installers/charm/lcm/config.yaml
+++ b/installers/charm/lcm/config.yaml
@@ -280,3 +280,13 @@
ImagePullPolicy configuration for the pod.
Possible values: always, ifnotpresent, never
default: always
+ debug_mode:
+ description: |
+ If true, debug mode is activated. It means that the service will not run,
+ and instead, the command for the container will be a `sleep infinity`.
+ type: boolean
+ default: false
+ debug_pubkey:
+ description: |
+ Public SSH key that will be injected to the application pod.
+ type: string
diff --git a/installers/charm/lcm/src/charm.py b/installers/charm/lcm/src/charm.py
index 9d7f552..af407e9 100755
--- a/installers/charm/lcm/src/charm.py
+++ b/installers/charm/lcm/src/charm.py
@@ -139,8 +139,13 @@
class LcmCharm(CharmedOsmBase):
def __init__(self, *args) -> NoReturn:
- 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,
+ )
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)
@@ -244,6 +249,28 @@
return pod_spec_builder.build()
+VSCODE_WORKSPACE = {
+ "folders": [
+ {"path": "/usr/lib/python3/dist-packages/osm_lcm"},
+ {"path": "/usr/lib/python3/dist-packages/osm_n2vc"},
+ {"path": "/usr/lib/python3/dist-packages/osm_common"},
+ ],
+ "settings": {},
+ "launch": {
+ "version": "0.2.0",
+ "configurations": [
+ {
+ "name": "LCM",
+ "type": "python",
+ "request": "launch",
+ "module": "osm_lcm.lcm",
+ "justMyCode": False,
+ }
+ ],
+ },
+}
+
+
if __name__ == "__main__":
main(LcmCharm)
diff --git a/installers/charm/lcm/tox.ini b/installers/charm/lcm/tox.ini
index f207ac3..c341c8e 100644
--- a/installers/charm/lcm/tox.ini
+++ b/installers/charm/lcm/tox.ini
@@ -95,13 +95,15 @@
#######################################################################################
[testenv:build]
passenv=HTTP_PROXY HTTPS_PROXY NO_PROXY
-deps = charmcraft
whitelist_externals =
charmcraft
- cp
+ sh
commands =
charmcraft build
- cp -r build release
+ sh -c 'ubuntu_version=20.04; \
+ architectures="amd64-aarch64-arm64"; \
+ charm_name=`cat metadata.yaml | grep -E "^name: " | cut -f 2 -d " "`; \
+ mv $charm_name"_ubuntu-"$ubuntu_version-$architectures.charm $charm_name.charm'
#######################################################################################
[flake8]
diff --git a/installers/charm/mon/charmcraft.yaml b/installers/charm/mon/charmcraft.yaml
new file mode 100644
index 0000000..0a285a9
--- /dev/null
+++ b/installers/charm/mon/charmcraft.yaml
@@ -0,0 +1,37 @@
+# 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
+##
+
+type: charm
+bases:
+ - build-on:
+ - name: ubuntu
+ channel: "20.04"
+ architectures: ["amd64"]
+ run-on:
+ - name: ubuntu
+ channel: "20.04"
+ architectures:
+ - amd64
+ - aarch64
+ - arm64
+parts:
+ charm:
+ build-packages: [git]
diff --git a/installers/charm/mon/config.yaml b/installers/charm/mon/config.yaml
index ee593ff..b8477b1 100644
--- a/installers/charm/mon/config.yaml
+++ b/installers/charm/mon/config.yaml
@@ -93,3 +93,13 @@
ImagePullPolicy configuration for the pod.
Possible values: always, ifnotpresent, never
default: always
+ debug_mode:
+ description: |
+ If true, debug mode is activated. It means that the service will not run,
+ and instead, the command for the container will be a `sleep infinity`.
+ type: boolean
+ default: false
+ debug_pubkey:
+ description: |
+ Public SSH key that will be injected to the application pod.
+ type: string
diff --git a/installers/charm/mon/src/charm.py b/installers/charm/mon/src/charm.py
index 1b7c74b..f253c09 100755
--- a/installers/charm/mon/src/charm.py
+++ b/installers/charm/mon/src/charm.py
@@ -119,7 +119,13 @@
class MonCharm(CharmedOsmBase):
def __init__(self, *args) -> NoReturn:
- 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,
+ )
self.kafka_client = KafkaClient(self, "kafka")
self.framework.observe(self.on["kafka"].relation_changed, self.configure_pod)
@@ -239,5 +245,46 @@
return pod_spec_builder.build()
+VSCODE_WORKSPACE = {
+ "folders": [
+ {"path": "/usr/lib/python3/dist-packages/osm_mon"},
+ {"path": "/usr/lib/python3/dist-packages/osm_common"},
+ {"path": "/usr/lib/python3/dist-packages/n2vc"},
+ ],
+ "settings": {},
+ "launch": {
+ "version": "0.2.0",
+ "configurations": [
+ {
+ "name": "MON Server",
+ "type": "python",
+ "request": "launch",
+ "module": "osm_mon.cmd.mon_server",
+ "justMyCode": False,
+ },
+ {
+ "name": "MON evaluator",
+ "type": "python",
+ "request": "launch",
+ "module": "osm_mon.cmd.mon_evaluator",
+ "justMyCode": False,
+ },
+ {
+ "name": "MON collector",
+ "type": "python",
+ "request": "launch",
+ "module": "osm_mon.cmd.mon_collector",
+ "justMyCode": False,
+ },
+ {
+ "name": "MON dashboarder",
+ "type": "python",
+ "request": "launch",
+ "module": "osm_mon.cmd.mon_dashboarder",
+ "justMyCode": False,
+ },
+ ],
+ },
+}
if __name__ == "__main__":
main(MonCharm)
diff --git a/installers/charm/mon/tox.ini b/installers/charm/mon/tox.ini
index f207ac3..c341c8e 100644
--- a/installers/charm/mon/tox.ini
+++ b/installers/charm/mon/tox.ini
@@ -95,13 +95,15 @@
#######################################################################################
[testenv:build]
passenv=HTTP_PROXY HTTPS_PROXY NO_PROXY
-deps = charmcraft
whitelist_externals =
charmcraft
- cp
+ sh
commands =
charmcraft build
- cp -r build release
+ sh -c 'ubuntu_version=20.04; \
+ architectures="amd64-aarch64-arm64"; \
+ charm_name=`cat metadata.yaml | grep -E "^name: " | cut -f 2 -d " "`; \
+ mv $charm_name"_ubuntu-"$ubuntu_version-$architectures.charm $charm_name.charm'
#######################################################################################
[flake8]
diff --git a/installers/charm/mongodb-exporter/charmcraft.yaml b/installers/charm/mongodb-exporter/charmcraft.yaml
new file mode 100644
index 0000000..0a285a9
--- /dev/null
+++ b/installers/charm/mongodb-exporter/charmcraft.yaml
@@ -0,0 +1,37 @@
+# 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
+##
+
+type: charm
+bases:
+ - build-on:
+ - name: ubuntu
+ channel: "20.04"
+ architectures: ["amd64"]
+ run-on:
+ - name: ubuntu
+ channel: "20.04"
+ architectures:
+ - amd64
+ - aarch64
+ - arm64
+parts:
+ charm:
+ build-packages: [git]
diff --git a/installers/charm/mongodb-exporter/src/charm.py b/installers/charm/mongodb-exporter/src/charm.py
index f4c232a..ad596c3 100755
--- a/installers/charm/mongodb-exporter/src/charm.py
+++ b/installers/charm/mongodb-exporter/src/charm.py
@@ -144,7 +144,7 @@
if self.unit.is_leader():
self.dashboard_target.publish_info(
name="osm-mongodb",
- dashboard=Path("files/mongodb_exporter_dashboard.json").read_text(),
+ dashboard=Path("templates/mongodb_exporter_dashboard.json").read_text(),
)
def _check_missing_dependencies(self, config: ConfigModel):
diff --git a/installers/charm/mongodb-exporter/files/mongodb_exporter_dashboard.json b/installers/charm/mongodb-exporter/templates/mongodb_exporter_dashboard.json
similarity index 100%
rename from installers/charm/mongodb-exporter/files/mongodb_exporter_dashboard.json
rename to installers/charm/mongodb-exporter/templates/mongodb_exporter_dashboard.json
diff --git a/installers/charm/mongodb-exporter/tox.ini b/installers/charm/mongodb-exporter/tox.ini
index f207ac3..c341c8e 100644
--- a/installers/charm/mongodb-exporter/tox.ini
+++ b/installers/charm/mongodb-exporter/tox.ini
@@ -95,13 +95,15 @@
#######################################################################################
[testenv:build]
passenv=HTTP_PROXY HTTPS_PROXY NO_PROXY
-deps = charmcraft
whitelist_externals =
charmcraft
- cp
+ sh
commands =
charmcraft build
- cp -r build release
+ sh -c 'ubuntu_version=20.04; \
+ architectures="amd64-aarch64-arm64"; \
+ charm_name=`cat metadata.yaml | grep -E "^name: " | cut -f 2 -d " "`; \
+ mv $charm_name"_ubuntu-"$ubuntu_version-$architectures.charm $charm_name.charm'
#######################################################################################
[flake8]
diff --git a/installers/charm/mysqld-exporter/charmcraft.yaml b/installers/charm/mysqld-exporter/charmcraft.yaml
new file mode 100644
index 0000000..0a285a9
--- /dev/null
+++ b/installers/charm/mysqld-exporter/charmcraft.yaml
@@ -0,0 +1,37 @@
+# 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
+##
+
+type: charm
+bases:
+ - build-on:
+ - name: ubuntu
+ channel: "20.04"
+ architectures: ["amd64"]
+ run-on:
+ - name: ubuntu
+ channel: "20.04"
+ architectures:
+ - amd64
+ - aarch64
+ - arm64
+parts:
+ charm:
+ build-packages: [git]
diff --git a/installers/charm/mysqld-exporter/src/charm.py b/installers/charm/mysqld-exporter/src/charm.py
index adbb519..a351d2b 100755
--- a/installers/charm/mysqld-exporter/src/charm.py
+++ b/installers/charm/mysqld-exporter/src/charm.py
@@ -144,7 +144,7 @@
if self.unit.is_leader():
self.dashboard_target.publish_info(
name="osm-mysql",
- dashboard=Path("files/mysql_exporter_dashboard.json").read_text(),
+ dashboard=Path("templates/mysql_exporter_dashboard.json").read_text(),
)
def _check_missing_dependencies(self, config: ConfigModel):
diff --git a/installers/charm/mysqld-exporter/files/mysql_exporter_dashboard.json b/installers/charm/mysqld-exporter/templates/mysql_exporter_dashboard.json
similarity index 100%
rename from installers/charm/mysqld-exporter/files/mysql_exporter_dashboard.json
rename to installers/charm/mysqld-exporter/templates/mysql_exporter_dashboard.json
diff --git a/installers/charm/mysqld-exporter/tox.ini b/installers/charm/mysqld-exporter/tox.ini
index f207ac3..c341c8e 100644
--- a/installers/charm/mysqld-exporter/tox.ini
+++ b/installers/charm/mysqld-exporter/tox.ini
@@ -95,13 +95,15 @@
#######################################################################################
[testenv:build]
passenv=HTTP_PROXY HTTPS_PROXY NO_PROXY
-deps = charmcraft
whitelist_externals =
charmcraft
- cp
+ sh
commands =
charmcraft build
- cp -r build release
+ sh -c 'ubuntu_version=20.04; \
+ architectures="amd64-aarch64-arm64"; \
+ charm_name=`cat metadata.yaml | grep -E "^name: " | cut -f 2 -d " "`; \
+ mv $charm_name"_ubuntu-"$ubuntu_version-$architectures.charm $charm_name.charm'
#######################################################################################
[flake8]
diff --git a/installers/charm/nbi/charmcraft.yaml b/installers/charm/nbi/charmcraft.yaml
new file mode 100644
index 0000000..0a285a9
--- /dev/null
+++ b/installers/charm/nbi/charmcraft.yaml
@@ -0,0 +1,37 @@
+# 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
+##
+
+type: charm
+bases:
+ - build-on:
+ - name: ubuntu
+ channel: "20.04"
+ architectures: ["amd64"]
+ run-on:
+ - name: ubuntu
+ channel: "20.04"
+ architectures:
+ - amd64
+ - aarch64
+ - arm64
+parts:
+ charm:
+ build-packages: [git]
diff --git a/installers/charm/nbi/config.yaml b/installers/charm/nbi/config.yaml
index 9c35366..89e248d 100644
--- a/installers/charm/nbi/config.yaml
+++ b/installers/charm/nbi/config.yaml
@@ -78,3 +78,13 @@
ImagePullPolicy configuration for the pod.
Possible values: always, ifnotpresent, never
default: always
+ debug_mode:
+ description: |
+ If true, debug mode is activated. It means that the service will not run,
+ and instead, the command for the container will be a `sleep infinity`.
+ type: boolean
+ default: false
+ debug_pubkey:
+ description: |
+ Public SSH key that will be injected to the application pod.
+ type: string
diff --git a/installers/charm/nbi/src/charm.py b/installers/charm/nbi/src/charm.py
index 938a75a..0e36073 100755
--- a/installers/charm/nbi/src/charm.py
+++ b/installers/charm/nbi/src/charm.py
@@ -116,7 +116,13 @@
class NbiCharm(CharmedOsmBase):
def __init__(self, *args) -> NoReturn:
- 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,
+ )
self.kafka_client = KafkaClient(self, "kafka")
self.framework.observe(self.on["kafka"].relation_changed, self.configure_pod)
@@ -296,5 +302,27 @@
return pod_spec_builder.build()
+VSCODE_WORKSPACE = {
+ "folders": [
+ {"path": "/usr/lib/python3/dist-packages/osm_nbi"},
+ {"path": "/usr/lib/python3/dist-packages/osm_common"},
+ {"path": "/usr/lib/python3/dist-packages/osm_im"},
+ ],
+ "settings": {},
+ "launch": {
+ "version": "0.2.0",
+ "configurations": [
+ {
+ "name": "NBI",
+ "type": "python",
+ "request": "launch",
+ "module": "osm_nbi.nbi",
+ "justMyCode": False,
+ }
+ ],
+ },
+}
+
+
if __name__ == "__main__":
main(NbiCharm)
diff --git a/installers/charm/nbi/tox.ini b/installers/charm/nbi/tox.ini
index f207ac3..c341c8e 100644
--- a/installers/charm/nbi/tox.ini
+++ b/installers/charm/nbi/tox.ini
@@ -95,13 +95,15 @@
#######################################################################################
[testenv:build]
passenv=HTTP_PROXY HTTPS_PROXY NO_PROXY
-deps = charmcraft
whitelist_externals =
charmcraft
- cp
+ sh
commands =
charmcraft build
- cp -r build release
+ sh -c 'ubuntu_version=20.04; \
+ architectures="amd64-aarch64-arm64"; \
+ charm_name=`cat metadata.yaml | grep -E "^name: " | cut -f 2 -d " "`; \
+ mv $charm_name"_ubuntu-"$ubuntu_version-$architectures.charm $charm_name.charm'
#######################################################################################
[flake8]
diff --git a/installers/charm/ng-ui/charmcraft.yaml b/installers/charm/ng-ui/charmcraft.yaml
new file mode 100644
index 0000000..0a285a9
--- /dev/null
+++ b/installers/charm/ng-ui/charmcraft.yaml
@@ -0,0 +1,37 @@
+# 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
+##
+
+type: charm
+bases:
+ - build-on:
+ - name: ubuntu
+ channel: "20.04"
+ architectures: ["amd64"]
+ run-on:
+ - name: ubuntu
+ channel: "20.04"
+ architectures:
+ - amd64
+ - aarch64
+ - arm64
+parts:
+ charm:
+ build-packages: [git]
diff --git a/installers/charm/ng-ui/src/charm.py b/installers/charm/ng-ui/src/charm.py
index cf0b091..56644f2 100755
--- a/installers/charm/ng-ui/src/charm.py
+++ b/installers/charm/ng-ui/src/charm.py
@@ -116,7 +116,7 @@
files_builder = FilesV3Builder()
files_builder.add_file(
"default",
- Template(Path("files/default").read_text()).substitute(
+ Template(Path("templates/default.template").read_text()).substitute(
port=config.port,
server_name=config.server_name,
max_file_size=config.max_file_size,
diff --git a/installers/charm/ng-ui/files/default b/installers/charm/ng-ui/templates/default.template
similarity index 100%
rename from installers/charm/ng-ui/files/default
rename to installers/charm/ng-ui/templates/default.template
diff --git a/installers/charm/ng-ui/tox.ini b/installers/charm/ng-ui/tox.ini
index dc4074f..d3e139d 100644
--- a/installers/charm/ng-ui/tox.ini
+++ b/installers/charm/ng-ui/tox.ini
@@ -95,19 +95,22 @@
#######################################################################################
[testenv:build]
passenv=HTTP_PROXY HTTPS_PROXY NO_PROXY
-deps = charmcraft
whitelist_externals =
charmcraft
- cp
+ sh
commands =
charmcraft build
- cp -r build release
+ sh -c 'ubuntu_version=20.04; \
+ architectures="amd64-aarch64-arm64"; \
+ charm_name=`cat metadata.yaml | grep -E "^name: " | cut -f 2 -d " "`; \
+ mv $charm_name"_ubuntu-"$ubuntu_version-$architectures.charm $charm_name.charm'
#######################################################################################
[flake8]
ignore =
W291,
W293,
+ W503,
E123,
E125,
E226,
diff --git a/installers/charm/pla/charmcraft.yaml b/installers/charm/pla/charmcraft.yaml
new file mode 100644
index 0000000..0a285a9
--- /dev/null
+++ b/installers/charm/pla/charmcraft.yaml
@@ -0,0 +1,37 @@
+# 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
+##
+
+type: charm
+bases:
+ - build-on:
+ - name: ubuntu
+ channel: "20.04"
+ architectures: ["amd64"]
+ run-on:
+ - name: ubuntu
+ channel: "20.04"
+ architectures:
+ - amd64
+ - aarch64
+ - arm64
+parts:
+ charm:
+ build-packages: [git]
diff --git a/installers/charm/pla/tox.ini b/installers/charm/pla/tox.ini
index f207ac3..c341c8e 100644
--- a/installers/charm/pla/tox.ini
+++ b/installers/charm/pla/tox.ini
@@ -95,13 +95,15 @@
#######################################################################################
[testenv:build]
passenv=HTTP_PROXY HTTPS_PROXY NO_PROXY
-deps = charmcraft
whitelist_externals =
charmcraft
- cp
+ sh
commands =
charmcraft build
- cp -r build release
+ sh -c 'ubuntu_version=20.04; \
+ architectures="amd64-aarch64-arm64"; \
+ charm_name=`cat metadata.yaml | grep -E "^name: " | cut -f 2 -d " "`; \
+ mv $charm_name"_ubuntu-"$ubuntu_version-$architectures.charm $charm_name.charm'
#######################################################################################
[flake8]
diff --git a/installers/charm/pol/charmcraft.yaml b/installers/charm/pol/charmcraft.yaml
new file mode 100644
index 0000000..0a285a9
--- /dev/null
+++ b/installers/charm/pol/charmcraft.yaml
@@ -0,0 +1,37 @@
+# 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
+##
+
+type: charm
+bases:
+ - build-on:
+ - name: ubuntu
+ channel: "20.04"
+ architectures: ["amd64"]
+ run-on:
+ - name: ubuntu
+ channel: "20.04"
+ architectures:
+ - amd64
+ - aarch64
+ - arm64
+parts:
+ charm:
+ build-packages: [git]
diff --git a/installers/charm/pol/config.yaml b/installers/charm/pol/config.yaml
index 7b64f57..3264ca3 100644
--- a/installers/charm/pol/config.yaml
+++ b/installers/charm/pol/config.yaml
@@ -38,3 +38,13 @@
ImagePullPolicy configuration for the pod.
Possible values: always, ifnotpresent, never
default: always
+ debug_mode:
+ description: |
+ If true, debug mode is activated. It means that the service will not run,
+ and instead, the command for the container will be a `sleep infinity`.
+ type: boolean
+ default: false
+ debug_pubkey:
+ description: |
+ Public SSH key that will be injected to the application pod.
+ type: string
diff --git a/installers/charm/pol/src/charm.py b/installers/charm/pol/src/charm.py
index 727ffbe..d1341c1 100755
--- a/installers/charm/pol/src/charm.py
+++ b/installers/charm/pol/src/charm.py
@@ -85,7 +85,13 @@
class PolCharm(CharmedOsmBase):
def __init__(self, *args) -> NoReturn:
- 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,
+ )
self.kafka_client = KafkaClient(self, "kafka")
self.framework.observe(self.on["kafka"].relation_changed, self.configure_pod)
@@ -156,5 +162,26 @@
return pod_spec_builder.build()
+VSCODE_WORKSPACE = {
+ "folders": [
+ {"path": "/usr/lib/python3/dist-packages/osm_policy_module"},
+ {"path": "/usr/lib/python3/dist-packages/osm_common"},
+ ],
+ "settings": {},
+ "launch": {
+ "version": "0.2.0",
+ "configurations": [
+ {
+ "name": "POL",
+ "type": "python",
+ "request": "launch",
+ "module": "osm_policy_module.cmd.policy_module_agent",
+ "justMyCode": False,
+ }
+ ],
+ },
+}
+
+
if __name__ == "__main__":
main(PolCharm)
diff --git a/installers/charm/pol/tox.ini b/installers/charm/pol/tox.ini
index f207ac3..c341c8e 100644
--- a/installers/charm/pol/tox.ini
+++ b/installers/charm/pol/tox.ini
@@ -95,13 +95,15 @@
#######################################################################################
[testenv:build]
passenv=HTTP_PROXY HTTPS_PROXY NO_PROXY
-deps = charmcraft
whitelist_externals =
charmcraft
- cp
+ sh
commands =
charmcraft build
- cp -r build release
+ sh -c 'ubuntu_version=20.04; \
+ architectures="amd64-aarch64-arm64"; \
+ charm_name=`cat metadata.yaml | grep -E "^name: " | cut -f 2 -d " "`; \
+ mv $charm_name"_ubuntu-"$ubuntu_version-$architectures.charm $charm_name.charm'
#######################################################################################
[flake8]
diff --git a/installers/charm/prometheus/charmcraft.yaml b/installers/charm/prometheus/charmcraft.yaml
new file mode 100644
index 0000000..0a285a9
--- /dev/null
+++ b/installers/charm/prometheus/charmcraft.yaml
@@ -0,0 +1,37 @@
+# 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
+##
+
+type: charm
+bases:
+ - build-on:
+ - name: ubuntu
+ channel: "20.04"
+ architectures: ["amd64"]
+ run-on:
+ - name: ubuntu
+ channel: "20.04"
+ architectures:
+ - amd64
+ - aarch64
+ - arm64
+parts:
+ charm:
+ build-packages: [git]
diff --git a/installers/charm/prometheus/tox.ini b/installers/charm/prometheus/tox.ini
index 30e0ea8..c341c8e 100644
--- a/installers/charm/prometheus/tox.ini
+++ b/installers/charm/prometheus/tox.ini
@@ -95,19 +95,22 @@
#######################################################################################
[testenv:build]
passenv=HTTP_PROXY HTTPS_PROXY NO_PROXY
-deps = charmcraft
whitelist_externals =
charmcraft
- cp
+ sh
commands =
charmcraft build
- cp -r build release
+ sh -c 'ubuntu_version=20.04; \
+ architectures="amd64-aarch64-arm64"; \
+ charm_name=`cat metadata.yaml | grep -E "^name: " | cut -f 2 -d " "`; \
+ mv $charm_name"_ubuntu-"$ubuntu_version-$architectures.charm $charm_name.charm'
#######################################################################################
[flake8]
ignore =
W291,
W293,
+ W503,
E123,
E125,
E226,
diff --git a/installers/charm/ro/charmcraft.yaml b/installers/charm/ro/charmcraft.yaml
new file mode 100644
index 0000000..0a285a9
--- /dev/null
+++ b/installers/charm/ro/charmcraft.yaml
@@ -0,0 +1,37 @@
+# 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
+##
+
+type: charm
+bases:
+ - build-on:
+ - name: ubuntu
+ channel: "20.04"
+ architectures: ["amd64"]
+ run-on:
+ - name: ubuntu
+ channel: "20.04"
+ architectures:
+ - amd64
+ - aarch64
+ - arm64
+parts:
+ charm:
+ build-packages: [git]
diff --git a/installers/charm/ro/config.yaml b/installers/charm/ro/config.yaml
index 5bb0362..9828438 100644
--- a/installers/charm/ro/config.yaml
+++ b/installers/charm/ro/config.yaml
@@ -76,3 +76,13 @@
ImagePullPolicy configuration for the pod.
Possible values: always, ifnotpresent, never
default: always
+ debug_mode:
+ description: |
+ If true, debug mode is activated. It means that the service will not run,
+ and instead, the command for the container will be a `sleep infinity`.
+ type: boolean
+ default: false
+ debug_pubkey:
+ description: |
+ Public SSH key that will be injected to the application pod.
+ type: string
diff --git a/installers/charm/ro/src/charm.py b/installers/charm/ro/src/charm.py
index d87007e..5212393 100755
--- a/installers/charm/ro/src/charm.py
+++ b/installers/charm/ro/src/charm.py
@@ -121,7 +121,13 @@
def __init__(self, *args) -> NoReturn:
"""Prometheus Charm constructor."""
- 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,
+ )
self.kafka_client = KafkaClient(self, "kafka")
self.framework.observe(self.on["kafka"].relation_changed, self.configure_pod)
@@ -284,5 +290,42 @@
return pod_spec_builder.build()
+VSCODE_WORKSPACE = {
+ "folders": [
+ {"path": "/usr/lib/python3/dist-packages/osm_ng_ro"},
+ {"path": "/usr/lib/python3/dist-packages/osm_common"},
+ {"path": "/usr/lib/python3/dist-packages/osm_ro_plugin"},
+ {"path": "/usr/lib/python3/dist-packages/osm_rosdn_arista_cloudvision"},
+ {"path": "/usr/lib/python3/dist-packages/osm_rosdn_dpb"},
+ {"path": "/usr/lib/python3/dist-packages/osm_rosdn_dynpac"},
+ {"path": "/usr/lib/python3/dist-packages/osm_rosdn_floodlightof"},
+ {"path": "/usr/lib/python3/dist-packages/osm_rosdn_ietfl2vpn"},
+ {"path": "/usr/lib/python3/dist-packages/osm_rosdn_juniper_contrail"},
+ {"path": "/usr/lib/python3/dist-packages/osm_rosdn_odlof"},
+ {"path": "/usr/lib/python3/dist-packages/osm_rosdn_onos_vpls"},
+ {"path": "/usr/lib/python3/dist-packages/osm_rosdn_onosof"},
+ {"path": "/usr/lib/python3/dist-packages/osm_rovim_aws"},
+ {"path": "/usr/lib/python3/dist-packages/osm_rovim_azure"},
+ {"path": "/usr/lib/python3/dist-packages/osm_rovim_fos"},
+ {"path": "/usr/lib/python3/dist-packages/osm_rovim_opennebula"},
+ {"path": "/usr/lib/python3/dist-packages/osm_rovim_openstack"},
+ {"path": "/usr/lib/python3/dist-packages/osm_rovim_openvim"},
+ {"path": "/usr/lib/python3/dist-packages/osm_rovim_vmware"},
+ ],
+ "launch": {
+ "configurations": [
+ {
+ "module": "osm_ng_ro.ro_main",
+ "name": "NG RO",
+ "request": "launch",
+ "type": "python",
+ "justMyCode": False,
+ }
+ ],
+ "version": "0.2.0",
+ },
+ "settings": {},
+}
+
if __name__ == "__main__":
main(RoCharm)
diff --git a/installers/charm/ro/tox.ini b/installers/charm/ro/tox.ini
index f207ac3..c341c8e 100644
--- a/installers/charm/ro/tox.ini
+++ b/installers/charm/ro/tox.ini
@@ -95,13 +95,15 @@
#######################################################################################
[testenv:build]
passenv=HTTP_PROXY HTTPS_PROXY NO_PROXY
-deps = charmcraft
whitelist_externals =
charmcraft
- cp
+ sh
commands =
charmcraft build
- cp -r build release
+ sh -c 'ubuntu_version=20.04; \
+ architectures="amd64-aarch64-arm64"; \
+ charm_name=`cat metadata.yaml | grep -E "^name: " | cut -f 2 -d " "`; \
+ mv $charm_name"_ubuntu-"$ubuntu_version-$architectures.charm $charm_name.charm'
#######################################################################################
[flake8]
diff --git a/tools/debug/charmed/README.md b/tools/debug/charmed/README.md
new file mode 100644
index 0000000..1330454
--- /dev/null
+++ b/tools/debug/charmed/README.md
@@ -0,0 +1,113 @@
+<!--
+ Copyright 2020 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
+-->
+
+# Debugging Charmed OSM
+
+This document aims to provide the OSM community an easy way of testing and debugging OSM.
+
+Benefits:
+
+- Use upstream published images for debugging: No need to build local images anymore.
+- 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.
+
+## Install OSM
+
+Download the installer:
+
+```bash
+wget http://osm-download.etsi.org/ftp/osm-10.0-ten/install_osm.sh
+chmod +x install_osm.sh
+```
+
+Install OSM from master (tag=testing-daily):
+
+```bash
+./install_osm.sh -R testing-daily -r testing --charmed
+```
+
+Install OSM from a specific tag:
+
+```bash
+./install_osm.sh -R testing-daily -r testing --charmed --tag <X.Y.Z>
+```
+
+## Debugging
+
+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 ..."`
+
+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
+
+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
+```
+
+> 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`.
+
+### Connect to Pods
+
+In VScode, navigate to [Remote Explorer](https://code.visualstudio.com/docs/remote/ssh#_remember-hosts-and-advanced-settings), and select the pod to which you want to connect.
+
+You should be able to see the following hosts in the Remote Explorer:
+
+- lcm
+- mon
+- nbi
+- ro
+- pol
+
+Right click on the host, and "Connect to host in a New Window".
+
+### Add workspace
+
+The `./prepare_pods.sh` script adds a workspace to the `/root` folder of each pod, with the following name: `<module>.code-workspace`.
+
+In the window of the connected host, go to `File/Open Workspace...`. Then select the `<module>.code-workspace` file.
+
+### 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`.
+
+Now you will be asked to select a folder in your workspace. Select the folder of the main component:
+
+- 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)
diff --git a/tools/debug/charmed/prepare_pods.sh b/tools/debug/charmed/prepare_pods.sh
new file mode 100755
index 0000000..8f740e4
--- /dev/null
+++ b/tools/debug/charmed/prepare_pods.sh
@@ -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 .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