Exemple #1
0
    def instance_for_image(imgfile, imgfmt, partition):
        LOG.debug("Instance for image imgfile=%(imgfile)s "
                  "imgfmt=%(imgfmt)s partition=%(partition)s",
                  {'imgfile': imgfile, 'imgfmt': imgfmt,
                   'partition': partition})

        vfs = None
        try:
            LOG.debug("Using primary VFSGuestFS")
            vfs = importutils.import_object(
                "nova.virt.disk.vfs.guestfs.VFSGuestFS",
                imgfile, imgfmt, partition)
            if not VFS.guestfs_ready:
                # Inspect for capabilities and keep
                # track of the result only if succeeded.
                vfs.inspect_capabilities()
                VFS.guestfs_ready = True
            return vfs
        except exception.NovaException:
            if vfs is not None:
                # We are able to load libguestfs but
                # something wrong happens when trying to
                # check for capabilities.
                raise
            else:
                LOG.info(_LI("Unable to import guestfs, "
                             "falling back to VFSLocalFS"))

        return importutils.import_object(
            "nova.virt.disk.vfs.localfs.VFSLocalFS",
            imgfile, imgfmt, partition)
Exemple #2
0
    def __init__(self):
        super(NECPluginV2, self).__init__()
        self.ofc = ofc_manager.OFCManager(self.safe_reference)
        self.base_binding_dict = self._get_base_binding_dict()
        portbindings_base.register_port_dict_function()

        neutron_extensions.append_api_extensions_path(extensions.__path__)

        self.setup_rpc()
        self.l3_rpc_notifier = nec_router.L3AgentNotifyAPI()

        self.network_scheduler = importutils.import_object(
            config.CONF.network_scheduler_driver
        )
        self.router_scheduler = importutils.import_object(
            config.CONF.router_scheduler_driver
        )

        nec_router.load_driver(self.safe_reference, self.ofc)
        self.port_handlers = {
            'create': {
                const.DEVICE_OWNER_ROUTER_GW: self.create_router_port,
                const.DEVICE_OWNER_ROUTER_INTF: self.create_router_port,
                'default': self.activate_port_if_ready,
            },
            'delete': {
                const.DEVICE_OWNER_ROUTER_GW: self.delete_router_port,
                const.DEVICE_OWNER_ROUTER_INTF: self.delete_router_port,
                'default': self.deactivate_port,
            }
        }
Exemple #3
0
def load_auth_methods():
    global AUTH_PLUGINS_LOADED

    if AUTH_PLUGINS_LOADED:
        # Only try and load methods a single time.
        return
    # config.setup_authentication should be idempotent, call it to ensure we
    # have setup all the appropriate configuration options we may need.
    config.setup_authentication()
    for plugin in CONF.auth.methods:
        if '.' in plugin:
            # NOTE(morganfainberg): if '.' is in the plugin name, it should be
            # imported rather than used as a plugin identifier.
            plugin_class = plugin
            driver = importutils.import_object(plugin)
            if not hasattr(driver, 'method'):
                raise ValueError(_('Cannot load an auth-plugin by class-name '
                                   'without a "method" attribute defined: %s'),
                                 plugin_class)

            LOG.info(_LI('Loading auth-plugins by class-name is deprecated.'))
            plugin_name = driver.method
        else:
            plugin_name = plugin
            plugin_class = CONF.auth.get(plugin)
            driver = importutils.import_object(plugin_class)
        if plugin_name in AUTH_METHODS:
            raise ValueError(_('Auth plugin %(plugin)s is requesting '
                               'previously registered method %(method)s') %
                             {'plugin': plugin_class, 'method': driver.method})
        AUTH_METHODS[plugin_name] = driver
    AUTH_PLUGINS_LOADED = True
Exemple #4
0
def get_openstack_security_group_driver():
    if CONF.security_group_api.lower() == 'nova':
        return importutils.import_object(NOVA_DRIVER)
    elif is_neutron_security_groups():
        return importutils.import_object(NEUTRON_DRIVER)
    else:
        return importutils.import_object(CONF.security_group_api)
Exemple #5
0
    def __init__(self):
        """Initialize Brocade Plugin.

        Specify switch address and db configuration.
        """

        super(BrocadePluginV2, self).__init__()
        self.supported_extension_aliases = ["binding", "security-group",
                                            "external-net", "router",
                                            "extraroute", "agent",
                                            "l3_agent_scheduler",
                                            "dhcp_agent_scheduler"]

        self.physical_interface = (cfg.CONF.PHYSICAL_INTERFACE.
                                   physical_interface)
        self.base_binding_dict = self._get_base_binding_dict()
        portbindings_base.register_port_dict_function()
        self.ctxt = context.get_admin_context()
        self.ctxt.session = db.get_session()
        self._vlan_bitmap = vbm.VlanBitmap(self.ctxt)
        self._setup_rpc()
        self.network_scheduler = importutils.import_object(
            cfg.CONF.network_scheduler_driver
        )
        self.router_scheduler = importutils.import_object(
            cfg.CONF.router_scheduler_driver
        )
        self.brocade_init()
