Exemplo n.º 1
0
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["container_registry"] = config.get("docker-registry")
    ctx["contrail_version_tag"] = config.get("image-tag")
    ctx.update(common_utils.json_loads(config.get("orchestrator_info"),
                                       dict()))
    if not ctx.get("cloud_orchestrators"):
        ctx["cloud_orchestrators"] = list(
            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()
    ctx["contrail_version"] = common_utils.get_contrail_version()

    ctx.update(controller_ctx())
    ctx.update(analytics_ctx())
    ctx.update(analyticsdb_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["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.update(common_utils.json_loads(config.get("orchestrator_info"),
                                       dict()))

    ctx["ssl_enabled"] = config.get("ssl_enabled", False)
    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()
    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")
    # 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
Exemplo n.º 4
0
def get_context():
    ctx = {}
    ctx["module"] = MODULE
    ctx["ssl_enabled"] = config.get("ssl_enabled", False)
    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_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)

    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"] = config.get(
        "config_analytics_ssl_available", False)

    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["logging"] = docker_utils.render_logging()
    log("CTX: " + str(ctx))

    ctx.update(common_utils.json_loads(config.get("auth_info"), dict()))
    return ctx
def _notify_neutron(rid=None):
    rids = [rid] if rid else relation_ids("neutron-api")
    if not rids:
        return

    version = utils.get_openstack_version_codename('neutron')
    utils.deploy_openstack_code(
        "contrail-openstack-neutron-init", "neutron",
        {"OPENSTACK_VERSION": utils.PACKAGE_CODENAMES['neutron'][version]})

    # create plugin config
    contrail_version = common_utils.get_contrail_version()
    plugin_path = utils.get_component_sys_paths("neutron")
    base = "neutron_plugin_contrail.plugins.opencontrail"
    plugin = base + ".contrail_plugin.NeutronPluginContrailCoreV2"
    # pass just separator to prevent setting of default list
    service_plugins = "contrail-timestamp,"
    if contrail_version >= 1909:
        service_plugins += "contrail-trunk,"
    if contrail_version >= 2005 and version > 12:
        service_plugins += "contrail-tags,"
    if version < 15:
        service_plugins += base + ".loadbalancer.v2.plugin.LoadBalancerPluginV2,"
    contrail_plugin_extension = plugin_path + "/neutron_plugin_contrail/extensions"
    neutron_lbaas_extensions = plugin_path + "/neutron_lbaas/extensions"
    extensions = [contrail_plugin_extension, neutron_lbaas_extensions]
    conf = {
        "neutron-api": {
            "/etc/neutron/neutron.conf": {
                "sections": {
                    "DEFAULT": [("api_extensions_path", ":".join(extensions))]
                }
            }
        }
    }
    settings = {
        "neutron-plugin": "contrail",
        "core-plugin": plugin,
        "neutron-plugin-config":
        "/etc/neutron/plugins/opencontrail/ContrailPlugin.ini",
        "service-plugins": service_plugins,
        "quota-driver": base + ".quota.driver.QuotaDriver",
        "subordinate_configuration": json.dumps(conf),
    }
    auth_mode = config.get("auth_mode", "cloud-admin")
    if auth_mode == "rbac":
        settings["extra_middleware"] = [{
            "name": "user_token",
            "type": "filter",
            "config": {
                "paste.filter_factory":
                base + ".neutron_middleware:token_factory"
            }
        }]
    for rid in rids:
        relation_set(relation_id=rid, relation_settings=settings)
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["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"] = list(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
Exemplo n.º 7
0
def ziu_stage_1(ziu_stage, trigger):
    # stop API services
    cver = common_utils.get_contrail_version()
    docker_utils.compose_down(ANALYTICS_CONFIGS_PATH + "/docker-compose.yaml")
    docker_utils.compose_down(REDIS_CONFIGS_PATH + "/docker-compose.yaml")
    if cver >= 510:
        docker_utils.compose_down(ANALYTICS_ALARM_CONFIGS_PATH +
                                  "/docker-compose.yaml")
        docker_utils.compose_down(ANALYTICS_SNMP_CONFIGS_PATH +
                                  "/docker-compose.yaml")

    signal_ziu("ziu_done", ziu_stage)
Exemplo n.º 8
0
def analyticsdb_ctx():
    """Get the ipaddress of all contrail analyticsdb nodes"""

    data = {"analyticsdb_enabled": True}
    if common_utils.get_contrail_version() > 500:
        data["analyticsdb_enabled"] = False
        for rid in relation_ids("contrail-analyticsdb"):
            if related_units(rid):
                data["analyticsdb_enabled"] = True
                break

    data["analyticsdb_servers"] = get_analyticsdb_list()
    return data
Exemplo n.º 9
0
def compile_kernel_modules():
    modules = '/lib/modules'
    need_to_compile = False
    for item in os.listdir(modules):
        # vrouter doesn't support kernels version 5, remove check after fix
        if item.split('.')[0] == '5':
            continue
        path = os.path.join(modules, item, 'updates/dkms/vrouter.ko')
        if not os.path.exists(path):
            need_to_compile = True
            break
    contrail_version = common_utils.get_contrail_version()
    if not need_to_compile or contrail_version < 2008:
        return

    path = CONFIGS_PATH + "/docker-compose.yaml"
    state = docker_utils.get_container_state(path, "vrouter-kernel-init")
    if state and state.get('Status', '').lower() != 'running':
        docker_utils.restart_container(path, "vrouter-kernel-init")
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
Exemplo n.º 11
0
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