def __init__(self, conf): self.conf = conf try: vif_driver = importutils.import_object(conf.interface_driver, conf) except ImportError: msg = _('Error importing interface driver: %s') raise SystemExit(msg % conf.interface_driver) try: self.driver = importutils.import_object( conf.device_driver, config.get_root_helper(self.conf), conf.loadbalancer_state_path, vif_driver, self._vip_plug_callback ) except ImportError: msg = _('Error importing loadbalancer device driver: %s') raise SystemExit(msg % conf.device_driver) self.agent_state = { 'binary': 'neutron-loadbalancer-agent', 'host': conf.host, 'topic': plugin_driver.TOPIC_LOADBALANCER_AGENT, 'configurations': {'device_driver': conf.device_driver, 'interface_driver': conf.interface_driver}, 'agent_type': constants.AGENT_TYPE_LOADBALANCER, 'start_flag': True} self.admin_state_up = True self.context = context.get_admin_context_without_session() self._setup_rpc() self.needs_resync = False self.cache = LogicalDeviceCache()
def __init__(self, configfile=None): self.extra_binding_dict = { portbindings.VIF_TYPE: portbindings.VIF_TYPE_OVS, portbindings.CAPABILITIES: { portbindings.CAP_PORT_FILTER: 'security-group' in self.supported_extension_aliases}} ovs_db_v2.initialize() self._parse_network_vlan_ranges() ovs_db_v2.sync_vlan_allocations(self.network_vlan_ranges) self.tenant_network_type = cfg.CONF.OVS.tenant_network_type if self.tenant_network_type not in [constants.TYPE_LOCAL, constants.TYPE_VLAN, constants.TYPE_GRE, constants.TYPE_VXLAN, constants.TYPE_NONE]: LOG.error(_("Invalid tenant_network_type: %s. " "Server terminated!"), self.tenant_network_type) sys.exit(1) self.enable_tunneling = cfg.CONF.OVS.enable_tunneling self.tunnel_id_ranges = [] if self.enable_tunneling: self._parse_tunnel_id_ranges() ovs_db_v2.sync_tunnel_allocations(self.tunnel_id_ranges) elif self.tenant_network_type in constants.TUNNEL_NETWORK_TYPES: LOG.error(_("Tunneling disabled but tenant_network_type is '%s'. " "Server terminated!"), self.tenant_network_type) sys.exit(1) 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 )
def __init__(self, conf): self.conf = conf try: vif_driver = importutils.import_object(conf.interface_driver, conf) except ImportError: # the driver is optional msg = _('Error importing interface driver: %s') raise SystemExit(msg % conf.interface_driver) vif_driver = None try: self.driver = importutils.import_object( conf.device_driver, config.get_root_helper(self.conf), conf.loadbalancer_state_path, vif_driver, self._vip_plug_callback ) except ImportError: msg = _('Error importing loadbalancer device driver: %s') raise SystemExit(msg % conf.device_driver) ctx = context.get_admin_context_without_session() self.plugin_rpc = agent_api.LbaasAgentApi( plugin_driver.TOPIC_PROCESS_ON_HOST, ctx, conf.host ) self.needs_resync = False self.cache = LogicalDeviceCache()
def __init__(self): super(LinuxBridgePluginV2, self).__init__() self.base_binding_dict = { portbindings.VIF_TYPE: portbindings.VIF_TYPE_BRIDGE, portbindings.VIF_DETAILS: { # TODO(rkukura): Replace with new VIF security details portbindings.CAP_PORT_FILTER: 'security-group' in self.supported_extension_aliases}} self._parse_network_vlan_ranges() db.sync_network_states(self.network_vlan_ranges) self.tenant_network_type = cfg.CONF.VLANS.tenant_network_type if self.tenant_network_type not in [svc_constants.TYPE_LOCAL, svc_constants.TYPE_VLAN, svc_constants.TYPE_NONE]: LOG.error(_("Invalid tenant_network_type: %s. " "Service terminated!"), self.tenant_network_type) sys.exit(1) 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 ) LOG.debug(_("Linux Bridge Plugin initialization complete"))
def __init__(self): self.base_binding_dict = { portbindings.VIF_TYPE: portbindings.VIF_TYPE_BRIDGE, portbindings.CAPABILITIES: { portbindings.CAP_PORT_FILTER: 'security-group' in self.supported_extension_aliases}} db.initialize() self._parse_network_vlan_ranges() db.sync_network_states(self.network_vlan_ranges) self.mvrp = cfg.CONF.AGENT.mvrp self.tenant_network_type = cfg.CONF.VLANS.tenant_network_type if self.tenant_network_type not in [constants.TYPE_LOCAL, constants.TYPE_VLAN, constants.TYPE_NONE]: LOG.error(_("Invalid tenant_network_type: %s. " "Service terminated!"), self.tenant_network_type) sys.exit(1) 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 ) LOG.debug(_("Linux Bridge Plugin initialization complete"))
def __init__(self): ndb.initialize() self.ofc = ofc_manager.OFCManager() self.base_binding_dict = self._get_base_binding_dict() portbindings_base.register_port_dict_function() # Set the plugin default extension path # if no api_extensions_path is specified. if not config.CONF.api_extensions_path: config.CONF.set_override('api_extensions_path', 'neutron/plugins/nec/extensions') 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, 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, } }
def _load_device_plugins(self): # Load OVS plug-in, if configured, and use its database parameters if len(self.ovs_plugin) != 0: # if ovs plug-in is configured, use ovs plug-in's database parameters self.ovs_plugin_obj = importutils.import_object(self.ovs_plugin) self.omni_db_obj = importutils.import_object(omni_const.OMNI_DB_CLASS) self.omni_db_obj.initialize(None, None, None, omni_const.OVS_TABLES) else: # if ovs plug-in is not configured, use omni plug-in's database parameters self.omni_db_obj = importutils.import_object(omni_const.OMNI_DB_CLASS) self.omni_db_obj.initialize(None, None, None, omni_const.OMNI_TABLES) self._parse_network_vlan_ranges() self.omni_db_obj.sync_vlan_allocations(self.network_vlan_ranges) config.register_agent_state_opts_helper(cfg.CONF) config.register_root_helper(cfg.CONF) #cfg.CONF.register_opts(scheduler.AGENTS_SCHEDULER_OPTS) # for havana # Load Omni device plug-in if len(self.omni_plugin) != 0: self.omni_plugin_obj = importutils.import_object(self.omni_plugin) self.omni_plugin_obj.initialize(self.omni_db_obj) else: LOG.info("Omni Device plug-in is not specified in the config!!!") return LOG.info("Device plug-ins loaded!")
def __init__(self): self._load_config() self._load_device_plugins() 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)
def __init__(self): ndb.initialize() self.ofc = ofc_manager.OFCManager() 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, 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, } }
def __init__(self): """Initialize Brocade Plugin. Specify switch address and db configuration. """ self.supported_extension_aliases = ["binding", "security-group", "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() db.configure_db() 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 __init__(self): ndb.initialize() self.ofc = ofc_manager.OFCManager() # Set the plugin default extension path # if no api_extensions_path is specified. if not config.CONF.api_extensions_path: config.CONF.set_override("api_extensions_path", "neutron/plugins/nec/extensions") self.setup_rpc() self.network_scheduler = importutils.import_object(config.CONF.network_scheduler_driver) self.router_scheduler = importutils.import_object(config.CONF.router_scheduler_driver)
def __init__(self): # First load drivers, then initialize DB, then initialize drivers self.type_manager = managers.TypeManager() self.mechanism_manager = managers.MechanismManager() db.initialize() self.type_manager.initialize() self.mechanism_manager.initialize() self._setup_rpc() # REVISIT(rkukura): Use stevedore for these? self.network_scheduler = importutils.import_object(cfg.CONF.network_scheduler_driver) self.router_scheduler = importutils.import_object(cfg.CONF.router_scheduler_driver) LOG.info(_("Modular L2 Plugin initialization complete"))
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)
def new_nexus_init(self): self._client = importutils.import_object(NEXUS_DRIVER) self._client.nexus_switches = { (NEXUS_IP_ADDRESS, HOSTNAME1): NEXUS_PORT1, (NEXUS_IP_ADDRESS, 'ssh_port'): NEXUS_SSH_PORT, (NEXUS_IP_ADDRESS, HOSTNAME2): NEXUS_PORT2, (NEXUS_IP_ADDRESS, 'ssh_port'): NEXUS_SSH_PORT, (NEXUS_PC_IP_ADDRESS, 'ssh_port'): NEXUS_SSH_PORT, } self._nexus_switches = { ('NEXUS_SWITCH', NEXUS_IP_ADDRESS, HOSTNAME1): NEXUS_PORT1, ('NEXUS_SWITCH', NEXUS_IP_ADDRESS, HOSTNAME2): NEXUS_PORT2, ('NEXUS_SWITCH', NEXUS_PC_IP_ADDRESS, HOSTNAME3): NEXUS_PORTCHANNELS, ('NEXUS_SWITCH', NEXUS_PC_IP_ADDRESS, 'ssh_port'): NEXUS_SSH_PORT, ('NEXUS_SWITCH', NEXUS_IP_ADDRESS, HOSTNAME3): NEXUS_PORTCHANNELS, ('NEXUS_SWITCH', NEXUS_IP_ADDRESS, 'ssh_port'): NEXUS_SSH_PORT, } self._client.credentials = { NEXUS_IP_ADDRESS: { 'username': '******', 'password': '******' }, NEXUS_PC_IP_ADDRESS: { 'username': '******', 'password': '******' }, } db.configure_db()
def __init__(self, plugin): if not self.device_driver: raise DriverNotSpecified() self.agent_rpc = agent_driver_base.LoadBalancerAgentApi(topics.LOADBALANCER_AGENT) self.plugin = plugin self._set_callbacks_on_plugin() self.plugin.agent_notifiers.update( {q_const.AGENT_TYPE_LOADBALANCER: self.agent_rpc}) self.pool_scheduler = importutils.import_object( cfg.CONF.loadbalancer_pool_scheduler_driver) #configure CRD client LOG.info(_("Initializing CRD client... ")) crd_client_params = { 'username': FSLCONF.crd_user_name, 'tenant_name': FSLCONF.crd_tenant_name, 'region_name': FSLCONF.crd_region_name, 'password': FSLCONF.crd_password, 'auth_url': FSLCONF.crd_auth_url, 'auth_strategy': FSLCONF.crd_auth_strategy, 'endpoint_url': FSLCONF.crd_url, 'timeout': FSLCONF.crd_url_timeout, 'insecure': FSLCONF.crd_api_insecure, 'service_type': SERVICE_TYPE, 'ca_cert': FSLCONF.crd_ca_certificates_file, } self._crdclient = client.Client(**crd_client_params)
def __init__(self, host, conf=None): if conf: self.conf = conf else: self.conf = cfg.CONF self.root_helper = config.get_root_helper(self.conf) self.router_info = {} if not self.conf.interface_driver: raise SystemExit(_('An interface driver must be specified')) try: self.driver = importutils.import_object( self.conf.interface_driver, self.conf ) except Exception: msg = _("Error importing interface driver " "'%s'") % self.conf.interface_driver raise SystemExit(msg) self.context = context.get_admin_context_without_session() self.plugin_rpc = L3PluginApi(topics.PLUGIN, host) self.fullsync = True self.sync_sem = semaphore.Semaphore(1) if self.conf.use_namespaces: self._destroy_router_namespaces(self.conf.router_id) super(L3NATAgent, self).__init__(host=self.conf.host)
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() for key in conf.CISCO_PLUGINS.keys(): plugin_obj = conf.CISCO_PLUGINS[key] self._plugins[key] = importutils.import_object(plugin_obj) LOG.debug(_("Loaded device plugin %s\n"), conf.CISCO_PLUGINS[key]) 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) # At this point, all the database models should have been loaded. It's # possible that configure_db() may have been called by one of the # plugins loaded in above. Otherwise, this call is to make sure that # the database is initialized db_api.configure_db() # Initialize credential store after database initialization cred.Store.initialize() LOG.debug(_("%(module)s.%(name)s init done"), {'module': __name__, 'name': self.__class__.__name__})
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: LOG.exception(_("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': hosting_device['name']}) with excutils.save_and_reraise_exception(reraise=False): raise cfg_exceptions.DriverNotExist(driver=driver_class) except KeyError as e: with excutils.save_and_reraise_exception(reraise=False): raise cfg_exceptions.DriverNotSetForMissingParameter(e)
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)
def __init__(self, host, conf=None): if conf: self.conf = conf else: self.conf = cfg.CONF self.root_helper = config.get_root_helper(self.conf) self.router_info = {} self._check_config_params() try: self.driver = importutils.import_object( self.conf.interface_driver, self.conf ) except Exception: msg = _("Error importing interface driver " "'%s'") % self.conf.interface_driver LOG.error(msg) raise SystemExit(1) self.context = context.get_admin_context_without_session() self.plugin_rpc = L3PluginApi(topics.L3PLUGIN, host) self.fullsync = True self.updated_routers = set() self.removed_routers = set() self.sync_progress = False self._clean_stale_namespaces = self.conf.use_namespaces self._queue = RouterProcessingQueue() super(L3NATAgent, self).__init__(conf=self.conf) self.target_ex_net_id = None
def __init__(self, conf, plugin_rpc): self.conf = conf self.root_helper = config.get_root_helper(conf) self.state_path = conf.zorp.loadbalancer_state_path try: vif_driver = importutils.import_object(conf.interface_driver, conf) except ImportError: with excutils.save_and_reraise_exception(): msg = (_('Error importing interface driver: %s') % conf.zorp.interface_driver) LOG.error(msg) self.vif_driver = vif_driver self.plugin_rpc = plugin_rpc self.pool_to_port_id = {} # generators for zorp config # xml generator generates policy.xml for easy tracking of changes # policy.py generator policy.py and instances.conf for Zorp configuration self.xml_generator = XMLGenerator() # TODO: maybe loadbalancer_state_path should be used self.policy_py_generator = PolicyPyFromXMLGenerator( policy_xml='/tmp/policy.xml', policy_py='/tmp/policy.py', instances_conf='/tmp/instances.conf' )
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 = {} for key in conf.CISCO_PLUGINS.keys(): plugin_obj = conf.CISCO_PLUGINS[key] if plugin_obj is not None: self._plugins[key] = importutils.import_object(plugin_obj) LOG.debug(_("Loaded device plugin %s"), conf.CISCO_PLUGINS[key]) 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__}) # Check whether we have a valid Nexus driver loaded self.is_nexus_plugin = False nexus_driver = conf.CISCO.nexus_driver if nexus_driver.endswith('CiscoNEXUSDriver'): self.is_nexus_plugin = True
def __init__(self, server_timeout=None): super(NeutronRestProxyV2, self).__init__() LOG.info(_('NeutronRestProxy: Starting plugin. Version=%s'), version_string_with_vcs()) pl_config.register_config() self.evpool = eventlet.GreenPool(cfg.CONF.RESTPROXY.thread_pool_size) # Include the BigSwitch 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(server_timeout) 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"))
def __init__(self, server_timeout=None): super(NeutronRestProxyV2, self).__init__() LOG.info(_('NeutronRestProxy: Starting plugin. Version=%s'), version_string_with_vcs()) pl_config.register_config() # Include the BigSwitch 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(server_timeout) # init dhcp support self.topic = topics.PLUGIN self.network_scheduler = importutils.import_object( cfg.CONF.network_scheduler_driver ) self._dhcp_agent_notifier = dhcp_rpc_agent_api.DhcpAgentNotifyAPI() self.agent_notifiers[const.AGENT_TYPE_DHCP] = ( self._dhcp_agent_notifier ) self.conn = rpc.create_connection(new=True) self.callbacks = RpcProxy() self.dispatcher = self.callbacks.create_rpc_dispatcher() self.conn.create_consumer(self.topic, self.dispatcher, fanout=False) # Consume from all consumers in a thread self.conn.consume_in_thread() if cfg.CONF.RESTPROXY.sync_data: self._send_all_data() LOG.debug(_("NeutronRestProxyV2: initialization done"))
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__})
def __init__(self, host, conf=None): if conf: self.conf = conf else: self.conf = cfg.CONF self.root_helper = config.get_root_helper(self.conf) self.router_info = {} self._check_config_params() try: self.driver = importutils.import_object( self.conf.interface_driver, self.conf ) except Exception: msg = _("Error importing interface driver " "'%s'") % self.conf.interface_driver LOG.error(msg) raise SystemExit(msg) self.context = context.get_admin_context_without_session() self.plugin_rpc = L3PluginApi(topics.L3PLUGIN, host) self.fullsync = True self.updated_routers = set() self.removed_routers = set() self.sync_progress = False if self.conf.use_namespaces: self._destroy_router_namespaces(self.conf.router_id) self.rpc_loop = loopingcall.FixedIntervalLoopingCall( self._rpc_loop) self.rpc_loop.start(interval=RPC_LOOP_INTERVAL) super(L3NATAgent, self).__init__(conf=self.conf)
def load_drivers(service_type, plugin): """Loads drivers for specific service. Passes plugin instance to driver's constructor """ service_type_manager = sdb.ServiceTypeManager.get_instance() providers = service_type_manager.get_service_providers(None, filters={"service_type": [service_type]}) if not providers: msg = _("No providers specified for '%s' service, exiting") % service_type LOG.error(msg) raise SystemExit(1) drivers = {} for provider in providers: try: drivers[provider["name"]] = importutils.import_object(provider["driver"], plugin) LOG.debug( _("Loaded '%(provider)s' provider for service " "%(service_type)s"), {"provider": provider["driver"], "service_type": service_type}, ) except ImportError: with excutils.save_and_reraise_exception(): LOG.exception( _("Error loading provider '%(provider)s' for " "service %(service_type)s"), {"provider": provider["driver"], "service_type": service_type}, ) default_provider = None try: provider = service_type_manager.get_default_service_provider(None, service_type) default_provider = provider["name"] except pconf.DefaultServiceProviderNotFound: LOG.info(_("Default provider is not specified for service type %s"), service_type) return drivers, default_provider
def __init__(self): self.ovs_network_driver = cfg.CONF.OVSNETWORK.ovs_network_driver if self.ovs_network_driver: LOG.debug(_("Loading ovs network driver %s"), self.ovs_network_driver) self.ovs_network_driver = importutils.import_object(self.ovs_network_driver) else: LOG.debug(_("ovs network driver is not defined on %s!"), cfg.CONF.host)
def _load_drivers(self): """Loads plugin-driver from configuration.""" LOG.info(_("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)
def __init__(self, host=None): super(DhcpAgent, self).__init__(host=host) self.needs_resync = False self.conf = cfg.CONF self.cache = NetworkCache() self.root_helper = config.get_root_helper(self.conf) self.dhcp_driver_cls = importutils.import_class(self.conf.dhcp_driver) # Work out if DHCP serving for bridged or routed VM interfaces. try: interface_driver = importutils.import_object( self.conf.interface_driver, self.conf) self.bridged = interface_driver.bridged() except Exception as e: msg = (_("Error importing interface driver '%(driver)s': " "%(inner)s") % {'driver': self.conf.interface_driver, 'inner': e}) LOG.error(msg) raise SystemExit(msg) ctx = context.get_admin_context_without_session() self.plugin_rpc = DhcpPluginApi(topics.PLUGIN, ctx, self.bridged and self.conf.use_namespaces) # create dhcp dir to store dhcp info dhcp_dir = os.path.dirname("/%s/dhcp/" % self.conf.state_path) if not os.path.isdir(dhcp_dir): os.makedirs(dhcp_dir, 0o755) self.dhcp_version = self.dhcp_driver_cls.check_version() self._populate_networks_cache()
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(_("Loading interface driver %s"), self.conf.interface_driver) self.driver = importutils.import_object(self.conf.interface_driver, self.conf)
def __init__(self): # First load drivers, then initialize DB, then initialize drivers self.type_manager = managers.TypeManager() self.mechanism_manager = managers.MechanismManager() db.initialize() self.type_manager.initialize() self.mechanism_manager.initialize() self._setup_rpc() # REVISIT(rkukura): Use stevedore for these? self.network_scheduler = importutils.import_object( cfg.CONF.network_scheduler_driver ) self.router_scheduler = importutils.import_object( cfg.CONF.router_scheduler_driver ) LOG.info(_("Modular L2 Plugin initialization complete"))
def __init__(self): self.ovs_network_driver = cfg.CONF.OVSNETWORK.ovs_network_driver if self.ovs_network_driver: LOG.debug(_("Loading ovs network driver %s"), self.ovs_network_driver) self.ovs_network_driver = importutils.import_object( self.ovs_network_driver) else: LOG.debug(_("ovs network driver is not defined on %s!"), cfg.CONF.host)
def plumgrid_init(self): """PLUMgrid initialization.""" director_plumgrid = cfg.CONF.PLUMgridDirector.director_server director_port = cfg.CONF.PLUMgridDirector.director_server_port timeout = cfg.CONF.PLUMgridDirector.servertimeout # PLUMgrid Director info validation LOG.info(_('Neutron PLUMgrid Director: %s'), director_plumgrid) self._plumlib = importutils.import_object(PLUM_DRIVER) self._plumlib.director_conn(director_plumgrid, director_port, timeout)
def _setup_rpc_dhcp_metadata(self): self.topic = topics.PLUGIN self.conn = rpc.create_connection(new=True) self.dispatcher = nvp_rpc.NVPRpcCallbacks().create_rpc_dispatcher() self.conn.create_consumer(self.topic, self.dispatcher, fanout=False) self.agent_notifiers[const.AGENT_TYPE_DHCP] = ( dhcp_rpc_agent_api.DhcpAgentNotifyAPI()) self.conn.consume_in_thread() self.network_scheduler = importutils.import_object( cfg.CONF.network_scheduler_driver)
def __init__(self, configfile=None): super(OVSNeutronPluginV2, self).__init__() self.base_binding_dict = { portbindings.VIF_TYPE: portbindings.VIF_TYPE_OVS, portbindings.VIF_DETAILS: { # TODO(rkukura): Replace with new VIF security details portbindings.CAP_PORT_FILTER: 'security-group' in self.supported_extension_aliases}} self._parse_network_vlan_ranges() ovs_db_v2.sync_vlan_allocations(self.network_vlan_ranges) self.tenant_network_type = cfg.CONF.OVS.tenant_network_type if self.tenant_network_type not in [svc_constants.TYPE_LOCAL, svc_constants.TYPE_VLAN, svc_constants.TYPE_GRE, svc_constants.TYPE_VXLAN, svc_constants.TYPE_NONE]: LOG.error(_("Invalid tenant_network_type: %s. " "Server terminated!"), self.tenant_network_type) sys.exit(1) self.enable_tunneling = cfg.CONF.OVS.enable_tunneling self.tunnel_type = None if self.enable_tunneling: self.tunnel_type = (cfg.CONF.OVS.tunnel_type or svc_constants.TYPE_GRE) elif cfg.CONF.OVS.tunnel_type: self.tunnel_type = cfg.CONF.OVS.tunnel_type self.enable_tunneling = True self.tunnel_id_ranges = [] if self.enable_tunneling: self._parse_tunnel_id_ranges() ovs_db_v2.sync_tunnel_allocations(self.tunnel_id_ranges) elif self.tenant_network_type in constants.TUNNEL_NETWORK_TYPES: LOG.error(_("Tunneling disabled but tenant_network_type is '%s'. " "Server terminated!"), self.tenant_network_type) sys.exit(1) 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 )
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)
def __init__(self): """Start Mellanox Neutron Plugin.""" super(MellanoxEswitchPlugin, self).__init__() self._parse_network_vlan_ranges() db.sync_network_states(self.network_vlan_ranges) self._set_tenant_network_type() self.vnic_type = cfg.CONF.ESWITCH.vnic_type self.base_binding_dict = { portbindings.VIF_TYPE: self.vnic_type, portbindings.CAPABILITIES: { portbindings.CAP_PORT_FILTER: 'security-group' in self.supported_extension_aliases}} 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 ) LOG.debug(_("Mellanox Embedded Switch Plugin initialisation complete"))
def get_hosting_device_plugging_driver(self): """Returns plugging driver.""" if self._plugging_driver: return self._plugging_driver else: try: self._plugging_driver = importutils.import_object( cfg.CONF.hosting_devices.csr1kv_plugging_driver) except (ImportError, TypeError, n_exc.NeutronException): LOG.exception(_('Error loading plugging driver')) return self._plugging_driver
def _configure(self): config.setup_logging(cfg.CONF) config.register_root_helper(cfg.CONF) cfg.CONF.set_override('root_helper', self.root_helper, group='AGENT') 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 __init__(self): ndb.initialize() self.ofc = ofc_manager.OFCManager() self.base_binding_dict = self._get_base_binding_dict() portbindings_base.register_port_dict_function() # Set the plugin default extension path # if no api_extensions_path is specified. if not config.CONF.api_extensions_path: config.CONF.set_override('api_extensions_path', 'neutron/plugins/nec/extensions') self.setup_rpc() self.network_scheduler = importutils.import_object( config.CONF.network_scheduler_driver ) self.router_scheduler = importutils.import_object( config.CONF.router_scheduler_driver )
def _initialize_service_helpers(self, host): svc_helper_class = self.conf.routing_svc_helper_class try: self.routing_service_helper = importutils.import_object( svc_helper_class, host, self.conf, self) except ImportError as e: LOG.warn(_("Error in loading routing service helper. Class " "specified is %(class)s. Reason:%(reason)s"), {'class': self.conf.routing_svc_helper_class, 'reason': e}) self.routing_service_helper = None
def __init__(self, quota_driver_class=None): """Initialize a Quota object.""" if not quota_driver_class: quota_driver_class = cfg.CONF.QUOTAS.quota_driver if isinstance(quota_driver_class, basestring): quota_driver_class = importutils.import_object(quota_driver_class) self._resources = {} self._driver = quota_driver_class
def _load_drivers(self): """Loads plugin-driver from configuration. That method will later leverage service type framework """ try: self.driver = importutils.import_object(cfg.CONF.LBAAS.driver_fqn, self) except ImportError: LOG.exception(_("Error loading LBaaS driver %s"), cfg.CONF.LBAAS.driver_fqn)
def __init__(self): super(OneConvergencePluginV2, self).__init__() self.oneconvergence_init() self.base_binding_dict = { portbindings.VIF_TYPE: portbindings.VIF_TYPE_OVS, portbindings.VIF_DETAILS: { portbindings.CAP_PORT_FILTER: 'security-group' in self.supported_extension_aliases}} portbindings_base.register_port_dict_function() 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)
def kill_dhcp(conf, namespace): """Disable DHCP for a network if DHCP is still active.""" root_helper = agent_config.get_root_helper(conf) network_id = namespace.replace(dhcp.NS_PREFIX, '') dhcp_driver = importutils.import_object(conf.dhcp_driver, conf, FakeNetwork(network_id), root_helper) if dhcp_driver.active: dhcp_driver.disable()
def __init__(self, configfile=None): self.base_binding_dict = { portbindings.VIF_TYPE: portbindings.VIF_TYPE_OVS, portbindings.CAPABILITIES: { portbindings.CAP_PORT_FILTER: 'security-group' in self.supported_extension_aliases } } ovs_db_v2.initialize() self._parse_network_vlan_ranges() ovs_db_v2.sync_vlan_allocations(self.network_vlan_ranges) self.tenant_network_type = cfg.CONF.OVS.tenant_network_type if self.tenant_network_type not in [ constants.TYPE_LOCAL, constants.TYPE_VLAN, constants.TYPE_GRE, constants.TYPE_VXLAN, constants.TYPE_NONE ]: LOG.error( _("Invalid tenant_network_type: %s. " "Server terminated!"), self.tenant_network_type) sys.exit(1) self.enable_tunneling = cfg.CONF.OVS.enable_tunneling self.tunnel_type = None if self.enable_tunneling: self.tunnel_type = cfg.CONF.OVS.tunnel_type or constants.TYPE_GRE elif cfg.CONF.OVS.tunnel_type: self.tunnel_type = cfg.CONF.OVS.tunnel_type self.enable_tunneling = True self.tunnel_id_ranges = [] if self.enable_tunneling: self._parse_tunnel_id_ranges() ovs_db_v2.sync_tunnel_allocations(self.tunnel_id_ranges) elif self.tenant_network_type in constants.TUNNEL_NETWORK_TYPES: LOG.error( _("Tunneling disabled but tenant_network_type is '%s'. " "Server terminated!"), self.tenant_network_type) sys.exit(1) 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)
def init_firewall(self, defer_refresh_firewall=False): firewall_driver = cfg.CONF.SECURITYGROUP.firewall_driver LOG.debug(_("Init firewall settings (driver=%s)"), firewall_driver) self.firewall = importutils.import_object(firewall_driver) # The following flag will be set to true if port filter must not be # applied as soon as a rule or membership notification is received self.defer_refresh_firewall = defer_refresh_firewall # Stores devices for which firewall should be refreshed when # deferred refresh is enabled. self.devices_to_refilter = set() # Flag raised when a global refresh is needed self.global_refresh_firewall = False
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
def _setup_rpc_dhcp_metadata(self, notifier=None): self.topic = topics.PLUGIN self.conn = rpc.create_connection(new=True) self.dispatcher = nsx_rpc.NSXRpcCallbacks().create_rpc_dispatcher() self.conn.create_consumer(self.topic, self.dispatcher, fanout=False) self.agent_notifiers[const.AGENT_TYPE_DHCP] = ( notifier or dhcp_rpc_agent_api.DhcpAgentNotifyAPI()) self.conn.consume_in_thread() self.network_scheduler = importutils.import_object( cfg.CONF.network_scheduler_driver) self.supported_extension_aliases.extend( ['agent', 'dhcp_agent_scheduler'])
def __init__(self, conf, plugin): self.conf = conf self.root_helper = config.get_root_helper(conf) self.plugin = plugin if not conf.interface_driver: raise SystemExit(_('You must specify an interface driver')) try: self.driver = importutils.import_object(conf.interface_driver, conf) except Exception: msg = _("Error importing interface driver " "'%s'") % conf.interface_driver raise SystemExit(msg)
def __init__(self, plugin): if not self.device_driver: raise DriverNotSpecified() self.agent_rpc = LoadBalancerAgentApi(topics.LOADBALANCER_AGENT) self.plugin = plugin self._set_callbacks_on_plugin() self.plugin.agent_notifiers.update( {q_const.AGENT_TYPE_LOADBALANCER: self.agent_rpc}) self.pool_scheduler = importutils.import_object( cfg.CONF.loadbalancer_pool_scheduler_driver)
def __init__(self): """Initialize Brocade Plugin. Specify switch address and db configuration. """ self.supported_extension_aliases = [ "binding", "security-group", "router", "extraroute", "agent", "l3_agent_scheduler", "dhcp_agent_scheduler" ] self.physical_interface = ( cfg.CONF.PHYSICAL_INTERFACE.physical_interface) db.configure_db() 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 _load_driver(self, conf): self.lbdriver = None LOG.debug('loading LBaaS driver %s' % conf.f5_bigip_lbaas_device_driver) try: self.lbdriver = importutils.import_object( conf.f5_bigip_lbaas_device_driver, self.conf) return except ImportError as ie: msg = ('Error importing loadbalancer device driver: %s error %s' % (conf.f5_bigip_lbaas_device_driver, repr(ie))) LOG.error(msg) raise SystemExit(msg)
def __init__(self, plugin): self.agent_rpc = LoadBalancerAgentApi(TOPIC_LOADBALANCER_AGENT) self.callbacks = LoadBalancerCallbacks(plugin) self.conn = rpc.create_connection(new=True) self.conn.create_consumer(TOPIC_LOADBALANCER_DEVICE, self.callbacks.create_rpc_dispatcher(), fanout=False) self.conn.consume_in_thread() self.plugin = plugin self.plugin.agent_notifiers.update( {q_const.AGENT_TYPE_LOADBALANCER: self.agent_rpc}) self.pool_scheduler = importutils.import_object( cfg.CONF.loadbalancer_pool_scheduler_driver)
def __init__(self, conf, root_helper, plugin): self.conf = conf self.root_helper = root_helper self.plugin = plugin if not conf.interface_driver: raise SystemExit(_('You must specify an interface driver')) try: self.driver = importutils.import_object( conf.interface_driver, conf) except Exception as e: msg = (_("Error importing interface driver '%(driver)s': " "%(inner)s") % {'driver': conf.interface_driver, 'inner': e}) raise SystemExit(msg)
def setUp(self, core_plugin=None, fw_plugin=None): if not fw_plugin: fw_plugin = DB_FW_PLUGIN_KLASS service_plugins = {'fw_plugin_name': fw_plugin} fdb.Firewall_db_mixin.supported_extension_aliases = ["fwaas"] super(FirewallPluginDbTestCase, self).setUp(service_plugins=service_plugins) self.plugin = importutils.import_object(fw_plugin) ext_mgr = api_ext.PluginAwareExtensionManager( extensions_path, {constants.FIREWALL: self.plugin}) app = config.load_paste_app('extensions_test_app') self.ext_api = api_ext.ExtensionMiddleware(app, ext_mgr=ext_mgr)
def kill_dhcp(conf, namespace): """Disable DHCP for a network if DHCP is still active.""" root_helper = agent_config.get_root_helper(conf) network_id = namespace.replace(dhcp.NS_PREFIX, '') dhcp_driver = importutils.import_object( conf.dhcp_driver, conf=conf, network=dhcp.NetModel(conf.use_namespaces, {'id': network_id}), root_helper=root_helper, plugin=FakeDhcpPlugin()) if dhcp_driver.active: dhcp_driver.disable()
def plumgrid_init(self): """PLUMgrid initialization.""" director_plumgrid = cfg.CONF.plumgriddirector.director_server director_port = cfg.CONF.plumgriddirector.director_server_port director_admin = cfg.CONF.plumgriddirector.username director_password = cfg.CONF.plumgriddirector.password timeout = cfg.CONF.plumgriddirector.servertimeout plum_driver = cfg.CONF.plumgriddirector.driver # PLUMgrid Director info validation LOG.info(_('Neutron PLUMgrid Director: %s'), director_plumgrid) self._plumlib = importutils.import_object(plum_driver) self._plumlib.director_conn(director_plumgrid, director_port, timeout, director_admin, director_password)
def __init__(self, conf, plugin_rpc): self.conf = conf self.root_helper = config.get_root_helper(conf) self.state_path = conf.haproxy.loadbalancer_state_path try: vif_driver = importutils.import_object(conf.interface_driver, conf) except ImportError: with excutils.save_and_reraise_exception(): msg = (_('Error importing interface driver: %s') % conf.interface_driver) LOG.error(msg) self.vif_driver = vif_driver self.plugin_rpc = plugin_rpc self.pool_to_port_id = {}