def update_charm_status(): tag = config.get('image-tag') for image in IMAGES + (IMAGES_DPDK if config["dpdk"] else IMAGES_KERNEL): try: docker_utils.pull(image, tag) except Exception as e: log("Can't load image {}".format(e)) status_set('blocked', 'Image could not be pulled: {}:{}'.format(image, tag)) return for image in IMAGES_OPTIONAL: try: docker_utils.pull(image, tag) except Exception as e: log("Can't load optional image {}".format(e)) if config.get("maintenance"): log("Maintenance is in progress") common_utils.update_services_status(MODULE, SERVICES) return fix_dns_settings() ctx = get_context() _update_charm_status(ctx)
def _update_charm_status(ctx): missing_relations = [] if not ctx.get("controller_servers"): missing_relations.append("contrail-controller") if not ctx.get("analytics_servers"): missing_relations.append("contrail-analytics") if config.get('tls_present', False) != config.get('ssl_enabled', False): missing_relations.append("tls-certificates") if missing_relations: status_set('blocked', 'Missing or incomplete relations: ' + ', '.join(missing_relations)) return if len(ctx.get("analyticsdb_servers")) < config.get("min-cluster-size"): status_set('blocked', 'Count of cluster nodes is not enough ({} < {}).'.format( len(ctx.get("analyticsdb_servers")), config.get("min-cluster-size") )) return if not ctx.get("cloud_orchestrator"): status_set('blocked', 'Missing cloud_orchestrator info in relation ' 'with contrail-controller.') return if "openstack" in ctx.get("cloud_orchestrators") and not ctx.get("keystone_ip"): status_set('blocked', 'Missing auth info in relation with contrail-controller.') return # TODO: what should happens if relation departed? changed_dict = _render_configs(ctx) changed = changed_dict["common"] or changed_dict["analytics-database"] docker_utils.compose_run(CONFIGS_PATH + "/docker-compose.yaml", changed) common_utils.update_services_status(MODULE, SERVICES.get(ctx["contrail_version"], SERVICES.get(9999)))
def _update_charm_status(ctx, services_to_run=None): # services to run: config-api, control, config-database, webui, redis missing_relations = [] if not ctx.get("analytics_servers"): missing_relations.append("contrail-analytics") if common_utils.get_ip() not in ctx.get("controller_servers"): missing_relations.append("contrail-cluster") if config.get('tls_present', False) != config.get('ssl_enabled', False): missing_relations.append("tls-certificates") if missing_relations: status_set( 'blocked', 'Missing or incomplete relations: ' + ', '.join(missing_relations)) return if len(ctx.get("controller_servers")) < config.get("min-cluster-size"): status_set( 'blocked', 'Count of cluster nodes is not enough ({} < {}).'.format( len(ctx.get("controller_servers")), config.get("min-cluster-size"))) return if not ctx.get("cloud_orchestrator"): status_set('blocked', 'Missing cloud orchestrator info in relations.') return if "openstack" in ctx.get( "cloud_orchestrators") and not ctx.get("keystone_ip"): status_set('blocked', 'Missing auth info in relation with contrail-auth.') return # TODO: what should happens if relation departed? changed_dict = _render_configs(ctx) changed = changed_dict["common"] service_changed = changed_dict["config-api"] docker_utils.compose_run(CONFIG_API_CONFIGS_PATH + "/docker-compose.yaml", changed or service_changed) service_changed = changed_dict["config-database"] docker_utils.compose_run( CONFIG_DATABASE_CONFIGS_PATH + "/docker-compose.yaml", changed or service_changed) service_changed = changed_dict["control"] docker_utils.compose_run(CONTROL_CONFIGS_PATH + "/docker-compose.yaml", changed or service_changed) service_changed = changed_dict["webui"] docker_utils.compose_run(WEBUI_CONFIGS_PATH + "/docker-compose.yaml", changed or service_changed) # redis is a common service that needs own synchronized env service_changed = changed_dict["redis"] docker_utils.compose_run(REDIS_CONFIGS_PATH + "/docker-compose.yaml", changed or service_changed) common_utils.update_services_status(MODULE, SERVICES) if _has_provisioning_finished(): config['apply-defaults'] = False
def update_charm_status(): tag = config.get('image-tag') cver = '5.1' if '5.0' in tag: cver = '5.0' for image in IMAGES[cver]: try: docker_utils.pull(image, tag) except Exception as e: log("Can't load image {}".format(e)) status_set('blocked', 'Image could not be pulled: {}:{}'.format(image, tag)) return for image in IMAGES_OPTIONAL: try: docker_utils.pull(image, tag) except Exception as e: log("Can't load optional image {}".format(e)) if config.get("maintenance"): return ctx = get_context() missing_relations = [] if not ctx.get("controller_servers"): missing_relations.append("contrail-controller") if not ctx.get("analytics_servers"): missing_relations.append("contrail-analytics") if missing_relations: status_set('blocked', 'Missing relations: ' + ', '.join(missing_relations)) return if not ctx.get("cloud_orchestrator"): status_set( 'blocked', 'Missing cloud_orchestrator info in relation ' 'with contrail-controller.') return if ctx.get("cloud_orchestrator" ) == "openstack" and not ctx.get("keystone_ip"): status_set('blocked', 'Missing auth info in relation with contrail-controller.') return # TODO: what should happens if relation departed? changed = common_utils.apply_keystone_ca(MODULE, ctx) changed |= common_utils.render_and_log( cver + "/analytics-database.env", BASE_CONFIGS_PATH + "/common_analyticsdb.env", ctx) if ctx["contrail_version"] >= 2002: changed |= common_utils.render_and_log( cver + "/defaults.env", BASE_CONFIGS_PATH + "/defaults_analyticsdb.env", ctx) changed |= common_utils.render_and_log( cver + "/analytics-database.yaml", CONFIGS_PATH + "/docker-compose.yaml", ctx) docker_utils.compose_run(CONFIGS_PATH + "/docker-compose.yaml", changed) common_utils.update_services_status(MODULE, SERVICES[cver])
def _update_charm_status(ctx): missing_relations = [] if not ctx.get("controller_servers"): missing_relations.append("contrail-controller") if ctx.get("analyticsdb_enabled") and not ctx.get("analyticsdb_servers"): missing_relations.append("contrail-analyticsdb") if missing_relations: status_set('blocked', 'Missing relations: ' + ', '.join(missing_relations)) return if len(ctx.get("analytics_servers")) < config.get("min-cluster-size"): status_set( 'blocked', 'Count of cluster nodes is not enough ({} < {}).'.format( len(ctx.get("analytics_servers")), config.get("min-cluster-size"))) return if not ctx.get("cloud_orchestrator"): status_set( 'blocked', 'Missing cloud_orchestrator info in relation ' 'with contrail-controller.') return if "openstack" in ctx.get( "cloud_orchestrators") and not ctx.get("keystone_ip"): status_set('blocked', 'Missing auth info in relation with contrail-controller.') return # TODO: what should happens if relation departed? changed_dict = _render_configs(ctx) changed = changed_dict["common"] service_changed = changed_dict["analytics"] docker_utils.compose_run(ANALYTICS_CONFIGS_PATH + "/docker-compose.yaml", changed or service_changed) if ctx["contrail_version"] >= 510 and ctx.get("analyticsdb_enabled"): service_changed = changed_dict["analytics-alarm"] docker_utils.compose_run( ANALYTICS_ALARM_CONFIGS_PATH + "/docker-compose.yaml", changed or service_changed) service_changed = changed_dict["analytics-snmp"] docker_utils.compose_run( ANALYTICS_SNMP_CONFIGS_PATH + "/docker-compose.yaml", changed or service_changed) # redis is a common service that needs own synchronized env service_changed = changed_dict["redis"] docker_utils.compose_run(REDIS_CONFIGS_PATH + "/docker-compose.yaml", changed or service_changed) services = SERVICES.get(ctx["contrail_version"], SERVICES.get(9999)).copy() if not ctx.get("analyticsdb_enabled"): services.pop("analytics-alarm") services.pop("analytics-snmp") common_utils.update_services_status(MODULE, services)
def update_charm_status(): fix_dns_settings() if config.get("maintenance"): log("Maintenance is in progress") common_utils.update_services_status(MODULE, SERVICES) return ctx = get_context() if not _check_readyness(ctx): return _run_services(ctx)
def _update_charm_status(ctx): missing_relations = [] if not ctx.get("controller_servers"): missing_relations.append("contrail-controller") if config.get("wait-for-external-plugin", False) and "plugin_settings" not in ctx: missing_relations.append("vrouter-plugin") if missing_relations: status_set('blocked', 'Missing relations: ' + ', '.join(missing_relations)) return if not ctx.get("analytics_servers"): status_set('blocked', 'Missing analytics_servers info in relation ' 'with contrail-controller.') return if not ctx.get("cloud_orchestrator"): status_set('blocked', 'Missing cloud_orchestrator info in relation ' 'with contrail-controller.') return if ctx.get("cloud_orchestrator") == "openstack" and not ctx.get("keystone_ip"): status_set('blocked', 'Missing auth info in relation with contrail-controller.') return if ctx.get("cloud_orchestrator") == "kubernetes" and not ctx.get("kube_manager_token"): status_set('blocked', 'Kube manager token undefined.') return if ctx.get("cloud_orchestrator") == "kubernetes" and not ctx.get("kubernetes_api_server"): status_set('blocked', 'Kubernetes API unavailable') return # TODO: what should happens if relation departed? changed = common_utils.apply_keystone_ca(MODULE, ctx) changed |= common_utils.render_and_log("vrouter.env", BASE_CONFIGS_PATH + "/common_vrouter.env", ctx) if ctx["contrail_version"] >= 2002: changed |= common_utils.render_and_log("defaults.env", BASE_CONFIGS_PATH + "/defaults_vrouter.env", ctx) changed |= common_utils.render_and_log("vrouter.yaml", CONFIGS_PATH + "/docker-compose.yaml", ctx) docker_utils.compose_run(CONFIGS_PATH + "/docker-compose.yaml", changed) # local file for vif utility common_utils.render_and_log("contrail-vrouter-agent.conf", "/etc/contrail/contrail-vrouter-agent.conf", ctx, perms=0o440) common_utils.update_services_status(MODULE, SERVICES)
def update_charm_status(): tag = config.get('image-tag') for image in IMAGES: try: docker_utils.pull(image, tag) except Exception as e: log("Can't load image {}".format(e)) status_set('blocked', 'Image could not be pulled: {}:{}'.format(image, tag)) return if config.get("maintenance") or config.get("ziu"): return ctx = get_context() missing_relations = [] if not ctx.get("nested_mode") and not ctx.get("controller_servers"): missing_relations.append("contrail-controller") if not ctx.get("kubernetes_api_server"): missing_relations.append("kube-api-endpoint") if missing_relations: status_set('blocked', 'Missing relations: ' + ', '.join(missing_relations)) return if not ctx.get("cloud_orchestrator"): status_set( 'blocked', 'Missing cloud_orchestrator info in relation ' 'with contrail-controller.') return if not ctx.get("kube_manager_token"): status_set( 'waiting', 'Kube manager token is absent. Wait for token from kubectl run.') return if "openstack" in ctx.get( "cloud_orchestrators") and not ctx.get("keystone_ip"): status_set('blocked', 'Missing auth info in relation with contrail-controller.') return changed = common_utils.render_and_log( "kubemanager.env", BASE_CONFIGS_PATH + "/common_kubemanager.env", ctx) changed |= common_utils.render_and_log( "/contrail-kubemanager.yaml", CONFIGS_PATH + "/docker-compose.yaml", ctx) docker_utils.compose_run(CONFIGS_PATH + "/docker-compose.yaml", changed) common_utils.update_services_status(MODULE, SERVICES)
def ziu_restart_control(stage): ctx = get_context() _render_configs(ctx) docker_utils.compose_run(CONTROL_CONFIGS_PATH + "/docker-compose.yaml") result = common_utils.update_services_status(MODULE, SERVICES) if result: signal_ziu("ziu_done", stage)
def ziu_restart_db(stage): ctx = get_context() _render_configs(ctx) docker_utils.compose_run(CONFIGS_PATH + "/docker-compose.yaml") result = common_utils.update_services_status(MODULE, SERVICES.get(ctx["contrail_version"], SERVICES.get(9999))) if result: signal_ziu("ziu_done", stage)
def _run_services(ctx): # local file for vif utility common_utils.render_and_log( "contrail-vrouter-agent.conf", BASE_CONFIGS_PATH + "/contrail-vrouter-agent.conf", ctx, perms=0o440) changed = common_utils.apply_keystone_ca(MODULE, ctx) changed |= common_utils.render_and_log( "vrouter.env", BASE_CONFIGS_PATH + "/common_vrouter.env", ctx) changed |= common_utils.render_and_log("vrouter.yaml", CONFIGS_PATH + "/docker-compose.yaml", ctx) docker_utils.compose_run(CONFIGS_PATH + "/docker-compose.yaml", changed) if is_reboot_required(): status_set('blocked', 'Reboot is required due to hugepages allocation.') return common_utils.update_services_status(MODULE, SERVICES)
def ziu_stage_2(ziu_stage, trigger): # start API services ctx = get_context() _render_configs(ctx) docker_utils.compose_run(CONFIG_API_CONFIGS_PATH + "/docker-compose.yaml") docker_utils.compose_run(WEBUI_CONFIGS_PATH + "/docker-compose.yaml") docker_utils.compose_run(REDIS_CONFIGS_PATH + "/docker-compose.yaml") result = common_utils.update_services_status(MODULE, SERVICES) if result: signal_ziu("ziu_done", ziu_stage)
def update_charm_status(): if config.get("maintenance") or config.get("ziu"): return ctx = get_context() missing_relations = [] if not ctx.get("nested_mode") and not ctx.get("controller_servers"): missing_relations.append("contrail-controller") if not ctx.get("kubernetes_api_server"): missing_relations.append("kube-api-endpoint") if config.get('tls_present', False) != config.get('ssl_enabled', False): missing_relations.append("tls-certificates") if missing_relations: status_set( 'blocked', 'Missing or incomplete relations: ' + ', '.join(missing_relations)) return if not ctx.get("cloud_orchestrator"): status_set( 'blocked', 'Missing cloud_orchestrator info in relation ' 'with contrail-controller.') return if not ctx.get("kube_manager_token"): status_set( 'waiting', 'Kube manager token is absent. Wait for token from kubectl run.') return if "openstack" in ctx.get( "cloud_orchestrators") and not ctx.get("keystone_ip"): status_set('blocked', 'Missing auth info in relation with contrail-controller.') return changed = common_utils.render_and_log( "kubemanager.env", BASE_CONFIGS_PATH + "/common_kubemanager.env", ctx) changed |= common_utils.render_and_log( "/contrail-kubemanager.yaml", CONFIGS_PATH + "/docker-compose.yaml", ctx) docker_utils.compose_run(CONFIGS_PATH + "/docker-compose.yaml", changed) common_utils.update_services_status(MODULE, SERVICES)
def update_charm_status(): if config.get("maintenance") or config.get("ziu"): return ctx = get_context() missing_relations = [] if not ctx.get('rabbitmq_hostname'): missing_relations.append("rabbitmq-server:amqp") if config.get('tls_present', False) != config.get('ssl_enabled', False): missing_relations.append("tls-certificates") if missing_relations: status_set( 'blocked', 'Missing or incomplete relations: ' + ', '.join(missing_relations)) return if not ctx.get("cloud_orchestrator"): status_set( 'blocked', 'Missing cloud_orchestrator info in relation ' 'with contrail-controller.') return if "openstack" in ctx.get( "cloud_orchestrators") and not ctx.get("keystone_ip"): status_set('blocked', 'Missing auth info in relation with contrail-controller.') return changed = common_utils.apply_keystone_ca(MODULE, ctx) changed |= common_utils.render_and_log( "openstack-ironic.env", BASE_CONFIGS_PATH + "/common_openstack_ironic.env", ctx) changed |= common_utils.render_and_log( "/contrail-openstack-ironic.yaml", CONFIGS_PATH + "/docker-compose.yaml", ctx) docker_utils.compose_run(CONFIGS_PATH + "/docker-compose.yaml", changed) common_utils.update_services_status(MODULE, SERVICES)
def ziu_stage_2(ziu_stage, trigger): # start API services ctx = get_context() _render_configs(ctx) docker_utils.compose_run(ANALYTICS_CONFIGS_PATH + "/docker-compose.yaml") docker_utils.compose_run(REDIS_CONFIGS_PATH + "/docker-compose.yaml") if ctx["contrail_version"] >= 510: docker_utils.compose_run(ANALYTICS_ALARM_CONFIGS_PATH + "/docker-compose.yaml") docker_utils.compose_run(ANALYTICS_SNMP_CONFIGS_PATH + "/docker-compose.yaml") result = common_utils.update_services_status( MODULE, SERVICES.get(ctx["contrail_version"], SERVICES.get(9999))) if result: signal_ziu("ziu_done", ziu_stage)
def ziu_stage_2(ziu_stage, trigger): # start API services ctx = get_context() _render_configs(ctx) docker_utils.compose_run(ANALYTICS_CONFIGS_PATH + "/docker-compose.yaml") docker_utils.compose_run(REDIS_CONFIGS_PATH + "/docker-compose.yaml") if ctx["contrail_version"] >= 510 and ctx.get("analyticsdb_enabled"): docker_utils.compose_run(ANALYTICS_ALARM_CONFIGS_PATH + "/docker-compose.yaml") docker_utils.compose_run(ANALYTICS_SNMP_CONFIGS_PATH + "/docker-compose.yaml") services = SERVICES.get(ctx["contrail_version"], SERVICES.get(9999)).copy() if not ctx.get("analyticsdb_enabled"): services.pop("analytics-alarm") services.pop("analytics-snmp") result = common_utils.update_services_status(MODULE, services) if result: signal_ziu("ziu_done", ziu_stage)
def update_charm_status(): tag = config.get('image-tag') for image in IMAGES: try: docker_utils.pull(image, tag) except Exception as e: log("Can't load image {}".format(e)) status_set('blocked', 'Image could not be pulled: {}:{}'.format(image, tag)) return for image in IMAGES_OPTIONAL: try: docker_utils.pull(image, tag) except Exception as e: log("Can't load optional image {}".format(e)) if config.get("maintenance"): return ctx = get_context() missing_relations = [] if not ctx.get("analytics_servers"): missing_relations.append("contrail-analytics") if common_utils.get_ip() not in ctx.get("controller_servers"): missing_relations.append("contrail-cluster") if missing_relations: status_set('blocked', 'Missing relations: ' + ', '.join(missing_relations)) return if not ctx.get("cloud_orchestrator"): status_set('blocked', 'Missing cloud orchestrator info in relations.') return if ctx.get("cloud_orchestrator" ) == "openstack" and not ctx.get("keystone_ip"): status_set('blocked', 'Missing auth info in relation with contrail-auth.') return # TODO: what should happens if relation departed? changed = common_utils.apply_keystone_ca(MODULE, ctx) changed |= common_utils.render_and_log( "config.env", BASE_CONFIGS_PATH + "/common_config.env", ctx) if ctx["contrail_version"] >= 2002: changed |= common_utils.render_and_log( "defaults.env", BASE_CONFIGS_PATH + "/defaults_controller.env", ctx) service_changed = common_utils.render_and_log( "config-api.yaml", CONFIG_API_CONFIGS_PATH + "/docker-compose.yaml", ctx) docker_utils.compose_run(CONFIG_API_CONFIGS_PATH + "/docker-compose.yaml", changed or service_changed) service_changed = common_utils.render_and_log( "config-database.yaml", CONFIG_DATABASE_CONFIGS_PATH + "/docker-compose.yaml", ctx) docker_utils.compose_run( CONFIG_DATABASE_CONFIGS_PATH + "/docker-compose.yaml", changed or service_changed) service_changed = common_utils.render_and_log( "control.yaml", CONTROL_CONFIGS_PATH + "/docker-compose.yaml", ctx) docker_utils.compose_run(CONTROL_CONFIGS_PATH + "/docker-compose.yaml", changed or service_changed) service_changed = common_utils.render_and_log( "webui.yaml", WEBUI_CONFIGS_PATH + "/docker-compose.yaml", ctx) service_changed |= common_utils.render_and_log( "web.env", BASE_CONFIGS_PATH + "/common_web.env", ctx) docker_utils.compose_run(WEBUI_CONFIGS_PATH + "/docker-compose.yaml", changed or service_changed) # redis is a common service that needs own synchronized env service_changed = common_utils.render_and_log( "redis.env", BASE_CONFIGS_PATH + "/redis.env", ctx) service_changed |= common_utils.render_and_log( "redis.yaml", REDIS_CONFIGS_PATH + "/docker-compose.yaml", ctx) docker_utils.compose_run(REDIS_CONFIGS_PATH + "/docker-compose.yaml", changed or service_changed) common_utils.update_services_status(MODULE, SERVICES)
def update_charm_status(update_config=True, force=False): def _render_config(ctx=None, do_check=True): if not ctx: ctx = get_context() changed = render_and_check(ctx, "controller.conf", "/etc/contrailctl/controller.conf", do_check) return (force or changed) update_config_func = _render_config if update_config else None result = check_run_prerequisites(CONTAINER_NAME, CONFIG_NAME, update_config_func, SERVICES_TO_CHECK) # hack for 4.1 due to fat containers do not call provision_control _, message = status_get() identity = json_loads(config.get("auth_info"), dict()) if (identity and 'contrail-control' in message and '(No BGP configuration for self)' in message): try: ip = get_ip() bgp_asn = '64512' # register control node to config api server (no auth) cmd = [ '/usr/share/contrail-utils/provision_control.py', '--api_server_ip', ip, '--router_asn', bgp_asn, '--admin_user', identity.get("keystone_admin_user"), '--admin_password', identity.get("keystone_admin_password"), '--admin_tenant_name', identity.get("keystone_admin_tenant") ] docker_utils.docker_exec(CONTAINER_NAME, cmd, shell=True) # register control node as a BGP speaker without md5 (no auth) cmd = [ '/usr/share/contrail-utils/provision_control.py', '--api_server_ip', ip, '--router_asn', bgp_asn, '--host_name', gethostname(), '--host_ip', ip, '--oper', 'add', '--admin_user', identity.get("keystone_admin_user"), '--admin_password', identity.get("keystone_admin_password"), '--admin_tenant_name', identity.get("keystone_admin_tenant") ] docker_utils.docker_exec(CONTAINER_NAME, cmd, shell=True) # wait a bit time.sleep(8) update_services_status(CONTAINER_NAME, SERVICES_TO_CHECK) except Exception as e: log("Can't provision control: {}".format(e), level=ERROR) # hack for contrail-api that is started at inapropriate moment to keystone if (identity and 'contrail-api' in message and '(Generic Connection:Keystone[] connection down)' in message): try: cmd = ['systemctl', 'restart', 'contrail-api'] docker_utils.docker_exec(CONTAINER_NAME, cmd, shell=True) # wait a bit time.sleep(8) update_services_status(CONTAINER_NAME, SERVICES_TO_CHECK) except Exception as e: log("Can't restart contrail-api: {}".format(e), level=ERROR) if not result: return ctx = get_context() missing_relations = [] if not ctx.get("db_user"): # NOTE: Charms don't allow to deploy cassandra in AllowAll mode missing_relations.append("contrail-controller-cluster") if not ctx.get("analytics_servers"): missing_relations.append("contrail-analytics") if get_ip() not in ctx.get("controller_servers"): missing_relations.append("contrail-cluster") if missing_relations: status_set('blocked', 'Missing relations: ' + ', '.join(missing_relations)) return if not ctx.get("cloud_orchestrator"): status_set('blocked', 'Missing cloud orchestrator info in relations.') return if not ctx.get("rabbitmq_password"): status_set('blocked', 'Missing RabbitMQ info in external relations.') return if not ctx.get("keystone_ip"): status_set('blocked', 'Missing auth info in relation with contrail-auth.') return # TODO: what should happens if relation departed? _render_config(ctx, do_check=False) run_container(CONTAINER_NAME, ctx.get("cloud_orchestrator"))
def _update_charm_status(ctx): missing_relations = [] if not ctx.get("controller_servers"): missing_relations.append("contrail-controller") if config.get("wait-for-external-plugin", False) and "plugin_settings" not in ctx: missing_relations.append("vrouter-plugin") if missing_relations: status_set('blocked', 'Missing relations: ' + ', '.join(missing_relations)) return if not ctx.get("analytics_servers"): status_set( 'blocked', 'Missing analytics_servers info in relation ' 'with contrail-controller.') return if not ctx.get("cloud_orchestrator"): status_set( 'blocked', 'Missing cloud_orchestrator info in relation ' 'with contrail-controller.') return if ctx.get("cloud_orchestrator" ) == "openstack" and not ctx.get("keystone_ip"): status_set('blocked', 'Missing auth info in relation with contrail-controller.') return if ctx.get("cloud_orchestrator" ) == "kubernetes" and not ctx.get("kube_manager_token"): status_set('blocked', 'Kube manager token undefined.') return if ctx.get("cloud_orchestrator" ) == "kubernetes" and not ctx.get("kubernetes_api_server"): status_set('blocked', 'Kubernetes API unavailable') return # TODO: what should happens if relation departed? # local file for vif utility common_utils.render_and_log("contrail-vrouter-agent.conf", "/etc/contrail/contrail-vrouter-agent.conf", ctx, perms=0o440) changed = common_utils.apply_keystone_ca(MODULE, ctx) changed |= common_utils.render_and_log( "vrouter.env", BASE_CONFIGS_PATH + "/common_vrouter.env", ctx) changed |= common_utils.render_and_log("vrouter.yaml", VROUTER_COMPOSE_PATH, ctx) changed |= common_utils.render_and_log("vrouter-init.yaml", VROUTER_INIT_COMPOSE_PATH, ctx) if is_vrouter_init_successfully_passed(): docker_utils.compose_run(VROUTER_COMPOSE_PATH, changed) else: # let's down this compose. it will not fail but this will guarantee next run docker_utils.compose_down(VROUTER_INIT_COMPOSE_PATH) docker_utils.compose_run(VROUTER_INIT_COMPOSE_PATH, True) if is_reboot_required(): status_set('blocked', 'Reboot is required due to hugepages allocation.') return common_utils.update_services_status(MODULE, SERVICES)