def get_openstack_security_group_driver(skip_policy_check=False):
    if CONF.security_group_api.lower() == 'nova':
        return importutils.import_object(NOVA_DRIVER,
                                         skip_policy_check=skip_policy_check)
    elif is_neutron_security_groups():
        return importutils.import_object(NEUTRON_DRIVER,
                                         skip_policy_check=skip_policy_check)
    else:
        return importutils.import_object(CONF.security_group_api,
                                         skip_policy_check=skip_policy_check)
Exemple #7
0
 def __init__(self):
     super(LocalManager, self).__init__()
     # NOTE(vish): setting the host to none ensures that the actual
     #             l3driver commands for l3 are done via rpc.
     self.host = None
     self.servicegroup_api = servicegroup.API()
     self.network_rpcapi = network_rpcapi.NetworkAPI()
     self.floating_dns_manager = importutils.import_object(
             CONF.floating_ip_dns_manager)
     self.instance_dns_manager = importutils.import_object(
             CONF.instance_dns_manager)
     self.notifier = rpc.get_notifier('network', CONF.host)
    def setUp(self):
        def fake_get_nw_info(cls, ctxt, instance):
            self.assertTrue(ctxt.is_admin)
            return fake_network.fake_get_instance_nw_info(self.stubs, 1, 1)

        super(UsageInfoTestCase, self).setUp()
        self.stubs.Set(network_api.API, 'get_instance_nw_info',
                       fake_get_nw_info)

        fake_notifier.stub_notifier(self.stubs)
        self.addCleanup(fake_notifier.reset)

        self.flags(use_local=True, group='conductor')
        self.flags(compute_driver='nova.virt.fake.FakeDriver',
                   network_manager='nova.network.manager.FlatManager')
        self.compute = importutils.import_object(CONF.compute_manager)
        self.user_id = 'fake'
        self.project_id = 'fake'
        self.context = context.RequestContext(self.user_id, self.project_id)

        def fake_show(meh, context, id, **kwargs):
            return {'id': 1, 'properties': {'kernel_id': 1, 'ramdisk_id': 1}}

        self.stubs.Set(nova.tests.image.fake._FakeImageService, 'show',
                       fake_show)
        fake_network.set_stub_network_methods(self.stubs)
        fake_server_actions.stub_out_action_events(self.stubs)
Exemple #9
0
    def __new__(cls, *args, **kwargs):
        '''Create an instance of the servicegroup API.

        args and kwargs are passed down to the servicegroup driver when it gets
        created.  No args currently exist, though.  Valid kwargs are:

        db_allowed - Boolean. False if direct db access is not allowed and
                     alternative data access (conductor) should be used
                     instead.
        '''

        if not cls._driver:
            LOG.debug('ServiceGroup driver defined as an instance of %s',
                      str(CONF.servicegroup_driver))
            driver_name = CONF.servicegroup_driver
            try:
                driver_class = cls._driver_name_class_mapping[driver_name]
            except KeyError:
                raise TypeError(_("unknown ServiceGroup driver name: %s")
                                % driver_name)
            cls._driver = importutils.import_object(driver_class,
                                                    *args, **kwargs)
            utils.check_isinstance(cls._driver, ServiceGroupDriver)
            # we don't have to check that cls._driver is not NONE,
            # check_isinstance does it
        return super(API, cls).__new__(cls)
Exemple #10
0
 def instance_for_device(imgfile, mountdir, partition, device):
     LOG.debug("Instance for device imgfile=%(imgfile)s "
               "mountdir=%(mountdir)s partition=%(partition)s "
               "device=%(device)s",
               {'imgfile': imgfile, 'mountdir': mountdir,
                'partition': partition, 'device': device})
     if "loop" in device:
         LOG.debug("Using LoopMount")
         return importutils.import_object(
             "nova.virt.disk.mount.loop.LoopMount",
             imgfile, mountdir, partition, device)
     else:
         LOG.debug("Using NbdMount")
         return importutils.import_object(
             "nova.virt.disk.mount.nbd.NbdMount",
             imgfile, mountdir, partition, device)
Exemple #11
0
    def create_driver(storage_family, storage_protocol, *args, **kwargs):
        """"Creates an appropriate driver based on family and protocol."""

        fmt = {'storage_family': storage_family.lower(),
               'storage_protocol': storage_protocol.lower()}
        LOG.info(_LI('Requested unified config: %(storage_family)s and '
                     '%(storage_protocol)s') % fmt)

        family_meta = netapp_unified_plugin_registry.get(storage_family)
        if family_meta is None:
            raise exception.InvalidInput(
                reason=_('Storage family %s is not supported')
                % storage_family)

        driver_loc = family_meta.get(storage_protocol)
        if driver_loc is None:
            raise exception.InvalidInput(
                reason=_('Protocol %(storage_protocol)s is not supported'
                         ' for storage family %(storage_family)s')
                % fmt)

        NetAppDriverFactory.check_netapp_driver(driver_loc)
        kwargs = kwargs or {}
        kwargs['netapp_mode'] = 'proxy'
        driver = importutils.import_object(driver_loc, *args, **kwargs)
        LOG.info(_LI('NetApp driver of family %(storage_family)s and protocol'
                     ' %(storage_protocol)s loaded') % fmt)
        return driver
