| sousaedu | 1dd4c0d | 2020-11-04 17:43:47 +0000 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
| David Garcia | 49379ce | 2021-02-24 13:48:22 +0100 | [diff] [blame] | 2 | # Copyright 2021 Canonical Ltd. |
| sousaedu | 1dd4c0d | 2020-11-04 17:43:47 +0000 | [diff] [blame] | 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 5 | # not use this file except in compliance with the License. You may obtain |
| 6 | # a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 12 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 13 | # License for the specific language governing permissions and limitations |
| 14 | # under the License. |
| 15 | # |
| 16 | # For those usages not covered by the Apache License, Version 2.0 please |
| 17 | # contact: legal@canonical.com |
| 18 | # |
| 19 | # To get in touch with the maintainers, please contact: |
| 20 | # osm-charmers@lists.launchpad.net |
| 21 | ## |
| 22 | |
| David Garcia | 49379ce | 2021-02-24 13:48:22 +0100 | [diff] [blame] | 23 | # pylint: disable=E0213 |
| 24 | |
| 25 | |
| David Garcia | 5d1ec6e | 2021-03-25 15:04:52 +0100 | [diff] [blame] | 26 | import base64 |
| sousaedu | 1dd4c0d | 2020-11-04 17:43:47 +0000 | [diff] [blame] | 27 | import logging |
| David Garcia | 5d1ec6e | 2021-03-25 15:04:52 +0100 | [diff] [blame] | 28 | from typing import NoReturn, Optional |
| sousaedu | 1dd4c0d | 2020-11-04 17:43:47 +0000 | [diff] [blame] | 29 | |
| David Garcia | c753dc5 | 2021-03-17 15:28:47 +0100 | [diff] [blame] | 30 | |
| sousaedu | 1dd4c0d | 2020-11-04 17:43:47 +0000 | [diff] [blame] | 31 | from ops.main import main |
| David Garcia | 49379ce | 2021-02-24 13:48:22 +0100 | [diff] [blame] | 32 | from opslib.osm.charm import CharmedOsmBase, RelationsMissing |
| David Garcia | 49379ce | 2021-02-24 13:48:22 +0100 | [diff] [blame] | 33 | from opslib.osm.interfaces.kafka import KafkaClient |
| David Garcia | c753dc5 | 2021-03-17 15:28:47 +0100 | [diff] [blame] | 34 | from opslib.osm.interfaces.keystone import KeystoneClient |
| David Garcia | 49379ce | 2021-02-24 13:48:22 +0100 | [diff] [blame] | 35 | from opslib.osm.interfaces.mongo import MongoClient |
| 36 | from opslib.osm.interfaces.prometheus import PrometheusClient |
| David Garcia | 141d935 | 2021-09-08 17:48:40 +0200 | [diff] [blame] | 37 | from opslib.osm.pod import ( |
| 38 | ContainerV3Builder, |
| 39 | FilesV3Builder, |
| 40 | PodRestartPolicy, |
| 41 | PodSpecV3Builder, |
| 42 | ) |
| David Garcia | c753dc5 | 2021-03-17 15:28:47 +0100 | [diff] [blame] | 43 | from opslib.osm.validator import ModelValidator, validator |
| sousaedu | 1dd4c0d | 2020-11-04 17:43:47 +0000 | [diff] [blame] | 44 | |
| 45 | |
| David Garcia | 49379ce | 2021-02-24 13:48:22 +0100 | [diff] [blame] | 46 | logger = logging.getLogger(__name__) |
| sousaedu | 1dd4c0d | 2020-11-04 17:43:47 +0000 | [diff] [blame] | 47 | |
| David Garcia | 49379ce | 2021-02-24 13:48:22 +0100 | [diff] [blame] | 48 | PORT = 8000 |
| sousaedu | 1dd4c0d | 2020-11-04 17:43:47 +0000 | [diff] [blame] | 49 | |
| 50 | |
| David Garcia | 5d1ec6e | 2021-03-25 15:04:52 +0100 | [diff] [blame] | 51 | def _check_certificate_data(name: str, content: str): |
| 52 | if not name or not content: |
| 53 | raise ValueError("certificate name and content must be a non-empty string") |
| 54 | |
| 55 | |
| 56 | def _extract_certificates(certs_config: str): |
| 57 | certificates = {} |
| 58 | if certs_config: |
| 59 | cert_list = certs_config.split(",") |
| 60 | for cert in cert_list: |
| 61 | name, content = cert.split(":") |
| 62 | _check_certificate_data(name, content) |
| 63 | certificates[name] = content |
| 64 | return certificates |
| 65 | |
| 66 | |
| 67 | def decode(content: str): |
| 68 | return base64.b64decode(content.encode("utf-8")).decode("utf-8") |
| 69 | |
| 70 | |
| David Garcia | 49379ce | 2021-02-24 13:48:22 +0100 | [diff] [blame] | 71 | class ConfigModel(ModelValidator): |
| calvinosanc1 | a43a22f | 2021-03-08 15:20:07 +0100 | [diff] [blame] | 72 | keystone_enabled: bool |
| David Garcia | 49379ce | 2021-02-24 13:48:22 +0100 | [diff] [blame] | 73 | vca_host: str |
| 74 | vca_user: str |
| David Garcia | c753dc5 | 2021-03-17 15:28:47 +0100 | [diff] [blame] | 75 | vca_secret: str |
| David Garcia | 49379ce | 2021-02-24 13:48:22 +0100 | [diff] [blame] | 76 | vca_cacert: str |
| 77 | database_commonkey: str |
| sousaedu | 996a560 | 2021-05-03 00:22:43 +0200 | [diff] [blame] | 78 | mongodb_uri: Optional[str] |
| David Garcia | 49379ce | 2021-02-24 13:48:22 +0100 | [diff] [blame] | 79 | log_level: str |
| 80 | openstack_default_granularity: int |
| 81 | global_request_timeout: int |
| 82 | collector_interval: int |
| 83 | evaluator_interval: int |
| 84 | grafana_url: str |
| 85 | grafana_user: str |
| 86 | grafana_password: str |
| David Garcia | 5d1ec6e | 2021-03-25 15:04:52 +0100 | [diff] [blame] | 87 | certificates: Optional[str] |
| sousaedu | 0dc25b3 | 2021-08-30 16:33:33 +0100 | [diff] [blame] | 88 | image_pull_policy: str |
| sousaedu | 540d937 | 2021-09-29 01:53:30 +0100 | [diff] [blame] | 89 | debug_mode: bool |
| 90 | security_context: bool |
| sousaedu | 1dd4c0d | 2020-11-04 17:43:47 +0000 | [diff] [blame] | 91 | |
| David Garcia | 49379ce | 2021-02-24 13:48:22 +0100 | [diff] [blame] | 92 | @validator("log_level") |
| 93 | def validate_log_level(cls, v): |
| 94 | if v not in {"INFO", "DEBUG"}: |
| 95 | raise ValueError("value must be INFO or DEBUG") |
| 96 | return v |
| sousaedu | 1dd4c0d | 2020-11-04 17:43:47 +0000 | [diff] [blame] | 97 | |
| David Garcia | 5d1ec6e | 2021-03-25 15:04:52 +0100 | [diff] [blame] | 98 | @validator("certificates") |
| 99 | def validate_certificates(cls, v): |
| 100 | # Raises an exception if it cannot extract the certificates |
| 101 | _extract_certificates(v) |
| 102 | return v |
| 103 | |
| sousaedu | 996a560 | 2021-05-03 00:22:43 +0200 | [diff] [blame] | 104 | @validator("mongodb_uri") |
| 105 | def validate_mongodb_uri(cls, v): |
| 106 | if v and not v.startswith("mongodb://"): |
| 107 | raise ValueError("mongodb_uri is not properly formed") |
| 108 | return v |
| 109 | |
| sousaedu | 3ddbbd1 | 2021-08-24 19:57:24 +0100 | [diff] [blame] | 110 | @validator("image_pull_policy") |
| 111 | def validate_image_pull_policy(cls, v): |
| 112 | values = { |
| 113 | "always": "Always", |
| 114 | "ifnotpresent": "IfNotPresent", |
| 115 | "never": "Never", |
| 116 | } |
| 117 | v = v.lower() |
| 118 | if v not in values.keys(): |
| 119 | raise ValueError("value must be always, ifnotpresent or never") |
| 120 | return values[v] |
| 121 | |
| David Garcia | 5d1ec6e | 2021-03-25 15:04:52 +0100 | [diff] [blame] | 122 | @property |
| 123 | def certificates_dict(cls): |
| 124 | return _extract_certificates(cls.certificates) if cls.certificates else {} |
| 125 | |
| sousaedu | 1dd4c0d | 2020-11-04 17:43:47 +0000 | [diff] [blame] | 126 | |
| David Garcia | 49379ce | 2021-02-24 13:48:22 +0100 | [diff] [blame] | 127 | class MonCharm(CharmedOsmBase): |
| sousaedu | 1dd4c0d | 2020-11-04 17:43:47 +0000 | [diff] [blame] | 128 | def __init__(self, *args) -> NoReturn: |
| David Garcia | d680be4 | 2021-08-17 11:03:55 +0200 | [diff] [blame] | 129 | super().__init__( |
| 130 | *args, |
| 131 | oci_image="image", |
| David Garcia | d680be4 | 2021-08-17 11:03:55 +0200 | [diff] [blame] | 132 | vscode_workspace=VSCODE_WORKSPACE, |
| 133 | ) |
| David Garcia | cafe31e | 2021-11-18 16:45:05 +0100 | [diff] [blame] | 134 | if self.config.get("debug_mode"): |
| 135 | self.enable_debug_mode( |
| 136 | pubkey=self.config.get("debug_pubkey"), |
| 137 | hostpaths={ |
| 138 | "MON": { |
| 139 | "hostpath": self.config.get("debug_mon_local_path"), |
| 140 | "container-path": "/usr/lib/python3/dist-packages/osm_mon", |
| 141 | }, |
| 142 | "N2VC": { |
| 143 | "hostpath": self.config.get("debug_n2vc_local_path"), |
| 144 | "container-path": "/usr/lib/python3/dist-packages/n2vc", |
| 145 | }, |
| 146 | "osm_common": { |
| 147 | "hostpath": self.config.get("debug_common_local_path"), |
| 148 | "container-path": "/usr/lib/python3/dist-packages/osm_common", |
| 149 | }, |
| 150 | }, |
| 151 | ) |
| David Garcia | 49379ce | 2021-02-24 13:48:22 +0100 | [diff] [blame] | 152 | self.kafka_client = KafkaClient(self, "kafka") |
| 153 | self.framework.observe(self.on["kafka"].relation_changed, self.configure_pod) |
| 154 | self.framework.observe(self.on["kafka"].relation_broken, self.configure_pod) |
| sousaedu | 1dd4c0d | 2020-11-04 17:43:47 +0000 | [diff] [blame] | 155 | |
| David Garcia | 49379ce | 2021-02-24 13:48:22 +0100 | [diff] [blame] | 156 | self.mongodb_client = MongoClient(self, "mongodb") |
| 157 | self.framework.observe(self.on["mongodb"].relation_changed, self.configure_pod) |
| 158 | self.framework.observe(self.on["mongodb"].relation_broken, self.configure_pod) |
| sousaedu | 1dd4c0d | 2020-11-04 17:43:47 +0000 | [diff] [blame] | 159 | |
| David Garcia | 49379ce | 2021-02-24 13:48:22 +0100 | [diff] [blame] | 160 | self.prometheus_client = PrometheusClient(self, "prometheus") |
| sousaedu | 1dd4c0d | 2020-11-04 17:43:47 +0000 | [diff] [blame] | 161 | self.framework.observe( |
| David Garcia | 49379ce | 2021-02-24 13:48:22 +0100 | [diff] [blame] | 162 | self.on["prometheus"].relation_changed, self.configure_pod |
| sousaedu | 1dd4c0d | 2020-11-04 17:43:47 +0000 | [diff] [blame] | 163 | ) |
| 164 | self.framework.observe( |
| David Garcia | 49379ce | 2021-02-24 13:48:22 +0100 | [diff] [blame] | 165 | self.on["prometheus"].relation_broken, self.configure_pod |
| sousaedu | 1dd4c0d | 2020-11-04 17:43:47 +0000 | [diff] [blame] | 166 | ) |
| 167 | |
| calvinosanc1 | a43a22f | 2021-03-08 15:20:07 +0100 | [diff] [blame] | 168 | self.keystone_client = KeystoneClient(self, "keystone") |
| 169 | self.framework.observe(self.on["keystone"].relation_changed, self.configure_pod) |
| 170 | self.framework.observe(self.on["keystone"].relation_broken, self.configure_pod) |
| 171 | |
| David Garcia | 49379ce | 2021-02-24 13:48:22 +0100 | [diff] [blame] | 172 | def _check_missing_dependencies(self, config: ConfigModel): |
| 173 | missing_relations = [] |
| 174 | |
| David Garcia | de440ed | 2021-10-11 19:56:53 +0200 | [diff] [blame] | 175 | if ( |
| 176 | self.kafka_client.is_missing_data_in_unit() |
| 177 | and self.kafka_client.is_missing_data_in_app() |
| 178 | ): |
| David Garcia | 49379ce | 2021-02-24 13:48:22 +0100 | [diff] [blame] | 179 | missing_relations.append("kafka") |
| sousaedu | 996a560 | 2021-05-03 00:22:43 +0200 | [diff] [blame] | 180 | if not config.mongodb_uri and self.mongodb_client.is_missing_data_in_unit(): |
| David Garcia | 49379ce | 2021-02-24 13:48:22 +0100 | [diff] [blame] | 181 | missing_relations.append("mongodb") |
| 182 | if self.prometheus_client.is_missing_data_in_app(): |
| 183 | missing_relations.append("prometheus") |
| calvinosanc1 | a43a22f | 2021-03-08 15:20:07 +0100 | [diff] [blame] | 184 | if config.keystone_enabled: |
| 185 | if self.keystone_client.is_missing_data_in_app(): |
| 186 | missing_relations.append("keystone") |
| David Garcia | 49379ce | 2021-02-24 13:48:22 +0100 | [diff] [blame] | 187 | |
| 188 | if missing_relations: |
| 189 | raise RelationsMissing(missing_relations) |
| 190 | |
| David Garcia | 5d1ec6e | 2021-03-25 15:04:52 +0100 | [diff] [blame] | 191 | def _build_cert_files( |
| 192 | self, |
| 193 | config: ConfigModel, |
| 194 | ): |
| 195 | cert_files_builder = FilesV3Builder() |
| 196 | for name, content in config.certificates_dict.items(): |
| 197 | cert_files_builder.add_file(name, decode(content), mode=0o600) |
| 198 | return cert_files_builder.build() |
| 199 | |
| David Garcia | 49379ce | 2021-02-24 13:48:22 +0100 | [diff] [blame] | 200 | def build_pod_spec(self, image_info): |
| 201 | # Validate config |
| 202 | config = ConfigModel(**dict(self.config)) |
| sousaedu | 996a560 | 2021-05-03 00:22:43 +0200 | [diff] [blame] | 203 | |
| 204 | if config.mongodb_uri and not self.mongodb_client.is_missing_data_in_unit(): |
| 205 | raise Exception("Mongodb data cannot be provided via config and relation") |
| 206 | |
| David Garcia | 49379ce | 2021-02-24 13:48:22 +0100 | [diff] [blame] | 207 | # Check relations |
| 208 | self._check_missing_dependencies(config) |
| sousaedu | 996a560 | 2021-05-03 00:22:43 +0200 | [diff] [blame] | 209 | |
| sousaedu | 540d937 | 2021-09-29 01:53:30 +0100 | [diff] [blame] | 210 | security_context_enabled = ( |
| 211 | config.security_context if not config.debug_mode else False |
| 212 | ) |
| 213 | |
| David Garcia | 49379ce | 2021-02-24 13:48:22 +0100 | [diff] [blame] | 214 | # Create Builder for the PodSpec |
| sousaedu | 540d937 | 2021-09-29 01:53:30 +0100 | [diff] [blame] | 215 | pod_spec_builder = PodSpecV3Builder( |
| 216 | enable_security_context=security_context_enabled |
| 217 | ) |
| sousaedu | 996a560 | 2021-05-03 00:22:43 +0200 | [diff] [blame] | 218 | |
| David Garcia | 141d935 | 2021-09-08 17:48:40 +0200 | [diff] [blame] | 219 | # Add secrets to the pod |
| 220 | mongodb_secret_name = f"{self.app.name}-mongodb-secret" |
| 221 | pod_spec_builder.add_secret( |
| 222 | mongodb_secret_name, |
| 223 | { |
| 224 | "uri": config.mongodb_uri or self.mongodb_client.connection_string, |
| 225 | "commonkey": config.database_commonkey, |
| 226 | }, |
| 227 | ) |
| 228 | grafana_secret_name = f"{self.app.name}-grafana-secret" |
| 229 | pod_spec_builder.add_secret( |
| 230 | grafana_secret_name, |
| 231 | { |
| 232 | "url": config.grafana_url, |
| 233 | "user": config.grafana_user, |
| 234 | "password": config.grafana_password, |
| 235 | }, |
| 236 | ) |
| 237 | |
| 238 | vca_secret_name = f"{self.app.name}-vca-secret" |
| 239 | pod_spec_builder.add_secret( |
| 240 | vca_secret_name, |
| 241 | { |
| 242 | "host": config.vca_host, |
| 243 | "user": config.vca_user, |
| 244 | "secret": config.vca_secret, |
| 245 | "cacert": config.vca_cacert, |
| 246 | }, |
| 247 | ) |
| 248 | |
| David Garcia | 49379ce | 2021-02-24 13:48:22 +0100 | [diff] [blame] | 249 | # Build Container |
| sousaedu | 3ddbbd1 | 2021-08-24 19:57:24 +0100 | [diff] [blame] | 250 | container_builder = ContainerV3Builder( |
| sousaedu | 540d937 | 2021-09-29 01:53:30 +0100 | [diff] [blame] | 251 | self.app.name, |
| 252 | image_info, |
| 253 | config.image_pull_policy, |
| 254 | run_as_non_root=security_context_enabled, |
| sousaedu | 3ddbbd1 | 2021-08-24 19:57:24 +0100 | [diff] [blame] | 255 | ) |
| David Garcia | 5d1ec6e | 2021-03-25 15:04:52 +0100 | [diff] [blame] | 256 | certs_files = self._build_cert_files(config) |
| sousaedu | 996a560 | 2021-05-03 00:22:43 +0200 | [diff] [blame] | 257 | |
| David Garcia | 5d1ec6e | 2021-03-25 15:04:52 +0100 | [diff] [blame] | 258 | if certs_files: |
| 259 | container_builder.add_volume_config("certs", "/certs", certs_files) |
| sousaedu | 996a560 | 2021-05-03 00:22:43 +0200 | [diff] [blame] | 260 | |
| David Garcia | 49379ce | 2021-02-24 13:48:22 +0100 | [diff] [blame] | 261 | container_builder.add_port(name=self.app.name, port=PORT) |
| 262 | container_builder.add_envs( |
| 263 | { |
| 264 | # General configuration |
| 265 | "ALLOW_ANONYMOUS_LOGIN": "yes", |
| 266 | "OSMMON_OPENSTACK_DEFAULT_GRANULARITY": config.openstack_default_granularity, |
| 267 | "OSMMON_GLOBAL_REQUEST_TIMEOUT": config.global_request_timeout, |
| 268 | "OSMMON_GLOBAL_LOGLEVEL": config.log_level, |
| 269 | "OSMMON_COLLECTOR_INTERVAL": config.collector_interval, |
| 270 | "OSMMON_EVALUATOR_INTERVAL": config.evaluator_interval, |
| 271 | # Kafka configuration |
| 272 | "OSMMON_MESSAGE_DRIVER": "kafka", |
| 273 | "OSMMON_MESSAGE_HOST": self.kafka_client.host, |
| 274 | "OSMMON_MESSAGE_PORT": self.kafka_client.port, |
| 275 | # Database configuration |
| 276 | "OSMMON_DATABASE_DRIVER": "mongo", |
| David Garcia | 49379ce | 2021-02-24 13:48:22 +0100 | [diff] [blame] | 277 | # Prometheus configuration |
| 278 | "OSMMON_PROMETHEUS_URL": f"http://{self.prometheus_client.hostname}:{self.prometheus_client.port}", |
| David Garcia | 49379ce | 2021-02-24 13:48:22 +0100 | [diff] [blame] | 279 | } |
| sousaedu | 1dd4c0d | 2020-11-04 17:43:47 +0000 | [diff] [blame] | 280 | ) |
| David Garcia | de440ed | 2021-10-11 19:56:53 +0200 | [diff] [blame] | 281 | prometheus_user = self.prometheus_client.user |
| 282 | prometheus_password = self.prometheus_client.password |
| 283 | if prometheus_user and prometheus_password: |
| 284 | container_builder.add_envs( |
| 285 | { |
| 286 | "OSMMON_PROMETHEUS_USER": prometheus_user, |
| 287 | "OSMMON_PROMETHEUS_PASSWORD": prometheus_password, |
| 288 | } |
| 289 | ) |
| David Garcia | 141d935 | 2021-09-08 17:48:40 +0200 | [diff] [blame] | 290 | container_builder.add_secret_envs( |
| 291 | secret_name=mongodb_secret_name, |
| 292 | envs={ |
| 293 | "OSMMON_DATABASE_URI": "uri", |
| 294 | "OSMMON_DATABASE_COMMONKEY": "commonkey", |
| 295 | }, |
| 296 | ) |
| 297 | container_builder.add_secret_envs( |
| 298 | secret_name=vca_secret_name, |
| 299 | envs={ |
| 300 | "OSMMON_VCA_HOST": "host", |
| 301 | "OSMMON_VCA_USER": "user", |
| 302 | "OSMMON_VCA_SECRET": "secret", |
| 303 | "OSMMON_VCA_CACERT": "cacert", |
| 304 | }, |
| 305 | ) |
| 306 | container_builder.add_secret_envs( |
| 307 | secret_name=grafana_secret_name, |
| 308 | envs={ |
| 309 | "OSMMON_GRAFANA_URL": "url", |
| 310 | "OSMMON_GRAFANA_USER": "user", |
| 311 | "OSMMON_GRAFANA_PASSWORD": "password", |
| 312 | }, |
| 313 | ) |
| calvinosanc1 | a43a22f | 2021-03-08 15:20:07 +0100 | [diff] [blame] | 314 | if config.keystone_enabled: |
| David Garcia | 141d935 | 2021-09-08 17:48:40 +0200 | [diff] [blame] | 315 | keystone_secret_name = f"{self.app.name}-keystone-secret" |
| 316 | pod_spec_builder.add_secret( |
| 317 | keystone_secret_name, |
| calvinosanc1 | a43a22f | 2021-03-08 15:20:07 +0100 | [diff] [blame] | 318 | { |
| David Garcia | 141d935 | 2021-09-08 17:48:40 +0200 | [diff] [blame] | 319 | "url": self.keystone_client.host, |
| 320 | "user_domain": self.keystone_client.user_domain_name, |
| 321 | "project_domain": self.keystone_client.project_domain_name, |
| 322 | "service_username": self.keystone_client.username, |
| 323 | "service_password": self.keystone_client.password, |
| 324 | "service_project": self.keystone_client.service, |
| 325 | }, |
| 326 | ) |
| 327 | container_builder.add_env("OSMMON_KEYSTONE_ENABLED", True) |
| 328 | container_builder.add_secret_envs( |
| 329 | secret_name=keystone_secret_name, |
| 330 | envs={ |
| 331 | "OSMMON_KEYSTONE_URL": "url", |
| 332 | "OSMMON_KEYSTONE_DOMAIN_NAME": "user_domain", |
| 333 | "OSMMON_KEYSTONE_PROJECT_DOMAIN_NAME": "project_domain", |
| 334 | "OSMMON_KEYSTONE_SERVICE_USER": "service_username", |
| 335 | "OSMMON_KEYSTONE_SERVICE_PASSWORD": "service_password", |
| 336 | "OSMMON_KEYSTONE_SERVICE_PROJECT": "service_project", |
| 337 | }, |
| calvinosanc1 | a43a22f | 2021-03-08 15:20:07 +0100 | [diff] [blame] | 338 | ) |
| David Garcia | 49379ce | 2021-02-24 13:48:22 +0100 | [diff] [blame] | 339 | container = container_builder.build() |
| sousaedu | 996a560 | 2021-05-03 00:22:43 +0200 | [diff] [blame] | 340 | |
| David Garcia | 141d935 | 2021-09-08 17:48:40 +0200 | [diff] [blame] | 341 | # Add restart policy |
| 342 | restart_policy = PodRestartPolicy() |
| 343 | restart_policy.add_secrets() |
| 344 | pod_spec_builder.set_restart_policy(restart_policy) |
| 345 | |
| David Garcia | 49379ce | 2021-02-24 13:48:22 +0100 | [diff] [blame] | 346 | # Add container to pod spec |
| 347 | pod_spec_builder.add_container(container) |
| sousaedu | 996a560 | 2021-05-03 00:22:43 +0200 | [diff] [blame] | 348 | |
| David Garcia | 49379ce | 2021-02-24 13:48:22 +0100 | [diff] [blame] | 349 | return pod_spec_builder.build() |
| sousaedu | 1dd4c0d | 2020-11-04 17:43:47 +0000 | [diff] [blame] | 350 | |
| 351 | |
| David Garcia | d680be4 | 2021-08-17 11:03:55 +0200 | [diff] [blame] | 352 | VSCODE_WORKSPACE = { |
| 353 | "folders": [ |
| 354 | {"path": "/usr/lib/python3/dist-packages/osm_mon"}, |
| 355 | {"path": "/usr/lib/python3/dist-packages/osm_common"}, |
| 356 | {"path": "/usr/lib/python3/dist-packages/n2vc"}, |
| 357 | ], |
| 358 | "settings": {}, |
| 359 | "launch": { |
| 360 | "version": "0.2.0", |
| 361 | "configurations": [ |
| 362 | { |
| 363 | "name": "MON Server", |
| 364 | "type": "python", |
| 365 | "request": "launch", |
| 366 | "module": "osm_mon.cmd.mon_server", |
| 367 | "justMyCode": False, |
| 368 | }, |
| 369 | { |
| 370 | "name": "MON evaluator", |
| 371 | "type": "python", |
| 372 | "request": "launch", |
| 373 | "module": "osm_mon.cmd.mon_evaluator", |
| 374 | "justMyCode": False, |
| 375 | }, |
| 376 | { |
| 377 | "name": "MON collector", |
| 378 | "type": "python", |
| 379 | "request": "launch", |
| 380 | "module": "osm_mon.cmd.mon_collector", |
| 381 | "justMyCode": False, |
| 382 | }, |
| 383 | { |
| 384 | "name": "MON dashboarder", |
| 385 | "type": "python", |
| 386 | "request": "launch", |
| 387 | "module": "osm_mon.cmd.mon_dashboarder", |
| 388 | "justMyCode": False, |
| 389 | }, |
| 390 | ], |
| 391 | }, |
| 392 | } |
| sousaedu | 1dd4c0d | 2020-11-04 17:43:47 +0000 | [diff] [blame] | 393 | if __name__ == "__main__": |
| 394 | main(MonCharm) |