예제 #1
0
    def _prepare_res_handlers(self):
        contrail_extension_enabled = cfg.CONF.APISERVER.contrail_extensions
        apply_subnet_host_routes = cfg.CONF.APISERVER.apply_subnet_host_routes
        kwargs = {
            'contrail_extensions_enabled': contrail_extension_enabled,
            'apply_subnet_host_routes': apply_subnet_host_routes
        }

        self._res_handlers['network'] = vn_handler.VNetworkHandler(
            self._vnc_lib, **kwargs)

        self._res_handlers['subnet'] = subnet_handler.SubnetHandler(
            self._vnc_lib, **kwargs)
        self._res_handlers['port'] = vmi_handler.VMInterfaceHandler(
            self._vnc_lib, **kwargs)
        self._res_handlers['router'] = rtr_handler.LogicalRouterHandler(
            self._vnc_lib, **kwargs)
        self._res_handlers['floatingip'] = fip_handler.FloatingIpHandler(
            self._vnc_lib, **kwargs)
        self._res_handlers['security_group'] = sg_handler.SecurityGroupHandler(
            self._vnc_lib, **kwargs)
        self._res_handlers['security_group_rule'] = (
            sgrule_handler.SecurityGroupRuleHandler(self._vnc_lib, **kwargs))

        self._res_handlers['ipam'] = ipam_handler.IPamHandler(
            self._vnc_lib, **kwargs)
        self._res_handlers['policy'] = policy_handler.PolicyHandler(
            self._vnc_lib, **kwargs)
        self._res_handlers['route_table'] = (
            route_table_handler.RouteTableHandler(self._vnc_lib, **kwargs))
        self._res_handlers['svc'] = svc_instance_handler.SvcInstanceHandler(
            self._vnc_lib, **kwargs)
        self._res_handlers['virtual_router'] = \
            vrouter_handler.VirtualRouterHandler(self._vnc_lib, **kwargs)
예제 #2
0
 def _validate_shared_attr(self, is_shared, vn_obj):
     if not is_shared and vn_obj.is_shared:
         for vmi in vn_obj.get_virtual_machine_interface_back_refs() or []:
             vmi_obj = vmi_handler.VMInterfaceHandler(
                 self._vnc_lib).get_vmi_obj(vmi['uuid'])
             if vmi_obj.parent_type == 'project' and (
                vmi_obj.parent_uuid != vn_obj.parent_uuid):
                 self._raise_contrail_exception(
                     'InvalidSharedSetting',
                     network=vn_obj.display_name, resource='network')
예제 #3
0
 def __init__(self, vnc_lib):
     super(LogicalRouterInterfaceHandler, self).__init__(vnc_lib)
     self._vmi_handler = vmi_handler.VMInterfaceHandler(self._vnc_lib)
     self._subnet_handler = subnet_handler.SubnetHandler(self._vnc_lib)
    def initialize(self):
        logger.info("Initializing ConGl (Contrail Gluon) mechanism driver ...")

        logger.warn("Cfg is %s %d" % (cfg.CONF.ml2_driver_contrail.controller,
                                      cfg.CONF.ml2_driver_contrail.port))

        cfg.CONF.register_opts(vnc_extra_opts, 'APISERVER')
        admin_user = cfg.CONF.keystone_authtoken.admin_user
        admin_password = cfg.CONF.keystone_authtoken.admin_password
        admin_tenant_name = cfg.CONF.keystone_authtoken.admin_tenant_name
        try:
            api_srvr_ip = cfg.CONF.ml2_driver_contrail.controller
        except cfg.NoSuchOptError:
            logger.info("No controller address in config - using default")
            api_srvr_ip = "127.0.0.1"

        try:
            api_srvr_port = cfg.CONF.ml2_driver_contrail.port
        except cfg.NoSuchOptError:
            logger.info("No controller port in config - using default")
            api_srvr_port = 8082

        try:
            auth_host = cfg.CONF.keystone_authtoken.auth_host
        except cfg.NoSuchOptError:
            auth_host = "127.0.0.1"

        try:
            auth_protocol = cfg.CONF.keystone_authtoken.auth_protocol
        except cfg.NoSuchOptError:
            auth_protocol = "http"

        try:
            auth_port = cfg.CONF.keystone_authtoken.auth_port
        except cfg.NoSuchOptError:
            auth_port = "35357"

        try:
            auth_url = cfg.CONF.keystone_authtoken.auth_url
        except cfg.NoSuchOptError:
            auth_url = "/v2.0/tokens"

        try:
            auth_type = cfg.CONF.auth_strategy
        except cfg.NoSuchOptError:
            auth_type = "keystone"

        try:
            api_server_url = cfg.CONF.APISERVER.api_server_url
        except cfg.NoSuchOptError:
            api_server_url = "/"

        logger.info("Connecting to Contrail server %s : %s" %
                    (api_srvr_ip, api_srvr_port))

        connected = False
        while not connected:
            try:
                self._vnc_lib = vnc_api.VncApi(admin_user,
                                               admin_password,
                                               admin_tenant_name,
                                               api_srvr_ip,
                                               api_srvr_port,
                                               api_server_url,
                                               auth_host=auth_host,
                                               auth_port=auth_port,
                                               auth_protocol=auth_protocol,
                                               auth_url=auth_url,
                                               auth_type=auth_type)
                connected = True
            except requests.exceptions.RequestException:
                time.sleep(3)

        self.handlers = {
            Hndl.VirtualNetwork: vn_res_handler.VNetworkHandler(self._vnc_lib),
            Hndl.Subnet: subnet_res_handler.SubnetHandler(self._vnc_lib),
            Hndl.VMInterface:
            vmi_res_handler.VMInterfaceHandler(self._vnc_lib),
            Hndl.SecurityGroup:
            sg_res_handler.SecurityGroupHandler(self._vnc_lib),
            Hndl.SGRule: sgrule_handler.SecurityGroupRuleHandler(self._vnc_lib)
        }