def __init__(self, configfile=None): options = {"sql_connection": cfg.CONF.DATABASE.sql_connection} options.update({'base': models_v2.model_base.BASEV2}) reconnect_interval = cfg.CONF.DATABASE.reconnect_interval options.update({"reconnect_interval": reconnect_interval}) db.configure_db(options) self.tunnel_key = db_api_v2.TunnelKey(cfg.CONF.OVS.tunnel_key_min, cfg.CONF.OVS.tunnel_key_max) ofp_con_host = cfg.CONF.OVS.openflow_controller ofp_api_host = cfg.CONF.OVS.openflow_rest_api if ofp_con_host is None or ofp_api_host is None: raise q_exc.Invalid(_('invalid configuration. check ryu.ini')) hosts = [(ofp_con_host, ofp_service_type.CONTROLLER), (ofp_api_host, ofp_service_type.REST_API)] db_api_v2.set_ofp_servers(hosts) self.client = client.OFPClient(ofp_api_host) self.tun_client = client.TunnelClient(ofp_api_host) for nw_id in rest_nw_id.RESERVED_NETWORK_IDS: if nw_id != rest_nw_id.NW_ID_UNKNOWN: self.client.update_network(nw_id) self._setup_rpc() # register known all network list on startup self._create_all_tenant_network()
def __init__(self, plugin, collection, resource, attr_info, allow_bulk=False, member_actions=None, parent=None, allow_pagination=False, allow_sorting=False): if member_actions is None: member_actions = [] self._plugin = plugin self._collection = collection.replace('-', '_') self._resource = resource.replace('-', '_') self._attr_info = attr_info self._allow_bulk = allow_bulk self._allow_pagination = allow_pagination self._allow_sorting = allow_sorting self._native_bulk = self._is_native_bulk_supported() self._native_pagination = self._is_native_pagination_supported() self._native_sorting = self._is_native_sorting_supported() self._policy_attrs = [ name for (name, info) in self._attr_info.items() if info.get('required_by_policy') ] self._publisher_id = notifier_api.publisher_id('network') self._dhcp_agent_notifier = dhcp_rpc_agent_api.DhcpAgentNotifyAPI() self._member_actions = member_actions self._primary_key = self._get_primary_key() if self._allow_pagination and self._native_pagination: # Native pagination need native sorting support if not self._native_sorting: raise exceptions.Invalid( _("Native pagination depend on native sorting")) if not self._allow_sorting: LOG.info( _("Allow sorting is enabled because native " "pagination requires native sorting")) self._allow_sorting = True if parent: self._parent_id_name = '%s_id' % parent['member_name'] parent_part = '_%s' % parent['member_name'] else: self._parent_id_name = None parent_part = '' self._plugin_handlers = { self.LIST: 'get%s_%s' % (parent_part, self._collection), self.SHOW: 'get%s_%s' % (parent_part, self._resource) } for action in [self.CREATE, self.UPDATE, self.DELETE]: self._plugin_handlers[action] = '%s%s_%s' % (action, parent_part, self._resource)
def get_logical_device(self, context, pool_id=None, activate=True, **kwargs): with context.session.begin(subtransactions=True): qry = context.session.query(loadbalancer_db.Pool) qry = qry.filter_by(id=pool_id) pool = qry.one() if activate: # set all resources to active if pool.status in ACTIVE_PENDING: pool.status = constants.ACTIVE if pool.vip.status in ACTIVE_PENDING: pool.vip.status = constants.ACTIVE for m in pool.members: if m.status in ACTIVE_PENDING: m.status = constants.ACTIVE for hm in pool.monitors: if hm.healthmonitor.status in ACTIVE_PENDING: hm.healthmonitor.status = constants.ACTIVE if (pool.status != constants.ACTIVE or pool.vip.status != constants.ACTIVE): raise q_exc.Invalid(_('Expected active pool and vip')) retval = {} retval['pool'] = self.plugin._make_pool_dict(pool) retval['vip'] = self.plugin._make_vip_dict(pool.vip) retval['vip']['port'] = (self.plugin._core_plugin._make_port_dict( pool.vip.port)) for fixed_ip in retval['vip']['port']['fixed_ips']: fixed_ip['subnet'] = (self.plugin._core_plugin.get_subnet( context, fixed_ip['subnet_id'])) retval['members'] = [ self.plugin._make_member_dict(m) for m in pool.members if m.status == constants.ACTIVE ] retval['healthmonitors'] = [ self.plugin._make_health_monitor_dict(hm.healthmonitor) for hm in pool.monitors if hm.healthmonitor.status == constants.ACTIVE ] return retval
def __init__(self, config): super(OFPRyuDriver, self).__init__() ofp_con_host = config.get("OVS", "openflow-controller") ofp_api_host = config.get("OVS", "openflow-rest-api") if ofp_con_host is None or ofp_api_host is None: raise q_exc.Invalid("invalid configuration. check ryu.ini") hosts = [(ofp_con_host, ofp_service_type.CONTROLLER), (ofp_api_host, ofp_service_type.REST_API)] db_api.set_ofp_servers(hosts) self.client = client.OFPClient(ofp_api_host) self.client.update_network(rest_nw_id.NW_ID_EXTERNAL) # register known all network list on startup self._create_all_tenant_network()
def __init__(self, configfile=None): db.configure_db() self.tunnel_key = db_api_v2.TunnelKey(cfg.CONF.OVS.tunnel_key_min, cfg.CONF.OVS.tunnel_key_max) self.ofp_api_host = cfg.CONF.OVS.openflow_rest_api if not self.ofp_api_host: raise q_exc.Invalid(_('Invalid configuration. check ryu.ini')) self.client = client.OFPClient(self.ofp_api_host) self.tun_client = client.TunnelClient(self.ofp_api_host) self.iface_client = client.QuantumIfaceClient(self.ofp_api_host) for nw_id in rest_nw_id.RESERVED_NETWORK_IDS: if nw_id != rest_nw_id.NW_ID_UNKNOWN: self.client.update_network(nw_id) self._setup_rpc() # register known all network list on startup self._create_all_tenant_network()
def _setup_integration_br(self, root_helper, integ_br, tunnel_ip, ovsdb_port, ovsdb_ip): self.int_br = OVSBridge(integ_br, root_helper) self.int_br.find_datapath_id() rest_api_addr = self.plugin_rpc.get_ofp_rest_api_addr(self.context) if not rest_api_addr: raise q_exc.Invalid(_("Ryu rest API port isn't specified")) LOG.debug(_("Going to ofp controller mode %s"), rest_api_addr) ryu_rest_client = client.OFPClient(rest_api_addr) self.vif_ports = VifPortSet(self.int_br, ryu_rest_client) self.vif_ports.setup() sc_client = client.SwitchConfClient(rest_api_addr) sc_client.set_key(self.int_br.datapath_id, conf_switch_key.OVS_TUNNEL_ADDR, tunnel_ip) # Currently Ryu supports only tcp methods. (ssl isn't supported yet) self.int_br.set_manager('ptcp:%d' % ovsdb_port) sc_client.set_key(self.int_br.datapath_id, conf_switch_key.OVSDB_ADDR, 'tcp:%s:%d' % (ovsdb_ip, ovsdb_port))
def __init__(self, configfile=None): options = {"sql_connection": cfg.CONF.DATABASE.sql_connection} options.update({'base': models_v2.model_base.BASEV2}) reconnect_interval = cfg.CONF.DATABASE.reconnect_interval options.update({"reconnect_interval": reconnect_interval}) db.configure_db(options) ofp_con_host = cfg.CONF.OVS.openflow_controller ofp_api_host = cfg.CONF.OVS.openflow_rest_api if ofp_con_host is None or ofp_api_host is None: raise q_exc.Invalid("invalid configuration. check ryu.ini") hosts = [(ofp_con_host, ofp_service_type.CONTROLLER), (ofp_api_host, ofp_service_type.REST_API)] db_api_v2.set_ofp_servers(hosts) self.client = client.OFPClient(ofp_api_host) self.client.update_network(rest_nw_id.NW_ID_EXTERNAL) self._setup_rpc() # register known all network list on startup self._create_all_tenant_network()
def __init__(self, configfile=None): LOG.debug(_("Start initializing metaplugin")) self.supported_extension_aliases = \ cfg.CONF.META.supported_extension_aliases.split(',') self.supported_extension_aliases += ['flavor', 'router', 'extraroute'] # Ignore config option overapping def _is_opt_registered(opts, opt): if opt.dest in opts: return True else: return False cfg._is_opt_registered = _is_opt_registered # Keep existing tables if multiple plugin use same table name. db.model_base.QuantumBase.__table_args__ = {'keep_existing': True} self.plugins = {} plugin_list = [plugin_set.split(':') for plugin_set in cfg.CONF.META.plugin_list.split(',')] for flavor, plugin_provider in plugin_list: self.plugins[flavor] = self._load_plugin(plugin_provider) # Needed to clear _ENGINE for each plugin db._ENGINE = None self.l3_plugins = {} l3_plugin_list = [plugin_set.split(':') for plugin_set in cfg.CONF.META.l3_plugin_list.split(',')] for flavor, plugin_provider in l3_plugin_list: if flavor in self.plugins: self.l3_plugins[flavor] = self.plugins[flavor] else: # For l3 only plugin self.l3_plugins[flavor] = self._load_plugin(plugin_provider) db._ENGINE = None self.default_flavor = cfg.CONF.META.default_flavor if self.default_flavor not in self.plugins: raise exc.Invalid(_('default_flavor %s is not plugin list') % self.default_flavor) self.default_l3_flavor = cfg.CONF.META.default_l3_flavor if self.default_l3_flavor not in self.l3_plugins: raise exc.Invalid(_('default_l3_flavor %s is not plugin list') % self.default_l3_flavor) db.configure_db() self.extension_map = {} if not cfg.CONF.META.extension_map == '': extension_list = [method_set.split(':') for method_set in cfg.CONF.META.extension_map.split(',')] for method_name, flavor in extension_list: self.extension_map[method_name] = flavor self.default_flavor = cfg.CONF.META.default_flavor
def __init__(self, configfile=None): LOG.debug("Start initializing metaplugin") options = {"sql_connection": cfg.CONF.DATABASE.sql_connection} options.update({'base': models_v2.model_base.BASEV2}) sql_max_retries = cfg.CONF.DATABASE.sql_max_retries options.update({"sql_max_retries": sql_max_retries}) reconnect_interval = cfg.CONF.DATABASE.reconnect_interval options.update({"reconnect_interval": reconnect_interval}) self.supported_extension_aliases = \ cfg.CONF.META.supported_extension_aliases.split(',') self.supported_extension_aliases += ['flavor', 'os-quantum-router'] # Ignore config option overapping def _is_opt_registered(opts, opt): if opt.dest in opts: return True else: return False cfg._is_opt_registered = _is_opt_registered # Keep existing tables if multiple plugin use same table name. db.model_base.QuantumBase.__table_args__ = {'keep_existing': True} self.plugins = {} plugin_list = [ plugin_set.split(':') for plugin_set in cfg.CONF.META.plugin_list.split(',') ] for flavor, plugin_provider in plugin_list: self.plugins[flavor] = self._load_plugin(plugin_provider) # Needed to clear _ENGINE for each plugin db._ENGINE = None self.l3_plugins = {} l3_plugin_list = [ plugin_set.split(':') for plugin_set in cfg.CONF.META.l3_plugin_list.split(',') ] for flavor, plugin_provider in l3_plugin_list: if flavor in self.plugins: self.l3_plugins[flavor] = self.plugins[flavor] else: # For l3 only plugin self.l3_plugins[flavor] = self._load_plugin(plugin_provider) db._ENGINE = None self.default_flavor = cfg.CONF.META.default_flavor if not self.default_flavor in self.plugins: raise exc.Invalid('default_flavor %s is not plugin list' % self.default_flavor) self.default_l3_flavor = cfg.CONF.META.default_l3_flavor if not self.default_l3_flavor in self.l3_plugins: raise exc.Invalid('default_l3_flavor %s is not plugin list' % self.default_l3_flavor) db.configure_db(options) self.extension_map = {} if not cfg.CONF.META.extension_map == '': extension_list = [ method_set.split(':') for method_set in cfg.CONF.META.extension_map.split(',') ] for method_name, flavor in extension_list: self.extension_map[method_name] = flavor self.default_flavor = cfg.CONF.META.default_flavor