Exemple #12
0
    def setUp(self):
        def fake_get_nw_info(cls, ctxt, instance):
            self.assertTrue(ctxt.is_admin)
            return fake_network.fake_get_instance_nw_info(self.stubs, 1, 1)

        super(UsageInfoTestCase, self).setUp()
        self.stubs.Set(network_api.API, 'get_instance_nw_info',
                       fake_get_nw_info)

        fake_notifier.stub_notifier(self.stubs)
        self.addCleanup(fake_notifier.reset)

        self.flags(use_local=True, group='conductor')
        self.flags(compute_driver='nova.virt.fake.FakeDriver',
                   network_manager='nova.network.manager.FlatManager')
        self.compute = importutils.import_object(CONF.compute_manager)
        self.user_id = 'fake'
        self.project_id = 'fake'
        self.context = context.RequestContext(self.user_id, self.project_id)

        def fake_show(meh, context, id, **kwargs):
            return {'id': 1, 'properties': {'kernel_id': 1, 'ramdisk_id': 1}}

        self.stubs.Set(nova.tests.unit.image.fake._FakeImageService,
                       'show', fake_show)
        fake_network.set_stub_network_methods(self.stubs)
        fake_server_actions.stub_out_action_events(self.stubs)
    def __init__(self):
        """Initialize the segmentation manager.

        Checks which device plugins are configured, and load the inventories
        those device plugins for which the inventory is configured.
        """
        conf.CiscoConfigOptions()

        self._plugins = {}
        self._plugins['vswitch_plugin'] = importutils.import_object(
            'neutron.plugins.cisco.n1kv.n1kv_neutron_plugin.'
            'N1kvNeutronPluginV2')

        if ((const.VSWITCH_PLUGIN in self._plugins) and
            hasattr(self._plugins[const.VSWITCH_PLUGIN],
                    "supported_extension_aliases")):
            self.supported_extension_aliases.extend(
                self._plugins[const.VSWITCH_PLUGIN].
                supported_extension_aliases)

        # Initialize credential store after database initialization
        cred.Store.initialize()
        LOG.debug("%(module)s.%(name)s init done",
                  {'module': __name__,
                   'name': self.__class__.__name__})
Exemple #14
0
    def create_driver(storage_family, storage_protocol, *args, **kwargs):
        """"Creates an appropriate driver based on family and protocol."""

        fmt = {
            'storage_family': storage_family.lower(),
            'storage_protocol': storage_protocol.lower()
        }
        LOG.info(
            _LI('Requested unified config: %(storage_family)s and '
                '%(storage_protocol)s') % fmt)

        family_meta = netapp_unified_plugin_registry.get(storage_family)
        if family_meta is None:
            raise exception.InvalidInput(
                reason=_('Storage family %s is not supported') %
                storage_family)

        driver_loc = family_meta.get(storage_protocol)
        if driver_loc is None:
            raise exception.InvalidInput(
                reason=_('Protocol %(storage_protocol)s is not supported'
                         ' for storage family %(storage_family)s') % fmt)

        NetAppDriverFactory.check_netapp_driver(driver_loc)
        kwargs = kwargs or {}
        kwargs['netapp_mode'] = 'proxy'
        driver = importutils.import_object(driver_loc, *args, **kwargs)
        LOG.info(
            _LI('NetApp driver of family %(storage_family)s and protocol'
                ' %(storage_protocol)s loaded') % fmt)
        return driver
    def test_compute_manager(self):
        was = {'called': False}

        def fake_get_all_by_filters(context, *args, **kwargs):
            was['called'] = True
            instances = []
            for x in xrange(2):
                instances.append(fake_instance.fake_db_instance(
                                                        image_ref='1',
                                                        uuid=x,
                                                        name=x,
                                                        vm_state='',
                                                        task_state=''))
            return instances

        with utils.tempdir() as tmpdir:
            self.flags(instances_path=tmpdir)

            self.stubs.Set(db, 'instance_get_all_by_filters',
                           fake_get_all_by_filters)
            compute = importutils.import_object(CONF.compute_manager)
            self.flags(use_local=True, group='conductor')
            compute.conductor_api = conductor.API()
            compute._run_image_cache_manager_pass(None)
            self.assertTrue(was['called'])
Exemple #16
0
 def test_backup_manager_driver_name(self):
     """"Test mapping between backup services and backup drivers."""
     self.override_config('backup_driver', "cinder.backup.services.swift")
     backup_mgr = \
         importutils.import_object(CONF.backup_manager)
     self.assertEqual('cinder.backup.drivers.swift',
                      backup_mgr.driver_name)
