def get_context(): ctx = {} ctx["module"] = MODULE ctx["log_level"] = config.get("log-level", "SYS_NOTICE") # previous versions of charm may store next value in config as string. ssl_enabled = config.get("ssl_enabled", False) if not isinstance(ssl_enabled, bool): ssl_enabled = yaml.load(ssl_enabled) if not isinstance(ssl_enabled, bool): ssl_enabled = False ctx["ssl_enabled"] = ssl_enabled ctx["certs_hash"] = common_utils.get_certs_hash(MODULE) if ctx["ssl_enabled"] else '' ctx["analyticsdb_minimum_diskgb"] = config.get("cassandra-minimum-diskgb") ctx["jvm_extra_opts"] = config.get("cassandra-jvm-extra-opts") ctx["container_registry"] = config.get("docker-registry") ctx["contrail_version_tag"] = config.get("image-tag") ctx["config_analytics_ssl_available"] = common_utils.is_config_analytics_ssl_available() ctx["logging"] = docker_utils.render_logging() ctx["contrail_version"] = common_utils.get_contrail_version() ctx.update(common_utils.json_loads(config.get("orchestrator_info"), dict())) if not ctx.get("cloud_orchestrators"): ctx["cloud_orchestrators"] = [ctx.get("cloud_orchestrator")] if ctx.get("cloud_orchestrator") else list() ctx["analyticsdb_servers"] = list(common_utils.json_loads(leader_get("cluster_info"), dict()).values()) ctx.update(servers_ctx()) log("CTX: {}".format(ctx)) ctx.update(common_utils.json_loads(config.get("auth_info"), dict())) return ctx
def get_context(): ctx = {} ctx["module"] = MODULE ctx["log_level"] = config.get("log-level", "SYS_NOTICE") ctx["bgp_asn"] = config.get("bgp-asn", "64512") ctx["enable_4byte_as"] = config.get("enable-4byte-as") ctx["encap_priority"] = config.get("encap-priority") ctx["vxlan_vn_id_mode"] = config.get("vxlan-vn-id-mode") ctx["flow_export_rate"] = config.get("flow-export-rate") ctx["auth_mode"] = config.get("auth-mode") ctx["cloud_admin_role"] = config.get("cloud-admin-role") ctx["global_read_only_role"] = config.get("global-read-only-role") ctx["configdb_minimum_diskgb"] = config.get("cassandra-minimum-diskgb") ctx["jvm_extra_opts"] = config.get("cassandra-jvm-extra-opts") ctx["container_registry"] = config.get("docker-registry") ctx["contrail_version_tag"] = config.get("image-tag") ctx["contrail_version"] = common_utils.get_contrail_version() ctx["config_api_worker_count"] = config.get("config-api-worker-count") ctx["apply_defaults"] = config.get("apply-defaults") ctx["huge_scale"] = config.get("huge-scale", False) ctx.update(common_utils.json_loads(config.get("orchestrator_info"), dict())) if not ctx.get("cloud_orchestrators"): ctx["cloud_orchestrators"] = [ ctx.get("cloud_orchestrator") ] if ctx.get("cloud_orchestrator") else list() ctx["ssl_enabled"] = config.get("ssl_enabled", False) ctx["certs_hash"] = common_utils.get_certs_hash( MODULE) if ctx["ssl_enabled"] else '' ctx["config_analytics_ssl_available"] = common_utils.is_config_analytics_ssl_available( ) ctx["use_internal_endpoints"] = config.get("use_internal_endpoints", False) ctx["logging"] = docker_utils.render_logging() ips = common_utils.json_loads(leader_get("controller_ip_list"), list()) data_ips = common_utils.json_loads(leader_get("controller_data_ip_list"), list()) ctx["controller_servers"] = ips ctx["control_servers"] = data_ips ctx["analytics_servers"] = get_analytics_list() ctx["analyticsdb_enabled"] = analyticsdb_enabled() log("CTX: " + str(ctx)) ctx.update(common_utils.json_loads(config.get("auth_info"), dict())) return ctx
def get_context(): ctx = {} ctx["module"] = MODULE ctx["log_level"] = config.get("log-level", "SYS_NOTICE") ctx["container_registry"] = config.get("docker-registry") ctx["contrail_version_tag"] = config.get("image-tag") ctx["contrail_version"] = common_utils.get_contrail_version() ips = common_utils.json_loads(config.get("analytics_servers"), list()) ctx["analytics_servers"] = ips ctx["ssl_enabled"] = config.get("ssl_enabled", False) ctx["certs_hash"] = common_utils.get_certs_hash( MODULE) if ctx["ssl_enabled"] else '' ctx["rabbitmq_user"] = config.get("rabbit-user") ctx["rabbitmq_password"] = config.get("rabbit-password") ctx["rabbitmq_hostname"] = config.get("rabbit-hostname") ctx["rabbitmq_vhost"] = config.get("rabbit-vhost") ctx["ironic_notification_level"] = config.get('ironic-notification-level') ctx.update(common_utils.json_loads(config.get("orchestrator_info"), dict())) if not ctx.get("cloud_orchestrators"): ctx["cloud_orchestrators"] = [ ctx.get("cloud_orchestrator") ] if ctx.get("cloud_orchestrator") else list() ctx["config_analytics_ssl_available"] = common_utils.is_config_analytics_ssl_available( ) ctx["logging"] = docker_utils.render_logging() log("CTX: {}".format(ctx)) ctx.update(common_utils.json_loads(config.get("auth_info"), dict())) return ctx
def get_context(): ctx = {} ctx["module"] = MODULE ctx["log_level"] = config.get("log-level", "SYS_NOTICE") ctx["container_registry"] = config.get("docker-registry") ctx["contrail_version_tag"] = config.get("image-tag") ctx["contrail_version"] = common_utils.get_contrail_version() ctx["kubemanager_servers"] = list( common_utils.json_loads(leader_get("cluster_info"), dict()).values()) # get contrail configuration from relation ips = common_utils.json_loads(config.get("controller_ips"), list()) data_ips = common_utils.json_loads(config.get("controller_data_ips"), list()) ctx["controller_servers"] = ips ctx["control_servers"] = data_ips ips = common_utils.json_loads(config.get("analytics_servers"), list()) ctx["analytics_servers"] = ips ctx["analyticsdb_enabled"] = config.get("analyticsdb_enabled", True) ctx["ssl_enabled"] = config.get("ssl_enabled", False) ctx["certs_hash"] = common_utils.get_certs_hash( MODULE) if ctx["ssl_enabled"] else '' ctx["cluster_name"] = config.get("cluster_name") ctx["cluster_project"] = config.get("cluster_project") ctx["cluster_network"] = config.get("cluster_network") ctx["pod_subnets"] = config.get("pod_subnets") ctx["ip_fabric_subnets"] = config.get("ip_fabric_subnets") ctx["service_subnets"] = config.get("service_subnets") ctx["ip_fabric_forwarding"] = config.get("ip_fabric_forwarding") ctx["ip_fabric_snat"] = config.get("ip_fabric_snat") ctx["host_network_service"] = config.get("host_network_service") ctx["public_fip_pool"] = config.get("public_fip_pool") ctx.update(common_utils.json_loads(config.get("orchestrator_info"), dict())) if not ctx.get("cloud_orchestrators"): ctx["cloud_orchestrators"] = [ ctx.get("cloud_orchestrator") ] if ctx.get("cloud_orchestrator") else list() # TODO: switch to use context for this ctx["kube_manager_token"] = leader_get("kube_manager_token") if config.get("kubernetes_api_hostname") and config.get( "kubernetes_api_secure_port"): ctx["kubernetes_api_server"] = config.get("kubernetes_api_hostname") ctx["kubernetes_api_secure_port"] = config.get( "kubernetes_api_secure_port") else: ctx["kubernetes_api_server"] = config.get("kubernetes_api_server") ctx["kubernetes_api_secure_port"] = config.get("kubernetes_api_port") ctx["nested_mode"] = config.get("nested_mode") if ctx["nested_mode"]: # TODO: create KUBERNETES_NESTED_VROUTER_VIP link-local services in Contrail via config API ctx["nested_mode_config"] = common_utils.json_loads( config.get("nested_mode_config"), dict()) ctx["config_analytics_ssl_available"] = common_utils.is_config_analytics_ssl_available( ) ctx["logging"] = docker_utils.render_logging() log("CTX: {}".format(ctx)) ctx.update(common_utils.json_loads(config.get("auth_info"), dict())) return ctx
def get_context(): ctx = {} ctx["module"] = MODULE ctx["ssl_enabled"] = config.get("ssl_enabled", False) ctx["certs_hash"] = common_utils.get_certs_hash( MODULE) if ctx["ssl_enabled"] else '' ctx["l3mh_cidr"] = config.get("l3mh-cidr", None) ctx["log_level"] = config.get("log-level", "SYS_NOTICE") ctx["container_registry"] = config.get("docker-registry") ctx["contrail_version_tag"] = config.get("image-tag") ctx["sriov_physical_interface"] = config.get("sriov-physical-interface") ctx["sriov_numvfs"] = config.get("sriov-numvfs") ctx["max_vm_flows"] = config.get("max-vm-flows") ctx["contrail_version"] = common_utils.get_contrail_version() # NOTE: charm should set non-fqdn hostname to be compatible with R5.0 deployments ctx["hostname"] = socket.getfqdn() if config.get( "hostname-use-fqdn", True) else socket.gethostname() iface = config.get("physical-interface") ctx["physical_interface"] = iface gateway_ip = config.get("vhost-gateway") if gateway_ip == "auto": gateway_ip = _get_iface_gateway_ip(iface) ctx["vrouter_gateway"] = gateway_ip if gateway_ip else '' ctx["agent_mode"] = "dpdk" if config["dpdk"] else "kernel" if config["dpdk"]: ctx["dpdk_additional_args"] = _get_dpdk_args() ctx["dpdk_driver"] = config.get("dpdk-driver") ctx["dpdk_coremask"] = config.get("dpdk-coremask") ctx["dpdk_service_coremask"] = config.get("dpdk-service-coremask") ctx["dpdk_ctrl_thread_coremask"] = config.get( "dpdk-ctrl-thread-coremask") cpuset = _convert2cpuset(config.get("dpdk-ctrl-thread-coremask")) if cpuset: ctx["agent_containers_cpuset"] = cpuset ctx["dpdk_hugepages"] = _get_hugepages() else: ctx["hugepages_1g"] = config.get("kernel-hugepages-1g") ctx["hugepages_2m"] = config.get("kernel-hugepages-2m") ctx.update(tsn_ctx()) info = common_utils.json_loads(config.get("orchestrator_info"), dict()) ctx.update(info) if not ctx.get("cloud_orchestrators"): ctx["cloud_orchestrators"] = [ ctx.get("cloud_orchestrator") ] if ctx.get("cloud_orchestrator") else list() ctx["controller_servers"] = common_utils.json_loads( config.get("controller_ips"), list()) ctx["control_servers"] = common_utils.json_loads( config.get("controller_data_ips"), list()) ctx["analytics_servers"] = common_utils.json_loads( config.get("analytics_servers"), list()) ctx["config_analytics_ssl_available"] = common_utils.is_config_analytics_ssl_available( ) ctx["analyticsdb_enabled"] = config.get("analyticsdb_enabled", True) if "plugin-ips" in config: plugin_ips = common_utils.json_loads(config["plugin-ips"], dict()) my_ip = unit_get("private-address") if my_ip in plugin_ips: ctx["plugin_settings"] = plugin_ips[my_ip] ctx["pod_subnets"] = config.get("pod_subnets") if config.get('maintenance') == 'issu': ctx["controller_servers"] = common_utils.json_loads( config.get("issu_controller_ips"), list()) ctx["control_servers"] = common_utils.json_loads( config.get("issu_controller_data_ips"), list()) ctx["analytics_servers"] = common_utils.json_loads( config.get("issu_analytics_ips"), list()) # orchestrator_info and auth_info can be taken from old relation ctx["logging"] = docker_utils.render_logging() log("CTX: " + str(ctx)) ctx.update(common_utils.json_loads(config.get("auth_info"), dict())) return ctx