def heat_plugin_joined(rel_id=None):
    utils.deploy_openstack_code("contrail-openstack-heat-init", "heat")

    plugin_path = utils.get_component_sys_paths(
        "heat") + "/vnc_api/gen/heat/resources"
    plugin_dirs = config.get("heat-plugin-dirs")
    if plugin_path not in plugin_dirs:
        plugin_dirs += ',' + plugin_path
    ctx = utils.get_context()
    sections = {
        "clients_contrail": [
            ("user", ctx.get("keystone_admin_user")),
            ("password", ctx.get("keystone_admin_password")),
            ("tenant", ctx.get("keystone_admin_tenant")),
            ("api_server", " ".join(ctx.get("api_servers"))),
            ("auth_host_ip", ctx.get("keystone_ip")),
            ("use_ssl", ctx.get("ssl_enabled")),
        ]
    }

    if ctx.get("ssl_enabled") and "ca_cert_data" in ctx:
        ca_file_path = "/etc/heat/contrail-ca-cert.pem"
        common_utils.save_file(ca_file_path, ctx["ca_cert_data"], perms=0o644)
        sections["clients_contrail"].append(("cafile", ca_file_path))

    conf = {"heat": {"/etc/heat/heat.conf": {"sections": sections}}}
    settings = {
        "plugin-dirs": plugin_dirs,
        "subordinate_configuration": json.dumps(conf)
    }
    relation_set(relation_id=rel_id, relation_settings=settings)
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 neutron_api_joined(rel_id=None):
    version = utils.get_openstack_version_codename('neutron')
    utils.deploy_openstack_code("contrail-openstack-neutron-init", "neutron",
                                {"OPENSTACK_VERSION": version})

    # create plugin config
    plugin_path = utils.get_component_sys_paths("neutron")
    base = "neutron_plugin_contrail.plugins.opencontrail"
    plugin = base + ".contrail_plugin.NeutronPluginContrailCoreV2"
    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"
            }
        }]
    relation_set(relation_id=rel_id, relation_settings=settings)

    # if this hook raised after contrail-controller we need
    # to overwrite default config file after installation
    utils.write_configs()