Exemple #17
0
    def __init__(self):
        super(NeutronRestProxyV2, self).__init__()
        LOG.info(_('NeutronRestProxy: Starting plugin. Version=%s'),
                 version.version_string_with_vcs())
        pl_config.register_config()
        self.evpool = eventlet.GreenPool(cfg.CONF.RESTPROXY.thread_pool_size)

        # Include the Big Switch Extensions path in the api_extensions
        neutron_extensions.append_api_extensions_path(extensions.__path__)

        self.add_meta_server_route = cfg.CONF.RESTPROXY.add_meta_server_route

        # init network ctrl connections
        self.servers = servermanager.ServerPool()
        self.servers.get_topo_function = self._get_all_data
        self.servers.get_topo_function_args = {
            'get_ports': True,
            'get_floating_ips': True,
            'get_routers': True
        }

        self.network_scheduler = importutils.import_object(
            cfg.CONF.network_scheduler_driver)

        # setup rpc for security and DHCP agents
        self._setup_rpc()

        if cfg.CONF.RESTPROXY.sync_data:
            self._send_all_data()

        LOG.debug(_("NeutronRestProxyV2: initialization done"))
Exemple #18
0
    def __init__(self):
        super(NeutronRestProxyV2, self).__init__()
        LOG.info(_LI('NeutronRestProxy: Starting plugin. Version=%s'),
                 version.version_string_with_vcs())
        pl_config.register_config()
        self.evpool = eventlet.GreenPool(cfg.CONF.RESTPROXY.thread_pool_size)

        # Include the Big Switch Extensions path in the api_extensions
        neutron_extensions.append_api_extensions_path(extensions.__path__)

        self.add_meta_server_route = cfg.CONF.RESTPROXY.add_meta_server_route

        # init network ctrl connections
        self.servers = servermanager.ServerPool()
        self.servers.get_topo_function = self._get_all_data
        self.servers.get_topo_function_args = {'get_ports': True,
                                               'get_floating_ips': True,
                                               'get_routers': True}

        self.network_scheduler = importutils.import_object(
            cfg.CONF.network_scheduler_driver
        )

        # setup rpc for security and DHCP agents
        self._setup_rpc()

        if cfg.CONF.RESTPROXY.sync_data:
            self._send_all_data()

        LOG.debug("NeutronRestProxyV2: initialization done")
Exemple #19
0
    def __new__(cls, *args, **kwargs):
        '''Create an instance of the servicegroup API.

        args and kwargs are passed down to the servicegroup driver when it gets
        created.  No args currently exist, though.  Valid kwargs are:

        db_allowed - Boolean. False if direct db access is not allowed and
                     alternative data access (conductor) should be used
                     instead.
        '''

        if not cls._driver:
            LOG.debug('ServiceGroup driver defined as an instance of %s',
                      str(CONF.servicegroup_driver))
            driver_name = CONF.servicegroup_driver
            try:
                driver_class = cls._driver_name_class_mapping[driver_name]
            except KeyError:
                raise TypeError(
                    _("unknown ServiceGroup driver name: %s") % driver_name)
            cls._driver = importutils.import_object(driver_class, *args,
                                                    **kwargs)
            utils.check_isinstance(cls._driver, ServiceGroupDriver)
            # we don't have to check that cls._driver is not NONE,
            # check_isinstance does it
        return super(API, cls).__new__(cls)
Exemple #20
0
 def __init__(self, scheduler_driver=None, *args, **kwargs):
     if not scheduler_driver:
         scheduler_driver = CONF.scheduler_driver
     self.driver = importutils.import_object(scheduler_driver)
     super(SchedulerManager, self).__init__(service_name='scheduler',
                                            *args, **kwargs)
     self.additional_endpoints.append(_SchedulerManagerV3Proxy(self))
Exemple #21
0
    def __init__(self):
        """Initialize the segmentation manager.

        Checks which device plugins are configured, and load the inventories
        those device plugins for which the inventory is configured.
        """
        conf.CiscoConfigOptions()

        self._plugins = {}
        self._plugins['vswitch_plugin'] = importutils.import_object(
            'neutron.plugins.cisco.n1kv.n1kv_neutron_plugin.'
            'N1kvNeutronPluginV2')

        if ((const.VSWITCH_PLUGIN in self._plugins)
                and hasattr(self._plugins[const.VSWITCH_PLUGIN],
                            "supported_extension_aliases")):
            self.supported_extension_aliases.extend(self._plugins[
                const.VSWITCH_PLUGIN].supported_extension_aliases)

        # Initialize credential store after database initialization
        cred.Store.initialize()
        LOG.debug("%(module)s.%(name)s init done", {
            'module': __name__,
            'name': self.__class__.__name__
        })
Exemple #22
0
 def _load_drivers(self):
     """Loads plugin-driver from configuration."""
     LOG.info(_LI("Loading Metering driver %s"), self.conf.driver)
     if not self.conf.driver:
         raise SystemExit(_('A metering driver must be specified'))
     self.metering_driver = importutils.import_object(
         self.conf.driver, self, self.conf)
