desc stringlengths 3 26.7k | decl stringlengths 11 7.89k | bodies stringlengths 8 553k |
|---|---|---|
'Disable DHCP for a network known to the agent.'
| def disable_dhcp_helper(self, network_id):
| network = self.cache.get_network_by_id(network_id)
if network:
if self.conf.use_namespaces:
self.disable_isolated_metadata_proxy(network)
if self.call_driver('disable', network):
self.cache.remove(network)
|
'Refresh or disable DHCP for a network depending on the current state
of the network.'
| def refresh_dhcp_helper(self, network_id):
| old_network = self.cache.get_network_by_id(network_id)
if (not old_network):
return self.enable_dhcp_helper(network_id)
try:
network = self.plugin_rpc.get_network_info(network_id)
except:
self.needs_resync = True
LOG.exception(_('Network %s RPC info call fa... |
'Handle the network.create.end notification event.'
| @lockutils.synchronized('agent', 'dhcp-')
def network_create_end(self, context, payload):
| network_id = payload['network']['id']
self.enable_dhcp_helper(network_id)
|
'Handle the network.update.end notification event.'
| @lockutils.synchronized('agent', 'dhcp-')
def network_update_end(self, context, payload):
| network_id = payload['network']['id']
if payload['network']['admin_state_up']:
self.enable_dhcp_helper(network_id)
else:
self.disable_dhcp_helper(network_id)
|
'Handle the network.delete.end notification event.'
| @lockutils.synchronized('agent', 'dhcp-')
def network_delete_end(self, context, payload):
| self.disable_dhcp_helper(payload['network_id'])
|
'Handle the subnet.update.end notification event.'
| @lockutils.synchronized('agent', 'dhcp-')
def subnet_update_end(self, context, payload):
| network_id = payload['subnet']['network_id']
self.refresh_dhcp_helper(network_id)
|
'Handle the subnet.delete.end notification event.'
| @lockutils.synchronized('agent', 'dhcp-')
def subnet_delete_end(self, context, payload):
| subnet_id = payload['subnet_id']
network = self.cache.get_network_by_subnet_id(subnet_id)
if network:
self.refresh_dhcp_helper(network.id)
|
'Handle the port.update.end notification event.'
| @lockutils.synchronized('agent', 'dhcp-')
def port_update_end(self, context, payload):
| port = DictModel(payload['port'])
network = self.cache.get_network_by_id(port.network_id)
if network:
self.cache.put_port(port)
self.call_driver('reload_allocations', network)
|
'Handle the port.delete.end notification event.'
| @lockutils.synchronized('agent', 'dhcp-')
def port_delete_end(self, context, payload):
| port = self.cache.get_port_by_id(payload['port_id'])
if port:
network = self.cache.get_network_by_id(port.network_id)
self.cache.remove_port(port)
self.call_driver('reload_allocations', network)
|
'Make a remote process call to retrieve the active networks.'
| def get_active_networks(self):
| return self.call(self.context, self.make_msg('get_active_networks', host=self.host), topic=self.topic)
|
'Make a remote process call to retrieve network info.'
| def get_network_info(self, network_id):
| return DictModel(self.call(self.context, self.make_msg('get_network_info', network_id=network_id, host=self.host), topic=self.topic))
|
'Make a remote process call to create the dhcp port.'
| def get_dhcp_port(self, network_id, device_id):
| return DictModel(self.call(self.context, self.make_msg('get_dhcp_port', network_id=network_id, device_id=device_id, host=self.host), topic=self.topic))
|
'Make a remote process call to release the dhcp port.'
| def release_dhcp_port(self, network_id, device_id):
| return self.call(self.context, self.make_msg('release_dhcp_port', network_id=network_id, device_id=device_id, host=self.host), topic=self.topic)
|
'Make a remote process call to release a fixed_ip on the port.'
| def release_port_fixed_ip(self, network_id, device_id, subnet_id):
| return self.call(self.context, self.make_msg('release_port_fixed_ip', network_id=network_id, subnet_id=subnet_id, device_id=device_id, host=self.host), topic=self.topic)
|
'Make a remote process call to update the ip lease expiration.'
| def update_lease_expiration(self, network_id, ip_address, lease_remaining):
| self.cast(self.context, self.make_msg('update_lease_expiration', network_id=network_id, ip_address=ip_address, lease_remaining=lease_remaining, host=self.host), topic=self.topic)
|
'Return interface(device) name for use by the DHCP process.'
| def get_interface_name(self, network, port=None):
| if (not port):
device_id = self.get_device_id(network)
port = self.plugin.get_dhcp_port(network.id, device_id)
return self.driver.get_device_name(port)
|
'Return a unique DHCP device ID for this host on the network.'
| def get_device_id(self, network):
| host_uuid = uuid.uuid5(uuid.NAMESPACE_DNS, socket.gethostname())
return ('dhcp%s-%s' % (host_uuid, network.id))
|
'Create and initialize a device for network\'s DHCP on this host.'
| def setup(self, network, reuse_existing=False):
| device_id = self.get_device_id(network)
port = self.plugin.get_dhcp_port(network.id, device_id)
interface_name = self.get_interface_name(network, port)
if self.conf.use_namespaces:
namespace = (NS_PREFIX + network.id)
else:
namespace = None
if ip_lib.device_exists(interface_name,... |
'Destroy the device used for the network\'s DHCP on this host.'
| def destroy(self, network, device_name):
| if self.conf.use_namespaces:
namespace = (NS_PREFIX + network.id)
else:
namespace = None
self.driver.unplug(device_name, namespace=namespace)
self.plugin.release_dhcp_port(network.id, self.get_device_id(network))
|
'Handle incoming lease relay stream connection.
This method will only read the first 1024 bytes and then close the
connection. The limit exists to limit the impact of misbehaving
clients.'
| def _handler(self, client_sock, client_addr):
| try:
msg = client_sock.recv(1024)
data = jsonutils.loads(msg)
client_sock.close()
network_id = data['network_id']
if (not uuidutils.is_uuid_like(network_id)):
raise ValueError((_('Network ID %s is not a valid UUID') % network_id))
ip_a... |
'Spawn a green thread to run the lease relay unix socket server.'
| def start(self):
| listener = eventlet.listen(cfg.CONF.dhcp_lease_relay_socket, family=socket.AF_UNIX)
eventlet.spawn(eventlet.serve, listener, self._handler)
|
'Handle the agent_updated notification event.'
| def agent_updated(self, context, payload):
| self.needs_resync = True
LOG.info(_('agent_updated by server side %s!'), payload)
|
'Daemonize process by doing Stevens double fork.'
| def daemonize(self):
| self._fork()
os.chdir('/')
os.setsid()
os.umask(0)
self._fork()
sys.stdout.flush()
sys.stderr.flush()
stdin = open(self.stdin, 'r')
stdout = open(self.stdout, 'a+')
stderr = open(self.stderr, 'a+', 0)
os.dup2(stdin.fileno(), sys.stdin.fileno())
os.dup2(stdout.fileno(), sy... |
'Start the daemon'
| def start(self):
| if self.pidfile.is_running():
self.pidfile.unlock()
message = _('Pidfile %s already exist. Daemon already running?')
LOG.error(message, self.pidfile)
sys.exit(1)
self.daemonize()
self.run()
|
'Override this method when subclassing Daemon.
start() will call this method after the process has daemonized.'
| def run(self):
| pass
|
'Set the L3 settings for the interface using data from the port.
ip_cidrs: list of \'X.X.X.X/YY\' strings'
| def init_l3(self, device_name, ip_cidrs, namespace=None):
| device = ip_lib.IPDevice(device_name, self.root_helper, namespace=namespace)
previous = {}
for address in device.addr.list(scope='global', filters=['permanent']):
previous[address['cidr']] = address['ip_version']
for ip_cidr in ip_cidrs:
net = netaddr.IPNetwork(ip_cidr)
if (ip_ci... |
'Plug in the interface.'
| def plug(self, network_id, port_id, device_name, mac_address, bridge=None, namespace=None, prefix=None):
| if (not bridge):
bridge = self.conf.ovs_integration_bridge
self.check_bridge_exists(bridge)
if (not ip_lib.device_exists(device_name, self.root_helper, namespace=namespace)):
ip = ip_lib.IPWrapper(self.root_helper)
tap_name = self._get_tap_name(device_name, prefix)
if self.co... |
'Unplug the interface.'
| def unplug(self, device_name, bridge=None, namespace=None, prefix=None):
| if (not bridge):
bridge = self.conf.ovs_integration_bridge
tap_name = self._get_tap_name(device_name, prefix)
self.check_bridge_exists(bridge)
ovs = ovs_lib.OVSBridge(bridge, self.root_helper)
try:
ovs.delete_port(tap_name)
if self.conf.ovs_use_veth:
device = ip_l... |
'Plugin the interface.'
| def plug(self, network_id, port_id, device_name, mac_address, bridge=None, namespace=None, prefix=None):
| if (not ip_lib.device_exists(device_name, self.root_helper, namespace=namespace)):
ip = ip_lib.IPWrapper(self.root_helper)
if prefix:
tap_name = device_name.replace(prefix, 'tap')
else:
tap_name = device_name.replace(self.DEV_NAME_PREFIX, 'tap')
(root_veth, ns... |
'Unplug the interface.'
| def unplug(self, device_name, bridge=None, namespace=None, prefix=None):
| device = ip_lib.IPDevice(device_name, self.root_helper, namespace)
try:
device.link.delete()
LOG.debug(_("Unplugged interface '%s'"), device_name)
except RuntimeError:
LOG.error(_("Failed unplugging interface '%s'"), device_name)
|
'Returns the file name for a given kind of config file.'
| def get_pid_file_name(self, ensure_pids_dir=False):
| pids_dir = os.path.abspath(os.path.normpath(self.conf.external_pids))
if (ensure_pids_dir and (not os.path.isdir(pids_dir))):
os.makedirs(pids_dir, 493)
return os.path.join(pids_dir, (self.uuid + '.pid'))
|
'Last known pid for this external process spawned for this uuid.'
| @property
def pid(self):
| file_name = self.get_pid_file_name()
msg = _('Error while reading %s')
try:
with open(file_name, 'r') as f:
return int(f.read())
except IOError as e:
msg = _('Unable to access %s')
except ValueError as e:
msg = _('Unable to convert value... |
'Conditionally destroy the namespace if it is empty.'
| def garbage_collect_namespace(self):
| if (self.namespace and self.netns.exists(self.namespace)):
if self.namespace_is_empty():
self.netns.delete(self.namespace)
return True
return False
|
'Ensures that the route entry for the interface is before all
others on the same subnet.'
| def pullup_route(self, interface_name):
| device_list = []
device_route_list_lines = self._run('list', 'proto', 'kernel', 'dev', interface_name).split('\n')
for device_route_line in device_route_list_lines:
try:
subnet = device_route_line.split()[0]
except:
continue
subnet_route_list_lines = self._run... |
'Restart the dhcp service for the network.'
| def restart(self):
| self.disable(retain_port=True)
self.enable()
|
'Return a list of existing networks ids (ones we have configs for)'
| @classmethod
def existing_dhcp_networks(cls, conf, root_helper):
| raise NotImplementedError
|
'check if there is a subnet within the network with dhcp enabled.'
| def _enable_dhcp(self):
| for subnet in self.network.subnets:
if subnet.enable_dhcp:
return True
return False
|
'Enables DHCP for this network by spawning a local process.'
| def enable(self):
| interface_name = self.device_delegate.setup(self.network, reuse_existing=True)
if self.active:
self.restart()
elif self._enable_dhcp():
self.interface_name = interface_name
self.spawn_process()
|
'Disable DHCP for this network by killing the local process.'
| def disable(self, retain_port=False):
| pid = self.pid
if self.active:
cmd = ['kill', '-9', pid]
if self.namespace:
ip_wrapper = ip_lib.IPWrapper(self.root_helper, self.namespace)
ip_wrapper.netns.execute(cmd)
else:
utils.execute(cmd, self.root_helper)
if (not retain_port):
... |
'Returns the file name for a given kind of config file.'
| def get_conf_file_name(self, kind, ensure_conf_dir=False):
| confs_dir = os.path.abspath(os.path.normpath(self.conf.dhcp_confs))
conf_dir = os.path.join(confs_dir, self.network.id)
if ensure_conf_dir:
if (not os.path.isdir(conf_dir)):
os.makedirs(conf_dir, 493)
return os.path.join(conf_dir, kind)
|
'A helper function to read a value from one of the state files.'
| def _get_value_from_conf_file(self, kind, converter=None):
| file_name = self.get_conf_file_name(kind)
msg = _('Error while reading %s')
try:
with open(file_name, 'r') as f:
try:
return ((converter and converter(f.read())) or f.read())
except ValueError as e:
msg = _('Unable to convert ... |
'Last known pid for the DHCP process spawned for this network.'
| @property
def pid(self):
| return self._get_value_from_conf_file('pid', int)
|
'Return a list of existing networks ids (ones we have configs for)'
| @classmethod
def existing_dhcp_networks(cls, conf, root_helper):
| confs_dir = os.path.abspath(os.path.normpath(conf.dhcp_confs))
class FakeNetwork:
def __init__(self, net_id):
self.id = net_id
return [c for c in os.listdir(confs_dir) if (uuidutils.is_uuid_like(c) and cls(conf, FakeNetwork(c), root_helper).active)]
|
'Spawns a Dnsmasq process for the network.'
| def spawn_process(self):
| env = {self.QUANTUM_NETWORK_ID_KEY: self.network.id, self.QUANTUM_RELAY_SOCKET_PATH_KEY: self.conf.dhcp_lease_relay_socket}
cmd = ['dnsmasq', '--no-hosts', '--no-resolv', '--strict-order', '--bind-interfaces', ('--interface=%s' % self.interface_name), '--except-interface=lo', ('--pid-file=%s' % self.get_conf_fi... |
'Rebuild the dnsmasq config and signal the dnsmasq to reload.'
| def reload_allocations(self):
| if (not self._enable_dhcp()):
self.disable()
LOG.debug(_('Killing dhcpmasq for network since all subnets have turned off DHCP: %s'), self.network.id)
return
self._output_hosts_file()
self._output_opts_file()
cmd = ['kill', '-HUP', self.pid]
if... |
'Writes a dnsmasq compatible hosts file.'
| def _output_hosts_file(self):
| r = re.compile('[:.]')
buf = StringIO.StringIO()
for port in self.network.ports:
for alloc in port.fixed_ips:
name = ('%s.%s' % (r.sub('-', alloc.ip_address), self.conf.dhcp_domain))
buf.write(('%s,%s,%s\n' % (port.mac_address, name, alloc.ip_address)))
name = self.get_co... |
'Write a dnsmasq compatible options file.'
| def _output_opts_file(self):
| if self.conf.enable_isolated_metadata:
subnet_to_interface_ip = self._make_subnet_interface_ip_map()
options = []
for (i, subnet) in enumerate(self.network.subnets):
if (not subnet.enable_dhcp):
continue
if subnet.dns_nameservers:
options.append(self._format_o... |
'Setup ingress and egress chain for a port.'
| def _setup_chains(self):
| self._add_chain_by_name_v4v6(SG_CHAIN)
for port in self.filtered_ports.values():
self._setup_chain(port, INGRESS_DIRECTION)
self._setup_chain(port, EGRESS_DIRECTION)
self.iptables.ipv4['filter'].add_rule(SG_CHAIN, '-j ACCEPT')
self.iptables.ipv6['filter'].add_rule(SG_CHAIN, '-... |
'Remove ingress and egress chain for a port'
| def _remove_chains(self):
| for port in self.filtered_ports.values():
self._remove_chain(port, INGRESS_DIRECTION)
self._remove_chain(port, EGRESS_DIRECTION)
self._remove_chain_by_name_v4v6(SG_CHAIN)
|
'Adds a named chain to the table.
The chain name is wrapped to be unique for the component creating
it, so different components of Nova can safely create identically
named chains without interfering with one another.
At the moment, its wrapped name is <binary name>-<chain name>,
so if nova-compute creates a chain named... | def add_chain(self, name, wrap=True):
| name = get_chain_name(name, wrap)
if wrap:
self.chains.add(name)
else:
self.unwrapped_chains.add(name)
|
'Ensure the chain is removed.
This removal "cascades". All rule in the chain are removed, as are
all rules in other chains that jump to it.'
| def ensure_remove_chain(self, name, wrap=True):
| name = get_chain_name(name, wrap)
chain_set = self._select_chain_set(wrap)
if (name not in chain_set):
return
self.remove_chain(name, wrap)
|
'Remove named chain.
This removal "cascades". All rule in the chain are removed, as are
all rules in other chains that jump to it.
If the chain is not found, this is merely logged.'
| def remove_chain(self, name, wrap=True):
| name = get_chain_name(name, wrap)
chain_set = self._select_chain_set(wrap)
if (name not in chain_set):
LOG.warn(_('Attempted to remove chain %s which does not exist'), name)
return
chain_set.remove(name)
self.rules = filter((lambda r: (r.chain != name)), self.... |
'Add a rule to the table.
This is just like what you\'d feed to iptables, just without
the \'-A <chain name>\' bit at the start.
However, if you need to jump to one of your wrapped chains,
prepend its name with a \'$\' which will ensure the wrapping
is applied correctly.'
| def add_rule(self, chain, rule, wrap=True, top=False):
| chain = get_chain_name(chain, wrap)
if (wrap and (chain not in self.chains)):
raise LookupError((_('Unknown chain: %r') % chain))
if ('$' in rule):
rule = ' '.join(map(self._wrap_target_chain, rule.split(' ')))
self.rules.append(IptablesRule(chain, rule, wrap, top))
|
'Remove a rule from a chain.
Note: The rule must be exactly identical to the one that was added.
You cannot switch arguments around like you can with the iptables
CLI tool.'
| def remove_rule(self, chain, rule, wrap=True, top=False):
| chain = get_chain_name(chain, wrap)
try:
self.rules.remove(IptablesRule(chain, rule, wrap, top))
except ValueError:
LOG.warn(_('Tried to remove rule that was not there: %(chain)r %(rule)r %(wrap)r %(top)r'), {'chain': chain, 'rule': rule, 'top': top, 'wrap': ... |
'Remove all rules from a chain.'
| def empty_chain(self, chain, wrap=True):
| chain = get_chain_name(chain, wrap)
chained_rules = [rule for rule in self.rules if ((rule.chain == chain) and (rule.wrap == wrap))]
for rule in chained_rules:
self.rules.remove(rule)
|
'Apply the current in-memory set of iptables rules.
This will blow away any rules left over from previous runs of the
same component of Nova, and replace them with our current set of
rules. This happens atomically, thanks to iptables-restore.'
| @lockutils.synchronized('iptables', 'quantum-', external=True)
def _apply(self):
| s = [('iptables', self.ipv4)]
if self.use_ipv6:
s += [('ip6tables', self.ipv6)]
for (cmd, tables) in s:
for table in tables:
args = [('%s-save' % cmd), '-t', table]
if self.namespace:
args = (['ip', 'netns', 'exec', self.namespace] + args)
... |
'Make a remote process call to retrieve the sync data for routers.'
| def get_routers(self, context, fullsync=True, router_id=None):
| router_ids = ([router_id] if router_id else None)
return self.call(context, self.make_msg('sync_routers', host=self.host, fullsync=fullsync, router_ids=router_ids), topic=self.topic)
|
'Make a remote process call to retrieve the external network id.
@raise common.RemoteError: with TooManyExternalNetworks
as exc_type if there are
more than one external network'
| def get_external_network_id(self, context):
| return self.call(context, self.make_msg('get_external_network_id', host=self.host), topic=self.topic)
|
'Destroy router namespaces on the host to eliminate all stale
linux devices, iptables rules, and namespaces.
If only_router_id is passed, only destroy single namespace, to allow
for multiple l3 agents on the same host, without stepping on each
other\'s toes on init. This only makes sense if router_id is set.'
| def _destroy_router_namespaces(self, only_router_id=None):
| root_ip = ip_lib.IPWrapper(self.root_helper)
for ns in root_ip.get_namespaces(self.root_helper):
if ns.startswith(NS_PREFIX):
if (only_router_id and (not ns.endswith(only_router_id))):
continue
try:
self._destroy_router_namespace(ns)
ex... |
'Find UUID of single external network for this agent'
| def _fetch_external_net_id(self):
| if self.conf.gateway_external_network_id:
return self.conf.gateway_external_network_id
try:
return self.plugin_rpc.get_external_network_id(self.context)
except rpc_common.RemoteError as e:
if (e.exc_type == 'TooManyExternalNetworks'):
msg = _("The 'gateway_external_net... |
'Deal with router deletion RPC message.'
| def router_deleted(self, context, router_id):
| with self.sync_sem:
if (router_id in self.router_info):
try:
self._router_removed(router_id)
except Exception:
msg = _("Failed dealing with router '%s' deletion RPC message")
LOG.debug(msg, router_id)
... |
'Deal with routers modification and creation RPC message.'
| def routers_updated(self, context, routers):
| if (not routers):
return
with self.sync_sem:
try:
self._process_routers(routers)
except Exception:
msg = _('Failed dealing with routers update RPC message')
LOG.debug(msg)
self.fullsync = True
|
'Handle the agent_updated notification event.'
| def agent_updated(self, context, payload):
| self.fullsync = True
LOG.info(_('agent_updated by server side %s!'), payload)
|
'Prepare filters for the port.
This method should be called before the port is created.'
| def prepare_port_filter(self, port):
| raise NotImplementedError()
|
'Apply port filter.
Once this method returns, the port should be firewalled
appropriately. This method should as far as possible be a
no-op. It\'s vastly preferred to get everything set up in
prepare_port_filter.'
| def apply_port_filter(self, port):
| raise NotImplementedError()
|
'Refresh security group rules from data store
Gets called when an port gets added to or removed from
the security group the port is a member of or if the
group gains or looses a rule.'
| def update_port_filter(self, port):
| raise NotImplementedError()
|
'Stop filtering port'
| def remove_port_filter(self, port):
| raise NotImplementedError()
|
'Defer application of filtering rule'
| def filter_defer_apply_on(self):
| pass
|
'Turn off deferral of rules and apply the rules now'
| def filter_defer_apply_off(self):
| pass
|
'returns filterd ports'
| @property
def ports(self):
| pass
|
'defer apply context'
| @contextlib.contextmanager
def defer_apply(self):
| self.filter_defer_apply_on()
try:
(yield)
finally:
self.filter_defer_apply_off()
|
'callback for security group rule update
:param security_groups: list of updated security_groups'
| def security_groups_rule_updated(self, context, **kwargs):
| security_groups = kwargs.get('security_groups', [])
LOG.debug(_('Security group rule updated on remote: %s'), security_groups)
self.sg_agent.security_groups_rule_updated(security_groups)
|
'callback for security group member update
:param security_groups: list of updated security_groups'
| def security_groups_member_updated(self, context, **kwargs):
| security_groups = kwargs.get('security_groups', [])
LOG.debug(_('Security group member updated on remote: %s'), security_groups)
self.sg_agent.security_groups_member_updated(security_groups)
|
'callback for security group provider update'
| def security_groups_provider_updated(self, context, **kwargs):
| LOG.debug(_('Provider rule updated'))
self.sg_agent.security_groups_provider_updated()
|
'notify rule updated security groups'
| def security_groups_rule_updated(self, context, security_groups):
| if (not security_groups):
return
self.fanout_cast(context, self.make_msg('security_groups_rule_updated', security_groups=security_groups), version=SG_RPC_VERSION, topic=self._get_security_group_topic())
|
'notify member updated security groups'
| def security_groups_member_updated(self, context, security_groups):
| if (not security_groups):
return
self.fanout_cast(context, self.make_msg('security_groups_member_updated', security_groups=security_groups), version=SG_RPC_VERSION, topic=self._get_security_group_topic())
|
'notify provider updated security groups'
| def security_groups_provider_updated(self, context):
| self.fanout_cast(context, self.make_msg('security_groups_provider_updated'), version=SG_RPC_VERSION, topic=self._get_security_group_topic())
|
'Retrieve the tenant info in context.'
| def tenant(self, request):
| context = request.context
if (not context.tenant_id):
raise q_exc.QuotaMissingTenant()
return {'tenant': {'tenant_id': context.tenant_id}}
|
'Returns Ext Resources'
| @classmethod
def get_resources(cls):
| controller = resource.Resource(QuotaSetsController(QuantumManager.get_plugin()), faults=base.FAULT_MAP)
return [extensions.ResourceExtension(Quotasv2.get_alias(), controller, collection_actions={'tenant': 'GET'})]
|
'Returns Ext Resources'
| @classmethod
def get_resources(cls):
| my_plurals = [(key, key[:(-1)]) for key in RESOURCE_ATTRIBUTE_MAP.keys()]
attr.PLURALS.update(dict(my_plurals))
exts = []
plugin = manager.QuantumManager.get_plugin()
for resource_name in ['router', 'floatingip']:
collection_name = (resource_name + 's')
params = RESOURCE_ATTRIBUTE_MA... |
'Returns Ext Resources'
| @classmethod
def get_resources(cls):
| my_plurals = [(key, key[:(-1)]) for key in RESOURCE_ATTRIBUTE_MAP.keys()]
attr.PLURALS.update(dict(my_plurals))
plugin = manager.QuantumManager.get_plugin()
params = RESOURCE_ATTRIBUTE_MAP.get((RESOURCE_NAME + 's'))
controller = base.create_resource((RESOURCE_NAME + 's'), RESOURCE_NAME, plugin, para... |
'Create agent.
This operation is not allow in REST API.
@raise exceptions.BadRequest:'
| def create_agent(self, context, agent):
| raise exceptions.BadRequest
|
'Delete agent.
Agents register themselves on reporting state.
But if a agent does not report its status
for a long time (for example, it is dead for ever. ),
admin can remove it. Agents must be disabled before
being removed.'
| @abstractmethod
def delete_agent(self, context, id):
| pass
|
'Disable or Enable the agent.
Discription also can be updated.
Some agents cannot be disabled,
such as plugins, services.
An error code should be reported in this case.
@raise exceptions.BadRequest:'
| @abstractmethod
def update_agent(self, context, agent):
| pass
|
'Returns Extended Resource for service type management'
| @classmethod
def get_resources(cls):
| my_plurals = [(key.replace('-', '_'), key[:(-1)].replace('-', '_')) for key in RESOURCE_ATTRIBUTE_MAP.keys()]
my_plurals.append(('service_definitions', 'service_definition'))
attributes.PLURALS.update(dict(my_plurals))
attr_map = RESOURCE_ATTRIBUTE_MAP[COLLECTION_NAME]
controller = base.create_resou... |
'Returns Ext Resources'
| @classmethod
def get_resources(cls):
| exts = []
parent = dict(member_name='agent', collection_name='agents')
controller = resource.Resource(NetworkSchedulerController(), base.FAULT_MAP)
exts.append(extensions.ResourceExtension(DHCP_NETS, controller, parent))
controller = resource.Resource(RouterSchedulerController(), base.FAULT_MAP)
... |
'Returns Ext Resources'
| @classmethod
def get_resources(cls):
| my_plurals = [(key, key[:(-1)]) for key in RESOURCE_ATTRIBUTE_MAP.keys()]
attr.PLURALS.update(dict(my_plurals))
exts = []
plugin = manager.QuantumManager.get_plugin()
for resource_name in ['security_group', 'security_group_rule']:
collection_name = (resource_name.replace('_', '-') + 's')
... |
'Create a new chain for security group.
Creating a security group creates a pair of chains in MidoNet, one for
inbound and the other for outbound.'
| def create_for_sg(self, tenant_id, sg_id, sg_name):
| LOG.debug(_('ChainManager.create_for_sg called: tenant_id=%(tenant_id)s sg_id=%(sg_id)s sg_name=%(sg_name)s '), {'tenant_id': tenant_id, 'sg_id': sg_id, 'sg_name': sg_name})
cnames = chain_names(sg_id, sg_name)
self.mido_api.add_chain().tenant_id(tenant_id).name(cnames['in']).create()
sel... |
'Delete a chain mapped to a security group.
Delete a SG means deleting all the chains (inbound and outbound)
associated with the SG in MidoNet.'
| def delete_for_sg(self, tenant_id, sg_id, sg_name):
| LOG.debug(_('ChainManager.delete_for_sg called: tenant_id=%(tenant_id)s sg_id=%(sg_id)s sg_name=%(sg_name)s '), {'tenant_id': tenant_id, 'sg_id': sg_id, 'sg_name': sg_name})
cnames = chain_names(sg_id, sg_name)
chains = self.mido_api.get_chains({'tenant_id': tenant_id})
for c in chains:
... |
'Get router chains.
Returns a dictionary that has in/out chain resources key\'ed with \'in\'
and \'out\' respectively, given the tenant_id and the router_id passed
in in the arguments.'
| def get_router_chains(self, tenant_id, router_id):
| LOG.debug(_('ChainManager.get_router_chains called: tenant_id=%(tenant_id)s router_id=%(router_id)s'), {'tenant_id': tenant_id, 'router_id': router_id})
router_chain_names = self._get_router_chain_names(router_id)
chains = {}
for c in self.mido_api.get_chains({'tenant_id': tenant_id}):
... |
'Create a new chain on a router.
Creates chains for the router and returns the same dictionary as
get_router_chains() returns.'
| def create_router_chains(self, tenant_id, router_id):
| LOG.debug(_('ChainManager.create_router_chains called: tenant_id=%(tenant_id)s router_id=%(router_id)s'), {'tenant_id': tenant_id, 'router_id': router_id})
chains = {}
router_chain_names = self._get_router_chain_names(router_id)
chains['in'] = self.mido_api.add_chain().tenant_id(tenant_id).name... |
'Get a list of chains mapped to a security group.'
| def get_sg_chains(self, tenant_id, sg_id):
| LOG.debug(_('ChainManager.get_sg_chains called: tenant_id=%(tenant_id)s sg_id=%(sg_id)s'), {'tenant_id': tenant_id, 'sg_id': sg_id})
cnames = chain_names(sg_id, sg_name='')
chain_name_prefix_for_id = cnames['in'][:NAME_IDENTIFIABLE_PREFIX_LEN]
chains = {}
for c in self.mido_api.get_chains({... |
'Create Quantum subnet.
Creates a Quantum subnet and a DHCP entry in MidoNet bridge.'
| def create_subnet(self, context, subnet):
| LOG.debug(_('MidonetPluginV2.create_subnet called: subnet=%r'), subnet)
if (subnet['subnet']['ip_version'] == 6):
raise q_exc.NotImplementedError(_("MidoNet doesn't support IPv6."))
net = super(MidonetPluginV2, self).get_network(context, subnet['subnet']['network_id'], fields=None)
... |
'Get Quantum subnet.
Retrieves a Quantum subnet record but also including the DHCP entry
data stored in MidoNet.'
| def get_subnet(self, context, id, fields=None):
| LOG.debug(_('MidonetPluginV2.get_subnet called: id=%(id)s fields=%(fields)s'), {'id': id, 'fields': fields})
qsubnet = super(MidonetPluginV2, self).get_subnet(context, id)
bridge_id = qsubnet['network_id']
try:
bridge = self.mido_api.get_bridge(bridge_id)
except w_exc.HTTPNotFound:
... |
'List Quantum subnets.
Retrieves Quantum subnets with some fields populated by the data
stored in MidoNet.'
| def get_subnets(self, context, filters=None, fields=None):
| LOG.debug(_('MidonetPluginV2.get_subnets called: filters=%(filters)r, fields=%(fields)r'), {'filters': filters, 'fields': fields})
subnets = super(MidonetPluginV2, self).get_subnets(context, filters, fields)
for sn in subnets:
if (not ('network_id' in sn)):
continue
try:... |
'Delete Quantum subnet.
Delete quantum network and its corresponding MidoNet bridge.'
| def delete_subnet(self, context, id):
| LOG.debug(_('MidonetPluginV2.delete_subnet called: id=%s'), id)
subnet = super(MidonetPluginV2, self).get_subnet(context, id, fields=None)
net = super(MidonetPluginV2, self).get_network(context, subnet['network_id'], fields=None)
bridge_id = subnet['network_id']
try:
bridge = self.mido... |
'Create Quantum network.
Create a new Quantum network and its corresponding MidoNet bridge.'
| def create_network(self, context, network):
| LOG.debug(_('MidonetPluginV2.create_network called: network=%r'), network)
if (network['network']['admin_state_up'] is False):
LOG.warning(_('Ignoring admin_state_up=False for network=%rOverriding with True'), network)
network['network']['admin_state_up'] = True
tenant_i... |
'Update Quantum network.
Update an existing Quantum network and its corresponding MidoNet
bridge.'
| def update_network(self, context, id, network):
| LOG.debug(_('MidonetPluginV2.update_network called: id=%(id)r, network=%(network)r'), {'id': id, 'network': network})
if (network['network'].get('admin_state_up') and (network['network']['admin_state_up'] is False)):
raise q_exc.NotImplementedError(_('admin_state_up=False networks are ... |
'Get Quantum network.
Retrieves a Quantum network and its corresponding MidoNet bridge.'
| def get_network(self, context, id, fields=None):
| LOG.debug(_('MidonetPluginV2.get_network called: id=%(id)r, fields=%(fields)r'), {'id': id, 'fields': fields})
qnet = super(MidonetPluginV2, self).get_network(context, id, None)
try:
self.mido_api.get_bridge(id)
except w_exc.HTTPNotFound:
raise MidonetResourceNotFound(resource_t... |
'List quantum networks and verify that all exist in MidoNet.'
| def get_networks(self, context, filters=None, fields=None):
| LOG.debug(_('MidonetPluginV2.get_networks called: filters=%(filters)r, fields=%(fields)r'), {'filters': filters, 'fields': fields})
qnets = super(MidonetPluginV2, self).get_networks(context, filters, None)
self.mido_api.get_bridges({'tenant_id': context.tenant_id})
for n in qnets:
try:
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.