def __init__(self): """ Initialize the segmentation manager, check which device plugins are configured, and load the inventories those device plugins for which the inventory is configured """ cdb.initialize() cred.Store.initialize() for key in conf.PLUGINS[const.PLUGINS].keys(): plugin_obj = conf.PLUGINS[const.PLUGINS][key] self._plugins[key] = importutils.import_object(plugin_obj) LOG.debug(_("Loaded device plugin %s\n"), conf.PLUGINS[const.PLUGINS][key]) if key in conf.PLUGINS[const.INVENTORY].keys(): inventory_obj = conf.PLUGINS[const.INVENTORY][key] self._inventory[key] = importutils.import_object(inventory_obj) LOG.debug(_("Loaded device inventory %s\n"), conf.PLUGINS[const.INVENTORY][key]) if hasattr(self._plugins[const.VSWITCH_PLUGIN], "supported_extension_aliases"): self.supported_extension_aliases.extend( self._plugins[const.VSWITCH_PLUGIN]. supported_extension_aliases) LOG.debug(_("%(module)s.%(name)s init done"), {'module': __name__, 'name': self.__class__.__name__})
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_NONE]: LOG.error(_("Invalid tenant_network_type: %s. " "Agent 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 == constants.TYPE_GRE: LOG.error(_("Tunneling disabled but tenant_network_type is 'gre'. " "Agent terminated!")) 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): """ Initialize the segmentation manager, check which device plugins are configured, and load the inventories those device plugins for which the inventory is configured """ cdb.initialize() cred.Store.initialize() for key in conf.PLUGINS[const.PLUGINS].keys(): plugin_obj = conf.PLUGINS[const.PLUGINS][key] self._plugins[key] = importutils.import_object(plugin_obj) LOG.debug("Loaded device plugin %s\n" % conf.PLUGINS[const.PLUGINS][key]) if key in conf.PLUGINS[const.INVENTORY].keys(): inventory_obj = conf.PLUGINS[const.INVENTORY][key] self._inventory[key] = importutils.import_object(inventory_obj) LOG.debug("Loaded device inventory %s\n" % conf.PLUGINS[const.INVENTORY][key]) if hasattr(self._plugins[const.VSWITCH_PLUGIN], "supported_extension_aliases"): self.supported_extension_aliases.extend( self._plugins[const.VSWITCH_PLUGIN]. supported_extension_aliases) LOG.debug("%s.%s init done" % (__name__, self.__class__.__name__))
def __init__(self): """ Initialize the segmentation manager, check which device plugins are configured, and load the inventories those device plugins for which the inventory is configured """ for key in conf.PLUGINS[const.PLUGINS].keys(): plugin_obj = conf.PLUGINS[const.PLUGINS][key] self._plugins[key] = importutils.import_object(plugin_obj) LOG.debug(_("Loaded device plugin %s\n"), conf.PLUGINS[const.PLUGINS][key]) if key in conf.PLUGINS[const.INVENTORY].keys(): inventory_obj = conf.PLUGINS[const.INVENTORY][key] self._inventory[key] = importutils.import_object(inventory_obj) LOG.debug(_("Loaded device inventory %s\n"), conf.PLUGINS[const.INVENTORY][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 __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_NONE ]: LOG.error( _("Invalid tenant_network_type: %s. " "Agent 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 == constants.TYPE_GRE: LOG.error( _("Tunneling disabled but tenant_network_type is 'gre'. " "Agent terminated!")) 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): """ Initialize the segmentation manager, check which device plugins are configured, and load the inventories those device plugins for which the inventory is configured """ for key in conf.PLUGINS[const.PLUGINS].keys(): plugin_obj = conf.PLUGINS[const.PLUGINS][key] self._plugins[key] = importutils.import_object(plugin_obj) LOG.debug(_("Loaded device plugin %s\n"), conf.PLUGINS[const.PLUGINS][key]) if key in conf.PLUGINS[const.INVENTORY].keys(): inventory_obj = conf.PLUGINS[const.INVENTORY][key] self._inventory[key] = importutils.import_object(inventory_obj) LOG.debug(_("Loaded device inventory %s\n"), conf.PLUGINS[const.INVENTORY][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 __init__(self, configfile=None): 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_NONE]: LOG.error(_("Invalid tenant_network_type: %s. " "Agent 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 == constants.TYPE_GRE: LOG.error(_("Tunneling disabled but tenant_network_type is 'gre'. " "Agent terminated!")) 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): self.extra_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.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, 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): for key in conf.PLUGINS[const.PLUGINS].keys(): plugin_obj = conf.PLUGINS[const.PLUGINS][key] self._plugins[key] = importutils.import_object(plugin_obj) LOG.debug("Loaded device plugin %s\n" % conf.PLUGINS[const.PLUGINS][key]) if key in conf.PLUGINS[const.INVENTORY].keys(): inventory_obj = conf.PLUGINS[const.INVENTORY][key] self._inventory[key] = importutils.import_object(inventory_obj) LOG.debug("Loaded device inventory %s\n" % conf.PLUGINS[const.INVENTORY][key])
def __init__(self): db.initialize() 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 [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): cdb.initialize() cred.Store.initialize() self._model = importutils.import_object(conf.MODEL_CLASS) self._vlan_mgr = importutils.import_object(conf.MANAGER_CLASS) """ Changes for configure_db accordingly will be done later """ sql_connection = "mysql://%s:%s@%s/%s" % (conf.DB_USER, conf.DB_PASS, conf.DB_HOST, conf.DB_NAME) db.configure_db({'sql_connection': sql_connection, 'base': models_v2.model_base.BASEV2}) LOG.debug("L2Network plugin initialization done successfully\n")
def __init__(self, conf, db): self.conf = conf self.db = db if not conf.interface_driver: LOG.error(_('You must specify an interface driver')) self.driver = importutils.import_object(conf.interface_driver, conf)
def mocked_brocade_init(self): self._switch = {'address': FAKE_IPADDRESS, 'username': FAKE_USERNAME, 'password': FAKE_PASSWORD } self._driver = importutils.import_object(NOS_DRIVER)
def _load_drivers(self): self.drivers = {} drivers = cfg.CONF.service_drivers LOG.debug(_('Configured service drivers: "%s"'), drivers) for driver in drivers: try: LOG.debug(_('Loading service driver "%s"'), driver) driver_inst = importutils.import_object(driver) except ImportError: LOG.error(_('Error loading driver "%s"'), driver) raise DriverNotFound(driver_name=driver) service_type = driver_inst.get_service_type() driver_type = driver_inst.get_type() version = driver_inst.get_version() identity = (service_type, driver_type, version) # restrict multiple implementations of the same type and version if identity in self.drivers: raise DuplicateDriver(service_type=service_type, driver_type=driver_type, version=version) self.drivers[identity] = driver_inst LOG.info(_('Service driver "%(driver)s" loaded successfully. ' 'Driver identity is "%(identity)s"'), {'driver': driver, 'identity': ':'.join(identity)})
def new_nexus_init(self): self._client = importutils.import_object(NEXUS_DRIVER) self._nexus_ip = NEXUS_IP_ADDRESS self._nexus_username = NEXUS_USERNAME self._nexus_password = NEXUS_PASSWORD self._nexus_ports = NEXUS_PORTS self._nexus_ssh_port = NEXUS_SSH_PORT
def __init__(self, conf): self.conf = conf self.router_info = {} if not conf.interface_driver: LOG.error(_('You must specify an interface driver')) sys.exit(1) try: self.driver = importutils.import_object(conf.interface_driver, conf) except: LOG.exception( _("Error importing interface driver '%s'" % conf.interface_driver)) sys.exit(1) self.polling_interval = conf.polling_interval if not ip_lib.device_exists(self.conf.external_network_bridge): raise Exception("external network bridge '%s' does not exist" % self.conf.external_network_bridge) self.qclient = client.Client(username=self.conf.admin_user, password=self.conf.admin_password, tenant_name=self.conf.admin_tenant_name, auth_url=self.conf.auth_url, auth_strategy=self.conf.auth_strategy, auth_region=self.conf.auth_region) self._destroy_all_router_namespaces()
def __init__(self, conf, plugin): self.conf = conf self.root_helper = config.get_root_helper(conf) self.plugin = plugin if not conf.interface_driver: LOG.error(_("You must specify an interface driver")) self.driver = importutils.import_object(conf.interface_driver, conf)
def __init__(self, conf): self.conf = conf self.router_info = {} if not conf.interface_driver: LOG.error(_('You must specify an interface driver')) sys.exit(1) try: self.driver = importutils.import_object(conf.interface_driver, conf) except: LOG.exception(_("Error importing interface driver '%s'" % conf.interface_driver)) sys.exit(1) self.polling_interval = conf.polling_interval self.qclient = client.Client( username=self.conf.admin_user, password=self.conf.admin_password, tenant_name=self.conf.admin_tenant_name, auth_url=self.conf.auth_url, auth_strategy=self.conf.auth_strategy, auth_region=self.conf.auth_region ) if self.conf.use_namespaces: self._destroy_all_router_namespaces()
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: 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, conf): self.conf = conf self.router_info = {} if not conf.interface_driver: LOG.error(_('You must specify an interface driver')) sys.exit(1) try: self.driver = importutils.import_object(conf.interface_driver, conf) except: LOG.exception(_("Error importing interface driver '%s'"), conf.interface_driver) sys.exit(1) self.polling_interval = conf.polling_interval self.qclient = client.Client( username=self.conf.admin_user, password=self.conf.admin_password, tenant_name=self.conf.admin_tenant_name, auth_url=self.conf.auth_url, auth_strategy=self.conf.auth_strategy, region_name=self.conf.auth_region ) if self.conf.use_namespaces: self._destroy_all_router_namespaces()
def __init__(self, conf): self.conf = conf self.router_info = {} if not conf.interface_driver: LOG.error(_('You must specify an interface driver')) sys.exit(1) try: self.driver = importutils.import_object(conf.interface_driver, conf) except: LOG.exception(_("Error importing interface driver '%s'" % conf.interface_driver)) sys.exit(1) self.polling_interval = conf.polling_interval if (self.conf.external_network_bridge and not ip_lib.device_exists(self.conf.external_network_bridge)): raise Exception("external network bridge '%s' does not exist" % self.conf.external_network_bridge) self.qclient = client.Client( username=self.conf.admin_user, password=self.conf.admin_password, tenant_name=self.conf.admin_tenant_name, auth_url=self.conf.auth_url, auth_strategy=self.conf.auth_strategy, auth_region=self.conf.auth_region ) self._destroy_all_router_namespaces()
def __init__(self, conf, db, device_owner=""): self.conf = conf self.db = db self.device_owner = device_owner if not conf.interface_driver: LOG.error(_("You must specify an interface driver")) self.driver = importutils.import_object(conf.interface_driver, conf)
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)
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): """ Extracts the configuration parameters from the configuration file """ self._client = importutils.import_object(conf.NEXUS_DRIVER) LOG.debug("Loaded driver %s\n" % conf.NEXUS_DRIVER) self._nexus_switches = conf.NEXUS_DETAILS self.credentials = {}
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): """ Extracts the configuration parameters from the configuration file """ self._client = importutils.import_object(conf.CISCO.nexus_driver) LOG.debug(_("Loaded driver %s"), conf.CISCO.nexus_driver) self._nexus_switches = conf.get_nexus_dictionary() self.credentials = {}
def __init__(self): """ Initialize the segmentation manager, check which device plugins are configured, and load the inventories those device plugins for which the inventory is configured """ self._vlan_mgr = importutils.import_object(conf.MANAGER_CLASS) for key in conf.PLUGINS[const.PLUGINS].keys(): plugin_obj = conf.PLUGINS[const.PLUGINS][key] self._plugins[key] = importutils.import_object(plugin_obj) LOG.debug("Loaded device plugin %s\n" % conf.PLUGINS[const.PLUGINS][key]) if key in conf.PLUGINS[const.INVENTORY].keys(): inventory_obj = conf.PLUGINS[const.INVENTORY][key] self._inventory[key] = importutils.import_object(inventory_obj) LOG.debug("Loaded device inventory %s\n" % conf.PLUGINS[const.INVENTORY][key]) LOG.debug("%s.%s init done" % (__name__, self.__class__.__name__))
def __init__(self): """ Extracts the configuration parameters from the configuration file """ self._client = importutils.import_object(conf.NEXUS_DRIVER) LOG.debug(_("Loaded driver %s"), conf.NEXUS_DRIVER) self._nexus_switches = conf.NEXUS_DETAILS self.credentials = {}
def __init__(self): ndb.initialize() self.ofc = ofc_manager.OFCManager() self.packet_filter_enabled = config.OFC.enable_packet_filter and self.ofc.driver.filter_supported() if self.packet_filter_enabled: self.supported_extension_aliases.append("PacketFilters") # 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", "quantum/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): """ Initializes the DB, and credential store. """ cdb.initialize() cred.Store.initialize() self._model = importutils.import_object(conf.MODEL_CLASS) super(PluginV2, self).__init__() LOG.debug("Plugin initialization complete")
def __init__(self): db.initialize() 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 [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 new_nexus_init(self): self._client = importutils.import_object(NEXUS_DRIVER) self._nexus_ip = NEXUS_IP_ADDRESS self._nexus_username = NEXUS_USERNAME self._nexus_password = NEXUS_PASSWORD self._nexus_ports = NEXUS_PORTS self._nexus_ssh_port = NEXUS_SSH_PORT self.credentials = {self._nexus_ip: {"username": self._nexus_username, "password": self._nexus_password}} db.configure_db()
def _setup_logging_from_conf(): log_root = getLogger(None).logger for handler in log_root.handlers: log_root.removeHandler(handler) if CONF.use_syslog: facility = _find_facility_from_conf() syslog = logging.handlers.SysLogHandler(address='/dev/log', facility=facility) log_root.addHandler(syslog) logpath = _get_log_file_path() if logpath: filelog = logging.handlers.WatchedFileHandler(logpath) log_root.addHandler(filelog) if CONF.use_stderr: streamlog = ColorHandler() log_root.addHandler(streamlog) elif not CONF.log_file: # pass sys.stdout as a positional argument # python2.6 calls the argument strm, in 2.7 it's stream streamlog = logging.StreamHandler(sys.stdout) log_root.addHandler(streamlog) if CONF.publish_errors: handler = importutils.import_object( "quantum.openstack.common.log_handler.PublishErrorsHandler", logging.ERROR) log_root.addHandler(handler) datefmt = CONF.log_date_format for handler in log_root.handlers: # NOTE(alaski): CONF.log_format overrides everything currently. This # should be deprecated in favor of context aware formatting. if CONF.log_format: handler.setFormatter( logging.Formatter(fmt=CONF.log_format, datefmt=datefmt)) log_root.info('Deprecated: log_format is now deprecated and will ' 'be removed in the next release') else: handler.setFormatter(ContextFormatter(datefmt=datefmt)) if CONF.debug: log_root.setLevel(logging.DEBUG) elif CONF.verbose: log_root.setLevel(logging.INFO) else: log_root.setLevel(logging.WARNING) for pair in CONF.default_log_levels: mod, _sep, level_name = pair.partition('=') level = logging.getLevelName(level_name) logger = logging.getLogger(mod) logger.setLevel(level)
def _setup_logging_from_conf(): log_root = getLogger(None).logger for handler in log_root.handlers: log_root.removeHandler(handler) if CONF.use_syslog: facility = _find_facility_from_conf() syslog = logging.handlers.SysLogHandler(address='/dev/log', facility=facility) log_root.addHandler(syslog) logpath = _get_log_file_path() if logpath: filelog = logging.handlers.WatchedFileHandler(logpath) log_root.addHandler(filelog) if CONF.use_stderr: streamlog = ColorHandler() log_root.addHandler(streamlog) elif not CONF.log_file: # pass sys.stdout as a positional argument # python2.6 calls the argument strm, in 2.7 it's stream streamlog = logging.StreamHandler(sys.stdout) log_root.addHandler(streamlog) if CONF.publish_errors: handler = importutils.import_object( "quantum.openstack.common.log_handler.PublishErrorsHandler", logging.ERROR) log_root.addHandler(handler) datefmt = CONF.log_date_format for handler in log_root.handlers: # NOTE(alaski): CONF.log_format overrides everything currently. This # should be deprecated in favor of context aware formatting. if CONF.log_format: handler.setFormatter(logging.Formatter(fmt=CONF.log_format, datefmt=datefmt)) log_root.info('Deprecated: log_format is now deprecated and will ' 'be removed in the next release') else: handler.setFormatter(ContextFormatter(datefmt=datefmt)) if CONF.debug: log_root.setLevel(logging.DEBUG) elif CONF.verbose: log_root.setLevel(logging.INFO) else: log_root.setLevel(logging.WARNING) for pair in CONF.default_log_levels: mod, _sep, level_name = pair.partition('=') level = logging.getLevelName(level_name) logger = logging.getLogger(mod) logger.setLevel(level)
def __init__(self): """ Extracts the configuration parameters from the configuration file """ # Initialize the nxos db nxos_db.initialize() self._client = importutils.import_object(conf.NEXUS_DRIVER) LOG.debug(_("Loaded driver %s"), conf.NEXUS_DRIVER) self._nexus_switches = conf.NEXUS_DETAILS self.credentials = {}
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_agent.NS_PREFIX, "") null_delegate = NullDelegate() dhcp_driver = importutils.import_object(conf.dhcp_driver, conf, FakeNetwork(network_id), root_helper, null_delegate) if dhcp_driver.active: dhcp_driver.disable()
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 kill_dhcp(conf, namespace): """Disable DHCP for a network if DHCP is still active.""" network_id = namespace.replace(dhcp_agent.NS_PREFIX, '') null_delegate = NullDelegate() dhcp_driver = importutils.import_object(conf.dhcp_driver, conf, FakeNetwork(network_id), conf.root_helper, null_delegate) if dhcp_driver.active: dhcp_driver.disable()
def __init__(self): """ Extracts the configuration parameters from the configuration file """ self._client = importutils.import_object(conf.NEXUS_DRIVER) LOG.debug("Loaded driver %s\n" % conf.NEXUS_DRIVER) self._nexus_ip = conf.NEXUS_IP_ADDRESS self._nexus_username = cred.Store.get_username(conf.NEXUS_IP_ADDRESS) self._nexus_password = cred.Store.get_password(conf.NEXUS_IP_ADDRESS) self._nexus_ports = conf.NEXUS_PORTS self._nexus_ssh_port = conf.NEXUS_SSH_PORT
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, 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 _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 __init__(self): ndb.initialize() self.ofc = ofc_manager.OFCManager() self.packet_filter_enabled = (config.OFC.enable_packet_filter and self.ofc.driver.filter_supported()) if self.packet_filter_enabled: self.supported_extension_aliases.append("PacketFilters") # 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', 'quantum/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): """ Initialize the segmentation manager, check which device plugins are configured, and load the inventories those device plugins for which the inventory is configured """ cdb.initialize() cred.Store.initialize() self._vlan_mgr = importutils.import_object(conf.MANAGER_CLASS) for key in conf.PLUGINS[const.PLUGINS].keys(): plugin_obj = conf.PLUGINS[const.PLUGINS][key] self._plugins[key] = importutils.import_object(plugin_obj) LOG.debug("Loaded device plugin %s\n" % conf.PLUGINS[const.PLUGINS][key]) if key in conf.PLUGINS[const.INVENTORY].keys(): inventory_obj = conf.PLUGINS[const.INVENTORY][key] self._inventory[key] = importutils.import_object(inventory_obj) LOG.debug("Loaded device inventory %s\n" % conf.PLUGINS[const.INVENTORY][key]) LOG.debug("%s.%s init done" % (__name__, self.__class__.__name__))
def __init__(self): """Initialize Brocade Plugin. Specify switch address and db configuration. """ self.supported_extension_aliases = ["binding", "security-group", "agent", "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 initialize_app(self, argv): super(QuantumDebugShell, self).initialize_app(argv) if not self.options.config_file: raise exc.CommandError( "You must provide a config file for bridge -" " either --config-file or env[QUANTUM_TEST_CONFIG_FILE]") client = self.client_manager.quantum cfg.CONF.register_opts(interface.OPTS) cfg.CONF.register_opts(QuantumDebugAgent.OPTS) cfg.CONF(['--config-file', self.options.config_file]) config.setup_logging(cfg.CONF) driver = importutils.import_object(cfg.CONF.interface_driver, cfg.CONF) self.debug_agent = QuantumDebugAgent(cfg.CONF, client, driver)
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 verify_plugin(self, plugin_key): """ Verifies the PlugIn available """ _plugins = {} for key in conf.PLUGINS[const.PLUGINS].keys(): plugin_obj = conf.PLUGINS[const.PLUGINS][key] _plugins[key] = importutils.import_object(plugin_obj) if not plugin_key in _plugins.keys(): LOG.debug("No %s Plugin loaded" % plugin_key) return False else: LOG.debug("Plugin %s founded" % const.UCS_PLUGIN) return True
def __init__(self): fake_ucs_driver = "quantum.plugins.cisco.tests.unit.v2.ucs." + \ "fake_ucs_driver.CiscoUCSMFakeDriver" self._client = importutils.import_object(fake_ucs_driver) conf_parser = confp.CiscoConfigParser(curdir("fake_ucs_inventory.ini")) conf.INVENTORY = conf_parser.walk(conf_parser.dummy) for ucsm in conf.INVENTORY.keys(): ucsm_ip = conf.INVENTORY[ucsm][const.IP_ADDRESS] try: cred.Store.put_credential(ucsm_ip, "username", "password") except: pass self._load_inventory()
def new_nexus_init(self): self._client = importutils.import_object(NEXUS_DRIVER) self._nexus_ip = NEXUS_IP_ADDRESS self._nexus_username = NEXUS_USERNAME self._nexus_password = NEXUS_PASSWORD self._nexus_ports = NEXUS_PORTS self._nexus_ssh_port = NEXUS_SSH_PORT self.credentials = { self._nexus_ip: { 'username': self._nexus_username, 'password': self._nexus_password } } db.configure_db()