Exemple #23
0
 def instance_for_format(imgfile, mountdir, partition, imgfmt):
     LOG.debug("Instance for format imgfile=%(imgfile)s "
               "mountdir=%(mountdir)s partition=%(partition)s "
               "imgfmt=%(imgfmt)s",
               {'imgfile': imgfile, 'mountdir': mountdir,
                'partition': partition, 'imgfmt': imgfmt})
     if imgfmt == "raw":
         LOG.debug("Using LoopMount")
         return importutils.import_object(
             "nova.virt.disk.mount.loop.LoopMount",
             imgfile, mountdir, partition)
     else:
         LOG.debug("Using NbdMount")
         return importutils.import_object(
             "nova.virt.disk.mount.nbd.NbdMount",
             imgfile, mountdir, partition)
    def brocade_init(self):
        """Brocade specific initialization for this class."""

        osversion = None
        self._switch = {
            'address': cfg.CONF.ml2_brocade.address,
            'username': cfg.CONF.ml2_brocade.username,
            'password': cfg.CONF.ml2_brocade.password,
            'ostype': cfg.CONF.ml2_brocade.ostype,
            'osversion': cfg.CONF.ml2_brocade.osversion}

        self._driver = importutils.import_object(NOS_DRIVER)

        # Detect version of NOS on the switch
        osversion = self._switch['osversion']
        if osversion == "autodetect":
            osversion = self._driver.get_nos_version(
                self._switch['address'],
                self._switch['username'],
                self._switch['password'])

        virtual_fabric_enabled = self._driver.is_virtual_fabric_enabled(
                self._switch['address'],
                self._switch['username'],
                self._switch['password'])

        if virtual_fabric_enabled:
            LOG.debug("Virtual Fabric: enabled")
        else:
            LOG.debug("Virtual Fabric: not enabled")

        self.set_features_enabled(osversion, virtual_fabric_enabled)
Exemple #25
0
    def create_driver(storage_family, storage_protocol, *args, **kwargs):
        """"Creates an appropriate driver based on family and protocol."""

        storage_family = storage_family.lower()
        storage_protocol = storage_protocol.lower()

        fmt = {'storage_family': storage_family,
               'storage_protocol': storage_protocol}
        LOG.info(_LI('Requested unified config: %(storage_family)s and '
                     '%(storage_protocol)s.') % fmt)

        family_meta = NETAPP_UNIFIED_DRIVER_REGISTRY.get(storage_family)
        if family_meta is None:
            raise exception.InvalidInput(
                reason=_('Storage family %s is not supported.')
                % storage_family)

        driver_loc = family_meta.get(storage_protocol)
        if driver_loc is None:
            raise exception.InvalidInput(
                reason=_('Protocol %(storage_protocol)s is not supported '
                         'for storage family %(storage_family)s.') % fmt)

        kwargs = kwargs or {}
        kwargs['netapp_mode'] = 'proxy'
        driver = importutils.import_object(driver_loc, *args, **kwargs)
        LOG.info(_LI('NetApp driver of family %(storage_family)s and protocol '
                     '%(storage_protocol)s loaded.') % fmt)
        return driver
Exemple #26
0
    def set_driver(self, resource):
        """Set the driver for a neutron resource.

        :param resource: Neutron resource in dict format. Expected keys:
                        { 'id': <value>
                          'hosting_device': { 'id': <value>, }
                          'router_type': {'cfg_agent_driver': <value>,  }
                        }
        :return driver : driver object
        """
        try:
            resource_id = resource['id']
            hosting_device = resource['hosting_device']
            hd_id = hosting_device['id']
            if hd_id in self._hosting_device_routing_drivers_binding:
                driver = self._hosting_device_routing_drivers_binding[hd_id]
                self._drivers[resource_id] = driver
            else:
                driver_class = resource['router_type']['cfg_agent_driver']
                driver = importutils.import_object(driver_class,
                                                   **hosting_device)
                self._hosting_device_routing_drivers_binding[hd_id] = driver
                self._drivers[resource_id] = driver
            return driver
        except ImportError:
            with excutils.save_and_reraise_exception(reraise=False):
                LOG.exception(_LE("Error loading cfg agent driver %(driver)s "
                                "for hosting device template "
                                "%(t_name)s(%(t_id)s)"),
                              {'driver': driver_class, 't_id': hd_id,
                               't_name': resource['name']})
                raise cfg_exceptions.DriverNotExist(driver=driver_class)
        except KeyError as e:
            with excutils.save_and_reraise_exception(reraise=False):
                raise cfg_exceptions.DriverNotSetForMissingParameter(e)
Exemple #27
0
    def _build_driver(self):
        zone_driver = self.configuration.zone_driver
        LOG.debug("Zone Driver from config: {%s}", zone_driver)

        zm_config = config.Configuration(zone_manager_opts, "fc-zone-manager")
        # Initialize vendor specific implementation of  FCZoneDriver
        self.driver = importutils.import_object(zone_driver, configuration=zm_config)
