def test_make_pod_spec(self) -> NoReturn: """Teting make pod spec.""" image_info = {"upstream-source": "localhost:32000/mysql:5.7"} config = { "sql_port": 4567, } app_name = "mysql" with self.assertRaises(ValueError): pod_spec.make_pod_spec(image_info, config, app_name)
def test_make_pod_spec(self) -> NoReturn: """Teting make pod spec.""" image_info = {"upstream-source": "localhost:32000/free5gc-amf:1.0"} config = { "gin_mode": "12345", } app_name = "amf" relation_state = {"nrf_host": None} with self.assertRaises(ValueError): pod_spec.make_pod_spec(image_info, config, app_name, relation_state)
def test_make_pod_spec(self) -> NoReturn: """Testing make pod spec.""" image_info = {"upstream-source": "localhost:32000/free5gc-upf1:1.0"} config = { "gtp_port": 9999, } app_name = "upf1" relation_state = {"natapp_ip": "192.168.70.15"} with self.assertRaises(ValueError): pod_spec.make_pod_spec(image_info, config, app_name, relation_state)
def test_make_pod_spec(self) -> NoReturn: """Testing make pod spec.""" image_info = {"upstream-source": "localhost:32000/ue:1.0"} config = { "ssh_port": 9999, } relation_state = {"ran_host": "ran"} app_name = "udpnew" with self.assertRaises(ValueError): pod_spec.make_pod_spec(image_info, config, relation_state, app_name)
def test_make_pod_spec(self) -> NoReturn: """Teting make pod spec.""" image_info = {"upstream-source": "localhost:32000/ims_icscf:1.0"} config = {"diameter_port": 3999} app_name = "icscf" relation_state = { "db": "mysql", "user": "******", "pwd": "root", } with self.assertRaises(ValueError): pod_spec.make_pod_spec(image_info, config, app_name, relation_state)
def test_make_pod_spec(self) -> NoReturn: """Teting make pod spec.""" image_info = {"upstream-source": "localhost:32000/free5gc-webui:1.0"} config = {"gin_mode": 12345} app_name = "webui" relation_state = { "mongodb_uri": "nomongodb://mongodb/free5gc", "nrf_host": None, "mongodb_host": None, } with self.assertRaises(ValueError): pod_spec.make_pod_spec(image_info, config, relation_state, app_name)
def test_make_pod_spec(self) -> NoReturn: """Testing make pod spec.""" image_info = {"upstream-source": "localhost:32000/free5gc-nrf:1.0"} config = { "gin_mode": "release", } app_name = "nrf" relation_state = { "mongodb_uri": "norelation_mongodb", "mongodb_host": None } with self.assertRaises(ValueError): pod_spec.make_pod_spec(image_info, config, relation_state, app_name)
def configure_pod(self, _=None) -> NoReturn: """Assemble the pod spec and apply it, if possible.""" if not self.unit.is_leader(): self.unit.status = ActiveStatus("ready") return self.unit.status = MaintenanceStatus("Assembling pod spec") # Fetch image information image_info = self.config["image"] try: pod_spec = make_pod_spec( image_info, self.model.config, self.model.app.name, ) except ValueError as exc: logger.exception("Config data validation error") self.unit.status = BlockedStatus(str(exc)) return if self.state.pod_spec != pod_spec: self.model.pod.set_spec(pod_spec) self.state.pod_spec = pod_spec self.unit.status = ActiveStatus("ready")
def test_make_pod_spec(self) -> NoReturn: """Testing make pod spec.""" image_info = {"upstream-source": "localhost:32000/ran:1.0"} config = { "sctp_port": -9999, "pdn_subnet": "-60.60.0.0/16", "pdn_ip_range_start": "-60.60.0.50", "pdn_ip_range_end": "-60.60.0.250", "pdn_gateway_ip": "-60.60.0.100", "master_interface": 234, } model_name = "ran" app_name = "udpnew" with self.assertRaises(ValueError): pod_spec.make_pod_spec(image_info, config, model_name, app_name)
def configure_pod(self, _=None) -> NoReturn: """Assemble the pod spec and apply it, if possible.""" missing = self._missing_relations() if missing: self.unit.status = BlockedStatus( "Waiting for {0} relation{1}".format( missing, "s" if "," in missing else "")) return if not self.unit.is_leader(): self.unit.status = ActiveStatus("ready") return self.unit.status = MaintenanceStatus("Assembling pod spec") image_info = self.config["image"] try: pod_spec = make_pod_spec( image_info, self.model.config, self.model.app.name, self.relation_state, ) except ValueError as exc: logger.exception("Config data validation error") self.unit.status = BlockedStatus(str(exc)) return if self.state.pod_spec != pod_spec: self.model.pod.set_spec(pod_spec) self.state.pod_spec = pod_spec self.unit.status = ActiveStatus("ready")
def configure_pod(self, _=None) -> NoReturn: """Assemble the pod spec and apply it, if possible.""" if not self.unit.is_leader(): self.unit.status = ActiveStatus("ready") return self.unit.status = MaintenanceStatus("Assembling pod spec") # Fetch image information try: self.unit.status = MaintenanceStatus("Fetching image information") image_info = self.image.fetch() except OCIImageResourceError: self.unit.status = BlockedStatus( "Error fetching image information") return try: pod_spec = make_pod_spec( image_info, self.config, self.model.name, self.model.app.name, ) except ValueError as exc: error_message = f"Config data validation error: {str(exc)}" logger.exception(error_message) self.unit.status = BlockedStatus(str(exc)) return if self.state.pod_spec != pod_spec: self.model.pod.set_spec(pod_spec) self.state.pod_spec = pod_spec self.unit.status = ActiveStatus("ready")
def configure_pod(self, event): # Continue only if the unit is the leader if not self.unit.is_leader(): self.on_update_status(event) return logger.debug("Running configuring_pod") # Check problems in the settings problems = self._check_settings() if problems: self.unit.status = BlockedStatus(problems) return # Fetch image information try: self.unit.status = WaitingStatus("Fetching image information") image_info = self.image.fetch() except OCIImageResourceError: self.unit.status = BlockedStatus( "Error fetching image information") return # Build Pod spec self.unit.status = BlockedStatus("Assembling pod spec") pod_spec = make_pod_spec( image_info, self.port, replica_set_name=self.replica_set_name if not self.standalone else None, ) # Update pod spec if the generated one is different # from the one previously applied if self.state.pod_spec != pod_spec: self.model.pod.set_spec(pod_spec) self.state.pod_spec = pod_spec self.on_update_status(event) logger.debug("Running configuring_pod finished")