X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=installers%2Fcharm%2Fnbi%2Fsrc%2Fcharm.py;h=1460459a813e9959a79317af0d7cc3a305ca0dde;hb=refs%2Fchanges%2F27%2F11127%2F2;hp=550c88b02b7a47600772372c9e794b1efacc7f54;hpb=996a5604c7d31f3758503b08a426f1f40619b17b;p=osm%2Fdevops.git diff --git a/installers/charm/nbi/src/charm.py b/installers/charm/nbi/src/charm.py index 550c88b0..1460459a 100755 --- a/installers/charm/nbi/src/charm.py +++ b/installers/charm/nbi/src/charm.py @@ -57,9 +57,11 @@ class ConfigModel(ModelValidator): max_file_size: int site_url: Optional[str] cluster_issuer: Optional[str] + ingress_class: Optional[str] ingress_whitelist_source_range: Optional[str] tls_secret_name: Optional[str] mongodb_uri: Optional[str] + image_pull_policy: str @validator("auth_backend") def validate_auth_backend(cls, v): @@ -99,10 +101,28 @@ class ConfigModel(ModelValidator): raise ValueError("mongodb_uri is not properly formed") return v + @validator("image_pull_policy") + def validate_image_pull_policy(cls, v): + values = { + "always": "Always", + "ifnotpresent": "IfNotPresent", + "never": "Never", + } + v = v.lower() + if v not in values.keys(): + raise ValueError("value must be always, ifnotpresent or never") + return values[v] + 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) @@ -179,7 +199,9 @@ class NbiCharm(CharmedOsmBase): ) # Build Container - container_builder = ContainerV3Builder(self.app.name, image_info) + container_builder = ContainerV3Builder( + self.app.name, image_info, config.image_pull_policy + ) container_builder.add_port(name=self.app.name, port=PORT) container_builder.add_tcpsocket_readiness_probe( PORT, @@ -210,7 +232,8 @@ class NbiCharm(CharmedOsmBase): "OSMNBI_STORAGE_DRIVER": "mongo", "OSMNBI_STORAGE_PATH": "/app/storage", "OSMNBI_STORAGE_COLLECTION": "files", - "OSMNBI_STORAGE_URI": self.mongodb_client.connection_string, + "OSMNBI_STORAGE_URI": config.mongodb_uri + or self.mongodb_client.connection_string, # Prometheus configuration "OSMNBI_PROMETHEUS_HOST": self.prometheus_client.hostname, "OSMNBI_PROMETHEUS_PORT": self.prometheus_client.port, @@ -249,6 +272,8 @@ class NbiCharm(CharmedOsmBase): ), "nginx.ingress.kubernetes.io/backend-protocol": "HTTPS", } + if config.ingress_class: + annotations["kubernetes.io/ingress.class"] = config.ingress_class ingress_resource_builder = IngressResourceV3Builder( f"{self.app.name}-ingress", annotations ) @@ -277,5 +302,27 @@ class NbiCharm(CharmedOsmBase): 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)