Exemple #28
0
 def __init__(self, scheduler_driver=None, *args, **kwargs):
     if not scheduler_driver:
         scheduler_driver = CONF.scheduler_driver
     self.driver = importutils.import_object(scheduler_driver)
     self.compute_rpcapi = compute_rpcapi.ComputeAPI()
     super(SchedulerManager, self).__init__(service_name='scheduler',
                                            *args, **kwargs)
        def mocked_brocade_init(self):

            self._switch = {'address': FAKE_IPADDRESS,
                            'username': FAKE_USERNAME,
                            'password': FAKE_PASSWORD
                            }
            self._driver = importutils.import_object(NOS_DRIVER)
    def __init__(self, conf):
        LOG.debug("Initializing firewall agent")
        self.conf = conf
        fwaas_driver_class_path = cfg.CONF.fwaas.driver
        self.fwaas_enabled = cfg.CONF.fwaas.enabled

        # None means l3-agent has no information on the server
        # configuration due to the lack of RPC support.
        if self.neutron_service_plugins is not None:
            fwaas_plugin_configured = (constants.FIREWALL
                                       in self.neutron_service_plugins)
            if fwaas_plugin_configured and not self.fwaas_enabled:
                msg = _("FWaaS plugin is configured in the server side, but "
                        "FWaaS is disabled in L3-agent.")
                LOG.error(msg)
                raise SystemExit(1)
            self.fwaas_enabled = self.fwaas_enabled and fwaas_plugin_configured

        if self.fwaas_enabled:
            try:
                self.fwaas_driver = importutils.import_object(
                    fwaas_driver_class_path)
                LOG.debug("FWaaS Driver Loaded: '%s'", fwaas_driver_class_path)
            except ImportError:
                msg = _('Error importing FWaaS device driver: %s')
                raise ImportError(msg % fwaas_driver_class_path)
        self.services_sync = False
        self.root_helper = config.get_root_helper(conf)
        # setup RPC to msg fwaas plugin
        self.fwplugin_rpc = FWaaSL3PluginApi(topics.FIREWALL_PLUGIN,
                                             conf.host)
        super(FWaaSL3AgentRpcCallback, self).__init__(host=conf.host)
Exemple #31
0
 def _assign_data_mainpulator(self):
     if self._data_manipulator is None:
         if self.son_manipulator:
             self._data_manipulator = importutils.import_object(
                 self.son_manipulator)
         else:
             self._data_manipulator = BaseTransform()
 def __new__(cls, context):
     if cfg.CONF.cloud_backend == _default_backend:
         return OpenStackClients(context)
     else:
         return importutils.import_object(
             cfg.CONF.cloud_backend,
             context
         )
def InstanceActionAPI(*args, **kwargs):
    """Returns the 'InstanceActionAPI' class from the same module as the
    configured compute api.
    """
    compute_api_class_name = _get_compute_api_class_name()
    compute_api_class = importutils.import_class(compute_api_class_name)
    class_name = compute_api_class.__module__ + ".InstanceActionAPI"
    return importutils.import_object(class_name, *args, **kwargs)
Exemple #34
0
    def brocade_init(self):
        """Brocade specific initialization."""

        self._switch = {'address': cfg.CONF.SWITCH.address,
                        'username': cfg.CONF.SWITCH.username,
                        'password': cfg.CONF.SWITCH.password
                        }
        self._driver = importutils.import_object(NOS_DRIVER)
Exemple #35
0
    def _build_driver(self):
        zone_driver = self.configuration.zone_driver
        LOG.debug("Zone Driver from config: {%s}", zone_driver)

        zm_config = config.Configuration(zone_manager_opts, 'fc-zone-manager')
        # Initialize vendor specific implementation of  FCZoneDriver
        self.driver = importutils.import_object(zone_driver,
                                                configuration=zm_config)
Exemple #36
0
 def __new__(cls, context):
     if cfg.CONF.cloud_backend == _default_backend:
         return OpenStackClients(context)
     else:
         return importutils.import_object(
             cfg.CONF.cloud_backend,
             context
         )
Exemple #37
0
 def __init__(self, host=None, binary=None, topic=None, manager=None):
     host = host or CONF.host
     binary = binary or os.path.basename(inspect.stack()[-1][1])
     topic = topic or binary.rpartition('trove-')[2]
     self.manager_impl = importutils.import_object(manager)
     self.report_interval = CONF.report_interval
     super(RpcService, self).__init__(host, topic,
                                      manager=self.manager_impl)
Exemple #38
0
        def mocked_brocade_init(self):

            self._switch = {
                'address': FAKE_IPADDRESS,
                'username': FAKE_USERNAME,
                'password': FAKE_PASSWORD
            }
            self._driver = importutils.import_object(NOS_DRIVER)
Exemple #39
0
 def __new__(cls, context):
     if cfg.CONF.keystone_backend == _default_keystone_backend:
         return KeystoneClientV3(context)
     else:
         return importutils.import_object(
             cfg.CONF.keystone_backend,
             context
         )
Exemple #40
0
 def _load_vif_driver_class(self):
     try:
         class_name = self._vif_driver_class_map[CONF.network_api_class]
         self._vif_driver = importutils.import_object(class_name)
     except KeyError:
         raise TypeError(
             _("VIF driver not found for "
               "network_api_class: %s") % CONF.network_api_class)
Exemple #41
0
 def __init__(self, scheduler_driver=None, *args, **kwargs):
     if not scheduler_driver:
         scheduler_driver = CONF.scheduler_driver
     self.driver = importutils.import_object(scheduler_driver)
     self.compute_rpcapi = compute_rpcapi.ComputeAPI()
     super(SchedulerManager, self).__init__(service_name='scheduler',
                                            *args,
                                            **kwargs)
Exemple #42
0
 def _load_vif_driver_class(self):
     try:
         class_name = self._vif_driver_class_map[CONF.network_api_class]
         self._vif_driver = importutils.import_object(class_name)
     except KeyError:
         raise TypeError(_("VIF driver not found for "
                           "network_api_class: %s") %
                         CONF.network_api_class)
Exemple #43
0
 def __init__(self, scheduler_driver=None, *args, **kwargs):
     if not scheduler_driver:
         scheduler_driver = CONF.scheduler_driver
     self.driver = importutils.import_object(scheduler_driver)
     super(SchedulerManager, self).__init__(service_name='scheduler',
                                            *args,
                                            **kwargs)
     self.additional_endpoints.append(_SchedulerManagerV3Proxy(self))
Exemple #44
0
 def _configure(self):
     config.setup_logging()
     config.register_interface_driver_opts_helper(cfg.CONF)
     cfg.CONF.set_override(
         'interface_driver',
         'neutron.agent.linux.interface.OVSInterfaceDriver')
     cfg.CONF.register_opts(interface.OPTS)
     self.driver = importutils.import_object(cfg.CONF.interface_driver,
                                             cfg.CONF)
 def setUp(self):
     super(ConsoleTestCase, self).setUp()
     self.flags(console_driver='nova.console.fake.FakeConsoleProxy',
                stub_compute=True)
     self.console = importutils.import_object(CONF.console_manager)
     self.user_id = 'fake'
     self.project_id = 'fake'
     self.context = context.RequestContext(self.user_id, self.project_id)
     self.host = 'test_compute_host'
Exemple #46
0
 def _driver(self):
     if self.__driver:
         return self.__driver
     if not self._driver_cls:
         self._driver_cls = CONF.quota_driver
     if isinstance(self._driver_cls, six.string_types):
         self._driver_cls = importutils.import_object(self._driver_cls)
     self.__driver = self._driver_cls
     return self.__driver
Exemple #47
0
 def __init__(self, host=None, binary=None, topic=None, manager=None):
     host = host or CONF.host
     binary = binary or os.path.basename(inspect.stack()[-1][1])
     topic = topic or binary.rpartition('trove-')[2]
     self.manager_impl = importutils.import_object(manager)
     self.report_interval = CONF.report_interval
     super(RpcService, self).__init__(host,
                                      topic,
                                      manager=self.manager_impl)
Exemple #48
0
 def _setup_volume_drivers(self):
     if CONF.enabled_backends:
         for backend in CONF.enabled_backends:
             host = "%s@%s" % (CONF.host, backend)
             mgr = importutils.import_object(CONF.volume_manager,
                                             host=host,
                                             service_name=backend)
             config = mgr.configuration
             backend_name = config.safe_get('volume_backend_name')
             LOG.debug("Registering backend %(backend)s (host=%(host)s "
                       "backend_name=%(backend_name)s)." %
                       {'backend': backend, 'host': host,
                        'backend_name': backend_name})
             self.volume_managers[backend] = mgr
     else:
         default = importutils.import_object(CONF.volume_manager)
         LOG.debug("Registering default backend %s." % (default))
         self.volume_managers['default'] = default
Exemple #49
0
 def __init__(self, console_driver=None, *args, **kwargs):
     if not console_driver:
         console_driver = CONF.console_driver
     self.driver = importutils.import_object(console_driver)
     super(ConsoleProxyManager, self).__init__(service_name='console',
                                               *args,
                                               **kwargs)
     self.driver.host = self.host
     self.compute_rpcapi = compute_rpcapi.ComputeAPI()
Exemple #50
0
 def setUp(self):
     super(UsageInfoTestCase, self).setUp()
     self.addCleanup(fake_notifier.reset)
     self.flags(host='fake', notification_driver=["test"])
     self.volume = importutils.import_object(CONF.volume_manager)
     self.user_id = 'fake'
     self.project_id = 'fake'
     self.snapshot_id = 'fake'
     self.volume_size = 0
     self.context = context.RequestContext(self.user_id, self.project_id)
 def mocked_plumlib_init(self):
     director_plumgrid = FAKE_DIRECTOR
     director_port = FAKE_PORT
     director_username = FAKE_USERNAME
     director_password = FAKE_PASSWORD
     timeout = FAKE_TIMEOUT
     self._plumlib = importutils.import_object(PLUM_DRIVER)
     self._plumlib.director_conn(director_plumgrid, director_port,
                                 timeout, director_username,
                                 director_password)
Exemple #52
0
 def __init__(self):
     super(Manager, self).__init__()
     self.admin_context = TroveContext(
         user=CONF.nova_proxy_admin_user,
         auth_token=CONF.nova_proxy_admin_pass,
         tenant=CONF.nova_proxy_admin_tenant_name)
     if CONF.exists_notification_transformer:
         self.exists_transformer = importutils.import_object(
             CONF.exists_notification_transformer,
             context=self.admin_context)
Exemple #53
0
def _get_matchmaker(*args, **kwargs):
    global matchmaker
    if not matchmaker:
        mm = CONF.rpc_zmq_matchmaker
        if mm.endswith('matchmaker.MatchMakerRing'):
            mm.replace('matchmaker', 'matchmaker_ring')
            LOG.warn(_('rpc_zmq_matchmaker = %(orig)s is deprecated; use'
                       ' %(new)s instead') % dict(
                     orig=CONF.rpc_zmq_matchmaker, new=mm))
        matchmaker = importutils.import_object(mm, *args, **kwargs)
    return matchmaker
Exemple #54
0
 def get_hosting_device_plugging_driver(cls):
     """Returns  plugging driver."""
     if cls._plugging_driver:
         return cls._plugging_driver
     else:
         try:
             cls._plugging_driver = importutils.import_object(
                 cfg.CONF.hosting_devices.csr1kv_plugging_driver)
         except (ImportError, TypeError, n_exc.NeutronException):
             LOG.exception(_LE('Error loading plugging driver'))
         return cls._plugging_driver
Exemple #55
0
    def setUp(self):
        super(ComputeXenTestCase, self).setUp()
        self.flags(compute_driver='xenapi.XenAPIDriver')
        self.flags(connection_url='test_url',
                   connection_password='******',
                   group='xenserver')

        stubs.stubout_session(self.stubs, stubs.FakeSessionForVMTests)
        self.compute = importutils.import_object(CONF.compute_manager)
        # execute power syncing synchronously for testing:
        self.compute._sync_power_pool = eventlet_utils.SyncPool()
Exemple #56
0
 def instance_for_device(imgfile, mountdir, partition, device):
     LOG.debug(
         "Instance for device imgfile=%(imgfile)s "
         "mountdir=%(mountdir)s partition=%(partition)s "
         "device=%(device)s", {
             'imgfile': imgfile,
             'mountdir': mountdir,
             'partition': partition,
             'device': device
         })
     if "loop" in device:
         LOG.debug("Using LoopMount")
         return importutils.import_object(
             "nova.virt.disk.mount.loop.LoopMount", imgfile, mountdir,
             partition, device)
     else:
         LOG.debug("Using NbdMount")
         return importutils.import_object(
             "nova.virt.disk.mount.nbd.NbdMount", imgfile, mountdir,
             partition, device)
Exemple #57
0
 def instance_for_format(imgfile, mountdir, partition, imgfmt):
     LOG.debug(
         "Instance for format imgfile=%(imgfile)s "
         "mountdir=%(mountdir)s partition=%(partition)s "
         "imgfmt=%(imgfmt)s", {
             'imgfile': imgfile,
             'mountdir': mountdir,
             'partition': partition,
             'imgfmt': imgfmt
         })
     if imgfmt == "raw":
         LOG.debug("Using LoopMount")
         return importutils.import_object(
             "nova.virt.disk.mount.loop.LoopMount", imgfile, mountdir,
             partition)
     else:
         LOG.debug("Using NbdMount")
         return importutils.import_object(
             "nova.virt.disk.mount.nbd.NbdMount", imgfile, mountdir,
             partition)
Exemple #58
0
 def _initialize_service_helpers(self, host):
     svc_helper_class = self.conf.cfg_agent.routing_svc_helper_class
     try:
         self.routing_service_helper = importutils.import_object(
             svc_helper_class, host, self.conf, self)
     except ImportError as e:
         LOG.warning(_LW("Error in loading routing service helper. Class "
                    "specified is %(class)s. Reason:%(reason)s"),
                  {'class': self.conf.cfg_agent.routing_svc_helper_class,
                   'reason': e})
         self.routing_service_helper = None
Exemple #59
0
    def __init__(self, plugin, conf):
        self.plugin = plugin
        self.conf = conf or cfg.CONF
        self.routers = {}

        if not self.conf.interface_driver:
            raise SystemExit(_('An interface driver must be specified'))
        LOG.info(_LI("Loading interface driver %s"),
                 self.conf.interface_driver)
        self.driver = importutils.import_object(self.conf.interface_driver,
                                                self.conf)
Exemple #60
0
    def __init__(self, quota_driver_class=None):
        """Initialize a Quota object."""

        if not quota_driver_class:
            quota_driver_class = CONF.quota_driver

        if isinstance(quota_driver_class, basestring):
            quota_driver_class = importutils.import_object(quota_driver_class)

        self._resources = {}
        self._driver = quota_driver_class