Merge "Enable automatic validation of many HACKING rules."
This commit is contained in:
commit
40e0d33c8f
@ -36,8 +36,8 @@ from quantum import context
|
|||||||
from quantum import manager
|
from quantum import manager
|
||||||
from quantum.openstack.common import importutils
|
from quantum.openstack.common import importutils
|
||||||
from quantum.openstack.common import jsonutils
|
from quantum.openstack.common import jsonutils
|
||||||
from quantum.openstack.common import log as logging
|
|
||||||
from quantum.openstack.common import lockutils
|
from quantum.openstack.common import lockutils
|
||||||
|
from quantum.openstack.common import log as logging
|
||||||
from quantum.openstack.common import loopingcall
|
from quantum.openstack.common import loopingcall
|
||||||
from quantum.openstack.common.rpc import proxy
|
from quantum.openstack.common.rpc import proxy
|
||||||
from quantum.openstack.common import service
|
from quantum.openstack.common import service
|
||||||
@ -83,7 +83,7 @@ class DhcpAgent(manager.Manager):
|
|||||||
self._populate_networks_cache()
|
self._populate_networks_cache()
|
||||||
|
|
||||||
def _populate_networks_cache(self):
|
def _populate_networks_cache(self):
|
||||||
"""Populate the networks cache when the DHCP-agent starts"""
|
"""Populate the networks cache when the DHCP-agent starts."""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
existing_networks = self.dhcp_driver_cls.existing_dhcp_networks(
|
existing_networks = self.dhcp_driver_cls.existing_dhcp_networks(
|
||||||
@ -137,7 +137,7 @@ class DhcpAgent(manager.Manager):
|
|||||||
try:
|
try:
|
||||||
self.plugin_rpc.update_lease_expiration(network_id, ip_address,
|
self.plugin_rpc.update_lease_expiration(network_id, ip_address,
|
||||||
time_remaining)
|
time_remaining)
|
||||||
except:
|
except Exception:
|
||||||
self.needs_resync = True
|
self.needs_resync = True
|
||||||
LOG.exception(_('Unable to update lease'))
|
LOG.exception(_('Unable to update lease'))
|
||||||
|
|
||||||
@ -153,7 +153,7 @@ class DhcpAgent(manager.Manager):
|
|||||||
|
|
||||||
for network_id in active_networks:
|
for network_id in active_networks:
|
||||||
self.refresh_dhcp_helper(network_id)
|
self.refresh_dhcp_helper(network_id)
|
||||||
except:
|
except Exception:
|
||||||
self.needs_resync = True
|
self.needs_resync = True
|
||||||
LOG.exception(_('Unable to sync network state.'))
|
LOG.exception(_('Unable to sync network state.'))
|
||||||
|
|
||||||
@ -173,7 +173,7 @@ class DhcpAgent(manager.Manager):
|
|||||||
"""Enable DHCP for a network that meets enabling criteria."""
|
"""Enable DHCP for a network that meets enabling criteria."""
|
||||||
try:
|
try:
|
||||||
network = self.plugin_rpc.get_network_info(network_id)
|
network = self.plugin_rpc.get_network_info(network_id)
|
||||||
except:
|
except Exception:
|
||||||
self.needs_resync = True
|
self.needs_resync = True
|
||||||
LOG.exception(_('Network %s RPC info call failed.'), network_id)
|
LOG.exception(_('Network %s RPC info call failed.'), network_id)
|
||||||
return
|
return
|
||||||
@ -210,7 +210,7 @@ class DhcpAgent(manager.Manager):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
network = self.plugin_rpc.get_network_info(network_id)
|
network = self.plugin_rpc.get_network_info(network_id)
|
||||||
except:
|
except Exception:
|
||||||
self.needs_resync = True
|
self.needs_resync = True
|
||||||
LOG.exception(_('Network %s RPC info call failed.'), network_id)
|
LOG.exception(_('Network %s RPC info call failed.'), network_id)
|
||||||
return
|
return
|
||||||
@ -502,7 +502,7 @@ class DeviceManager(object):
|
|||||||
try:
|
try:
|
||||||
self.driver = importutils.import_object(conf.interface_driver,
|
self.driver = importutils.import_object(conf.interface_driver,
|
||||||
conf)
|
conf)
|
||||||
except:
|
except Exception:
|
||||||
msg = _("Error importing interface driver "
|
msg = _("Error importing interface driver "
|
||||||
"'%s'") % conf.interface_driver
|
"'%s'") % conf.interface_driver
|
||||||
raise SystemExit(msg)
|
raise SystemExit(msg)
|
||||||
|
@ -20,7 +20,7 @@ import contextlib
|
|||||||
|
|
||||||
|
|
||||||
class FirewallDriver(object):
|
class FirewallDriver(object):
|
||||||
""" Firewall Driver base class.
|
"""Firewall Driver base class.
|
||||||
|
|
||||||
Defines methods that any driver providing security groups
|
Defines methods that any driver providing security groups
|
||||||
and provider firewall functionality should implement.
|
and provider firewall functionality should implement.
|
||||||
@ -81,25 +81,25 @@ class FirewallDriver(object):
|
|||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
||||||
def remove_port_filter(self, port):
|
def remove_port_filter(self, port):
|
||||||
"""Stop filtering port"""
|
"""Stop filtering port."""
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
||||||
def filter_defer_apply_on(self):
|
def filter_defer_apply_on(self):
|
||||||
"""Defer application of filtering rule"""
|
"""Defer application of filtering rule."""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def filter_defer_apply_off(self):
|
def filter_defer_apply_off(self):
|
||||||
"""Turn off deferral of rules and apply the rules now"""
|
"""Turn off deferral of rules and apply the rules now."""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def ports(self):
|
def ports(self):
|
||||||
""" returns filterd ports"""
|
"""Returns filtered ports."""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@contextlib.contextmanager
|
@contextlib.contextmanager
|
||||||
def defer_apply(self):
|
def defer_apply(self):
|
||||||
"""defer apply context"""
|
"""Defer apply context."""
|
||||||
self.filter_defer_apply_on()
|
self.filter_defer_apply_on()
|
||||||
try:
|
try:
|
||||||
yield
|
yield
|
||||||
@ -108,7 +108,7 @@ class FirewallDriver(object):
|
|||||||
|
|
||||||
|
|
||||||
class NoopFirewallDriver(FirewallDriver):
|
class NoopFirewallDriver(FirewallDriver):
|
||||||
""" Noop Firewall Driver.
|
"""Noop Firewall Driver.
|
||||||
|
|
||||||
Firewall driver which does nothing.
|
Firewall driver which does nothing.
|
||||||
This driver is for disabling the firewall functionality.
|
This driver is for disabling the firewall functionality.
|
||||||
|
@ -156,7 +156,7 @@ class L3NATAgent(manager.Manager):
|
|||||||
try:
|
try:
|
||||||
self.driver = importutils.import_object(self.conf.interface_driver,
|
self.driver = importutils.import_object(self.conf.interface_driver,
|
||||||
self.conf)
|
self.conf)
|
||||||
except:
|
except Exception:
|
||||||
msg = _("Error importing interface driver "
|
msg = _("Error importing interface driver "
|
||||||
"'%s'") % self.conf.interface_driver
|
"'%s'") % self.conf.interface_driver
|
||||||
raise SystemExit(msg)
|
raise SystemExit(msg)
|
||||||
@ -185,7 +185,7 @@ class L3NATAgent(manager.Manager):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
self._destroy_router_namespace(ns)
|
self._destroy_router_namespace(ns)
|
||||||
except:
|
except Exception:
|
||||||
LOG.exception(_("Failed deleting namespace '%s'"), ns)
|
LOG.exception(_("Failed deleting namespace '%s'"), ns)
|
||||||
|
|
||||||
def _destroy_router_namespace(self, namespace):
|
def _destroy_router_namespace(self, namespace):
|
||||||
@ -200,7 +200,7 @@ class L3NATAgent(manager.Manager):
|
|||||||
bridge=self.conf.external_network_bridge,
|
bridge=self.conf.external_network_bridge,
|
||||||
namespace=namespace,
|
namespace=namespace,
|
||||||
prefix=EXTERNAL_DEV_PREFIX)
|
prefix=EXTERNAL_DEV_PREFIX)
|
||||||
#(TODO) Address the failure for the deletion of the namespace
|
#TODO(garyk) Address the failure for the deletion of the namespace
|
||||||
|
|
||||||
def _create_router_namespace(self, ri):
|
def _create_router_namespace(self, ri):
|
||||||
ip_wrapper_root = ip_lib.IPWrapper(self.root_helper)
|
ip_wrapper_root = ip_lib.IPWrapper(self.root_helper)
|
||||||
@ -208,7 +208,7 @@ class L3NATAgent(manager.Manager):
|
|||||||
ip_wrapper.netns.execute(['sysctl', '-w', 'net.ipv4.ip_forward=1'])
|
ip_wrapper.netns.execute(['sysctl', '-w', 'net.ipv4.ip_forward=1'])
|
||||||
|
|
||||||
def _fetch_external_net_id(self):
|
def _fetch_external_net_id(self):
|
||||||
"""Find UUID of single external network for this agent"""
|
"""Find UUID of single external network for this agent."""
|
||||||
if self.conf.gateway_external_network_id:
|
if self.conf.gateway_external_network_id:
|
||||||
return self.conf.gateway_external_network_id
|
return self.conf.gateway_external_network_id
|
||||||
try:
|
try:
|
||||||
|
@ -126,7 +126,7 @@ class Daemon(object):
|
|||||||
os.remove(str(self.pidfile))
|
os.remove(str(self.pidfile))
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
""" Start the daemon """
|
"""Start the daemon."""
|
||||||
|
|
||||||
if self.pidfile.is_running():
|
if self.pidfile.is_running():
|
||||||
self.pidfile.unlock()
|
self.pidfile.unlock()
|
||||||
|
@ -96,7 +96,7 @@ class DhcpBase(object):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def existing_dhcp_networks(cls, conf, root_helper):
|
def existing_dhcp_networks(cls, conf, root_helper):
|
||||||
"""Return a list of existing networks ids (ones we have configs for)"""
|
"""Return a list of existing networks ids that we have configs for."""
|
||||||
|
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
@ -218,7 +218,7 @@ class Dnsmasq(DhcpLocalProcess):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def existing_dhcp_networks(cls, conf, root_helper):
|
def existing_dhcp_networks(cls, conf, root_helper):
|
||||||
"""Return a list of existing networks ids (ones we have configs for)"""
|
"""Return a list of existing networks ids that we have configs for."""
|
||||||
|
|
||||||
confs_dir = os.path.abspath(os.path.normpath(conf.dhcp_confs))
|
confs_dir = os.path.abspath(os.path.normpath(conf.dhcp_confs))
|
||||||
|
|
||||||
@ -265,7 +265,7 @@ class Dnsmasq(DhcpLocalProcess):
|
|||||||
if subnet.ip_version == 4:
|
if subnet.ip_version == 4:
|
||||||
mode = 'static'
|
mode = 'static'
|
||||||
else:
|
else:
|
||||||
# TODO (mark): how do we indicate other options
|
# TODO(mark): how do we indicate other options
|
||||||
# ra-only, slaac, ra-nameservers, and ra-stateless.
|
# ra-only, slaac, ra-nameservers, and ra-stateless.
|
||||||
mode = 'static'
|
mode = 'static'
|
||||||
cmd.append('--dhcp-range=set:%s,%s,%s,%ss' %
|
cmd.append('--dhcp-range=set:%s,%s,%s,%ss' %
|
||||||
|
@ -354,7 +354,7 @@ class IpRouteCommand(IpDeviceCommandBase):
|
|||||||
for device_route_line in device_route_list_lines:
|
for device_route_line in device_route_list_lines:
|
||||||
try:
|
try:
|
||||||
subnet = device_route_line.split()[0]
|
subnet = device_route_line.split()[0]
|
||||||
except:
|
except Exception:
|
||||||
continue
|
continue
|
||||||
subnet_route_list_lines = self._run('list', 'proto', 'kernel',
|
subnet_route_list_lines = self._run('list', 'proto', 'kernel',
|
||||||
'match', subnet).split('\n')
|
'match', subnet).split('\n')
|
||||||
@ -367,7 +367,7 @@ class IpRouteCommand(IpDeviceCommandBase):
|
|||||||
while(i.next() != 'src'):
|
while(i.next() != 'src'):
|
||||||
pass
|
pass
|
||||||
src = i.next()
|
src = i.next()
|
||||||
except:
|
except Exception:
|
||||||
src = ''
|
src = ''
|
||||||
if device != interface_name:
|
if device != interface_name:
|
||||||
device_list.append((device, src))
|
device_list.append((device, src))
|
||||||
|
@ -81,7 +81,7 @@ class IptablesFirewallDriver(firewall.FirewallDriver):
|
|||||||
self.iptables.apply()
|
self.iptables.apply()
|
||||||
|
|
||||||
def _setup_chains(self):
|
def _setup_chains(self):
|
||||||
"""Setup ingress and egress chain for a port. """
|
"""Setup ingress and egress chain for a port."""
|
||||||
self._add_chain_by_name_v4v6(SG_CHAIN)
|
self._add_chain_by_name_v4v6(SG_CHAIN)
|
||||||
for port in self.filtered_ports.values():
|
for port in self.filtered_ports.values():
|
||||||
self._setup_chain(port, INGRESS_DIRECTION)
|
self._setup_chain(port, INGRESS_DIRECTION)
|
||||||
@ -90,7 +90,7 @@ class IptablesFirewallDriver(firewall.FirewallDriver):
|
|||||||
self.iptables.ipv6['filter'].add_rule(SG_CHAIN, '-j ACCEPT')
|
self.iptables.ipv6['filter'].add_rule(SG_CHAIN, '-j ACCEPT')
|
||||||
|
|
||||||
def _remove_chains(self):
|
def _remove_chains(self):
|
||||||
"""Remove ingress and egress chain for a port"""
|
"""Remove ingress and egress chain for a port."""
|
||||||
for port in self.filtered_ports.values():
|
for port in self.filtered_ports.values():
|
||||||
self._remove_chain(port, INGRESS_DIRECTION)
|
self._remove_chain(port, INGRESS_DIRECTION)
|
||||||
self._remove_chain(port, EGRESS_DIRECTION)
|
self._remove_chain(port, EGRESS_DIRECTION)
|
||||||
|
@ -53,7 +53,7 @@ def setup_conf():
|
|||||||
|
|
||||||
|
|
||||||
def collect_quantum_ports(bridges, root_helper):
|
def collect_quantum_ports(bridges, root_helper):
|
||||||
"""Collect ports created by Quantum from OVS"""
|
"""Collect ports created by Quantum from OVS."""
|
||||||
ports = []
|
ports = []
|
||||||
for bridge in bridges:
|
for bridge in bridges:
|
||||||
ovs = ovs_lib.OVSBridge(bridge, root_helper)
|
ovs = ovs_lib.OVSBridge(bridge, root_helper)
|
||||||
|
@ -66,7 +66,7 @@ class SecurityGroupAgentRpcCallbackMixin(object):
|
|||||||
sg_agent = None
|
sg_agent = None
|
||||||
|
|
||||||
def security_groups_rule_updated(self, context, **kwargs):
|
def security_groups_rule_updated(self, context, **kwargs):
|
||||||
""" callback for security group rule update
|
"""Callback for security group rule update.
|
||||||
|
|
||||||
:param security_groups: list of updated security_groups
|
:param security_groups: list of updated security_groups
|
||||||
"""
|
"""
|
||||||
@ -76,7 +76,7 @@ class SecurityGroupAgentRpcCallbackMixin(object):
|
|||||||
self.sg_agent.security_groups_rule_updated(security_groups)
|
self.sg_agent.security_groups_rule_updated(security_groups)
|
||||||
|
|
||||||
def security_groups_member_updated(self, context, **kwargs):
|
def security_groups_member_updated(self, context, **kwargs):
|
||||||
""" callback for security group member update
|
"""Callback for security group member update.
|
||||||
|
|
||||||
:param security_groups: list of updated security_groups
|
:param security_groups: list of updated security_groups
|
||||||
"""
|
"""
|
||||||
@ -86,9 +86,7 @@ class SecurityGroupAgentRpcCallbackMixin(object):
|
|||||||
self.sg_agent.security_groups_member_updated(security_groups)
|
self.sg_agent.security_groups_member_updated(security_groups)
|
||||||
|
|
||||||
def security_groups_provider_updated(self, context, **kwargs):
|
def security_groups_provider_updated(self, context, **kwargs):
|
||||||
""" callback for security group provider update
|
"""Callback for security group provider update."""
|
||||||
|
|
||||||
"""
|
|
||||||
LOG.debug(_("Provider rule updated"))
|
LOG.debug(_("Provider rule updated"))
|
||||||
self.sg_agent.security_groups_provider_updated()
|
self.sg_agent.security_groups_provider_updated()
|
||||||
|
|
||||||
@ -172,7 +170,7 @@ class SecurityGroupAgentRpcApiMixin(object):
|
|||||||
topics.UPDATE)
|
topics.UPDATE)
|
||||||
|
|
||||||
def security_groups_rule_updated(self, context, security_groups):
|
def security_groups_rule_updated(self, context, security_groups):
|
||||||
""" notify rule updated security groups """
|
"""Notify rule updated security groups."""
|
||||||
if not security_groups:
|
if not security_groups:
|
||||||
return
|
return
|
||||||
self.fanout_cast(context,
|
self.fanout_cast(context,
|
||||||
@ -182,7 +180,7 @@ class SecurityGroupAgentRpcApiMixin(object):
|
|||||||
topic=self._get_security_group_topic())
|
topic=self._get_security_group_topic())
|
||||||
|
|
||||||
def security_groups_member_updated(self, context, security_groups):
|
def security_groups_member_updated(self, context, security_groups):
|
||||||
""" notify member updated security groups """
|
"""Notify member updated security groups."""
|
||||||
if not security_groups:
|
if not security_groups:
|
||||||
return
|
return
|
||||||
self.fanout_cast(context,
|
self.fanout_cast(context,
|
||||||
@ -192,7 +190,7 @@ class SecurityGroupAgentRpcApiMixin(object):
|
|||||||
topic=self._get_security_group_topic())
|
topic=self._get_security_group_topic())
|
||||||
|
|
||||||
def security_groups_provider_updated(self, context):
|
def security_groups_provider_updated(self, context):
|
||||||
""" notify provider updated security groups """
|
"""Notify provider updated security groups."""
|
||||||
self.fanout_cast(context,
|
self.fanout_cast(context,
|
||||||
self.make_msg('security_groups_provider_updated'),
|
self.make_msg('security_groups_provider_updated'),
|
||||||
version=SG_RPC_VERSION,
|
version=SG_RPC_VERSION,
|
||||||
|
@ -119,7 +119,7 @@ def _get_limit_param(request, max_limit):
|
|||||||
|
|
||||||
|
|
||||||
def list_args(request, arg):
|
def list_args(request, arg):
|
||||||
"""Extracts the list of arg from request"""
|
"""Extracts the list of arg from request."""
|
||||||
return [v for v in request.GET.getall(arg) if v]
|
return [v for v in request.GET.getall(arg) if v]
|
||||||
|
|
||||||
|
|
||||||
@ -292,7 +292,7 @@ class NoSortingHelper(SortingHelper):
|
|||||||
|
|
||||||
|
|
||||||
class QuantumController(object):
|
class QuantumController(object):
|
||||||
""" Base controller class for Quantum API """
|
"""Base controller class for Quantum API."""
|
||||||
# _resource_name will be redefined in sub concrete controller
|
# _resource_name will be redefined in sub concrete controller
|
||||||
_resource_name = None
|
_resource_name = None
|
||||||
|
|
||||||
@ -301,7 +301,7 @@ class QuantumController(object):
|
|||||||
super(QuantumController, self).__init__()
|
super(QuantumController, self).__init__()
|
||||||
|
|
||||||
def _prepare_request_body(self, body, params):
|
def _prepare_request_body(self, body, params):
|
||||||
""" verifies required parameters are in request body.
|
"""Verifies required parameters are in request body.
|
||||||
sets default value for missing optional parameters.
|
sets default value for missing optional parameters.
|
||||||
|
|
||||||
body argument must be the deserialized body
|
body argument must be the deserialized body
|
||||||
|
@ -552,7 +552,8 @@ class PluginAwareExtensionManager(ExtensionManager):
|
|||||||
|
|
||||||
def _check_extension(self, extension):
|
def _check_extension(self, extension):
|
||||||
"""Checks if any of plugins supports extension and implements the
|
"""Checks if any of plugins supports extension and implements the
|
||||||
extension contract."""
|
extension contract.
|
||||||
|
"""
|
||||||
extension_is_valid = super(PluginAwareExtensionManager,
|
extension_is_valid = super(PluginAwareExtensionManager,
|
||||||
self)._check_extension(extension)
|
self)._check_extension(extension)
|
||||||
return (extension_is_valid and
|
return (extension_is_valid and
|
||||||
|
@ -51,14 +51,14 @@ class DhcpAgentNotifyAPI(proxy.RpcProxy):
|
|||||||
dhcp_agent in dhcp_agents]
|
dhcp_agent in dhcp_agents]
|
||||||
|
|
||||||
def _notification_host(self, context, method, payload, host):
|
def _notification_host(self, context, method, payload, host):
|
||||||
"""Notify the agent on host"""
|
"""Notify the agent on host."""
|
||||||
self.cast(
|
self.cast(
|
||||||
context, self.make_msg(method,
|
context, self.make_msg(method,
|
||||||
payload=payload),
|
payload=payload),
|
||||||
topic='%s.%s' % (topics.DHCP_AGENT, host))
|
topic='%s.%s' % (topics.DHCP_AGENT, host))
|
||||||
|
|
||||||
def _notification(self, context, method, payload, network_id):
|
def _notification(self, context, method, payload, network_id):
|
||||||
"""Notify all the agents that are hosting the network"""
|
"""Notify all the agents that are hosting the network."""
|
||||||
plugin = manager.QuantumManager.get_plugin()
|
plugin = manager.QuantumManager.get_plugin()
|
||||||
if (method != 'network_delete_end' and utils.is_extension_supported(
|
if (method != 'network_delete_end' and utils.is_extension_supported(
|
||||||
plugin, constants.AGENT_SCHEDULER_EXT_ALIAS)):
|
plugin, constants.AGENT_SCHEDULER_EXT_ALIAS)):
|
||||||
@ -87,7 +87,7 @@ class DhcpAgentNotifyAPI(proxy.RpcProxy):
|
|||||||
self._notification_fanout(context, method, payload)
|
self._notification_fanout(context, method, payload)
|
||||||
|
|
||||||
def _notification_fanout(self, context, method, payload):
|
def _notification_fanout(self, context, method, payload):
|
||||||
"""Fanout the payload to all dhcp agents"""
|
"""Fanout the payload to all dhcp agents."""
|
||||||
self.fanout_cast(
|
self.fanout_cast(
|
||||||
context, self.make_msg(method,
|
context, self.make_msg(method,
|
||||||
payload=payload),
|
payload=payload),
|
||||||
|
@ -33,7 +33,7 @@ class L3AgentNotifyAPI(proxy.RpcProxy):
|
|||||||
topic=topic, default_version=self.BASE_RPC_API_VERSION)
|
topic=topic, default_version=self.BASE_RPC_API_VERSION)
|
||||||
|
|
||||||
def _notification_host(self, context, method, payload, host):
|
def _notification_host(self, context, method, payload, host):
|
||||||
"""Notify the agent that is hosting the router"""
|
"""Notify the agent that is hosting the router."""
|
||||||
LOG.debug(_('Nofity agent at %(host)s the message '
|
LOG.debug(_('Nofity agent at %(host)s the message '
|
||||||
'%(method)s'), {'host': host,
|
'%(method)s'), {'host': host,
|
||||||
'method': method})
|
'method': method})
|
||||||
@ -69,7 +69,7 @@ class L3AgentNotifyAPI(proxy.RpcProxy):
|
|||||||
topic='%s.%s' % (l3_agent.topic, l3_agent.host))
|
topic='%s.%s' % (l3_agent.topic, l3_agent.host))
|
||||||
|
|
||||||
def _notification(self, context, method, routers, operation, data):
|
def _notification(self, context, method, routers, operation, data):
|
||||||
"""Notify all the agents that are hosting the routers"""
|
"""Notify all the agents that are hosting the routers."""
|
||||||
plugin = manager.QuantumManager.get_plugin()
|
plugin = manager.QuantumManager.get_plugin()
|
||||||
if utils.is_extension_supported(
|
if utils.is_extension_supported(
|
||||||
plugin, constants.AGENT_SCHEDULER_EXT_ALIAS):
|
plugin, constants.AGENT_SCHEDULER_EXT_ALIAS):
|
||||||
@ -85,7 +85,7 @@ class L3AgentNotifyAPI(proxy.RpcProxy):
|
|||||||
topic=topics.L3_AGENT)
|
topic=topics.L3_AGENT)
|
||||||
|
|
||||||
def _notification_fanout(self, context, method, router_id):
|
def _notification_fanout(self, context, method, router_id):
|
||||||
"""Fanout the deleted router to all L3 agents"""
|
"""Fanout the deleted router to all L3 agents."""
|
||||||
LOG.debug(_('Fanout notify agent at %(topic)s the message '
|
LOG.debug(_('Fanout notify agent at %(topic)s the message '
|
||||||
'%(method)s on router %(router_id)s'),
|
'%(method)s on router %(router_id)s'),
|
||||||
{'topic': topics.DHCP_AGENT,
|
{'topic': topics.DHCP_AGENT,
|
||||||
|
@ -32,7 +32,7 @@ SHARED = 'shared'
|
|||||||
|
|
||||||
|
|
||||||
def _verify_dict_keys(expected_keys, target_dict, strict=True):
|
def _verify_dict_keys(expected_keys, target_dict, strict=True):
|
||||||
""" Allows to verify keys in a dictionary.
|
"""Allows to verify keys in a dictionary.
|
||||||
:param expected_keys: A list of keys expected to be present.
|
:param expected_keys: A list of keys expected to be present.
|
||||||
:param target_dict: The dictionary which should be verified.
|
:param target_dict: The dictionary which should be verified.
|
||||||
:param strict: Specifies whether additional keys are allowed to be present.
|
:param strict: Specifies whether additional keys are allowed to be present.
|
||||||
|
@ -181,7 +181,7 @@ class Controller(object):
|
|||||||
return api_common.NoSortingHelper(request, self._attr_info)
|
return api_common.NoSortingHelper(request, self._attr_info)
|
||||||
|
|
||||||
def _items(self, request, do_authz=False, parent_id=None):
|
def _items(self, request, do_authz=False, parent_id=None):
|
||||||
"""Retrieves and formats a list of elements of the requested entity"""
|
"""Retrieves and formats a list of elements of the requested entity."""
|
||||||
# NOTE(salvatore-orlando): The following ensures that fields which
|
# NOTE(salvatore-orlando): The following ensures that fields which
|
||||||
# are needed for authZ policy validation are not stripped away by the
|
# are needed for authZ policy validation are not stripped away by the
|
||||||
# plugin before returning.
|
# plugin before returning.
|
||||||
@ -227,7 +227,7 @@ class Controller(object):
|
|||||||
|
|
||||||
def _item(self, request, id, do_authz=False, field_list=None,
|
def _item(self, request, id, do_authz=False, field_list=None,
|
||||||
parent_id=None):
|
parent_id=None):
|
||||||
"""Retrieves and formats a single element of the requested entity"""
|
"""Retrieves and formats a single element of the requested entity."""
|
||||||
kwargs = {'fields': field_list}
|
kwargs = {'fields': field_list}
|
||||||
action = self._plugin_handlers[self.SHOW]
|
action = self._plugin_handlers[self.SHOW]
|
||||||
if parent_id:
|
if parent_id:
|
||||||
@ -246,12 +246,12 @@ class Controller(object):
|
|||||||
self._dhcp_agent_notifier.notify(context, data, methodname)
|
self._dhcp_agent_notifier.notify(context, data, methodname)
|
||||||
|
|
||||||
def index(self, request, **kwargs):
|
def index(self, request, **kwargs):
|
||||||
"""Returns a list of the requested entity"""
|
"""Returns a list of the requested entity."""
|
||||||
parent_id = kwargs.get(self._parent_id_name)
|
parent_id = kwargs.get(self._parent_id_name)
|
||||||
return self._items(request, True, parent_id)
|
return self._items(request, True, parent_id)
|
||||||
|
|
||||||
def show(self, request, id, **kwargs):
|
def show(self, request, id, **kwargs):
|
||||||
"""Returns detailed information about the requested entity"""
|
"""Returns detailed information about the requested entity."""
|
||||||
try:
|
try:
|
||||||
# NOTE(salvatore-orlando): The following ensures that fields
|
# NOTE(salvatore-orlando): The following ensures that fields
|
||||||
# which are needed for authZ policy validation are not stripped
|
# which are needed for authZ policy validation are not stripped
|
||||||
@ -304,7 +304,7 @@ class Controller(object):
|
|||||||
raise ex
|
raise ex
|
||||||
|
|
||||||
def create(self, request, body=None, **kwargs):
|
def create(self, request, body=None, **kwargs):
|
||||||
"""Creates a new instance of the requested entity"""
|
"""Creates a new instance of the requested entity."""
|
||||||
parent_id = kwargs.get(self._parent_id_name)
|
parent_id = kwargs.get(self._parent_id_name)
|
||||||
notifier_api.notify(request.context,
|
notifier_api.notify(request.context,
|
||||||
self._publisher_id,
|
self._publisher_id,
|
||||||
@ -382,7 +382,7 @@ class Controller(object):
|
|||||||
return notify({self._resource: self._view(obj)})
|
return notify({self._resource: self._view(obj)})
|
||||||
|
|
||||||
def delete(self, request, id, **kwargs):
|
def delete(self, request, id, **kwargs):
|
||||||
"""Deletes the specified entity"""
|
"""Deletes the specified entity."""
|
||||||
notifier_api.notify(request.context,
|
notifier_api.notify(request.context,
|
||||||
self._publisher_id,
|
self._publisher_id,
|
||||||
self._resource + '.delete.start',
|
self._resource + '.delete.start',
|
||||||
@ -417,7 +417,7 @@ class Controller(object):
|
|||||||
notifier_method)
|
notifier_method)
|
||||||
|
|
||||||
def update(self, request, id, body=None, **kwargs):
|
def update(self, request, id, body=None, **kwargs):
|
||||||
"""Updates the specified entity's attributes"""
|
"""Updates the specified entity's attributes."""
|
||||||
parent_id = kwargs.get(self._parent_id_name)
|
parent_id = kwargs.get(self._parent_id_name)
|
||||||
try:
|
try:
|
||||||
payload = body.copy()
|
payload = body.copy()
|
||||||
@ -492,7 +492,7 @@ class Controller(object):
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def prepare_request_body(context, body, is_create, resource, attr_info,
|
def prepare_request_body(context, body, is_create, resource, attr_info,
|
||||||
allow_bulk=False):
|
allow_bulk=False):
|
||||||
""" verifies required attributes are in request body, and that
|
"""Verifies required attributes are in request body, and that
|
||||||
an attribute is only specified if it is allowed for the given
|
an attribute is only specified if it is allowed for the given
|
||||||
operation (create/update).
|
operation (create/update).
|
||||||
Attribute with default values are considered to be
|
Attribute with default values are considered to be
|
||||||
|
@ -25,7 +25,8 @@ LOG = logging.getLogger(__name__)
|
|||||||
|
|
||||||
class PluginRpcDispatcher(dispatcher.RpcDispatcher):
|
class PluginRpcDispatcher(dispatcher.RpcDispatcher):
|
||||||
"""This class is used to convert RPC common context into
|
"""This class is used to convert RPC common context into
|
||||||
Quantum Context."""
|
Quantum Context.
|
||||||
|
"""
|
||||||
|
|
||||||
def __init__(self, callbacks):
|
def __init__(self, callbacks):
|
||||||
super(PluginRpcDispatcher, self).__init__(callbacks)
|
super(PluginRpcDispatcher, self).__init__(callbacks)
|
||||||
|
@ -77,7 +77,7 @@ class _AnsiColorizer(object):
|
|||||||
except curses.error:
|
except curses.error:
|
||||||
curses.setupterm()
|
curses.setupterm()
|
||||||
return curses.tigetnum("colors") > 2
|
return curses.tigetnum("colors") > 2
|
||||||
except:
|
except Exception:
|
||||||
raise
|
raise
|
||||||
# guess false in case of error
|
# guess false in case of error
|
||||||
return False
|
return False
|
||||||
|
@ -154,7 +154,7 @@ def get_hostname():
|
|||||||
|
|
||||||
|
|
||||||
def compare_elements(a, b):
|
def compare_elements(a, b):
|
||||||
""" compare elements if a and b have same elements
|
"""Compare elements if a and b have same elements.
|
||||||
|
|
||||||
This method doesn't consider ordering
|
This method doesn't consider ordering
|
||||||
"""
|
"""
|
||||||
|
@ -34,7 +34,7 @@ cfg.CONF.register_opt(
|
|||||||
|
|
||||||
|
|
||||||
class Agent(model_base.BASEV2, models_v2.HasId):
|
class Agent(model_base.BASEV2, models_v2.HasId):
|
||||||
"""Represents agents running in quantum deployments"""
|
"""Represents agents running in quantum deployments."""
|
||||||
|
|
||||||
# L3 agent, DHCP agent, OVS agent, LinuxBridge
|
# L3 agent, DHCP agent, OVS agent, LinuxBridge
|
||||||
agent_type = sa.Column(sa.String(255), nullable=False)
|
agent_type = sa.Column(sa.String(255), nullable=False)
|
||||||
@ -162,7 +162,7 @@ class AgentExtRpcCallback(object):
|
|||||||
START_TIME = timeutils.utcnow()
|
START_TIME = timeutils.utcnow()
|
||||||
|
|
||||||
def report_state(self, context, **kwargs):
|
def report_state(self, context, **kwargs):
|
||||||
"""Report state from agent to server. """
|
"""Report state from agent to server."""
|
||||||
time = kwargs['time']
|
time = kwargs['time']
|
||||||
time = timeutils.parse_strtime(time)
|
time = timeutils.parse_strtime(time)
|
||||||
if self.START_TIME > time:
|
if self.START_TIME > time:
|
||||||
|
@ -32,7 +32,7 @@ LOG = logging.getLogger(__name__)
|
|||||||
|
|
||||||
|
|
||||||
class NetworkDhcpAgentBinding(model_base.BASEV2):
|
class NetworkDhcpAgentBinding(model_base.BASEV2):
|
||||||
"""Represents binding between quantum networks and DHCP agents"""
|
"""Represents binding between quantum networks and DHCP agents."""
|
||||||
network_id = sa.Column(sa.String(36),
|
network_id = sa.Column(sa.String(36),
|
||||||
sa.ForeignKey("networks.id", ondelete='CASCADE'),
|
sa.ForeignKey("networks.id", ondelete='CASCADE'),
|
||||||
primary_key=True)
|
primary_key=True)
|
||||||
@ -44,7 +44,7 @@ class NetworkDhcpAgentBinding(model_base.BASEV2):
|
|||||||
|
|
||||||
|
|
||||||
class RouterL3AgentBinding(model_base.BASEV2, models_v2.HasId):
|
class RouterL3AgentBinding(model_base.BASEV2, models_v2.HasId):
|
||||||
"""Represents binding between quantum routers and L3 agents"""
|
"""Represents binding between quantum routers and L3 agents."""
|
||||||
router_id = sa.Column(sa.String(36),
|
router_id = sa.Column(sa.String(36),
|
||||||
sa.ForeignKey("routers.id", ondelete='CASCADE'))
|
sa.ForeignKey("routers.id", ondelete='CASCADE'))
|
||||||
l3_agent = orm.relation(agents_db.Agent)
|
l3_agent = orm.relation(agents_db.Agent)
|
||||||
@ -194,7 +194,8 @@ class AgentSchedulerDbMixin(agentscheduler.AgentSchedulerPluginBase,
|
|||||||
def remove_router_from_l3_agent(self, context, id, router_id):
|
def remove_router_from_l3_agent(self, context, id, router_id):
|
||||||
"""Remove the router from l3 agent. After it, the router
|
"""Remove the router from l3 agent. After it, the router
|
||||||
will be non-hosted until there is update which
|
will be non-hosted until there is update which
|
||||||
lead to re schedule or be added to another agent manually."""
|
lead to re schedule or be added to another agent manually.
|
||||||
|
"""
|
||||||
agent = self._get_agent(context, id)
|
agent = self._get_agent(context, id)
|
||||||
with context.session.begin(subtransactions=True):
|
with context.session.begin(subtransactions=True):
|
||||||
query = context.session.query(RouterL3AgentBinding)
|
query = context.session.query(RouterL3AgentBinding)
|
||||||
@ -321,7 +322,7 @@ class AgentSchedulerDbMixin(agentscheduler.AgentSchedulerPluginBase,
|
|||||||
return l3_agents
|
return l3_agents
|
||||||
|
|
||||||
def get_l3_agent_candidates(self, sync_router, l3_agents):
|
def get_l3_agent_candidates(self, sync_router, l3_agents):
|
||||||
"""Get the valid l3 agents for the router from a list of l3_agents"""
|
"""Get the valid l3 agents for the router from a list of l3_agents."""
|
||||||
candidates = []
|
candidates = []
|
||||||
for l3_agent in l3_agents:
|
for l3_agent in l3_agents:
|
||||||
if not l3_agent.admin_state_up:
|
if not l3_agent.admin_state_up:
|
||||||
|
@ -120,7 +120,7 @@ def configure_db():
|
|||||||
if not sql_connection:
|
if not sql_connection:
|
||||||
LOG.warn(_("Option 'sql_connection' not specified "
|
LOG.warn(_("Option 'sql_connection' not specified "
|
||||||
"in any config file - using default "
|
"in any config file - using default "
|
||||||
"value '%s'" % SQL_CONNECTION_DEFAULT))
|
"value '%s'") % SQL_CONNECTION_DEFAULT)
|
||||||
sql_connection = SQL_CONNECTION_DEFAULT
|
sql_connection = SQL_CONNECTION_DEFAULT
|
||||||
connection_dict = sql.engine.url.make_url(sql_connection)
|
connection_dict = sql.engine.url.make_url(sql_connection)
|
||||||
engine_args = {
|
engine_args = {
|
||||||
@ -185,7 +185,7 @@ def clear_db(base=BASE):
|
|||||||
|
|
||||||
|
|
||||||
def get_session(autocommit=True, expire_on_commit=False):
|
def get_session(autocommit=True, expire_on_commit=False):
|
||||||
"""Helper method to grab session"""
|
"""Helper method to grab session."""
|
||||||
global _MAKER, _ENGINE
|
global _MAKER, _ENGINE
|
||||||
if not _MAKER:
|
if not _MAKER:
|
||||||
assert _ENGINE
|
assert _ENGINE
|
||||||
@ -213,7 +213,7 @@ def retry_registration(remaining, reconnect_interval, base=BASE):
|
|||||||
|
|
||||||
|
|
||||||
def register_models(base=BASE):
|
def register_models(base=BASE):
|
||||||
"""Register Models and create properties"""
|
"""Register Models and create properties."""
|
||||||
global _ENGINE
|
global _ENGINE
|
||||||
assert _ENGINE
|
assert _ENGINE
|
||||||
try:
|
try:
|
||||||
@ -225,7 +225,7 @@ def register_models(base=BASE):
|
|||||||
|
|
||||||
|
|
||||||
def unregister_models(base=BASE):
|
def unregister_models(base=BASE):
|
||||||
"""Unregister Models, useful clearing out data before testing"""
|
"""Unregister Models, useful clearing out data before testing."""
|
||||||
global _ENGINE
|
global _ENGINE
|
||||||
assert _ENGINE
|
assert _ENGINE
|
||||||
base.metadata.drop_all(_ENGINE)
|
base.metadata.drop_all(_ENGINE)
|
||||||
|
@ -50,7 +50,7 @@ AUTO_DELETE_PORT_OWNERS = ['network:dhcp']
|
|||||||
|
|
||||||
|
|
||||||
class QuantumDbPluginV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
|
class QuantumDbPluginV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
|
||||||
""" A class that implements the v2 Quantum plugin interface
|
"""A class that implements the v2 Quantum plugin interface
|
||||||
using SQLAlchemy models. Whenever a non-read call happens
|
using SQLAlchemy models. Whenever a non-read call happens
|
||||||
the plugin will call an event handler class method (e.g.,
|
the plugin will call an event handler class method (e.g.,
|
||||||
network_created()). The result is that this class can be
|
network_created()). The result is that this class can be
|
||||||
@ -120,7 +120,7 @@ class QuantumDbPluginV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def register_model_query_hook(cls, model, name, query_hook, filter_hook,
|
def register_model_query_hook(cls, model, name, query_hook, filter_hook,
|
||||||
result_filters=None):
|
result_filters=None):
|
||||||
""" register an hook to be invoked when a query is executed.
|
"""Register a hook to be invoked when a query is executed.
|
||||||
|
|
||||||
Add the hooks to the _model_query_hooks dict. Models are the keys
|
Add the hooks to the _model_query_hooks dict. Models are the keys
|
||||||
of this dict, whereas the value is another dict mapping hook names to
|
of this dict, whereas the value is another dict mapping hook names to
|
||||||
@ -948,7 +948,7 @@ class QuantumDbPluginV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
|
|||||||
return self._create_bulk('network', context, networks)
|
return self._create_bulk('network', context, networks)
|
||||||
|
|
||||||
def create_network(self, context, network):
|
def create_network(self, context, network):
|
||||||
""" handle creation of a single network """
|
"""Handle creation of a single network."""
|
||||||
# single request processing
|
# single request processing
|
||||||
n = network['network']
|
n = network['network']
|
||||||
# NOTE(jkoelker) Get the tenant_id outside of the session to avoid
|
# NOTE(jkoelker) Get the tenant_id outside of the session to avoid
|
||||||
@ -1026,7 +1026,7 @@ class QuantumDbPluginV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
|
|||||||
return self._create_bulk('subnet', context, subnets)
|
return self._create_bulk('subnet', context, subnets)
|
||||||
|
|
||||||
def _validate_ip_version(self, ip_version, addr, name):
|
def _validate_ip_version(self, ip_version, addr, name):
|
||||||
"""Check IP field of a subnet match specified ip version"""
|
"""Check IP field of a subnet match specified ip version."""
|
||||||
ip = netaddr.IPNetwork(addr)
|
ip = netaddr.IPNetwork(addr)
|
||||||
if ip.version != ip_version:
|
if ip.version != ip_version:
|
||||||
msg = _("%(name)s '%(addr)s' does not match "
|
msg = _("%(name)s '%(addr)s' does not match "
|
||||||
@ -1034,7 +1034,7 @@ class QuantumDbPluginV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
|
|||||||
raise q_exc.InvalidInput(error_message=msg)
|
raise q_exc.InvalidInput(error_message=msg)
|
||||||
|
|
||||||
def _validate_subnet(self, s):
|
def _validate_subnet(self, s):
|
||||||
"""Validate a subnet spec"""
|
"""Validate a subnet spec."""
|
||||||
|
|
||||||
# This method will validate attributes which may change during
|
# This method will validate attributes which may change during
|
||||||
# create_subnet() and update_subnet().
|
# create_subnet() and update_subnet().
|
||||||
@ -1155,7 +1155,8 @@ class QuantumDbPluginV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
|
|||||||
def update_subnet(self, context, id, subnet):
|
def update_subnet(self, context, id, subnet):
|
||||||
"""Update the subnet with new info. The change however will not be
|
"""Update the subnet with new info. The change however will not be
|
||||||
realized until the client renew the dns lease or we support
|
realized until the client renew the dns lease or we support
|
||||||
gratuitous DHCP offers"""
|
gratuitous DHCP offers
|
||||||
|
"""
|
||||||
|
|
||||||
s = subnet['subnet']
|
s = subnet['subnet']
|
||||||
db_subnet = self._get_subnet(context, id)
|
db_subnet = self._get_subnet(context, id)
|
||||||
|
@ -46,7 +46,7 @@ class RouterRoute(model_base.BASEV2, models_v2.Route):
|
|||||||
|
|
||||||
|
|
||||||
class ExtraRoute_db_mixin(l3_db.L3_NAT_db_mixin):
|
class ExtraRoute_db_mixin(l3_db.L3_NAT_db_mixin):
|
||||||
""" Mixin class to support extra route configuration on router"""
|
"""Mixin class to support extra route configuration on router."""
|
||||||
def update_router(self, context, id, router):
|
def update_router(self, context, id, router):
|
||||||
r = router['router']
|
r = router['router']
|
||||||
with context.session.begin(subtransactions=True):
|
with context.session.begin(subtransactions=True):
|
||||||
|
@ -75,7 +75,7 @@ class FloatingIP(model_base.BASEV2, models_v2.HasId, models_v2.HasTenant):
|
|||||||
|
|
||||||
|
|
||||||
class L3_NAT_db_mixin(l3.RouterPluginBase):
|
class L3_NAT_db_mixin(l3.RouterPluginBase):
|
||||||
"""Mixin class to add L3/NAT router methods to db_plugin_base_v2"""
|
"""Mixin class to add L3/NAT router methods to db_plugin_base_v2."""
|
||||||
|
|
||||||
def _network_model_hook(self, context, original_model, query):
|
def _network_model_hook(self, context, original_model, query):
|
||||||
query = query.outerjoin(ExternalNetwork,
|
query = query.outerjoin(ExternalNetwork,
|
||||||
@ -717,7 +717,7 @@ class L3_NAT_db_mixin(l3.RouterPluginBase):
|
|||||||
filters=filters)
|
filters=filters)
|
||||||
|
|
||||||
def prevent_l3_port_deletion(self, context, port_id):
|
def prevent_l3_port_deletion(self, context, port_id):
|
||||||
""" Checks to make sure a port is allowed to be deleted, raising
|
"""Checks to make sure a port is allowed to be deleted, raising
|
||||||
an exception if this is not the case. This should be called by
|
an exception if this is not the case. This should be called by
|
||||||
any plugin when the API requests the deletion of a port, since
|
any plugin when the API requests the deletion of a port, since
|
||||||
some ports for L3 are not intended to be deleted directly via a
|
some ports for L3 are not intended to be deleted directly via a
|
||||||
|
@ -48,7 +48,7 @@ class SessionPersistence(model_base.BASEV2):
|
|||||||
|
|
||||||
|
|
||||||
class PoolStatistics(model_base.BASEV2):
|
class PoolStatistics(model_base.BASEV2):
|
||||||
"""Represents pool statistics """
|
"""Represents pool statistics."""
|
||||||
pool_id = sa.Column(sa.String(36), sa.ForeignKey("pools.id"),
|
pool_id = sa.Column(sa.String(36), sa.ForeignKey("pools.id"),
|
||||||
primary_key=True)
|
primary_key=True)
|
||||||
bytes_in = sa.Column(sa.Integer, nullable=False)
|
bytes_in = sa.Column(sa.Integer, nullable=False)
|
||||||
@ -274,7 +274,7 @@ class LoadBalancerPluginDb(LoadBalancerPluginBase):
|
|||||||
return self._fields(res, fields)
|
return self._fields(res, fields)
|
||||||
|
|
||||||
def _check_session_persistence_info(self, info):
|
def _check_session_persistence_info(self, info):
|
||||||
""" Performs sanity check on session persistence info.
|
"""Performs sanity check on session persistence info.
|
||||||
:param info: Session persistence info
|
:param info: Session persistence info
|
||||||
"""
|
"""
|
||||||
if info['type'] == 'APP_COOKIE':
|
if info['type'] == 'APP_COOKIE':
|
||||||
|
@ -39,13 +39,14 @@ class QuantumBase(object):
|
|||||||
return n, getattr(self, n)
|
return n, getattr(self, n)
|
||||||
|
|
||||||
def update(self, values):
|
def update(self, values):
|
||||||
"""Make the model object behave like a dict"""
|
"""Make the model object behave like a dict."""
|
||||||
for k, v in values.iteritems():
|
for k, v in values.iteritems():
|
||||||
setattr(self, k, v)
|
setattr(self, k, v)
|
||||||
|
|
||||||
def iteritems(self):
|
def iteritems(self):
|
||||||
"""Make the model object behave like a dict.
|
"""Make the model object behave like a dict.
|
||||||
Includes attributes from joins."""
|
Includes attributes from joins.
|
||||||
|
"""
|
||||||
local = dict(self)
|
local = dict(self)
|
||||||
joined = dict([(k, v) for k, v in self.__dict__.iteritems()
|
joined = dict([(k, v) for k, v in self.__dict__.iteritems()
|
||||||
if not k[0] == '_'])
|
if not k[0] == '_'])
|
||||||
@ -53,7 +54,7 @@ class QuantumBase(object):
|
|||||||
return local.iteritems()
|
return local.iteritems()
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
"""sqlalchemy based automatic __repr__ method"""
|
"""sqlalchemy based automatic __repr__ method."""
|
||||||
items = ['%s=%r' % (col.name, getattr(self, col.name))
|
items = ['%s=%r' % (col.name, getattr(self, col.name))
|
||||||
for col in self.__table__.columns]
|
for col in self.__table__.columns]
|
||||||
return "<%s.%s[object at %x] {%s}>" % (self.__class__.__module__,
|
return "<%s.%s[object at %x] {%s}>" % (self.__class__.__module__,
|
||||||
|
@ -35,7 +35,7 @@ class SecurityGroup(model_base.BASEV2, models_v2.HasId, models_v2.HasTenant):
|
|||||||
|
|
||||||
|
|
||||||
class SecurityGroupPortBinding(model_base.BASEV2):
|
class SecurityGroupPortBinding(model_base.BASEV2):
|
||||||
"""Represents binding between quantum ports and security profiles"""
|
"""Represents binding between quantum ports and security profiles."""
|
||||||
port_id = sa.Column(sa.String(36),
|
port_id = sa.Column(sa.String(36),
|
||||||
sa.ForeignKey("ports.id",
|
sa.ForeignKey("ports.id",
|
||||||
ondelete='CASCADE'),
|
ondelete='CASCADE'),
|
||||||
@ -450,7 +450,8 @@ class SecurityGroupDbMixin(ext_sg.SecurityGroupPluginBase):
|
|||||||
|
|
||||||
def _check_update_deletes_security_groups(self, port):
|
def _check_update_deletes_security_groups(self, port):
|
||||||
"""Return True if port has as a security group and it's value
|
"""Return True if port has as a security group and it's value
|
||||||
is either [] or not is_attr_set, otherwise return False"""
|
is either [] or not is_attr_set, otherwise return False
|
||||||
|
"""
|
||||||
if (ext_sg.SECURITYGROUPS in port['port'] and
|
if (ext_sg.SECURITYGROUPS in port['port'] and
|
||||||
not (attr.is_attr_set(port['port'][ext_sg.SECURITYGROUPS])
|
not (attr.is_attr_set(port['port'][ext_sg.SECURITYGROUPS])
|
||||||
and port['port'][ext_sg.SECURITYGROUPS] != [])):
|
and port['port'][ext_sg.SECURITYGROUPS] != [])):
|
||||||
@ -459,7 +460,8 @@ class SecurityGroupDbMixin(ext_sg.SecurityGroupPluginBase):
|
|||||||
|
|
||||||
def _check_update_has_security_groups(self, port):
|
def _check_update_has_security_groups(self, port):
|
||||||
"""Return True if port has as a security group and False if the
|
"""Return True if port has as a security group and False if the
|
||||||
security_group field is is_attr_set or []."""
|
security_group field is is_attr_set or [].
|
||||||
|
"""
|
||||||
if (ext_sg.SECURITYGROUPS in port['port'] and
|
if (ext_sg.SECURITYGROUPS in port['port'] and
|
||||||
(attr.is_attr_set(port['port'][ext_sg.SECURITYGROUPS]) and
|
(attr.is_attr_set(port['port'][ext_sg.SECURITYGROUPS]) and
|
||||||
port['port'][ext_sg.SECURITYGROUPS] != [])):
|
port['port'][ext_sg.SECURITYGROUPS] != [])):
|
||||||
|
@ -63,7 +63,7 @@ class SecurityGroupServerRpcMixin(sg_db.SecurityGroupDbMixin):
|
|||||||
|
|
||||||
def update_security_group_on_port(self, context, id, port,
|
def update_security_group_on_port(self, context, id, port,
|
||||||
original_port, updated_port):
|
original_port, updated_port):
|
||||||
""" update security groups on port
|
"""Update security groups on port.
|
||||||
|
|
||||||
This method returns a flag which indicates request notification
|
This method returns a flag which indicates request notification
|
||||||
is required and does not perform notification itself.
|
is required and does not perform notification itself.
|
||||||
@ -85,7 +85,7 @@ class SecurityGroupServerRpcMixin(sg_db.SecurityGroupDbMixin):
|
|||||||
|
|
||||||
def is_security_group_member_updated(self, context,
|
def is_security_group_member_updated(self, context,
|
||||||
original_port, updated_port):
|
original_port, updated_port):
|
||||||
""" check security group member updated or not
|
"""Check security group member updated or not.
|
||||||
|
|
||||||
This method returns a flag which indicates request notification
|
This method returns a flag which indicates request notification
|
||||||
is required and does not perform notification itself.
|
is required and does not perform notification itself.
|
||||||
@ -102,7 +102,7 @@ class SecurityGroupServerRpcMixin(sg_db.SecurityGroupDbMixin):
|
|||||||
return need_notify
|
return need_notify
|
||||||
|
|
||||||
def notify_security_groups_member_updated(self, context, port):
|
def notify_security_groups_member_updated(self, context, port):
|
||||||
""" notify update event of security group members
|
"""Notify update event of security group members.
|
||||||
|
|
||||||
The agent setups the iptables rule to allow
|
The agent setups the iptables rule to allow
|
||||||
ingress packet from the dhcp server (as a part of provider rules),
|
ingress packet from the dhcp server (as a part of provider rules),
|
||||||
@ -126,7 +126,7 @@ class SecurityGroupServerRpcCallbackMixin(object):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def security_group_rules_for_devices(self, context, **kwargs):
|
def security_group_rules_for_devices(self, context, **kwargs):
|
||||||
""" return security group rules for each port
|
"""Return security group rules for each port.
|
||||||
|
|
||||||
also convert remote_group_id rule
|
also convert remote_group_id rule
|
||||||
to source_ip_prefix and dest_ip_prefix rule
|
to source_ip_prefix and dest_ip_prefix rule
|
||||||
|
@ -48,7 +48,7 @@ cfg.CONF.register_opts(default_servicetype_opts, 'DEFAULT_SERVICETYPE')
|
|||||||
|
|
||||||
|
|
||||||
def parse_service_definition_opt():
|
def parse_service_definition_opt():
|
||||||
""" parse service definition opts and returns result """
|
"""Parse service definition opts and returns result."""
|
||||||
results = []
|
results = []
|
||||||
svc_def_opt = cfg.CONF.DEFAULT_SERVICETYPE.service_definition
|
svc_def_opt = cfg.CONF.DEFAULT_SERVICETYPE.service_definition
|
||||||
try:
|
try:
|
||||||
@ -96,7 +96,7 @@ class ServiceDefinition(model_base.BASEV2, models_v2.HasId):
|
|||||||
|
|
||||||
|
|
||||||
class ServiceType(model_base.BASEV2, models_v2.HasId, models_v2.HasTenant):
|
class ServiceType(model_base.BASEV2, models_v2.HasId, models_v2.HasTenant):
|
||||||
""" Service Type Object Model """
|
"""Service Type Object Model."""
|
||||||
name = sa.Column(sa.String(255))
|
name = sa.Column(sa.String(255))
|
||||||
description = sa.Column(sa.String(255))
|
description = sa.Column(sa.String(255))
|
||||||
default = sa.Column(sa.Boolean(), nullable=False, default=False)
|
default = sa.Column(sa.Boolean(), nullable=False, default=False)
|
||||||
@ -108,7 +108,7 @@ class ServiceType(model_base.BASEV2, models_v2.HasId, models_v2.HasTenant):
|
|||||||
num_instances = sa.Column(sa.Integer(), default=0)
|
num_instances = sa.Column(sa.Integer(), default=0)
|
||||||
|
|
||||||
def as_dict(self):
|
def as_dict(self):
|
||||||
""" Convert a row into a dict """
|
"""Convert a row into a dict."""
|
||||||
ret_dict = {}
|
ret_dict = {}
|
||||||
for c in self.__table__.columns:
|
for c in self.__table__.columns:
|
||||||
ret_dict[c.name] = getattr(self, c.name)
|
ret_dict[c.name] = getattr(self, c.name)
|
||||||
@ -116,7 +116,7 @@ class ServiceType(model_base.BASEV2, models_v2.HasId, models_v2.HasTenant):
|
|||||||
|
|
||||||
|
|
||||||
class ServiceTypeManager(object):
|
class ServiceTypeManager(object):
|
||||||
""" Manage service type objects in Quantum database """
|
"""Manage service type objects in Quantum database."""
|
||||||
|
|
||||||
_instance = None
|
_instance = None
|
||||||
|
|
||||||
@ -254,13 +254,13 @@ class ServiceTypeManager(object):
|
|||||||
return res
|
return res
|
||||||
|
|
||||||
def get_service_type(self, context, id, fields=None):
|
def get_service_type(self, context, id, fields=None):
|
||||||
""" Retrieve a service type record """
|
"""Retrieve a service type record."""
|
||||||
return self._make_svc_type_dict(context,
|
return self._make_svc_type_dict(context,
|
||||||
self._get_service_type(context, id),
|
self._get_service_type(context, id),
|
||||||
fields)
|
fields)
|
||||||
|
|
||||||
def get_service_types(self, context, fields=None, filters=None):
|
def get_service_types(self, context, fields=None, filters=None):
|
||||||
""" Retrieve a possibly filtered list of service types """
|
"""Retrieve a possibly filtered list of service types."""
|
||||||
query = context.session.query(ServiceType)
|
query = context.session.query(ServiceType)
|
||||||
if filters:
|
if filters:
|
||||||
for key, value in filters.iteritems():
|
for key, value in filters.iteritems():
|
||||||
@ -271,21 +271,21 @@ class ServiceTypeManager(object):
|
|||||||
for svc_type in query.all()]
|
for svc_type in query.all()]
|
||||||
|
|
||||||
def create_service_type(self, context, service_type):
|
def create_service_type(self, context, service_type):
|
||||||
""" Create a new service type """
|
"""Create a new service type."""
|
||||||
svc_type_data = service_type['service_type']
|
svc_type_data = service_type['service_type']
|
||||||
svc_type_db = self._create_service_type(context, svc_type_data)
|
svc_type_db = self._create_service_type(context, svc_type_data)
|
||||||
LOG.debug(_("Created service type object:%s"), svc_type_db['id'])
|
LOG.debug(_("Created service type object:%s"), svc_type_db['id'])
|
||||||
return self._make_svc_type_dict(context, svc_type_db)
|
return self._make_svc_type_dict(context, svc_type_db)
|
||||||
|
|
||||||
def update_service_type(self, context, id, service_type):
|
def update_service_type(self, context, id, service_type):
|
||||||
""" Update a service type """
|
"""Update a service type."""
|
||||||
svc_type_data = service_type['service_type']
|
svc_type_data = service_type['service_type']
|
||||||
svc_type_db = self._update_service_type(context, id,
|
svc_type_db = self._update_service_type(context, id,
|
||||||
svc_type_data)
|
svc_type_data)
|
||||||
return self._make_svc_type_dict(context, svc_type_db)
|
return self._make_svc_type_dict(context, svc_type_db)
|
||||||
|
|
||||||
def delete_service_type(self, context, id):
|
def delete_service_type(self, context, id):
|
||||||
""" Delete a service type """
|
"""Delete a service type."""
|
||||||
# Verify that the service type is not in use.
|
# Verify that the service type is not in use.
|
||||||
svc_type_db = self._get_service_type(context, id)
|
svc_type_db = self._get_service_type(context, id)
|
||||||
if svc_type_db['num_instances'] > 0:
|
if svc_type_db['num_instances'] > 0:
|
||||||
@ -294,7 +294,7 @@ class ServiceTypeManager(object):
|
|||||||
context.session.delete(svc_type_db)
|
context.session.delete(svc_type_db)
|
||||||
|
|
||||||
def increase_service_type_refcount(self, context, id):
|
def increase_service_type_refcount(self, context, id):
|
||||||
""" Increase references count for a service type object
|
"""Increase references count for a service type object
|
||||||
|
|
||||||
This method should be invoked by plugins using the service
|
This method should be invoked by plugins using the service
|
||||||
type concept everytime an instance of an object associated
|
type concept everytime an instance of an object associated
|
||||||
@ -309,7 +309,7 @@ class ServiceTypeManager(object):
|
|||||||
return svc_type_db['num_instances']
|
return svc_type_db['num_instances']
|
||||||
|
|
||||||
def decrease_service_type_refcount(self, context, id):
|
def decrease_service_type_refcount(self, context, id):
|
||||||
""" Decrease references count for a service type object
|
"""Decrease references count for a service type object
|
||||||
|
|
||||||
This method should be invoked by plugins using the service
|
This method should be invoked by plugins using the service
|
||||||
type concept everytime an instance of an object associated
|
type concept everytime an instance of an object associated
|
||||||
|
@ -59,7 +59,7 @@ class CreateProbe(ProbeCommand):
|
|||||||
|
|
||||||
|
|
||||||
class DeleteProbe(ProbeCommand):
|
class DeleteProbe(ProbeCommand):
|
||||||
"""Delete probe - delete port then uplug """
|
"""Delete probe - delete port then uplug."""
|
||||||
|
|
||||||
log = logging.getLogger(__name__ + '.DeleteProbe')
|
log = logging.getLogger(__name__ + '.DeleteProbe')
|
||||||
|
|
||||||
@ -78,7 +78,7 @@ class DeleteProbe(ProbeCommand):
|
|||||||
|
|
||||||
|
|
||||||
class ListProbe(QuantumCommand, lister.Lister):
|
class ListProbe(QuantumCommand, lister.Lister):
|
||||||
""" List probes """
|
"""List probes."""
|
||||||
|
|
||||||
log = logging.getLogger(__name__ + '.ListProbe')
|
log = logging.getLogger(__name__ + '.ListProbe')
|
||||||
_formatters = {'fixed_ips': _format_fixed_ips, }
|
_formatters = {'fixed_ips': _format_fixed_ips, }
|
||||||
@ -97,7 +97,7 @@ class ListProbe(QuantumCommand, lister.Lister):
|
|||||||
|
|
||||||
|
|
||||||
class ClearProbe(ProbeCommand):
|
class ClearProbe(ProbeCommand):
|
||||||
"""Clear All probes """
|
"""Clear All probes."""
|
||||||
|
|
||||||
log = logging.getLogger(__name__ + '.ClearProbe')
|
log = logging.getLogger(__name__ + '.ClearProbe')
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ class QuantumDebugAgent():
|
|||||||
namespace=namespace)
|
namespace=namespace)
|
||||||
try:
|
try:
|
||||||
ip.netns.delete(namespace)
|
ip.netns.delete(namespace)
|
||||||
except:
|
except Exception:
|
||||||
LOG.warn(_('Failed to delete namespace %s'), namespace)
|
LOG.warn(_('Failed to delete namespace %s'), namespace)
|
||||||
else:
|
else:
|
||||||
self.driver.unplug(self.driver.get_device_name(port),
|
self.driver.unplug(self.driver.get_device_name(port),
|
||||||
|
@ -72,7 +72,7 @@ class MultipleAgentFoundByTypeHost(exceptions.Conflict):
|
|||||||
|
|
||||||
|
|
||||||
class Agent(object):
|
class Agent(object):
|
||||||
"""Agent management extension"""
|
"""Agent management extension."""
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_name(cls):
|
def get_name(cls):
|
||||||
@ -96,7 +96,7 @@ class Agent(object):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_resources(cls):
|
def get_resources(cls):
|
||||||
""" Returns Ext Resources """
|
"""Returns Ext Resources."""
|
||||||
my_plurals = [(key, key[:-1]) for key in RESOURCE_ATTRIBUTE_MAP.keys()]
|
my_plurals = [(key, key[:-1]) for key in RESOURCE_ATTRIBUTE_MAP.keys()]
|
||||||
attr.PLURALS.update(dict(my_plurals))
|
attr.PLURALS.update(dict(my_plurals))
|
||||||
plugin = manager.QuantumManager.get_plugin()
|
plugin = manager.QuantumManager.get_plugin()
|
||||||
@ -116,13 +116,13 @@ class Agent(object):
|
|||||||
|
|
||||||
|
|
||||||
class AgentPluginBase(object):
|
class AgentPluginBase(object):
|
||||||
""" REST API to operate the Agent.
|
"""REST API to operate the Agent.
|
||||||
|
|
||||||
All of method must be in an admin context.
|
All of method must be in an admin context.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def create_agent(self, context, agent):
|
def create_agent(self, context, agent):
|
||||||
""" Create agent.
|
"""Create agent.
|
||||||
|
|
||||||
This operation is not allow in REST API.
|
This operation is not allow in REST API.
|
||||||
@raise exceptions.BadRequest:
|
@raise exceptions.BadRequest:
|
||||||
|
@ -145,7 +145,7 @@ class Agentscheduler(extensions.ExtensionDescriptor):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_resources(cls):
|
def get_resources(cls):
|
||||||
"""Returns Ext Resources """
|
"""Returns Ext Resources."""
|
||||||
exts = []
|
exts = []
|
||||||
parent = dict(member_name="agent",
|
parent = dict(member_name="agent",
|
||||||
collection_name="agents")
|
collection_name="agents")
|
||||||
@ -214,7 +214,7 @@ class RouterNotHostedByL3Agent(exceptions.Conflict):
|
|||||||
|
|
||||||
|
|
||||||
class AgentSchedulerPluginBase(object):
|
class AgentSchedulerPluginBase(object):
|
||||||
""" REST API to operate the agent scheduler.
|
"""REST API to operate the agent scheduler.
|
||||||
|
|
||||||
All of method must be in an admin context.
|
All of method must be in an admin context.
|
||||||
"""
|
"""
|
||||||
|
@ -187,7 +187,7 @@ class L3(extensions.ExtensionDescriptor):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_resources(cls):
|
def get_resources(cls):
|
||||||
""" Returns Ext Resources """
|
"""Returns Ext Resources."""
|
||||||
my_plurals = [(key, key[:-1]) for key in RESOURCE_ATTRIBUTE_MAP.keys()]
|
my_plurals = [(key, key[:-1]) for key in RESOURCE_ATTRIBUTE_MAP.keys()]
|
||||||
attr.PLURALS.update(dict(my_plurals))
|
attr.PLURALS.update(dict(my_plurals))
|
||||||
exts = []
|
exts = []
|
||||||
|
@ -104,7 +104,7 @@ class QuotaSetsController(wsgi.Controller):
|
|||||||
|
|
||||||
|
|
||||||
class Quotasv2(extensions.ExtensionDescriptor):
|
class Quotasv2(extensions.ExtensionDescriptor):
|
||||||
"""Quotas management support"""
|
"""Quotas management support."""
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_name(cls):
|
def get_name(cls):
|
||||||
@ -131,7 +131,7 @@ class Quotasv2(extensions.ExtensionDescriptor):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_resources(cls):
|
def get_resources(cls):
|
||||||
""" Returns Ext Resources """
|
"""Returns Ext Resources."""
|
||||||
controller = resource.Resource(
|
controller = resource.Resource(
|
||||||
QuotaSetsController(QuantumManager.get_plugin()),
|
QuotaSetsController(QuantumManager.get_plugin()),
|
||||||
faults=base.FAULT_MAP)
|
faults=base.FAULT_MAP)
|
||||||
|
@ -216,7 +216,7 @@ cfg.CONF.register_opts(security_group_quota_opts, 'QUOTAS')
|
|||||||
|
|
||||||
|
|
||||||
class Securitygroup(extensions.ExtensionDescriptor):
|
class Securitygroup(extensions.ExtensionDescriptor):
|
||||||
""" Security group extension"""
|
"""Security group extension."""
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_name(cls):
|
def get_name(cls):
|
||||||
@ -241,7 +241,7 @@ class Securitygroup(extensions.ExtensionDescriptor):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_resources(cls):
|
def get_resources(cls):
|
||||||
""" Returns Ext Resources """
|
"""Returns Ext Resources."""
|
||||||
my_plurals = [(key, key[:-1]) for key in RESOURCE_ATTRIBUTE_MAP.keys()]
|
my_plurals = [(key, key[:-1]) for key in RESOURCE_ATTRIBUTE_MAP.keys()]
|
||||||
attr.PLURALS.update(dict(my_plurals))
|
attr.PLURALS.update(dict(my_plurals))
|
||||||
exts = []
|
exts = []
|
||||||
|
@ -72,7 +72,7 @@ def set_default_svctype_id(original_id):
|
|||||||
|
|
||||||
|
|
||||||
def _validate_servicetype_ref(data, valid_values=None):
|
def _validate_servicetype_ref(data, valid_values=None):
|
||||||
""" Verify the service type id exists """
|
"""Verify the service type id exists."""
|
||||||
svc_type_id = data
|
svc_type_id = data
|
||||||
svctype_mgr = servicetype_db.ServiceTypeManager.get_instance()
|
svctype_mgr = servicetype_db.ServiceTypeManager.get_instance()
|
||||||
try:
|
try:
|
||||||
@ -83,7 +83,7 @@ def _validate_servicetype_ref(data, valid_values=None):
|
|||||||
|
|
||||||
|
|
||||||
def _validate_service_defs(data, valid_values=None):
|
def _validate_service_defs(data, valid_values=None):
|
||||||
""" Validate the list of service definitions. """
|
"""Validate the list of service definitions."""
|
||||||
try:
|
try:
|
||||||
if not data:
|
if not data:
|
||||||
return _("No service type definition was provided. At least a "
|
return _("No service type definition was provided. At least a "
|
||||||
@ -182,7 +182,7 @@ class Servicetype(extensions.ExtensionDescriptor):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_resources(cls):
|
def get_resources(cls):
|
||||||
""" Returns Extended Resource for service type management """
|
"""Returns Extended Resource for service type management."""
|
||||||
my_plurals = [(key.replace('-', '_'),
|
my_plurals = [(key.replace('-', '_'),
|
||||||
key[:-1].replace('-', '_')) for
|
key[:-1].replace('-', '_')) for
|
||||||
key in RESOURCE_ATTRIBUTE_MAP.keys()]
|
key in RESOURCE_ATTRIBUTE_MAP.keys()]
|
||||||
|
@ -97,7 +97,7 @@ class QuantumManager(object):
|
|||||||
|
|
||||||
# core plugin as a part of plugin collection simplifies
|
# core plugin as a part of plugin collection simplifies
|
||||||
# checking extensions
|
# checking extensions
|
||||||
# TODO (enikanorov): make core plugin the same as
|
# TODO(enikanorov): make core plugin the same as
|
||||||
# the rest of service plugins
|
# the rest of service plugins
|
||||||
self.service_plugins = {constants.CORE: self.plugin}
|
self.service_plugins = {constants.CORE: self.plugin}
|
||||||
self._load_service_plugins()
|
self._load_service_plugins()
|
||||||
|
@ -789,7 +789,7 @@ class QuantumRestProxyV2(db_base_plugin_v2.QuantumDbPluginV2,
|
|||||||
try:
|
try:
|
||||||
self._send_update_network(orig_net)
|
self._send_update_network(orig_net)
|
||||||
except RemoteRestError:
|
except RemoteRestError:
|
||||||
# TODO (Sumit): rollback deletion of subnet
|
# TODO(Sumit): rollback deletion of subnet
|
||||||
raise
|
raise
|
||||||
|
|
||||||
def create_router(self, context, router):
|
def create_router(self, context, router):
|
||||||
|
@ -120,7 +120,7 @@ class TestNetworkCtrl(object):
|
|||||||
if request_data:
|
if request_data:
|
||||||
try:
|
try:
|
||||||
request_data = json.loads(request_data)
|
request_data = json.loads(request_data)
|
||||||
except:
|
except Exception:
|
||||||
# OK for it not to be json! Ignore it
|
# OK for it not to be json! Ignore it
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -141,7 +141,7 @@ class TestNetworkCtrl(object):
|
|||||||
if body:
|
if body:
|
||||||
try:
|
try:
|
||||||
body_data = json.loads(body)
|
body_data = json.loads(body)
|
||||||
except:
|
except Exception:
|
||||||
# OK for it not to be json! Ignore it
|
# OK for it not to be json! Ignore it
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
# Varma Bhupatiraju (vbhupati@#brocade.com)
|
# Varma Bhupatiraju (vbhupati@#brocade.com)
|
||||||
#
|
#
|
||||||
# (Some parts adapted from LinuxBridge Plugin)
|
# (Some parts adapted from LinuxBridge Plugin)
|
||||||
# TODO (shiv) need support for security groups
|
# TODO(shiv) need support for security groups
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
@ -66,7 +66,8 @@ class NOSdriver():
|
|||||||
LOG.debug(_("Connect failed to switch: %s"), e)
|
LOG.debug(_("Connect failed to switch: %s"), e)
|
||||||
raise
|
raise
|
||||||
|
|
||||||
LOG.debug(_("Connect success to host %s:%d"), host, SSH_PORT)
|
LOG.debug(_("Connect success to host %(host)s:%(ssh_port)d"),
|
||||||
|
dict(host=host, ssh_port=SSH_PORT))
|
||||||
return mgr
|
return mgr
|
||||||
|
|
||||||
def create_network(self, host, username, password, net_id):
|
def create_network(self, host, username, password, net_id):
|
||||||
|
@ -18,9 +18,9 @@
|
|||||||
|
|
||||||
import logging as LOG
|
import logging as LOG
|
||||||
|
|
||||||
from quantum.plugins.cisco.common import config
|
|
||||||
from quantum.plugins.cisco.common import cisco_constants as const
|
from quantum.plugins.cisco.common import cisco_constants as const
|
||||||
from quantum.plugins.cisco.common import cisco_exceptions as cexc
|
from quantum.plugins.cisco.common import cisco_exceptions as cexc
|
||||||
|
from quantum.plugins.cisco.common import config
|
||||||
from quantum.plugins.cisco.db import network_db_v2 as cdb
|
from quantum.plugins.cisco.db import network_db_v2 as cdb
|
||||||
|
|
||||||
|
|
||||||
@ -33,7 +33,7 @@ _nexus_dict = config.get_nexus_dictionary()
|
|||||||
|
|
||||||
|
|
||||||
class Store(object):
|
class Store(object):
|
||||||
"""Credential Store"""
|
"""Credential Store."""
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def initialize():
|
def initialize():
|
||||||
@ -51,29 +51,29 @@ class Store(object):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def put_credential(cred_name, username, password):
|
def put_credential(cred_name, username, password):
|
||||||
"""Set the username and password"""
|
"""Set the username and password."""
|
||||||
cdb.add_credential(TENANT, cred_name, username, password)
|
cdb.add_credential(TENANT, cred_name, username, password)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_username(cred_name):
|
def get_username(cred_name):
|
||||||
"""Get the username"""
|
"""Get the username."""
|
||||||
credential = cdb.get_credential_name(TENANT, cred_name)
|
credential = cdb.get_credential_name(TENANT, cred_name)
|
||||||
return credential[const.CREDENTIAL_USERNAME]
|
return credential[const.CREDENTIAL_USERNAME]
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_password(cred_name):
|
def get_password(cred_name):
|
||||||
"""Get the password"""
|
"""Get the password."""
|
||||||
credential = cdb.get_credential_name(TENANT, cred_name)
|
credential = cdb.get_credential_name(TENANT, cred_name)
|
||||||
return credential[const.CREDENTIAL_PASSWORD]
|
return credential[const.CREDENTIAL_PASSWORD]
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_credential(cred_name):
|
def get_credential(cred_name):
|
||||||
"""Get the username and password"""
|
"""Get the username and password."""
|
||||||
cdb.get_credential_name(TENANT, cred_name)
|
cdb.get_credential_name(TENANT, cred_name)
|
||||||
return {const.USERNAME: const.CREDENTIAL_USERNAME,
|
return {const.USERNAME: const.CREDENTIAL_USERNAME,
|
||||||
const.PASSWORD: const.CREDENTIAL_PASSWORD}
|
const.PASSWORD: const.CREDENTIAL_PASSWORD}
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def delete_credential(cred_name):
|
def delete_credential(cred_name):
|
||||||
"""Delete a credential"""
|
"""Delete a credential."""
|
||||||
cdb.remove_credential(TENANT, cred_name)
|
cdb.remove_credential(TENANT, cred_name)
|
||||||
|
@ -25,116 +25,116 @@ from quantum.common import exceptions
|
|||||||
|
|
||||||
|
|
||||||
class NoMoreNics(exceptions.QuantumException):
|
class NoMoreNics(exceptions.QuantumException):
|
||||||
"""No more dynamic nics are available in the system"""
|
"""No more dynamic nics are available in the system."""
|
||||||
message = _("Unable to complete operation. No more dynamic nics are "
|
message = _("Unable to complete operation. No more dynamic nics are "
|
||||||
"available in the system.")
|
"available in the system.")
|
||||||
|
|
||||||
|
|
||||||
class NetworksLimit(exceptions.QuantumException):
|
class NetworksLimit(exceptions.QuantumException):
|
||||||
"""Total number of network objects limit has been hit"""
|
"""Total number of network objects limit has been hit."""
|
||||||
message = _("Unable to create new network. Number of networks"
|
message = _("Unable to create new network. Number of networks"
|
||||||
"for the system has exceeded the limit")
|
"for the system has exceeded the limit")
|
||||||
|
|
||||||
|
|
||||||
class NetworkVlanBindingAlreadyExists(exceptions.QuantumException):
|
class NetworkVlanBindingAlreadyExists(exceptions.QuantumException):
|
||||||
"""Binding cannot be created, since it already exists"""
|
"""Binding cannot be created, since it already exists."""
|
||||||
message = _("NetworkVlanBinding for %(vlan_id)s and network "
|
message = _("NetworkVlanBinding for %(vlan_id)s and network "
|
||||||
"%(network_id)s already exists")
|
"%(network_id)s already exists")
|
||||||
|
|
||||||
|
|
||||||
class VlanIDNotFound(exceptions.QuantumException):
|
class VlanIDNotFound(exceptions.QuantumException):
|
||||||
"""VLAN ID cannot be found"""
|
"""VLAN ID cannot be found."""
|
||||||
message = _("Vlan ID %(vlan_id)s not found")
|
message = _("Vlan ID %(vlan_id)s not found")
|
||||||
|
|
||||||
|
|
||||||
class VlanIDNotAvailable(exceptions.QuantumException):
|
class VlanIDNotAvailable(exceptions.QuantumException):
|
||||||
"""No VLAN ID available"""
|
"""No VLAN ID available."""
|
||||||
message = _("No Vlan ID available")
|
message = _("No Vlan ID available")
|
||||||
|
|
||||||
|
|
||||||
class QosNotFound(exceptions.QuantumException):
|
class QosNotFound(exceptions.QuantumException):
|
||||||
"""QoS level with this ID cannot be found"""
|
"""QoS level with this ID cannot be found."""
|
||||||
message = _("QoS level %(qos_id)s could not be found "
|
message = _("QoS level %(qos_id)s could not be found "
|
||||||
"for tenant %(tenant_id)s")
|
"for tenant %(tenant_id)s")
|
||||||
|
|
||||||
|
|
||||||
class QoSLevelInvalidDelete(exceptions.QuantumException):
|
class QoSLevelInvalidDelete(exceptions.QuantumException):
|
||||||
"""QoS is associated with a port profile, hence cannot be deleted"""
|
"""QoS is associated with a port profile, hence cannot be deleted."""
|
||||||
message = _("QoS level %(qos_id)s could not be deleted "
|
message = _("QoS level %(qos_id)s could not be deleted "
|
||||||
"for tenant %(tenant_id)s since association exists")
|
"for tenant %(tenant_id)s since association exists")
|
||||||
|
|
||||||
|
|
||||||
class QosNameAlreadyExists(exceptions.QuantumException):
|
class QosNameAlreadyExists(exceptions.QuantumException):
|
||||||
"""QoS Name already exists"""
|
"""QoS Name already exists."""
|
||||||
message = _("QoS level with name %(qos_name)s already exists "
|
message = _("QoS level with name %(qos_name)s already exists "
|
||||||
"for tenant %(tenant_id)s")
|
"for tenant %(tenant_id)s")
|
||||||
|
|
||||||
|
|
||||||
class CredentialNotFound(exceptions.QuantumException):
|
class CredentialNotFound(exceptions.QuantumException):
|
||||||
"""Credential with this ID cannot be found"""
|
"""Credential with this ID cannot be found."""
|
||||||
message = _("Credential %(credential_id)s could not be found "
|
message = _("Credential %(credential_id)s could not be found "
|
||||||
"for tenant %(tenant_id)s")
|
"for tenant %(tenant_id)s")
|
||||||
|
|
||||||
|
|
||||||
class CredentialNameNotFound(exceptions.QuantumException):
|
class CredentialNameNotFound(exceptions.QuantumException):
|
||||||
"""Credential Name could not be found"""
|
"""Credential Name could not be found."""
|
||||||
message = _("Credential %(credential_name)s could not be found "
|
message = _("Credential %(credential_name)s could not be found "
|
||||||
"for tenant %(tenant_id)s")
|
"for tenant %(tenant_id)s")
|
||||||
|
|
||||||
|
|
||||||
class CredentialAlreadyExists(exceptions.QuantumException):
|
class CredentialAlreadyExists(exceptions.QuantumException):
|
||||||
"""Credential ID already exists"""
|
"""Credential ID already exists."""
|
||||||
message = _("Credential %(credential_id)s already exists "
|
message = _("Credential %(credential_id)s already exists "
|
||||||
"for tenant %(tenant_id)s")
|
"for tenant %(tenant_id)s")
|
||||||
|
|
||||||
|
|
||||||
class NexusPortBindingNotFound(exceptions.QuantumException):
|
class NexusPortBindingNotFound(exceptions.QuantumException):
|
||||||
"""NexusPort Binding is not present"""
|
"""NexusPort Binding is not present."""
|
||||||
message = _("Nexus Port Binding %(port_id)s is not present")
|
message = _("Nexus Port Binding %(port_id)s is not present")
|
||||||
|
|
||||||
|
|
||||||
class NexusPortBindingAlreadyExists(exceptions.QuantumException):
|
class NexusPortBindingAlreadyExists(exceptions.QuantumException):
|
||||||
"""NexusPort Binding alredy exists"""
|
"""NexusPort Binding alredy exists."""
|
||||||
message = _("Nexus Port Binding %(port_id)s already exists")
|
message = _("Nexus Port Binding %(port_id)s already exists")
|
||||||
|
|
||||||
|
|
||||||
class UcsmBindingNotFound(exceptions.QuantumException):
|
class UcsmBindingNotFound(exceptions.QuantumException):
|
||||||
"""Ucsm Binding is not present"""
|
"""Ucsm Binding is not present."""
|
||||||
message = _("Ucsm Binding with ip %(ucsm_ip)s is not present")
|
message = _("Ucsm Binding with ip %(ucsm_ip)s is not present")
|
||||||
|
|
||||||
|
|
||||||
class UcsmBindingAlreadyExists(exceptions.QuantumException):
|
class UcsmBindingAlreadyExists(exceptions.QuantumException):
|
||||||
"""Ucsm Binding already exists"""
|
"""Ucsm Binding already exists."""
|
||||||
message = _("Ucsm Binding with ip %(ucsm_ip)s already exists")
|
message = _("Ucsm Binding with ip %(ucsm_ip)s already exists")
|
||||||
|
|
||||||
|
|
||||||
class DynamicVnicNotFound(exceptions.QuantumException):
|
class DynamicVnicNotFound(exceptions.QuantumException):
|
||||||
"""Ucsm Binding is not present"""
|
"""Ucsm Binding is not present."""
|
||||||
message = _("Dyanmic Vnic %(vnic_id)s is not present")
|
message = _("Dyanmic Vnic %(vnic_id)s is not present")
|
||||||
|
|
||||||
|
|
||||||
class DynamicVnicAlreadyExists(exceptions.QuantumException):
|
class DynamicVnicAlreadyExists(exceptions.QuantumException):
|
||||||
"""Ucsm Binding already exists"""
|
"""Ucsm Binding already exists."""
|
||||||
message = _("Dynamic Vnic with name %(device_name)s already exists")
|
message = _("Dynamic Vnic with name %(device_name)s already exists")
|
||||||
|
|
||||||
|
|
||||||
class BladeNotFound(exceptions.QuantumException):
|
class BladeNotFound(exceptions.QuantumException):
|
||||||
"""Blade is not present"""
|
"""Blade is not present."""
|
||||||
message = _("Blade %(blade_id)s is not present")
|
message = _("Blade %(blade_id)s is not present")
|
||||||
|
|
||||||
|
|
||||||
class BladeAlreadyExists(exceptions.QuantumException):
|
class BladeAlreadyExists(exceptions.QuantumException):
|
||||||
"""Blade already exists"""
|
"""Blade already exists."""
|
||||||
message = _("Blade with mgmt_ip %(mgmt_ip)s already exists")
|
message = _("Blade with mgmt_ip %(mgmt_ip)s already exists")
|
||||||
|
|
||||||
|
|
||||||
class PortVnicBindingAlreadyExists(exceptions.QuantumException):
|
class PortVnicBindingAlreadyExists(exceptions.QuantumException):
|
||||||
"""PortVnic Binding already exists"""
|
"""PortVnic Binding already exists."""
|
||||||
message = _("PortVnic Binding %(port_id)s already exists")
|
message = _("PortVnic Binding %(port_id)s already exists")
|
||||||
|
|
||||||
|
|
||||||
class PortVnicNotFound(exceptions.QuantumException):
|
class PortVnicNotFound(exceptions.QuantumException):
|
||||||
"""PortVnic Binding is not present"""
|
"""PortVnic Binding is not present."""
|
||||||
message = _("PortVnic Binding %(port_id)s is not present")
|
message = _("PortVnic Binding %(port_id)s is not present")
|
||||||
|
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ from quantum import wsgi
|
|||||||
|
|
||||||
|
|
||||||
class Fault(webob.exc.HTTPException):
|
class Fault(webob.exc.HTTPException):
|
||||||
"""Error codes for API faults"""
|
"""Error codes for API faults."""
|
||||||
|
|
||||||
_fault_names = {
|
_fault_names = {
|
||||||
400: "malformedRequest",
|
400: "malformedRequest",
|
||||||
@ -42,7 +42,8 @@ class Fault(webob.exc.HTTPException):
|
|||||||
@webob.dec.wsgify(RequestClass=wsgi.Request)
|
@webob.dec.wsgify(RequestClass=wsgi.Request)
|
||||||
def __call__(self, req):
|
def __call__(self, req):
|
||||||
"""Generate a WSGI response based on the
|
"""Generate a WSGI response based on the
|
||||||
exception passed to constructor."""
|
exception passed to constructor.
|
||||||
|
"""
|
||||||
# Replace the body with fault details.
|
# Replace the body with fault details.
|
||||||
code = self.wrapped_exc.status_int
|
code = self.wrapped_exc.status_int
|
||||||
fault_name = self._fault_names.get(code, "quantumServiceFault")
|
fault_name = self._fault_names.get(code, "quantumServiceFault")
|
||||||
|
@ -34,14 +34,14 @@ def get16ByteUUID(uuid):
|
|||||||
|
|
||||||
|
|
||||||
def make_net_dict(net_id, net_name, ports):
|
def make_net_dict(net_id, net_name, ports):
|
||||||
"""Helper funciton"""
|
"""Helper funciton."""
|
||||||
res = {const.NET_ID: net_id, const.NET_NAME: net_name}
|
res = {const.NET_ID: net_id, const.NET_NAME: net_name}
|
||||||
res[const.NET_PORTS] = ports
|
res[const.NET_PORTS] = ports
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
|
||||||
def make_port_dict(port_id, port_state, net_id, attachment):
|
def make_port_dict(port_id, port_state, net_id, attachment):
|
||||||
"""Helper funciton"""
|
"""Helper funciton."""
|
||||||
res = {const.PORT_ID: port_id, const.PORT_STATE: port_state}
|
res = {const.PORT_ID: port_id, const.PORT_STATE: port_state}
|
||||||
res[const.NET_ID] = net_id
|
res[const.NET_ID] = net_id
|
||||||
res[const.ATTACHMENT] = attachment
|
res[const.ATTACHMENT] = attachment
|
||||||
|
@ -87,7 +87,7 @@ nexus_dictionary = {}
|
|||||||
|
|
||||||
|
|
||||||
class CiscoConfigOptions():
|
class CiscoConfigOptions():
|
||||||
""" Cisco Configuration Options Class """
|
"""Cisco Configuration Options Class."""
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self._create_nexus_dictionary()
|
self._create_nexus_dictionary()
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ def clear_db():
|
|||||||
|
|
||||||
|
|
||||||
def get_session(autocommit=True, expire_on_commit=False):
|
def get_session(autocommit=True, expire_on_commit=False):
|
||||||
"""Helper method to grab session"""
|
"""Helper method to grab session."""
|
||||||
global _MAKER, _ENGINE
|
global _MAKER, _ENGINE
|
||||||
if not _MAKER:
|
if not _MAKER:
|
||||||
assert _ENGINE
|
assert _ENGINE
|
||||||
@ -64,14 +64,14 @@ def get_session(autocommit=True, expire_on_commit=False):
|
|||||||
|
|
||||||
|
|
||||||
def register_models():
|
def register_models():
|
||||||
"""Register Models and create properties"""
|
"""Register Models and create properties."""
|
||||||
global _ENGINE
|
global _ENGINE
|
||||||
assert _ENGINE
|
assert _ENGINE
|
||||||
BASE.metadata.create_all(_ENGINE)
|
BASE.metadata.create_all(_ENGINE)
|
||||||
|
|
||||||
|
|
||||||
def unregister_models():
|
def unregister_models():
|
||||||
"""Unregister Models, useful clearing out data before testing"""
|
"""Unregister Models, useful clearing out data before testing."""
|
||||||
global _ENGINE
|
global _ENGINE
|
||||||
assert _ENGINE
|
assert _ENGINE
|
||||||
BASE.metadata.drop_all(_ENGINE)
|
BASE.metadata.drop_all(_ENGINE)
|
||||||
|
@ -30,12 +30,12 @@ LOG = logging.getLogger(__name__)
|
|||||||
|
|
||||||
|
|
||||||
def initialize():
|
def initialize():
|
||||||
"""Establish database connection and load models"""
|
"""Establish database connection and load models."""
|
||||||
db.configure_db()
|
db.configure_db()
|
||||||
|
|
||||||
|
|
||||||
def create_vlanids():
|
def create_vlanids():
|
||||||
"""Prepopulates the vlan_bindings table"""
|
"""Prepopulates the vlan_bindings table."""
|
||||||
LOG.debug(_("create_vlanids() called"))
|
LOG.debug(_("create_vlanids() called"))
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
@ -54,7 +54,7 @@ def create_vlanids():
|
|||||||
|
|
||||||
|
|
||||||
def get_all_vlanids():
|
def get_all_vlanids():
|
||||||
"""Gets all the vlanids"""
|
"""Gets all the vlanids."""
|
||||||
LOG.debug(_("get_all_vlanids() called"))
|
LOG.debug(_("get_all_vlanids() called"))
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
@ -65,7 +65,7 @@ def get_all_vlanids():
|
|||||||
|
|
||||||
|
|
||||||
def is_vlanid_used(vlan_id):
|
def is_vlanid_used(vlan_id):
|
||||||
"""Checks if a vlanid is in use"""
|
"""Checks if a vlanid is in use."""
|
||||||
LOG.debug(_("is_vlanid_used() called"))
|
LOG.debug(_("is_vlanid_used() called"))
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
@ -77,7 +77,7 @@ def is_vlanid_used(vlan_id):
|
|||||||
|
|
||||||
|
|
||||||
def release_vlanid(vlan_id):
|
def release_vlanid(vlan_id):
|
||||||
"""Sets the vlanid state to be unused"""
|
"""Sets the vlanid state to be unused."""
|
||||||
LOG.debug(_("release_vlanid() called"))
|
LOG.debug(_("release_vlanid() called"))
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
@ -93,7 +93,7 @@ def release_vlanid(vlan_id):
|
|||||||
|
|
||||||
|
|
||||||
def delete_vlanid(vlan_id):
|
def delete_vlanid(vlan_id):
|
||||||
"""Deletes a vlanid entry from db"""
|
"""Deletes a vlanid entry from db."""
|
||||||
LOG.debug(_("delete_vlanid() called"))
|
LOG.debug(_("delete_vlanid() called"))
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
@ -107,7 +107,7 @@ def delete_vlanid(vlan_id):
|
|||||||
|
|
||||||
|
|
||||||
def reserve_vlanid():
|
def reserve_vlanid():
|
||||||
"""Reserves the first unused vlanid"""
|
"""Reserves the first unused vlanid."""
|
||||||
LOG.debug(_("reserve_vlanid() called"))
|
LOG.debug(_("reserve_vlanid() called"))
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
@ -126,7 +126,7 @@ def reserve_vlanid():
|
|||||||
|
|
||||||
|
|
||||||
def get_all_vlanids_used():
|
def get_all_vlanids_used():
|
||||||
"""Gets all the vlanids used"""
|
"""Gets all the vlanids used."""
|
||||||
LOG.debug(_("get_all_vlanids() called"))
|
LOG.debug(_("get_all_vlanids() called"))
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
@ -138,7 +138,7 @@ def get_all_vlanids_used():
|
|||||||
|
|
||||||
|
|
||||||
def get_all_vlan_bindings():
|
def get_all_vlan_bindings():
|
||||||
"""Lists all the vlan to network associations"""
|
"""Lists all the vlan to network associations."""
|
||||||
LOG.debug(_("get_all_vlan_bindings() called"))
|
LOG.debug(_("get_all_vlan_bindings() called"))
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
@ -149,7 +149,7 @@ def get_all_vlan_bindings():
|
|||||||
|
|
||||||
|
|
||||||
def get_vlan_binding(netid):
|
def get_vlan_binding(netid):
|
||||||
"""Lists the vlan given a network_id"""
|
"""Lists the vlan given a network_id."""
|
||||||
LOG.debug(_("get_vlan_binding() called"))
|
LOG.debug(_("get_vlan_binding() called"))
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
@ -161,7 +161,7 @@ def get_vlan_binding(netid):
|
|||||||
|
|
||||||
|
|
||||||
def add_vlan_binding(vlanid, vlanname, netid):
|
def add_vlan_binding(vlanid, vlanname, netid):
|
||||||
"""Adds a vlan to network association"""
|
"""Adds a vlan to network association."""
|
||||||
LOG.debug(_("add_vlan_binding() called"))
|
LOG.debug(_("add_vlan_binding() called"))
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
@ -177,7 +177,7 @@ def add_vlan_binding(vlanid, vlanname, netid):
|
|||||||
|
|
||||||
|
|
||||||
def remove_vlan_binding(netid):
|
def remove_vlan_binding(netid):
|
||||||
"""Removes a vlan to network association"""
|
"""Removes a vlan to network association."""
|
||||||
LOG.debug(_("remove_vlan_binding() called"))
|
LOG.debug(_("remove_vlan_binding() called"))
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
@ -191,7 +191,7 @@ def remove_vlan_binding(netid):
|
|||||||
|
|
||||||
|
|
||||||
def update_vlan_binding(netid, newvlanid=None, newvlanname=None):
|
def update_vlan_binding(netid, newvlanid=None, newvlanname=None):
|
||||||
"""Updates a vlan to network association"""
|
"""Updates a vlan to network association."""
|
||||||
LOG.debug(_("update_vlan_binding() called"))
|
LOG.debug(_("update_vlan_binding() called"))
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
@ -209,7 +209,7 @@ def update_vlan_binding(netid, newvlanid=None, newvlanname=None):
|
|||||||
|
|
||||||
|
|
||||||
def get_all_qoss(tenant_id):
|
def get_all_qoss(tenant_id):
|
||||||
"""Lists all the qos to tenant associations"""
|
"""Lists all the qos to tenant associations."""
|
||||||
LOG.debug(_("get_all_qoss() called"))
|
LOG.debug(_("get_all_qoss() called"))
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
@ -221,7 +221,7 @@ def get_all_qoss(tenant_id):
|
|||||||
|
|
||||||
|
|
||||||
def get_qos(tenant_id, qos_id):
|
def get_qos(tenant_id, qos_id):
|
||||||
"""Lists the qos given a tenant_id and qos_id"""
|
"""Lists the qos given a tenant_id and qos_id."""
|
||||||
LOG.debug(_("get_qos() called"))
|
LOG.debug(_("get_qos() called"))
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
@ -235,7 +235,7 @@ def get_qos(tenant_id, qos_id):
|
|||||||
|
|
||||||
|
|
||||||
def add_qos(tenant_id, qos_name, qos_desc):
|
def add_qos(tenant_id, qos_name, qos_desc):
|
||||||
"""Adds a qos to tenant association"""
|
"""Adds a qos to tenant association."""
|
||||||
LOG.debug(_("add_qos() called"))
|
LOG.debug(_("add_qos() called"))
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
@ -252,7 +252,7 @@ def add_qos(tenant_id, qos_name, qos_desc):
|
|||||||
|
|
||||||
|
|
||||||
def remove_qos(tenant_id, qos_id):
|
def remove_qos(tenant_id, qos_id):
|
||||||
"""Removes a qos to tenant association"""
|
"""Removes a qos to tenant association."""
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
qos = (session.query(l2network_models.QoS).
|
qos = (session.query(l2network_models.QoS).
|
||||||
@ -266,7 +266,7 @@ def remove_qos(tenant_id, qos_id):
|
|||||||
|
|
||||||
|
|
||||||
def update_qos(tenant_id, qos_id, new_qos_name=None):
|
def update_qos(tenant_id, qos_id, new_qos_name=None):
|
||||||
"""Updates a qos to tenant association"""
|
"""Updates a qos to tenant association."""
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
qos = (session.query(l2network_models.QoS).
|
qos = (session.query(l2network_models.QoS).
|
||||||
@ -283,7 +283,7 @@ def update_qos(tenant_id, qos_id, new_qos_name=None):
|
|||||||
|
|
||||||
|
|
||||||
def get_all_credentials(tenant_id):
|
def get_all_credentials(tenant_id):
|
||||||
"""Lists all the creds for a tenant"""
|
"""Lists all the creds for a tenant."""
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
creds = (session.query(l2network_models.Credential).
|
creds = (session.query(l2network_models.Credential).
|
||||||
@ -294,7 +294,7 @@ def get_all_credentials(tenant_id):
|
|||||||
|
|
||||||
|
|
||||||
def get_credential(tenant_id, credential_id):
|
def get_credential(tenant_id, credential_id):
|
||||||
"""Lists the creds for given a cred_id and tenant_id"""
|
"""Lists the creds for given a cred_id and tenant_id."""
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
cred = (session.query(l2network_models.Credential).
|
cred = (session.query(l2network_models.Credential).
|
||||||
@ -307,7 +307,7 @@ def get_credential(tenant_id, credential_id):
|
|||||||
|
|
||||||
|
|
||||||
def get_credential_name(tenant_id, credential_name):
|
def get_credential_name(tenant_id, credential_name):
|
||||||
"""Lists the creds for given a cred_name and tenant_id"""
|
"""Lists the creds for given a cred_name and tenant_id."""
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
cred = (session.query(l2network_models.Credential).
|
cred = (session.query(l2network_models.Credential).
|
||||||
@ -320,7 +320,7 @@ def get_credential_name(tenant_id, credential_name):
|
|||||||
|
|
||||||
|
|
||||||
def add_credential(tenant_id, credential_name, user_name, password):
|
def add_credential(tenant_id, credential_name, user_name, password):
|
||||||
"""Adds a qos to tenant association"""
|
"""Adds a qos to tenant association."""
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
cred = (session.query(l2network_models.Credential).
|
cred = (session.query(l2network_models.Credential).
|
||||||
@ -337,7 +337,7 @@ def add_credential(tenant_id, credential_name, user_name, password):
|
|||||||
|
|
||||||
|
|
||||||
def remove_credential(tenant_id, credential_id):
|
def remove_credential(tenant_id, credential_id):
|
||||||
"""Removes a credential from a tenant"""
|
"""Removes a credential from a tenant."""
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
cred = (session.query(l2network_models.Credential).
|
cred = (session.query(l2network_models.Credential).
|
||||||
@ -352,7 +352,7 @@ def remove_credential(tenant_id, credential_id):
|
|||||||
|
|
||||||
def update_credential(tenant_id, credential_id,
|
def update_credential(tenant_id, credential_id,
|
||||||
new_user_name=None, new_password=None):
|
new_user_name=None, new_password=None):
|
||||||
"""Updates a credential for a tenant"""
|
"""Updates a credential for a tenant."""
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
cred = (session.query(l2network_models.Credential).
|
cred = (session.query(l2network_models.Credential).
|
||||||
|
@ -27,35 +27,36 @@ class L2NetworkBase(object):
|
|||||||
__table_args__ = {'mysql_engine': 'InnoDB'}
|
__table_args__ = {'mysql_engine': 'InnoDB'}
|
||||||
|
|
||||||
def __setitem__(self, key, value):
|
def __setitem__(self, key, value):
|
||||||
"""Internal Dict set method"""
|
"""Internal Dict set method."""
|
||||||
setattr(self, key, value)
|
setattr(self, key, value)
|
||||||
|
|
||||||
def __getitem__(self, key):
|
def __getitem__(self, key):
|
||||||
"""Internal Dict get method"""
|
"""Internal Dict get method."""
|
||||||
return getattr(self, key)
|
return getattr(self, key)
|
||||||
|
|
||||||
def get(self, key, default=None):
|
def get(self, key, default=None):
|
||||||
"""Dict get method"""
|
"""Dict get method."""
|
||||||
return getattr(self, key, default)
|
return getattr(self, key, default)
|
||||||
|
|
||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
"""Iterate over table columns"""
|
"""Iterate over table columns."""
|
||||||
self._i = iter(object_mapper(self).columns)
|
self._i = iter(object_mapper(self).columns)
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def next(self):
|
def next(self):
|
||||||
"""Next method for the iterator"""
|
"""Next method for the iterator."""
|
||||||
n = self._i.next().name
|
n = self._i.next().name
|
||||||
return n, getattr(self, n)
|
return n, getattr(self, n)
|
||||||
|
|
||||||
def update(self, values):
|
def update(self, values):
|
||||||
"""Make the model object behave like a dict"""
|
"""Make the model object behave like a dict."""
|
||||||
for k, v in values.iteritems():
|
for k, v in values.iteritems():
|
||||||
setattr(self, k, v)
|
setattr(self, k, v)
|
||||||
|
|
||||||
def iteritems(self):
|
def iteritems(self):
|
||||||
"""Make the model object behave like a dict"
|
"""Make the model object behave like a dict"
|
||||||
Includes attributes from joins."""
|
Includes attributes from joins.
|
||||||
|
"""
|
||||||
local = dict(self)
|
local = dict(self)
|
||||||
joined = dict([(k, v) for k, v in self.__dict__.iteritems()
|
joined = dict([(k, v) for k, v in self.__dict__.iteritems()
|
||||||
if not k[0] == '_'])
|
if not k[0] == '_'])
|
||||||
@ -64,7 +65,7 @@ class L2NetworkBase(object):
|
|||||||
|
|
||||||
|
|
||||||
class VlanID(BASE, L2NetworkBase):
|
class VlanID(BASE, L2NetworkBase):
|
||||||
"""Represents a vlan_id usage"""
|
"""Represents a vlan_id usage."""
|
||||||
__tablename__ = 'vlan_ids'
|
__tablename__ = 'vlan_ids'
|
||||||
|
|
||||||
vlan_id = Column(Integer, primary_key=True)
|
vlan_id = Column(Integer, primary_key=True)
|
||||||
@ -79,7 +80,7 @@ class VlanID(BASE, L2NetworkBase):
|
|||||||
|
|
||||||
|
|
||||||
class VlanBinding(BASE, L2NetworkBase):
|
class VlanBinding(BASE, L2NetworkBase):
|
||||||
"""Represents a binding of vlan_id to network_id"""
|
"""Represents a binding of vlan_id to network_id."""
|
||||||
__tablename__ = 'vlan_bindings'
|
__tablename__ = 'vlan_bindings'
|
||||||
|
|
||||||
vlan_id = Column(Integer, primary_key=True)
|
vlan_id = Column(Integer, primary_key=True)
|
||||||
@ -99,7 +100,7 @@ class VlanBinding(BASE, L2NetworkBase):
|
|||||||
|
|
||||||
|
|
||||||
class QoS(BASE, L2NetworkBase):
|
class QoS(BASE, L2NetworkBase):
|
||||||
"""Represents QoS for a tenant"""
|
"""Represents QoS for a tenant."""
|
||||||
__tablename__ = 'qoss'
|
__tablename__ = 'qoss'
|
||||||
|
|
||||||
qos_id = Column(String(255))
|
qos_id = Column(String(255))
|
||||||
@ -119,7 +120,7 @@ class QoS(BASE, L2NetworkBase):
|
|||||||
|
|
||||||
|
|
||||||
class Credential(BASE, L2NetworkBase):
|
class Credential(BASE, L2NetworkBase):
|
||||||
"""Represents credentials for a tenant"""
|
"""Represents credentials for a tenant."""
|
||||||
__tablename__ = 'credentials'
|
__tablename__ = 'credentials'
|
||||||
|
|
||||||
credential_id = Column(String(255))
|
credential_id = Column(String(255))
|
||||||
|
@ -50,13 +50,14 @@ class QuantumBase(object):
|
|||||||
return n, getattr(self, n)
|
return n, getattr(self, n)
|
||||||
|
|
||||||
def update(self, values):
|
def update(self, values):
|
||||||
"""Make the model object behave like a dict"""
|
"""Make the model object behave like a dict."""
|
||||||
for k, v in values.iteritems():
|
for k, v in values.iteritems():
|
||||||
setattr(self, k, v)
|
setattr(self, k, v)
|
||||||
|
|
||||||
def iteritems(self):
|
def iteritems(self):
|
||||||
"""Make the model object behave like a dict.
|
"""Make the model object behave like a dict.
|
||||||
Includes attributes from joins."""
|
Includes attributes from joins.
|
||||||
|
"""
|
||||||
local = dict(self)
|
local = dict(self)
|
||||||
joined = dict([(k, v) for k, v in self.__dict__.iteritems()
|
joined = dict([(k, v) for k, v in self.__dict__.iteritems()
|
||||||
if not k[0] == '_'])
|
if not k[0] == '_'])
|
||||||
@ -65,7 +66,7 @@ class QuantumBase(object):
|
|||||||
|
|
||||||
|
|
||||||
class Port(BASE, QuantumBase):
|
class Port(BASE, QuantumBase):
|
||||||
"""Represents a port on a quantum network"""
|
"""Represents a port on a quantum network."""
|
||||||
__tablename__ = 'ports'
|
__tablename__ = 'ports'
|
||||||
|
|
||||||
uuid = Column(String(255), primary_key=True)
|
uuid = Column(String(255), primary_key=True)
|
||||||
@ -86,7 +87,7 @@ class Port(BASE, QuantumBase):
|
|||||||
|
|
||||||
|
|
||||||
class Network(BASE, QuantumBase):
|
class Network(BASE, QuantumBase):
|
||||||
"""Represents a quantum network"""
|
"""Represents a quantum network."""
|
||||||
__tablename__ = 'networks'
|
__tablename__ = 'networks'
|
||||||
|
|
||||||
uuid = Column(String(255), primary_key=True)
|
uuid = Column(String(255), primary_key=True)
|
||||||
|
@ -32,7 +32,7 @@ LOG = logging.getLogger(__name__)
|
|||||||
|
|
||||||
|
|
||||||
def create_vlanids():
|
def create_vlanids():
|
||||||
"""Prepopulates the vlan_bindings table"""
|
"""Prepopulates the vlan_bindings table."""
|
||||||
LOG.debug(_("create_vlanids() called"))
|
LOG.debug(_("create_vlanids() called"))
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
@ -51,7 +51,7 @@ def create_vlanids():
|
|||||||
|
|
||||||
|
|
||||||
def get_all_vlanids():
|
def get_all_vlanids():
|
||||||
"""Gets all the vlanids"""
|
"""Gets all the vlanids."""
|
||||||
LOG.debug(_("get_all_vlanids() called"))
|
LOG.debug(_("get_all_vlanids() called"))
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
@ -62,7 +62,7 @@ def get_all_vlanids():
|
|||||||
|
|
||||||
|
|
||||||
def is_vlanid_used(vlan_id):
|
def is_vlanid_used(vlan_id):
|
||||||
"""Checks if a vlanid is in use"""
|
"""Checks if a vlanid is in use."""
|
||||||
LOG.debug(_("is_vlanid_used() called"))
|
LOG.debug(_("is_vlanid_used() called"))
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
@ -74,7 +74,7 @@ def is_vlanid_used(vlan_id):
|
|||||||
|
|
||||||
|
|
||||||
def release_vlanid(vlan_id):
|
def release_vlanid(vlan_id):
|
||||||
"""Sets the vlanid state to be unused"""
|
"""Sets the vlanid state to be unused."""
|
||||||
LOG.debug(_("release_vlanid() called"))
|
LOG.debug(_("release_vlanid() called"))
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
@ -90,7 +90,7 @@ def release_vlanid(vlan_id):
|
|||||||
|
|
||||||
|
|
||||||
def delete_vlanid(vlan_id):
|
def delete_vlanid(vlan_id):
|
||||||
"""Deletes a vlanid entry from db"""
|
"""Deletes a vlanid entry from db."""
|
||||||
LOG.debug(_("delete_vlanid() called"))
|
LOG.debug(_("delete_vlanid() called"))
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
@ -104,7 +104,7 @@ def delete_vlanid(vlan_id):
|
|||||||
|
|
||||||
|
|
||||||
def reserve_vlanid():
|
def reserve_vlanid():
|
||||||
"""Reserves the first unused vlanid"""
|
"""Reserves the first unused vlanid."""
|
||||||
LOG.debug(_("reserve_vlanid() called"))
|
LOG.debug(_("reserve_vlanid() called"))
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
@ -123,7 +123,7 @@ def reserve_vlanid():
|
|||||||
|
|
||||||
|
|
||||||
def get_all_vlanids_used():
|
def get_all_vlanids_used():
|
||||||
"""Gets all the vlanids used"""
|
"""Gets all the vlanids used."""
|
||||||
LOG.debug(_("get_all_vlanids() called"))
|
LOG.debug(_("get_all_vlanids() called"))
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
@ -135,7 +135,7 @@ def get_all_vlanids_used():
|
|||||||
|
|
||||||
|
|
||||||
def get_all_vlan_bindings():
|
def get_all_vlan_bindings():
|
||||||
"""Lists all the vlan to network associations"""
|
"""Lists all the vlan to network associations."""
|
||||||
LOG.debug(_("get_all_vlan_bindings() called"))
|
LOG.debug(_("get_all_vlan_bindings() called"))
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
@ -146,7 +146,7 @@ def get_all_vlan_bindings():
|
|||||||
|
|
||||||
|
|
||||||
def get_vlan_binding(netid):
|
def get_vlan_binding(netid):
|
||||||
"""Lists the vlan given a network_id"""
|
"""Lists the vlan given a network_id."""
|
||||||
LOG.debug(_("get_vlan_binding() called"))
|
LOG.debug(_("get_vlan_binding() called"))
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
@ -158,7 +158,7 @@ def get_vlan_binding(netid):
|
|||||||
|
|
||||||
|
|
||||||
def add_vlan_binding(vlanid, vlanname, netid):
|
def add_vlan_binding(vlanid, vlanname, netid):
|
||||||
"""Adds a vlan to network association"""
|
"""Adds a vlan to network association."""
|
||||||
LOG.debug(_("add_vlan_binding() called"))
|
LOG.debug(_("add_vlan_binding() called"))
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
@ -174,7 +174,7 @@ def add_vlan_binding(vlanid, vlanname, netid):
|
|||||||
|
|
||||||
|
|
||||||
def remove_vlan_binding(netid):
|
def remove_vlan_binding(netid):
|
||||||
"""Removes a vlan to network association"""
|
"""Removes a vlan to network association."""
|
||||||
LOG.debug(_("remove_vlan_binding() called"))
|
LOG.debug(_("remove_vlan_binding() called"))
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
@ -188,7 +188,7 @@ def remove_vlan_binding(netid):
|
|||||||
|
|
||||||
|
|
||||||
def update_vlan_binding(netid, newvlanid=None, newvlanname=None):
|
def update_vlan_binding(netid, newvlanid=None, newvlanname=None):
|
||||||
"""Updates a vlan to network association"""
|
"""Updates a vlan to network association."""
|
||||||
LOG.debug(_("update_vlan_binding() called"))
|
LOG.debug(_("update_vlan_binding() called"))
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
@ -206,7 +206,7 @@ def update_vlan_binding(netid, newvlanid=None, newvlanname=None):
|
|||||||
|
|
||||||
|
|
||||||
def get_all_qoss(tenant_id):
|
def get_all_qoss(tenant_id):
|
||||||
"""Lists all the qos to tenant associations"""
|
"""Lists all the qos to tenant associations."""
|
||||||
LOG.debug(_("get_all_qoss() called"))
|
LOG.debug(_("get_all_qoss() called"))
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
@ -218,7 +218,7 @@ def get_all_qoss(tenant_id):
|
|||||||
|
|
||||||
|
|
||||||
def get_qos(tenant_id, qos_id):
|
def get_qos(tenant_id, qos_id):
|
||||||
"""Lists the qos given a tenant_id and qos_id"""
|
"""Lists the qos given a tenant_id and qos_id."""
|
||||||
LOG.debug(_("get_qos() called"))
|
LOG.debug(_("get_qos() called"))
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
@ -232,7 +232,7 @@ def get_qos(tenant_id, qos_id):
|
|||||||
|
|
||||||
|
|
||||||
def add_qos(tenant_id, qos_name, qos_desc):
|
def add_qos(tenant_id, qos_name, qos_desc):
|
||||||
"""Adds a qos to tenant association"""
|
"""Adds a qos to tenant association."""
|
||||||
LOG.debug(_("add_qos() called"))
|
LOG.debug(_("add_qos() called"))
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
@ -249,7 +249,7 @@ def add_qos(tenant_id, qos_name, qos_desc):
|
|||||||
|
|
||||||
|
|
||||||
def remove_qos(tenant_id, qos_id):
|
def remove_qos(tenant_id, qos_id):
|
||||||
"""Removes a qos to tenant association"""
|
"""Removes a qos to tenant association."""
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
qos = (session.query(network_models_v2.QoS).
|
qos = (session.query(network_models_v2.QoS).
|
||||||
@ -263,7 +263,7 @@ def remove_qos(tenant_id, qos_id):
|
|||||||
|
|
||||||
|
|
||||||
def update_qos(tenant_id, qos_id, new_qos_name=None):
|
def update_qos(tenant_id, qos_id, new_qos_name=None):
|
||||||
"""Updates a qos to tenant association"""
|
"""Updates a qos to tenant association."""
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
qos = (session.query(network_models_v2.QoS).
|
qos = (session.query(network_models_v2.QoS).
|
||||||
@ -280,7 +280,7 @@ def update_qos(tenant_id, qos_id, new_qos_name=None):
|
|||||||
|
|
||||||
|
|
||||||
def get_all_credentials(tenant_id):
|
def get_all_credentials(tenant_id):
|
||||||
"""Lists all the creds for a tenant"""
|
"""Lists all the creds for a tenant."""
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
creds = (session.query(network_models_v2.Credential).
|
creds = (session.query(network_models_v2.Credential).
|
||||||
@ -291,7 +291,7 @@ def get_all_credentials(tenant_id):
|
|||||||
|
|
||||||
|
|
||||||
def get_credential(tenant_id, credential_id):
|
def get_credential(tenant_id, credential_id):
|
||||||
"""Lists the creds for given a cred_id and tenant_id"""
|
"""Lists the creds for given a cred_id and tenant_id."""
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
cred = (session.query(network_models_v2.Credential).
|
cred = (session.query(network_models_v2.Credential).
|
||||||
@ -304,7 +304,7 @@ def get_credential(tenant_id, credential_id):
|
|||||||
|
|
||||||
|
|
||||||
def get_credential_name(tenant_id, credential_name):
|
def get_credential_name(tenant_id, credential_name):
|
||||||
"""Lists the creds for given a cred_name and tenant_id"""
|
"""Lists the creds for given a cred_name and tenant_id."""
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
cred = (session.query(network_models_v2.Credential).
|
cred = (session.query(network_models_v2.Credential).
|
||||||
@ -317,7 +317,7 @@ def get_credential_name(tenant_id, credential_name):
|
|||||||
|
|
||||||
|
|
||||||
def add_credential(tenant_id, credential_name, user_name, password):
|
def add_credential(tenant_id, credential_name, user_name, password):
|
||||||
"""Adds a qos to tenant association"""
|
"""Adds a qos to tenant association."""
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
cred = (session.query(network_models_v2.Credential).
|
cred = (session.query(network_models_v2.Credential).
|
||||||
@ -334,7 +334,7 @@ def add_credential(tenant_id, credential_name, user_name, password):
|
|||||||
|
|
||||||
|
|
||||||
def remove_credential(tenant_id, credential_id):
|
def remove_credential(tenant_id, credential_id):
|
||||||
"""Removes a credential from a tenant"""
|
"""Removes a credential from a tenant."""
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
cred = (session.query(network_models_v2.Credential).
|
cred = (session.query(network_models_v2.Credential).
|
||||||
@ -349,7 +349,7 @@ def remove_credential(tenant_id, credential_id):
|
|||||||
|
|
||||||
def update_credential(tenant_id, credential_id,
|
def update_credential(tenant_id, credential_id,
|
||||||
new_user_name=None, new_password=None):
|
new_user_name=None, new_password=None):
|
||||||
"""Updates a credential for a tenant"""
|
"""Updates a credential for a tenant."""
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
cred = (session.query(network_models_v2.Credential).
|
cred = (session.query(network_models_v2.Credential).
|
||||||
|
@ -29,35 +29,36 @@ class L2NetworkBase(object):
|
|||||||
#__table_args__ = {'mysql_engine': 'InnoDB'}
|
#__table_args__ = {'mysql_engine': 'InnoDB'}
|
||||||
|
|
||||||
def __setitem__(self, key, value):
|
def __setitem__(self, key, value):
|
||||||
"""Internal Dict set method"""
|
"""Internal Dict set method."""
|
||||||
setattr(self, key, value)
|
setattr(self, key, value)
|
||||||
|
|
||||||
def __getitem__(self, key):
|
def __getitem__(self, key):
|
||||||
"""Internal Dict get method"""
|
"""Internal Dict get method."""
|
||||||
return getattr(self, key)
|
return getattr(self, key)
|
||||||
|
|
||||||
def get(self, key, default=None):
|
def get(self, key, default=None):
|
||||||
"""Dict get method"""
|
"""Dict get method."""
|
||||||
return getattr(self, key, default)
|
return getattr(self, key, default)
|
||||||
|
|
||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
"""Iterate over table columns"""
|
"""Iterate over table columns."""
|
||||||
self._i = iter(object_mapper(self).columns)
|
self._i = iter(object_mapper(self).columns)
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def next(self):
|
def next(self):
|
||||||
"""Next method for the iterator"""
|
"""Next method for the iterator."""
|
||||||
n = self._i.next().name
|
n = self._i.next().name
|
||||||
return n, getattr(self, n)
|
return n, getattr(self, n)
|
||||||
|
|
||||||
def update(self, values):
|
def update(self, values):
|
||||||
"""Make the model object behave like a dict"""
|
"""Make the model object behave like a dict."""
|
||||||
for k, v in values.iteritems():
|
for k, v in values.iteritems():
|
||||||
setattr(self, k, v)
|
setattr(self, k, v)
|
||||||
|
|
||||||
def iteritems(self):
|
def iteritems(self):
|
||||||
"""Make the model object behave like a dict"
|
"""Make the model object behave like a dict"
|
||||||
Includes attributes from joins."""
|
Includes attributes from joins.
|
||||||
|
"""
|
||||||
local = dict(self)
|
local = dict(self)
|
||||||
joined = dict([(k, v) for k, v in self.__dict__.iteritems()
|
joined = dict([(k, v) for k, v in self.__dict__.iteritems()
|
||||||
if not k[0] == '_'])
|
if not k[0] == '_'])
|
||||||
@ -66,7 +67,7 @@ class L2NetworkBase(object):
|
|||||||
|
|
||||||
|
|
||||||
class VlanID(model_base.BASEV2, L2NetworkBase):
|
class VlanID(model_base.BASEV2, L2NetworkBase):
|
||||||
"""Represents a vlan_id usage"""
|
"""Represents a vlan_id usage."""
|
||||||
__tablename__ = 'cisco_vlan_ids'
|
__tablename__ = 'cisco_vlan_ids'
|
||||||
|
|
||||||
vlan_id = Column(Integer, primary_key=True)
|
vlan_id = Column(Integer, primary_key=True)
|
||||||
@ -81,7 +82,7 @@ class VlanID(model_base.BASEV2, L2NetworkBase):
|
|||||||
|
|
||||||
|
|
||||||
class Vlan_Binding(model_base.BASEV2, L2NetworkBase):
|
class Vlan_Binding(model_base.BASEV2, L2NetworkBase):
|
||||||
"""Represents a binding of vlan_id to network_id"""
|
"""Represents a binding of vlan_id to network_id."""
|
||||||
__tablename__ = 'cisco_vlan_bindings'
|
__tablename__ = 'cisco_vlan_bindings'
|
||||||
|
|
||||||
vlan_id = Column(Integer, primary_key=True)
|
vlan_id = Column(Integer, primary_key=True)
|
||||||
@ -101,7 +102,7 @@ class Vlan_Binding(model_base.BASEV2, L2NetworkBase):
|
|||||||
|
|
||||||
|
|
||||||
class QoS(model_base.BASEV2, L2NetworkBase):
|
class QoS(model_base.BASEV2, L2NetworkBase):
|
||||||
"""Represents QoS for a tenant"""
|
"""Represents QoS for a tenant."""
|
||||||
__tablename__ = 'qoss'
|
__tablename__ = 'qoss'
|
||||||
|
|
||||||
qos_id = Column(String(255))
|
qos_id = Column(String(255))
|
||||||
@ -121,7 +122,7 @@ class QoS(model_base.BASEV2, L2NetworkBase):
|
|||||||
|
|
||||||
|
|
||||||
class Credential(model_base.BASEV2, L2NetworkBase):
|
class Credential(model_base.BASEV2, L2NetworkBase):
|
||||||
"""Represents credentials for a tenant"""
|
"""Represents credentials for a tenant."""
|
||||||
__tablename__ = 'credentials'
|
__tablename__ = 'credentials'
|
||||||
|
|
||||||
credential_id = Column(String(255))
|
credential_id = Column(String(255))
|
||||||
|
@ -30,7 +30,7 @@ LOG = logging.getLogger(__name__)
|
|||||||
|
|
||||||
|
|
||||||
def get_all_nexusport_bindings():
|
def get_all_nexusport_bindings():
|
||||||
"""Lists all the nexusport bindings"""
|
"""Lists all the nexusport bindings."""
|
||||||
LOG.debug(_("get_all_nexusport_bindings() called"))
|
LOG.debug(_("get_all_nexusport_bindings() called"))
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
@ -41,7 +41,7 @@ def get_all_nexusport_bindings():
|
|||||||
|
|
||||||
|
|
||||||
def get_nexusport_binding(port_id, vlan_id, switch_ip, instance_id):
|
def get_nexusport_binding(port_id, vlan_id, switch_ip, instance_id):
|
||||||
"""Lists a nexusport binding"""
|
"""Lists a nexusport binding."""
|
||||||
LOG.debug(_("get_nexusport_binding() called"))
|
LOG.debug(_("get_nexusport_binding() called"))
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
@ -55,7 +55,7 @@ def get_nexusport_binding(port_id, vlan_id, switch_ip, instance_id):
|
|||||||
|
|
||||||
|
|
||||||
def get_nexusvlan_binding(vlan_id, switch_ip):
|
def get_nexusvlan_binding(vlan_id, switch_ip):
|
||||||
"""Lists a vlan and switch binding"""
|
"""Lists a vlan and switch binding."""
|
||||||
LOG.debug(_("get_nexusvlan_binding() called"))
|
LOG.debug(_("get_nexusvlan_binding() called"))
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
@ -68,7 +68,7 @@ def get_nexusvlan_binding(vlan_id, switch_ip):
|
|||||||
|
|
||||||
|
|
||||||
def add_nexusport_binding(port_id, vlan_id, switch_ip, instance_id):
|
def add_nexusport_binding(port_id, vlan_id, switch_ip, instance_id):
|
||||||
"""Adds a nexusport binding"""
|
"""Adds a nexusport binding."""
|
||||||
LOG.debug(_("add_nexusport_binding() called"))
|
LOG.debug(_("add_nexusport_binding() called"))
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
binding = nexus_models_v2.NexusPortBinding(
|
binding = nexus_models_v2.NexusPortBinding(
|
||||||
@ -79,7 +79,7 @@ def add_nexusport_binding(port_id, vlan_id, switch_ip, instance_id):
|
|||||||
|
|
||||||
|
|
||||||
def remove_nexusport_binding(port_id, vlan_id, switch_ip, instance_id):
|
def remove_nexusport_binding(port_id, vlan_id, switch_ip, instance_id):
|
||||||
"""Removes a nexusport binding"""
|
"""Removes a nexusport binding."""
|
||||||
LOG.debug(_("remove_nexusport_binding() called"))
|
LOG.debug(_("remove_nexusport_binding() called"))
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
@ -97,7 +97,7 @@ def remove_nexusport_binding(port_id, vlan_id, switch_ip, instance_id):
|
|||||||
|
|
||||||
|
|
||||||
def update_nexusport_binding(port_id, new_vlan_id):
|
def update_nexusport_binding(port_id, new_vlan_id):
|
||||||
"""Updates nexusport binding"""
|
"""Updates nexusport binding."""
|
||||||
LOG.debug(_("update_nexusport_binding called"))
|
LOG.debug(_("update_nexusport_binding called"))
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
@ -113,7 +113,7 @@ def update_nexusport_binding(port_id, new_vlan_id):
|
|||||||
|
|
||||||
|
|
||||||
def get_nexusvm_binding(vlan_id, instance_id):
|
def get_nexusvm_binding(vlan_id, instance_id):
|
||||||
"""Lists nexusvm bindings"""
|
"""Lists nexusvm bindings."""
|
||||||
LOG.debug(_("get_nexusvm_binding() called"))
|
LOG.debug(_("get_nexusvm_binding() called"))
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
@ -126,7 +126,7 @@ def get_nexusvm_binding(vlan_id, instance_id):
|
|||||||
|
|
||||||
|
|
||||||
def get_port_vlan_switch_binding(port_id, vlan_id, switch_ip):
|
def get_port_vlan_switch_binding(port_id, vlan_id, switch_ip):
|
||||||
"""Lists nexusvm bindings"""
|
"""Lists nexusvm bindings."""
|
||||||
LOG.debug(_("get_port_vlan_switch_binding() called"))
|
LOG.debug(_("get_port_vlan_switch_binding() called"))
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
|
@ -22,7 +22,7 @@ from quantum.plugins.cisco.db.l2network_models import L2NetworkBase
|
|||||||
|
|
||||||
|
|
||||||
class NexusPortBinding(model_base.BASEV2, L2NetworkBase):
|
class NexusPortBinding(model_base.BASEV2, L2NetworkBase):
|
||||||
"""Represents a binding of VM's to nexus ports"""
|
"""Represents a binding of VM's to nexus ports."""
|
||||||
__tablename__ = "nexusport_bindings"
|
__tablename__ = "nexusport_bindings"
|
||||||
|
|
||||||
id = Column(Integer, primary_key=True, autoincrement=True)
|
id = Column(Integer, primary_key=True, autoincrement=True)
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
|
|
||||||
def get_view_builder(req):
|
def get_view_builder(req):
|
||||||
"""get view builder """
|
"""get view builder."""
|
||||||
base_url = req.application_url
|
base_url = req.application_url
|
||||||
return ViewBuilder(base_url)
|
return ViewBuilder(base_url)
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
|
|
||||||
def get_view_builder(req):
|
def get_view_builder(req):
|
||||||
"""get view builder"""
|
"""get view builder."""
|
||||||
base_url = req.application_url
|
base_url = req.application_url
|
||||||
return ViewBuilder(base_url)
|
return ViewBuilder(base_url)
|
||||||
|
|
||||||
|
@ -31,36 +31,36 @@ from quantum import wsgi
|
|||||||
|
|
||||||
|
|
||||||
class Credential(extensions.ExtensionDescriptor):
|
class Credential(extensions.ExtensionDescriptor):
|
||||||
"""extension class Credential"""
|
"""extension class Credential."""
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_name(cls):
|
def get_name(cls):
|
||||||
""" Returns Ext Resource Name """
|
"""Returns Ext Resource Name."""
|
||||||
return "Cisco Credential"
|
return "Cisco Credential"
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_alias(cls):
|
def get_alias(cls):
|
||||||
""" Returns Ext Resource Alias """
|
"""Returns Ext Resource Alias."""
|
||||||
return "Cisco Credential"
|
return "Cisco Credential"
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_description(cls):
|
def get_description(cls):
|
||||||
""" Returns Ext Resource Description """
|
"""Returns Ext Resource Description."""
|
||||||
return "Credential include username and password"
|
return "Credential include username and password"
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_namespace(cls):
|
def get_namespace(cls):
|
||||||
""" Returns Ext Resource Namespace """
|
"""Returns Ext Resource Namespace."""
|
||||||
return "http://docs.ciscocloud.com/api/ext/credential/v1.0"
|
return "http://docs.ciscocloud.com/api/ext/credential/v1.0"
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_updated(cls):
|
def get_updated(cls):
|
||||||
""" Returns Ext Resource Update Time """
|
"""Returns Ext Resource Update Time."""
|
||||||
return "2011-07-25T13:25:27-06:00"
|
return "2011-07-25T13:25:27-06:00"
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_resources(cls):
|
def get_resources(cls):
|
||||||
""" Returns Ext Resources """
|
"""Returns Ext Resources."""
|
||||||
parent_resource = dict(member_name="tenant",
|
parent_resource = dict(member_name="tenant",
|
||||||
collection_name="extensions/csco/tenants")
|
collection_name="extensions/csco/tenants")
|
||||||
controller = CredentialController(QuantumManager.get_plugin())
|
controller = CredentialController(QuantumManager.get_plugin())
|
||||||
@ -69,8 +69,7 @@ class Credential(extensions.ExtensionDescriptor):
|
|||||||
|
|
||||||
|
|
||||||
class CredentialController(common.QuantumController, wsgi.Controller):
|
class CredentialController(common.QuantumController, wsgi.Controller):
|
||||||
""" credential API controller
|
"""Credential API controller based on QuantumController."""
|
||||||
based on QuantumController """
|
|
||||||
|
|
||||||
_credential_ops_param_list = [
|
_credential_ops_param_list = [
|
||||||
{'param-name': 'credential_name', 'required': True},
|
{'param-name': 'credential_name', 'required': True},
|
||||||
@ -91,11 +90,11 @@ class CredentialController(common.QuantumController, wsgi.Controller):
|
|||||||
self._plugin = plugin
|
self._plugin = plugin
|
||||||
|
|
||||||
def index(self, request, tenant_id):
|
def index(self, request, tenant_id):
|
||||||
""" Returns a list of credential ids """
|
"""Returns a list of credential ids."""
|
||||||
return self._items(request, tenant_id, is_detail=False)
|
return self._items(request, tenant_id, is_detail=False)
|
||||||
|
|
||||||
def _items(self, request, tenant_id, is_detail):
|
def _items(self, request, tenant_id, is_detail):
|
||||||
""" Returns a list of credentials. """
|
"""Returns a list of credentials."""
|
||||||
credentials = self._plugin.get_all_credentials(tenant_id)
|
credentials = self._plugin.get_all_credentials(tenant_id)
|
||||||
builder = credential_view.get_view_builder(request)
|
builder = credential_view.get_view_builder(request)
|
||||||
result = [builder.build(credential, is_detail)['credential']
|
result = [builder.build(credential, is_detail)['credential']
|
||||||
@ -104,7 +103,7 @@ class CredentialController(common.QuantumController, wsgi.Controller):
|
|||||||
|
|
||||||
# pylint: disable-msg=E1101,W0613
|
# pylint: disable-msg=E1101,W0613
|
||||||
def show(self, request, tenant_id, id):
|
def show(self, request, tenant_id, id):
|
||||||
""" Returns credential details for the given credential id """
|
"""Returns credential details for the given credential id."""
|
||||||
try:
|
try:
|
||||||
credential = self._plugin.get_credential_details(tenant_id, id)
|
credential = self._plugin.get_credential_details(tenant_id, id)
|
||||||
builder = credential_view.get_view_builder(request)
|
builder = credential_view.get_view_builder(request)
|
||||||
@ -115,7 +114,7 @@ class CredentialController(common.QuantumController, wsgi.Controller):
|
|||||||
return faults.Fault(faults.CredentialNotFound(exp))
|
return faults.Fault(faults.CredentialNotFound(exp))
|
||||||
|
|
||||||
def create(self, request, tenant_id):
|
def create(self, request, tenant_id):
|
||||||
""" Creates a new credential for a given tenant """
|
"""Creates a new credential for a given tenant."""
|
||||||
try:
|
try:
|
||||||
body = self._deserialize(request.body, request.get_content_type())
|
body = self._deserialize(request.body, request.get_content_type())
|
||||||
req_body = self._prepare_request_body(
|
req_body = self._prepare_request_body(
|
||||||
@ -134,7 +133,7 @@ class CredentialController(common.QuantumController, wsgi.Controller):
|
|||||||
return dict(credentials=result)
|
return dict(credentials=result)
|
||||||
|
|
||||||
def update(self, request, tenant_id, id):
|
def update(self, request, tenant_id, id):
|
||||||
""" Updates the name for the credential with the given id """
|
"""Updates the name for the credential with the given id."""
|
||||||
try:
|
try:
|
||||||
body = self._deserialize(request.body, request.get_content_type())
|
body = self._deserialize(request.body, request.get_content_type())
|
||||||
req_body = self._prepare_request_body(
|
req_body = self._prepare_request_body(
|
||||||
@ -153,7 +152,7 @@ class CredentialController(common.QuantumController, wsgi.Controller):
|
|||||||
return faults.Fault(faults.CredentialNotFound(exp))
|
return faults.Fault(faults.CredentialNotFound(exp))
|
||||||
|
|
||||||
def delete(self, request, tenant_id, id):
|
def delete(self, request, tenant_id, id):
|
||||||
""" Destroys the credential with the given id """
|
"""Destroys the credential with the given id."""
|
||||||
try:
|
try:
|
||||||
self._plugin.delete_credential(tenant_id, id)
|
self._plugin.delete_credential(tenant_id, id)
|
||||||
return exc.HTTPOk()
|
return exc.HTTPOk()
|
||||||
|
@ -30,36 +30,36 @@ from quantum import wsgi
|
|||||||
|
|
||||||
|
|
||||||
class Qos(extensions.ExtensionDescriptor):
|
class Qos(extensions.ExtensionDescriptor):
|
||||||
"""Qos extension file"""
|
"""Qos extension file."""
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_name(cls):
|
def get_name(cls):
|
||||||
""" Returns Ext Resource Name """
|
"""Returns Ext Resource Name."""
|
||||||
return "Cisco qos"
|
return "Cisco qos"
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_alias(cls):
|
def get_alias(cls):
|
||||||
""" Returns Ext Resource Alias """
|
"""Returns Ext Resource Alias."""
|
||||||
return "Cisco qos"
|
return "Cisco qos"
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_description(cls):
|
def get_description(cls):
|
||||||
""" Returns Ext Resource Description """
|
"""Returns Ext Resource Description."""
|
||||||
return "qos includes qos_name and qos_desc"
|
return "qos includes qos_name and qos_desc"
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_namespace(cls):
|
def get_namespace(cls):
|
||||||
""" Returns Ext Resource Namespace """
|
"""Returns Ext Resource Namespace."""
|
||||||
return "http://docs.ciscocloud.com/api/ext/qos/v1.0"
|
return "http://docs.ciscocloud.com/api/ext/qos/v1.0"
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_updated(cls):
|
def get_updated(cls):
|
||||||
""" Returns Ext Resource update """
|
"""Returns Ext Resource update."""
|
||||||
return "2011-07-25T13:25:27-06:00"
|
return "2011-07-25T13:25:27-06:00"
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_resources(cls):
|
def get_resources(cls):
|
||||||
""" Returns Ext Resources """
|
"""Returns Ext Resources."""
|
||||||
parent_resource = dict(member_name="tenant",
|
parent_resource = dict(member_name="tenant",
|
||||||
collection_name="extensions/csco/tenants")
|
collection_name="extensions/csco/tenants")
|
||||||
|
|
||||||
@ -69,8 +69,7 @@ class Qos(extensions.ExtensionDescriptor):
|
|||||||
|
|
||||||
|
|
||||||
class QosController(common.QuantumController, wsgi.Controller):
|
class QosController(common.QuantumController, wsgi.Controller):
|
||||||
""" qos API controller
|
"""qos API controller based on QuantumController."""
|
||||||
based on QuantumController """
|
|
||||||
|
|
||||||
_qos_ops_param_list = [
|
_qos_ops_param_list = [
|
||||||
{'param-name': 'qos_name', 'required': True},
|
{'param-name': 'qos_name', 'required': True},
|
||||||
@ -90,11 +89,11 @@ class QosController(common.QuantumController, wsgi.Controller):
|
|||||||
self._plugin = plugin
|
self._plugin = plugin
|
||||||
|
|
||||||
def index(self, request, tenant_id):
|
def index(self, request, tenant_id):
|
||||||
""" Returns a list of qos ids """
|
"""Returns a list of qos ids."""
|
||||||
return self._items(request, tenant_id, is_detail=False)
|
return self._items(request, tenant_id, is_detail=False)
|
||||||
|
|
||||||
def _items(self, request, tenant_id, is_detail):
|
def _items(self, request, tenant_id, is_detail):
|
||||||
""" Returns a list of qoss. """
|
"""Returns a list of qoss."""
|
||||||
qoss = self._plugin.get_all_qoss(tenant_id)
|
qoss = self._plugin.get_all_qoss(tenant_id)
|
||||||
builder = qos_view.get_view_builder(request)
|
builder = qos_view.get_view_builder(request)
|
||||||
result = [builder.build(qos, is_detail)['qos'] for qos in qoss]
|
result = [builder.build(qos, is_detail)['qos'] for qos in qoss]
|
||||||
@ -102,7 +101,7 @@ class QosController(common.QuantumController, wsgi.Controller):
|
|||||||
|
|
||||||
# pylint: disable-msg=E1101
|
# pylint: disable-msg=E1101
|
||||||
def show(self, request, tenant_id, id):
|
def show(self, request, tenant_id, id):
|
||||||
""" Returns qos details for the given qos id """
|
"""Returns qos details for the given qos id."""
|
||||||
try:
|
try:
|
||||||
qos = self._plugin.get_qos_details(tenant_id, id)
|
qos = self._plugin.get_qos_details(tenant_id, id)
|
||||||
builder = qos_view.get_view_builder(request)
|
builder = qos_view.get_view_builder(request)
|
||||||
@ -113,7 +112,7 @@ class QosController(common.QuantumController, wsgi.Controller):
|
|||||||
return faults.Fault(faults.QosNotFound(exp))
|
return faults.Fault(faults.QosNotFound(exp))
|
||||||
|
|
||||||
def create(self, request, tenant_id):
|
def create(self, request, tenant_id):
|
||||||
""" Creates a new qos for a given tenant """
|
"""Creates a new qos for a given tenant."""
|
||||||
#look for qos name in request
|
#look for qos name in request
|
||||||
try:
|
try:
|
||||||
body = self._deserialize(request.body, request.get_content_type())
|
body = self._deserialize(request.body, request.get_content_type())
|
||||||
@ -130,7 +129,7 @@ class QosController(common.QuantumController, wsgi.Controller):
|
|||||||
return dict(qoss=result)
|
return dict(qoss=result)
|
||||||
|
|
||||||
def update(self, request, tenant_id, id):
|
def update(self, request, tenant_id, id):
|
||||||
""" Updates the name for the qos with the given id """
|
"""Updates the name for the qos with the given id."""
|
||||||
try:
|
try:
|
||||||
body = self._deserialize(request.body, request.get_content_type())
|
body = self._deserialize(request.body, request.get_content_type())
|
||||||
req_body = self._prepare_request_body(body,
|
req_body = self._prepare_request_body(body,
|
||||||
@ -149,7 +148,7 @@ class QosController(common.QuantumController, wsgi.Controller):
|
|||||||
return faults.Fault(faults.QosNotFound(exp))
|
return faults.Fault(faults.QosNotFound(exp))
|
||||||
|
|
||||||
def delete(self, request, tenant_id, id):
|
def delete(self, request, tenant_id, id):
|
||||||
""" Destroys the qos with the given id """
|
"""Destroys the qos with the given id."""
|
||||||
try:
|
try:
|
||||||
self._plugin.delete_qos(tenant_id, id)
|
self._plugin.delete_qos(tenant_id, id)
|
||||||
return exc.HTTPOk()
|
return exc.HTTPOk()
|
||||||
|
@ -25,15 +25,15 @@ import logging
|
|||||||
from novaclient.v1_1 import client as nova_client
|
from novaclient.v1_1 import client as nova_client
|
||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
|
|
||||||
|
from quantum.db import api as db_api
|
||||||
from quantum.manager import QuantumManager
|
from quantum.manager import QuantumManager
|
||||||
from quantum.openstack.common import importutils
|
from quantum.openstack.common import importutils
|
||||||
from quantum.plugins.cisco.common import cisco_constants as const
|
from quantum.plugins.cisco.common import cisco_constants as const
|
||||||
from quantum.plugins.cisco.common import cisco_credentials_v2 as cred
|
from quantum.plugins.cisco.common import cisco_credentials_v2 as cred
|
||||||
from quantum.plugins.cisco.db import network_db_v2 as cdb
|
|
||||||
from quantum.plugins.cisco.common import config as conf
|
from quantum.plugins.cisco.common import config as conf
|
||||||
|
from quantum.plugins.cisco.db import network_db_v2 as cdb
|
||||||
from quantum.plugins.openvswitch import ovs_db_v2 as odb
|
from quantum.plugins.openvswitch import ovs_db_v2 as odb
|
||||||
from quantum import quantum_plugin_base_v2
|
from quantum import quantum_plugin_base_v2
|
||||||
from quantum.db import api as db_api
|
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
@ -112,7 +112,7 @@ class VirtualPhysicalSwitchModelV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
|
|||||||
return getattr(plugin, name)
|
return getattr(plugin, name)
|
||||||
|
|
||||||
def _func_name(self, offset=0):
|
def _func_name(self, offset=0):
|
||||||
"""Get the name of the calling function"""
|
"""Get the name of the calling function."""
|
||||||
frame_record = inspect.stack()[1 + offset]
|
frame_record = inspect.stack()[1 + offset]
|
||||||
func_name = frame_record[3]
|
func_name = frame_record[3]
|
||||||
return func_name
|
return func_name
|
||||||
@ -206,8 +206,8 @@ class VirtualPhysicalSwitchModelV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
|
|||||||
ovs_output[0]['id'], vlan_name, vlan_id,
|
ovs_output[0]['id'], vlan_name, vlan_id,
|
||||||
{'vlan_ids': vlanids}]
|
{'vlan_ids': vlanids}]
|
||||||
return ovs_output[0]
|
return ovs_output[0]
|
||||||
except:
|
except Exception:
|
||||||
# TODO (Sumit): Check if we need to perform any rollback here
|
# TODO(Sumit): Check if we need to perform any rollback here
|
||||||
raise
|
raise
|
||||||
|
|
||||||
def update_network(self, context, id, network):
|
def update_network(self, context, id, network):
|
||||||
@ -253,15 +253,15 @@ class VirtualPhysicalSwitchModelV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
|
|||||||
self._invoke_plugin_per_device(const.NEXUS_PLUGIN,
|
self._invoke_plugin_per_device(const.NEXUS_PLUGIN,
|
||||||
self._func_name(), args)
|
self._func_name(), args)
|
||||||
return ovs_output[0]
|
return ovs_output[0]
|
||||||
except:
|
except Exception:
|
||||||
raise
|
raise
|
||||||
|
|
||||||
def get_network(self, context, id, fields=None):
|
def get_network(self, context, id, fields=None):
|
||||||
"""For this model this method will be delegated to vswitch plugin"""
|
"""For this model this method will be delegated to vswitch plugin."""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def get_networks(self, context, filters=None, fields=None):
|
def get_networks(self, context, filters=None, fields=None):
|
||||||
"""For this model this method will be delegated to vswitch plugin"""
|
"""For this model this method will be delegated to vswitch plugin."""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def _invoke_nexus_for_net_create(self, context, tenant_id, net_id,
|
def _invoke_nexus_for_net_create(self, context, tenant_id, net_id,
|
||||||
@ -308,16 +308,16 @@ class VirtualPhysicalSwitchModelV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
|
|||||||
context, tenant_id, net_id, instance_id)
|
context, tenant_id, net_id, instance_id)
|
||||||
|
|
||||||
return ovs_output[0]
|
return ovs_output[0]
|
||||||
except:
|
except Exception:
|
||||||
# TODO (asomya): Check if we need to perform any rollback here
|
# TODO(asomya): Check if we need to perform any rollback here
|
||||||
raise
|
raise
|
||||||
|
|
||||||
def get_port(self, context, id, fields=None):
|
def get_port(self, context, id, fields=None):
|
||||||
"""For this model this method will be delegated to vswitch plugin"""
|
"""For this model this method will be delegated to vswitch plugin."""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def get_ports(self, context, filters=None, fields=None):
|
def get_ports(self, context, filters=None, fields=None):
|
||||||
"""For this model this method will be delegated to vswitch plugin"""
|
"""For this model this method will be delegated to vswitch plugin."""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def update_port(self, context, id, port):
|
def update_port(self, context, id, port):
|
||||||
@ -348,7 +348,7 @@ class VirtualPhysicalSwitchModelV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
|
|||||||
context, tenant_id, net_id, instance_id)
|
context, tenant_id, net_id, instance_id)
|
||||||
|
|
||||||
return ovs_output[0]
|
return ovs_output[0]
|
||||||
except:
|
except Exception:
|
||||||
raise
|
raise
|
||||||
|
|
||||||
def delete_port(self, context, id):
|
def delete_port(self, context, id):
|
||||||
@ -369,26 +369,26 @@ class VirtualPhysicalSwitchModelV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
|
|||||||
self._func_name(),
|
self._func_name(),
|
||||||
n_args)
|
n_args)
|
||||||
return ovs_output[0]
|
return ovs_output[0]
|
||||||
except:
|
except Exception:
|
||||||
# TODO (asomya): Check if we need to perform any rollback here
|
# TODO(asomya): Check if we need to perform any rollback here
|
||||||
raise
|
raise
|
||||||
|
|
||||||
def create_subnet(self, context, subnet):
|
def create_subnet(self, context, subnet):
|
||||||
"""For this model this method will be delegated to vswitch plugin"""
|
"""For this model this method will be delegated to vswitch plugin."""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def update_subnet(self, context, id, subnet):
|
def update_subnet(self, context, id, subnet):
|
||||||
"""For this model this method will be delegated to vswitch plugin"""
|
"""For this model this method will be delegated to vswitch plugin."""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def get_subnet(self, context, id, fields=None):
|
def get_subnet(self, context, id, fields=None):
|
||||||
"""For this model this method will be delegated to vswitch plugin"""
|
"""For this model this method will be delegated to vswitch plugin."""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def delete_subnet(self, context, id, kwargs):
|
def delete_subnet(self, context, id, kwargs):
|
||||||
"""For this model this method will be delegated to vswitch plugin"""
|
"""For this model this method will be delegated to vswitch plugin."""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def get_subnets(self, context, filters=None, fields=None):
|
def get_subnets(self, context, filters=None, fields=None):
|
||||||
"""For this model this method will be delegated to vswitch plugin"""
|
"""For this model this method will be delegated to vswitch plugin."""
|
||||||
pass
|
pass
|
||||||
|
@ -110,7 +110,7 @@ class PluginV2(db_base_plugin_v2.QuantumDbPluginV2):
|
|||||||
self._invoke_device_plugins(self._func_name(), [context,
|
self._invoke_device_plugins(self._func_name(), [context,
|
||||||
new_network])
|
new_network])
|
||||||
return new_network
|
return new_network
|
||||||
except:
|
except Exception:
|
||||||
super(PluginV2, self).delete_network(context,
|
super(PluginV2, self).delete_network(context,
|
||||||
new_network['id'])
|
new_network['id'])
|
||||||
raise
|
raise
|
||||||
@ -153,7 +153,7 @@ class PluginV2(db_base_plugin_v2.QuantumDbPluginV2):
|
|||||||
self._invoke_device_plugins(self._func_name(), [context, id,
|
self._invoke_device_plugins(self._func_name(), [context, id,
|
||||||
kwargs])
|
kwargs])
|
||||||
return super(PluginV2, self).delete_network(context, id)
|
return super(PluginV2, self).delete_network(context, id)
|
||||||
except:
|
except Exception:
|
||||||
raise
|
raise
|
||||||
|
|
||||||
def get_network(self, context, id, fields=None):
|
def get_network(self, context, id, fields=None):
|
||||||
@ -179,7 +179,7 @@ class PluginV2(db_base_plugin_v2.QuantumDbPluginV2):
|
|||||||
try:
|
try:
|
||||||
self._invoke_device_plugins(self._func_name(), [context, new_port])
|
self._invoke_device_plugins(self._func_name(), [context, new_port])
|
||||||
return new_port
|
return new_port
|
||||||
except:
|
except Exception:
|
||||||
super(PluginV2, self).delete_port(context, new_port['id'])
|
super(PluginV2, self).delete_port(context, new_port['id'])
|
||||||
raise
|
raise
|
||||||
|
|
||||||
@ -199,11 +199,11 @@ class PluginV2(db_base_plugin_v2.QuantumDbPluginV2):
|
|||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
kwargs = {const.PORT: port}
|
kwargs = {const.PORT: port}
|
||||||
# TODO (Sumit): Might first need to check here if port is active
|
# TODO(Sumit): Might first need to check here if port is active
|
||||||
self._invoke_device_plugins(self._func_name(), [context, id,
|
self._invoke_device_plugins(self._func_name(), [context, id,
|
||||||
kwargs])
|
kwargs])
|
||||||
return super(PluginV2, self).delete_port(context, id)
|
return super(PluginV2, self).delete_port(context, id)
|
||||||
except:
|
except Exception:
|
||||||
raise
|
raise
|
||||||
|
|
||||||
def update_port(self, context, id, port):
|
def update_port(self, context, id, port):
|
||||||
@ -215,7 +215,7 @@ class PluginV2(db_base_plugin_v2.QuantumDbPluginV2):
|
|||||||
self._invoke_device_plugins(self._func_name(), [context, id,
|
self._invoke_device_plugins(self._func_name(), [context, id,
|
||||||
port])
|
port])
|
||||||
return super(PluginV2, self).update_port(context, id, port)
|
return super(PluginV2, self).update_port(context, id, port)
|
||||||
except:
|
except Exception:
|
||||||
raise
|
raise
|
||||||
|
|
||||||
def create_subnet(self, context, subnet):
|
def create_subnet(self, context, subnet):
|
||||||
@ -229,7 +229,7 @@ class PluginV2(db_base_plugin_v2.QuantumDbPluginV2):
|
|||||||
self._invoke_device_plugins(self._func_name(), [context,
|
self._invoke_device_plugins(self._func_name(), [context,
|
||||||
new_subnet])
|
new_subnet])
|
||||||
return new_subnet
|
return new_subnet
|
||||||
except:
|
except Exception:
|
||||||
super(PluginV2, self).delete_subnet(context, new_subnet['id'])
|
super(PluginV2, self).delete_subnet(context, new_subnet['id'])
|
||||||
raise
|
raise
|
||||||
|
|
||||||
@ -242,7 +242,7 @@ class PluginV2(db_base_plugin_v2.QuantumDbPluginV2):
|
|||||||
self._invoke_device_plugins(self._func_name(), [context, id,
|
self._invoke_device_plugins(self._func_name(), [context, id,
|
||||||
subnet])
|
subnet])
|
||||||
return super(PluginV2, self).update_subnet(context, id, subnet)
|
return super(PluginV2, self).update_subnet(context, id, subnet)
|
||||||
except:
|
except Exception:
|
||||||
raise
|
raise
|
||||||
|
|
||||||
def delete_subnet(self, context, id):
|
def delete_subnet(self, context, id):
|
||||||
@ -267,20 +267,20 @@ class PluginV2(db_base_plugin_v2.QuantumDbPluginV2):
|
|||||||
self._invoke_device_plugins(self._func_name(), [context, id,
|
self._invoke_device_plugins(self._func_name(), [context, id,
|
||||||
kwargs])
|
kwargs])
|
||||||
return super(PluginV2, self).delete_subnet(context, id)
|
return super(PluginV2, self).delete_subnet(context, id)
|
||||||
except:
|
except Exception:
|
||||||
raise
|
raise
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Extension API implementation
|
Extension API implementation
|
||||||
"""
|
"""
|
||||||
def get_all_qoss(self, tenant_id):
|
def get_all_qoss(self, tenant_id):
|
||||||
"""Get all QoS levels"""
|
"""Get all QoS levels."""
|
||||||
LOG.debug(_("get_all_qoss() called"))
|
LOG.debug(_("get_all_qoss() called"))
|
||||||
qoslist = cdb.get_all_qoss(tenant_id)
|
qoslist = cdb.get_all_qoss(tenant_id)
|
||||||
return qoslist
|
return qoslist
|
||||||
|
|
||||||
def get_qos_details(self, tenant_id, qos_id):
|
def get_qos_details(self, tenant_id, qos_id):
|
||||||
"""Get QoS Details"""
|
"""Get QoS Details."""
|
||||||
LOG.debug(_("get_qos_details() called"))
|
LOG.debug(_("get_qos_details() called"))
|
||||||
try:
|
try:
|
||||||
qos_level = cdb.get_qos(tenant_id, qos_id)
|
qos_level = cdb.get_qos(tenant_id, qos_id)
|
||||||
@ -290,13 +290,13 @@ class PluginV2(db_base_plugin_v2.QuantumDbPluginV2):
|
|||||||
return qos_level
|
return qos_level
|
||||||
|
|
||||||
def create_qos(self, tenant_id, qos_name, qos_desc):
|
def create_qos(self, tenant_id, qos_name, qos_desc):
|
||||||
"""Create a QoS level"""
|
"""Create a QoS level."""
|
||||||
LOG.debug(_("create_qos() called"))
|
LOG.debug(_("create_qos() called"))
|
||||||
qos = cdb.add_qos(tenant_id, qos_name, str(qos_desc))
|
qos = cdb.add_qos(tenant_id, qos_name, str(qos_desc))
|
||||||
return qos
|
return qos
|
||||||
|
|
||||||
def delete_qos(self, tenant_id, qos_id):
|
def delete_qos(self, tenant_id, qos_id):
|
||||||
"""Delete a QoS level"""
|
"""Delete a QoS level."""
|
||||||
LOG.debug(_("delete_qos() called"))
|
LOG.debug(_("delete_qos() called"))
|
||||||
try:
|
try:
|
||||||
cdb.get_qos(tenant_id, qos_id)
|
cdb.get_qos(tenant_id, qos_id)
|
||||||
@ -306,7 +306,7 @@ class PluginV2(db_base_plugin_v2.QuantumDbPluginV2):
|
|||||||
return cdb.remove_qos(tenant_id, qos_id)
|
return cdb.remove_qos(tenant_id, qos_id)
|
||||||
|
|
||||||
def rename_qos(self, tenant_id, qos_id, new_name):
|
def rename_qos(self, tenant_id, qos_id, new_name):
|
||||||
"""Rename QoS level"""
|
"""Rename QoS level."""
|
||||||
LOG.debug(_("rename_qos() called"))
|
LOG.debug(_("rename_qos() called"))
|
||||||
try:
|
try:
|
||||||
cdb.get_qos(tenant_id, qos_id)
|
cdb.get_qos(tenant_id, qos_id)
|
||||||
@ -317,13 +317,13 @@ class PluginV2(db_base_plugin_v2.QuantumDbPluginV2):
|
|||||||
return qos
|
return qos
|
||||||
|
|
||||||
def get_all_credentials(self, tenant_id):
|
def get_all_credentials(self, tenant_id):
|
||||||
"""Get all credentials"""
|
"""Get all credentials."""
|
||||||
LOG.debug(_("get_all_credentials() called"))
|
LOG.debug(_("get_all_credentials() called"))
|
||||||
credential_list = cdb.get_all_credentials(tenant_id)
|
credential_list = cdb.get_all_credentials(tenant_id)
|
||||||
return credential_list
|
return credential_list
|
||||||
|
|
||||||
def get_credential_details(self, tenant_id, credential_id):
|
def get_credential_details(self, tenant_id, credential_id):
|
||||||
"""Get a particular credential"""
|
"""Get a particular credential."""
|
||||||
LOG.debug(_("get_credential_details() called"))
|
LOG.debug(_("get_credential_details() called"))
|
||||||
try:
|
try:
|
||||||
credential = cdb.get_credential(tenant_id, credential_id)
|
credential = cdb.get_credential(tenant_id, credential_id)
|
||||||
@ -334,14 +334,14 @@ class PluginV2(db_base_plugin_v2.QuantumDbPluginV2):
|
|||||||
|
|
||||||
def create_credential(self, tenant_id, credential_name, user_name,
|
def create_credential(self, tenant_id, credential_name, user_name,
|
||||||
password):
|
password):
|
||||||
"""Create a new credential"""
|
"""Create a new credential."""
|
||||||
LOG.debug(_("create_credential() called"))
|
LOG.debug(_("create_credential() called"))
|
||||||
credential = cdb.add_credential(tenant_id, credential_name,
|
credential = cdb.add_credential(tenant_id, credential_name,
|
||||||
user_name, password)
|
user_name, password)
|
||||||
return credential
|
return credential
|
||||||
|
|
||||||
def delete_credential(self, tenant_id, credential_id):
|
def delete_credential(self, tenant_id, credential_id):
|
||||||
"""Delete a credential"""
|
"""Delete a credential."""
|
||||||
LOG.debug(_("delete_credential() called"))
|
LOG.debug(_("delete_credential() called"))
|
||||||
try:
|
try:
|
||||||
credential = cdb.get_credential(tenant_id, credential_id)
|
credential = cdb.get_credential(tenant_id, credential_id)
|
||||||
@ -352,7 +352,7 @@ class PluginV2(db_base_plugin_v2.QuantumDbPluginV2):
|
|||||||
return credential
|
return credential
|
||||||
|
|
||||||
def rename_credential(self, tenant_id, credential_id, new_name):
|
def rename_credential(self, tenant_id, credential_id, new_name):
|
||||||
"""Rename the particular credential resource"""
|
"""Rename the particular credential resource."""
|
||||||
LOG.debug(_("rename_credential() called"))
|
LOG.debug(_("rename_credential() called"))
|
||||||
try:
|
try:
|
||||||
credential = cdb.get_credential(tenant_id, credential_id)
|
credential = cdb.get_credential(tenant_id, credential_id)
|
||||||
@ -363,7 +363,7 @@ class PluginV2(db_base_plugin_v2.QuantumDbPluginV2):
|
|||||||
return credential
|
return credential
|
||||||
|
|
||||||
def schedule_host(self, tenant_id, instance_id, instance_desc):
|
def schedule_host(self, tenant_id, instance_id, instance_desc):
|
||||||
"""Provides the hostname on which a dynamic vnic is reserved"""
|
"""Provides the hostname on which a dynamic vnic is reserved."""
|
||||||
LOG.debug(_("schedule_host() called"))
|
LOG.debug(_("schedule_host() called"))
|
||||||
host_list = self._invoke_device_plugins(self._func_name(),
|
host_list = self._invoke_device_plugins(self._func_name(),
|
||||||
[tenant_id,
|
[tenant_id,
|
||||||
@ -401,5 +401,5 @@ class PluginV2(db_base_plugin_v2.QuantumDbPluginV2):
|
|||||||
return getattr(self._model, function_name)(*args)
|
return getattr(self._model, function_name)(*args)
|
||||||
|
|
||||||
def _func_name(self, offset=0):
|
def _func_name(self, offset=0):
|
||||||
"""Getting the name of the calling funciton"""
|
"""Getting the name of the calling funciton."""
|
||||||
return inspect.stack()[1 + offset][3]
|
return inspect.stack()[1 + offset][3]
|
||||||
|
@ -75,7 +75,7 @@ class ExtensionsTestApp(wsgi.Router):
|
|||||||
|
|
||||||
def create_request(self, path, body, content_type, method='GET'):
|
def create_request(self, path, body, content_type, method='GET'):
|
||||||
|
|
||||||
""" Test create request"""
|
"""Test create request."""
|
||||||
|
|
||||||
LOG.debug("test_create_request - START")
|
LOG.debug("test_create_request - START")
|
||||||
req = webob.Request.blank(path)
|
req = webob.Request.blank(path)
|
||||||
@ -88,7 +88,7 @@ class ExtensionsTestApp(wsgi.Router):
|
|||||||
|
|
||||||
def _create_network(self, name=None):
|
def _create_network(self, name=None):
|
||||||
|
|
||||||
""" Test create network"""
|
"""Test create network."""
|
||||||
|
|
||||||
LOG.debug("Creating network - START")
|
LOG.debug("Creating network - START")
|
||||||
if name:
|
if name:
|
||||||
@ -108,7 +108,7 @@ class ExtensionsTestApp(wsgi.Router):
|
|||||||
|
|
||||||
def _create_port(self, network_id, port_state):
|
def _create_port(self, network_id, port_state):
|
||||||
|
|
||||||
""" Test create port"""
|
"""Test create port."""
|
||||||
|
|
||||||
LOG.debug("Creating port for network %s - START", network_id)
|
LOG.debug("Creating port for network %s - START", network_id)
|
||||||
port_path = "/tenants/tt/networks/%s/ports" % network_id
|
port_path = "/tenants/tt/networks/%s/ports" % network_id
|
||||||
@ -124,7 +124,7 @@ class ExtensionsTestApp(wsgi.Router):
|
|||||||
return port_data['port']['id']
|
return port_data['port']['id']
|
||||||
|
|
||||||
def _delete_port(self, network_id, port_id):
|
def _delete_port(self, network_id, port_id):
|
||||||
""" Delete port """
|
"""Delete port."""
|
||||||
LOG.debug("Deleting port for network %s - START", network_id)
|
LOG.debug("Deleting port for network %s - START", network_id)
|
||||||
port_path = ("/tenants/tt/networks/%(network_id)s/ports/%(port_id)s" %
|
port_path = ("/tenants/tt/networks/%(network_id)s/ports/%(port_id)s" %
|
||||||
locals())
|
locals())
|
||||||
@ -134,7 +134,7 @@ class ExtensionsTestApp(wsgi.Router):
|
|||||||
LOG.debug("Deleting port for network - END")
|
LOG.debug("Deleting port for network - END")
|
||||||
|
|
||||||
def _delete_network(self, network_id):
|
def _delete_network(self, network_id):
|
||||||
""" Delete network """
|
"""Delete network."""
|
||||||
LOG.debug("Deleting network %s - START", network_id)
|
LOG.debug("Deleting network %s - START", network_id)
|
||||||
network_path = "/tenants/tt/networks/%s" % network_id
|
network_path = "/tenants/tt/networks/%s" % network_id
|
||||||
network_req = self.create_request(network_path, None,
|
network_req = self.create_request(network_path, None,
|
||||||
@ -143,7 +143,7 @@ class ExtensionsTestApp(wsgi.Router):
|
|||||||
LOG.debug("Deleting network - END")
|
LOG.debug("Deleting network - END")
|
||||||
|
|
||||||
def tear_down_port_network(self, net_id, port_id):
|
def tear_down_port_network(self, net_id, port_id):
|
||||||
""" Tear down port and network """
|
"""Tear down port and network."""
|
||||||
|
|
||||||
self._delete_port(net_id, port_id)
|
self._delete_port(net_id, port_id)
|
||||||
self._delete_network(net_id)
|
self._delete_network(net_id)
|
||||||
@ -153,7 +153,7 @@ class QosExtensionTest(base.BaseTestCase):
|
|||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
|
||||||
""" Set up function """
|
"""Set up function."""
|
||||||
|
|
||||||
super(QosExtensionTest, self).setUp()
|
super(QosExtensionTest, self).setUp()
|
||||||
parent_resource = dict(member_name="tenant",
|
parent_resource = dict(member_name="tenant",
|
||||||
@ -180,7 +180,7 @@ class QosExtensionTest(base.BaseTestCase):
|
|||||||
|
|
||||||
def test_create_qos(self):
|
def test_create_qos(self):
|
||||||
|
|
||||||
""" Test create qos """
|
"""Test create qos."""
|
||||||
|
|
||||||
LOG.debug("test_create_qos - START")
|
LOG.debug("test_create_qos - START")
|
||||||
req_body = jsonutils.dumps(self.test_qos_data)
|
req_body = jsonutils.dumps(self.test_qos_data)
|
||||||
@ -199,7 +199,7 @@ class QosExtensionTest(base.BaseTestCase):
|
|||||||
|
|
||||||
def test_create_qosBADRequest(self):
|
def test_create_qosBADRequest(self):
|
||||||
|
|
||||||
""" Test create qos bad request """
|
"""Test create qos bad request."""
|
||||||
|
|
||||||
LOG.debug("test_create_qosBADRequest - START")
|
LOG.debug("test_create_qosBADRequest - START")
|
||||||
index_response = self.test_app.post(self.qos_path,
|
index_response = self.test_app.post(self.qos_path,
|
||||||
@ -211,7 +211,7 @@ class QosExtensionTest(base.BaseTestCase):
|
|||||||
|
|
||||||
def test_list_qoss(self):
|
def test_list_qoss(self):
|
||||||
|
|
||||||
""" Test list qoss """
|
"""Test list qoss."""
|
||||||
|
|
||||||
LOG.debug("test_list_qoss - START")
|
LOG.debug("test_list_qoss - START")
|
||||||
req_body1 = jsonutils.dumps(self.test_qos_data)
|
req_body1 = jsonutils.dumps(self.test_qos_data)
|
||||||
@ -251,7 +251,7 @@ class QosExtensionTest(base.BaseTestCase):
|
|||||||
|
|
||||||
def test_show_qos(self):
|
def test_show_qos(self):
|
||||||
|
|
||||||
""" Test show qos """
|
"""Test show qos."""
|
||||||
|
|
||||||
LOG.debug("test_show_qos - START")
|
LOG.debug("test_show_qos - START")
|
||||||
req_body = jsonutils.dumps(self.test_qos_data)
|
req_body = jsonutils.dumps(self.test_qos_data)
|
||||||
@ -275,7 +275,7 @@ class QosExtensionTest(base.BaseTestCase):
|
|||||||
|
|
||||||
def test_show_qosDNE(self, qos_id='100'):
|
def test_show_qosDNE(self, qos_id='100'):
|
||||||
|
|
||||||
""" Test show qos does not exist"""
|
"""Test show qos does not exist."""
|
||||||
|
|
||||||
LOG.debug("test_show_qosDNE - START")
|
LOG.debug("test_show_qosDNE - START")
|
||||||
show_path_temp = self.qos_second_path + qos_id
|
show_path_temp = self.qos_second_path + qos_id
|
||||||
@ -286,7 +286,7 @@ class QosExtensionTest(base.BaseTestCase):
|
|||||||
|
|
||||||
def test_update_qos(self):
|
def test_update_qos(self):
|
||||||
|
|
||||||
""" Test update qos """
|
"""Test update qos."""
|
||||||
|
|
||||||
LOG.debug("test_update_qos - START")
|
LOG.debug("test_update_qos - START")
|
||||||
req_body = jsonutils.dumps(self.test_qos_data)
|
req_body = jsonutils.dumps(self.test_qos_data)
|
||||||
@ -318,7 +318,7 @@ class QosExtensionTest(base.BaseTestCase):
|
|||||||
|
|
||||||
def test_update_qosDNE(self, qos_id='100'):
|
def test_update_qosDNE(self, qos_id='100'):
|
||||||
|
|
||||||
""" Test update qos does not exist """
|
"""Test update qos does not exist."""
|
||||||
|
|
||||||
LOG.debug("test_update_qosDNE - START")
|
LOG.debug("test_update_qosDNE - START")
|
||||||
rename_req_body = jsonutils.dumps({
|
rename_req_body = jsonutils.dumps({
|
||||||
@ -340,7 +340,7 @@ class QosExtensionTest(base.BaseTestCase):
|
|||||||
|
|
||||||
def test_update_qosBADRequest(self):
|
def test_update_qosBADRequest(self):
|
||||||
|
|
||||||
""" Test update qos bad request """
|
"""Test update qos bad request."""
|
||||||
|
|
||||||
LOG.debug("test_update_qosBADRequest - START")
|
LOG.debug("test_update_qosBADRequest - START")
|
||||||
req_body = jsonutils.dumps(self.test_qos_data)
|
req_body = jsonutils.dumps(self.test_qos_data)
|
||||||
@ -361,7 +361,7 @@ class QosExtensionTest(base.BaseTestCase):
|
|||||||
|
|
||||||
def test_delete_qos(self):
|
def test_delete_qos(self):
|
||||||
|
|
||||||
""" Test delte qos """
|
"""Test delte qos."""
|
||||||
|
|
||||||
LOG.debug("test_delete_qos - START")
|
LOG.debug("test_delete_qos - START")
|
||||||
req_body = jsonutils.dumps({
|
req_body = jsonutils.dumps({
|
||||||
@ -386,7 +386,7 @@ class QosExtensionTest(base.BaseTestCase):
|
|||||||
|
|
||||||
def test_delete_qosDNE(self, qos_id='100'):
|
def test_delete_qosDNE(self, qos_id='100'):
|
||||||
|
|
||||||
""" Test delte qos does not exist"""
|
"""Test delte qos does not exist."""
|
||||||
|
|
||||||
LOG.debug("test_delete_qosDNE - START")
|
LOG.debug("test_delete_qosDNE - START")
|
||||||
delete_path_temp = self.qos_second_path + qos_id
|
delete_path_temp = self.qos_second_path + qos_id
|
||||||
@ -397,7 +397,7 @@ class QosExtensionTest(base.BaseTestCase):
|
|||||||
|
|
||||||
def tearDownQos(self, delete_profile_path):
|
def tearDownQos(self, delete_profile_path):
|
||||||
|
|
||||||
""" Tear Down Qos """
|
"""Tear Down Qos."""
|
||||||
|
|
||||||
self.test_app.delete(delete_profile_path)
|
self.test_app.delete(delete_profile_path)
|
||||||
|
|
||||||
@ -409,7 +409,7 @@ class CredentialExtensionTest(base.BaseTestCase):
|
|||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
|
||||||
""" Set up function """
|
"""Set up function."""
|
||||||
|
|
||||||
super(CredentialExtensionTest, self).setUp()
|
super(CredentialExtensionTest, self).setUp()
|
||||||
parent_resource = dict(member_name="tenant",
|
parent_resource = dict(member_name="tenant",
|
||||||
@ -434,7 +434,7 @@ class CredentialExtensionTest(base.BaseTestCase):
|
|||||||
|
|
||||||
def test_list_credentials(self):
|
def test_list_credentials(self):
|
||||||
|
|
||||||
""" Test list credentials """
|
"""Test list credentials."""
|
||||||
|
|
||||||
#Create Credential before listing
|
#Create Credential before listing
|
||||||
LOG.debug("test_list_credentials - START")
|
LOG.debug("test_list_credentials - START")
|
||||||
@ -479,7 +479,7 @@ class CredentialExtensionTest(base.BaseTestCase):
|
|||||||
|
|
||||||
def test_create_credential(self):
|
def test_create_credential(self):
|
||||||
|
|
||||||
""" Test create credential """
|
"""Test create credential."""
|
||||||
|
|
||||||
LOG.debug("test_create_credential - START")
|
LOG.debug("test_create_credential - START")
|
||||||
req_body = jsonutils.dumps(self.test_credential_data)
|
req_body = jsonutils.dumps(self.test_credential_data)
|
||||||
@ -498,7 +498,7 @@ class CredentialExtensionTest(base.BaseTestCase):
|
|||||||
|
|
||||||
def test_create_credentialBADRequest(self):
|
def test_create_credentialBADRequest(self):
|
||||||
|
|
||||||
""" Test create credential bad request """
|
"""Test create credential bad request."""
|
||||||
|
|
||||||
LOG.debug("test_create_credentialBADRequest - START")
|
LOG.debug("test_create_credentialBADRequest - START")
|
||||||
index_response = self.test_app.post(
|
index_response = self.test_app.post(
|
||||||
@ -509,7 +509,7 @@ class CredentialExtensionTest(base.BaseTestCase):
|
|||||||
|
|
||||||
def test_show_credential(self):
|
def test_show_credential(self):
|
||||||
|
|
||||||
""" Test show credential """
|
"""Test show credential."""
|
||||||
|
|
||||||
LOG.debug("test_show_credential - START")
|
LOG.debug("test_show_credential - START")
|
||||||
req_body = jsonutils.dumps(self.test_credential_data)
|
req_body = jsonutils.dumps(self.test_credential_data)
|
||||||
@ -534,7 +534,7 @@ class CredentialExtensionTest(base.BaseTestCase):
|
|||||||
|
|
||||||
def test_show_credentialDNE(self, credential_id='100'):
|
def test_show_credentialDNE(self, credential_id='100'):
|
||||||
|
|
||||||
""" Test show credential does not exist """
|
"""Test show credential does not exist."""
|
||||||
|
|
||||||
LOG.debug("test_show_credentialDNE - START")
|
LOG.debug("test_show_credentialDNE - START")
|
||||||
show_path_temp = self.cred_second_path + credential_id
|
show_path_temp = self.cred_second_path + credential_id
|
||||||
@ -545,7 +545,7 @@ class CredentialExtensionTest(base.BaseTestCase):
|
|||||||
|
|
||||||
def test_update_credential(self):
|
def test_update_credential(self):
|
||||||
|
|
||||||
""" Test update credential """
|
"""Test update credential."""
|
||||||
|
|
||||||
LOG.debug("test_update_credential - START")
|
LOG.debug("test_update_credential - START")
|
||||||
req_body = jsonutils.dumps(self.test_credential_data)
|
req_body = jsonutils.dumps(self.test_credential_data)
|
||||||
@ -581,7 +581,7 @@ class CredentialExtensionTest(base.BaseTestCase):
|
|||||||
|
|
||||||
def test_update_credBADReq(self):
|
def test_update_credBADReq(self):
|
||||||
|
|
||||||
""" Test update credential bad request """
|
"""Test update credential bad request."""
|
||||||
|
|
||||||
LOG.debug("test_update_credBADReq - START")
|
LOG.debug("test_update_credBADReq - START")
|
||||||
req_body = jsonutils.dumps(self.test_credential_data)
|
req_body = jsonutils.dumps(self.test_credential_data)
|
||||||
@ -600,7 +600,7 @@ class CredentialExtensionTest(base.BaseTestCase):
|
|||||||
|
|
||||||
def test_update_credentialDNE(self, credential_id='100'):
|
def test_update_credentialDNE(self, credential_id='100'):
|
||||||
|
|
||||||
""" Test update credential does not exist"""
|
"""Test update credential does not exist."""
|
||||||
|
|
||||||
LOG.debug("test_update_credentialDNE - START")
|
LOG.debug("test_update_credentialDNE - START")
|
||||||
rename_req_body = jsonutils.dumps({
|
rename_req_body = jsonutils.dumps({
|
||||||
@ -620,7 +620,7 @@ class CredentialExtensionTest(base.BaseTestCase):
|
|||||||
|
|
||||||
def test_delete_credential(self):
|
def test_delete_credential(self):
|
||||||
|
|
||||||
""" Test delete credential """
|
"""Test delete credential."""
|
||||||
|
|
||||||
LOG.debug("test_delete_credential - START")
|
LOG.debug("test_delete_credential - START")
|
||||||
req_body = jsonutils.dumps(self.test_credential_data)
|
req_body = jsonutils.dumps(self.test_credential_data)
|
||||||
@ -638,7 +638,7 @@ class CredentialExtensionTest(base.BaseTestCase):
|
|||||||
|
|
||||||
def test_delete_credentialDNE(self, credential_id='100'):
|
def test_delete_credentialDNE(self, credential_id='100'):
|
||||||
|
|
||||||
""" Test delete credential does not exist """
|
"""Test delete credential does not exist."""
|
||||||
|
|
||||||
LOG.debug("test_delete_credentialDNE - START")
|
LOG.debug("test_delete_credentialDNE - START")
|
||||||
delete_path_temp = self.cred_second_path + credential_id
|
delete_path_temp = self.cred_second_path + credential_id
|
||||||
|
@ -31,9 +31,9 @@ LOG = logging.getLogger(__name__)
|
|||||||
|
|
||||||
|
|
||||||
class NexusDB(object):
|
class NexusDB(object):
|
||||||
"""Class consisting of methods to call nexus db methods"""
|
"""Class consisting of methods to call nexus db methods."""
|
||||||
def get_all_nexusportbindings(self):
|
def get_all_nexusportbindings(self):
|
||||||
"""get all nexus port bindings"""
|
"""get all nexus port bindings."""
|
||||||
bindings = []
|
bindings = []
|
||||||
try:
|
try:
|
||||||
for bind in nexus_db.get_all_nexusport_bindings():
|
for bind in nexus_db.get_all_nexusport_bindings():
|
||||||
@ -47,7 +47,7 @@ class NexusDB(object):
|
|||||||
return bindings
|
return bindings
|
||||||
|
|
||||||
def get_nexusportbinding(self, vlan_id):
|
def get_nexusportbinding(self, vlan_id):
|
||||||
"""get nexus port binding"""
|
"""get nexus port binding."""
|
||||||
binding = []
|
binding = []
|
||||||
try:
|
try:
|
||||||
for bind in nexus_db.get_nexusport_binding(vlan_id):
|
for bind in nexus_db.get_nexusport_binding(vlan_id):
|
||||||
@ -61,7 +61,7 @@ class NexusDB(object):
|
|||||||
return binding
|
return binding
|
||||||
|
|
||||||
def create_nexusportbinding(self, port_id, vlan_id):
|
def create_nexusportbinding(self, port_id, vlan_id):
|
||||||
"""create nexus port binding"""
|
"""create nexus port binding."""
|
||||||
bind_dict = {}
|
bind_dict = {}
|
||||||
try:
|
try:
|
||||||
res = nexus_db.add_nexusport_binding(port_id, vlan_id)
|
res = nexus_db.add_nexusport_binding(port_id, vlan_id)
|
||||||
@ -73,7 +73,7 @@ class NexusDB(object):
|
|||||||
LOG.error("Failed to create nexus binding: %s" % str(exc))
|
LOG.error("Failed to create nexus binding: %s" % str(exc))
|
||||||
|
|
||||||
def delete_nexusportbinding(self, vlan_id):
|
def delete_nexusportbinding(self, vlan_id):
|
||||||
"""delete nexus port binding"""
|
"""delete nexus port binding."""
|
||||||
bindings = []
|
bindings = []
|
||||||
try:
|
try:
|
||||||
bind = nexus_db.remove_nexusport_binding(vlan_id)
|
bind = nexus_db.remove_nexusport_binding(vlan_id)
|
||||||
@ -88,7 +88,7 @@ class NexusDB(object):
|
|||||||
% str(exc))
|
% str(exc))
|
||||||
|
|
||||||
def update_nexusport_binding(self, port_id, new_vlan_id):
|
def update_nexusport_binding(self, port_id, new_vlan_id):
|
||||||
"""update nexus port binding"""
|
"""update nexus port binding."""
|
||||||
try:
|
try:
|
||||||
res = nexus_db.update_nexusport_binding(port_id, new_vlan_id)
|
res = nexus_db.update_nexusport_binding(port_id, new_vlan_id)
|
||||||
LOG.debug("Updating nexus port binding : %s" % res.port_id)
|
LOG.debug("Updating nexus port binding : %s" % res.port_id)
|
||||||
@ -102,9 +102,9 @@ class NexusDB(object):
|
|||||||
|
|
||||||
|
|
||||||
class L2networkDB(object):
|
class L2networkDB(object):
|
||||||
"""Class conisting of methods to call L2network db methods"""
|
"""Class conisting of methods to call L2network db methods."""
|
||||||
def get_all_vlan_bindings(self):
|
def get_all_vlan_bindings(self):
|
||||||
"""Get all vlan binding into a list of dict"""
|
"""Get all vlan binding into a list of dict."""
|
||||||
vlans = []
|
vlans = []
|
||||||
try:
|
try:
|
||||||
for vlan_bind in l2network_db.get_all_vlan_bindings():
|
for vlan_bind in l2network_db.get_all_vlan_bindings():
|
||||||
@ -120,7 +120,7 @@ class L2networkDB(object):
|
|||||||
return vlans
|
return vlans
|
||||||
|
|
||||||
def get_vlan_binding(self, network_id):
|
def get_vlan_binding(self, network_id):
|
||||||
"""Get a vlan binding"""
|
"""Get a vlan binding."""
|
||||||
vlan = []
|
vlan = []
|
||||||
try:
|
try:
|
||||||
for vlan_bind in l2network_db.get_vlan_binding(network_id):
|
for vlan_bind in l2network_db.get_vlan_binding(network_id):
|
||||||
@ -136,7 +136,7 @@ class L2networkDB(object):
|
|||||||
return vlan
|
return vlan
|
||||||
|
|
||||||
def create_vlan_binding(self, vlan_id, vlan_name, network_id):
|
def create_vlan_binding(self, vlan_id, vlan_name, network_id):
|
||||||
"""Create a vlan binding"""
|
"""Create a vlan binding."""
|
||||||
vlan_dict = {}
|
vlan_dict = {}
|
||||||
try:
|
try:
|
||||||
res = l2network_db.add_vlan_binding(vlan_id, vlan_name, network_id)
|
res = l2network_db.add_vlan_binding(vlan_id, vlan_name, network_id)
|
||||||
@ -149,7 +149,7 @@ class L2networkDB(object):
|
|||||||
LOG.error("Failed to create vlan binding: %s" % str(exc))
|
LOG.error("Failed to create vlan binding: %s" % str(exc))
|
||||||
|
|
||||||
def delete_vlan_binding(self, network_id):
|
def delete_vlan_binding(self, network_id):
|
||||||
"""Delete a vlan binding"""
|
"""Delete a vlan binding."""
|
||||||
try:
|
try:
|
||||||
res = l2network_db.remove_vlan_binding(network_id)
|
res = l2network_db.remove_vlan_binding(network_id)
|
||||||
LOG.debug("Deleted vlan binding for vlan: %s" % res.vlan_id)
|
LOG.debug("Deleted vlan binding for vlan: %s" % res.vlan_id)
|
||||||
@ -160,7 +160,7 @@ class L2networkDB(object):
|
|||||||
raise Exception("Failed to delete vlan binding: %s" % str(exc))
|
raise Exception("Failed to delete vlan binding: %s" % str(exc))
|
||||||
|
|
||||||
def update_vlan_binding(self, network_id, vlan_id, vlan_name):
|
def update_vlan_binding(self, network_id, vlan_id, vlan_name):
|
||||||
"""Update a vlan binding"""
|
"""Update a vlan binding."""
|
||||||
try:
|
try:
|
||||||
res = l2network_db.update_vlan_binding(network_id, vlan_id,
|
res = l2network_db.update_vlan_binding(network_id, vlan_id,
|
||||||
vlan_name)
|
vlan_name)
|
||||||
@ -175,9 +175,9 @@ class L2networkDB(object):
|
|||||||
|
|
||||||
|
|
||||||
class QuantumDB(object):
|
class QuantumDB(object):
|
||||||
"""Class conisting of methods to call Quantum db methods"""
|
"""Class conisting of methods to call Quantum db methods."""
|
||||||
def get_all_networks(self, tenant_id):
|
def get_all_networks(self, tenant_id):
|
||||||
"""Get all networks"""
|
"""Get all networks."""
|
||||||
nets = []
|
nets = []
|
||||||
try:
|
try:
|
||||||
for net in db.network_list(tenant_id):
|
for net in db.network_list(tenant_id):
|
||||||
@ -192,7 +192,7 @@ class QuantumDB(object):
|
|||||||
return nets
|
return nets
|
||||||
|
|
||||||
def get_network(self, network_id):
|
def get_network(self, network_id):
|
||||||
"""Get a network"""
|
"""Get a network."""
|
||||||
net = []
|
net = []
|
||||||
try:
|
try:
|
||||||
for net in db.network_get(network_id):
|
for net in db.network_get(network_id):
|
||||||
@ -207,7 +207,7 @@ class QuantumDB(object):
|
|||||||
return net
|
return net
|
||||||
|
|
||||||
def create_network(self, tenant_id, net_name):
|
def create_network(self, tenant_id, net_name):
|
||||||
"""Create a network"""
|
"""Create a network."""
|
||||||
net_dict = {}
|
net_dict = {}
|
||||||
try:
|
try:
|
||||||
res = db.network_create(tenant_id, net_name)
|
res = db.network_create(tenant_id, net_name)
|
||||||
@ -220,7 +220,7 @@ class QuantumDB(object):
|
|||||||
LOG.error("Failed to create network: %s" % str(exc))
|
LOG.error("Failed to create network: %s" % str(exc))
|
||||||
|
|
||||||
def delete_network(self, net_id):
|
def delete_network(self, net_id):
|
||||||
"""Delete a network"""
|
"""Delete a network."""
|
||||||
try:
|
try:
|
||||||
net = db.network_destroy(net_id)
|
net = db.network_destroy(net_id)
|
||||||
LOG.debug("Deleted network: %s" % net.uuid)
|
LOG.debug("Deleted network: %s" % net.uuid)
|
||||||
@ -231,7 +231,7 @@ class QuantumDB(object):
|
|||||||
raise Exception("Failed to delete port: %s" % str(exc))
|
raise Exception("Failed to delete port: %s" % str(exc))
|
||||||
|
|
||||||
def update_network(self, tenant_id, net_id, **kwargs):
|
def update_network(self, tenant_id, net_id, **kwargs):
|
||||||
"""Update a network"""
|
"""Update a network."""
|
||||||
try:
|
try:
|
||||||
net = db.network_update(net_id, tenant_id, **kwargs)
|
net = db.network_update(net_id, tenant_id, **kwargs)
|
||||||
LOG.debug("Updated network: %s" % net.uuid)
|
LOG.debug("Updated network: %s" % net.uuid)
|
||||||
@ -243,7 +243,7 @@ class QuantumDB(object):
|
|||||||
raise Exception("Failed to update network: %s" % str(exc))
|
raise Exception("Failed to update network: %s" % str(exc))
|
||||||
|
|
||||||
def get_all_ports(self, net_id):
|
def get_all_ports(self, net_id):
|
||||||
"""Get all ports"""
|
"""Get all ports."""
|
||||||
ports = []
|
ports = []
|
||||||
try:
|
try:
|
||||||
for port in db.port_list(net_id):
|
for port in db.port_list(net_id):
|
||||||
@ -260,7 +260,7 @@ class QuantumDB(object):
|
|||||||
LOG.error("Failed to get all ports: %s" % str(exc))
|
LOG.error("Failed to get all ports: %s" % str(exc))
|
||||||
|
|
||||||
def get_port(self, net_id, port_id):
|
def get_port(self, net_id, port_id):
|
||||||
"""Get a port"""
|
"""Get a port."""
|
||||||
port_list = []
|
port_list = []
|
||||||
port = db.port_get(net_id, port_id)
|
port = db.port_get(net_id, port_id)
|
||||||
try:
|
try:
|
||||||
@ -276,7 +276,7 @@ class QuantumDB(object):
|
|||||||
LOG.error("Failed to get port: %s" % str(exc))
|
LOG.error("Failed to get port: %s" % str(exc))
|
||||||
|
|
||||||
def create_port(self, net_id):
|
def create_port(self, net_id):
|
||||||
"""Add a port"""
|
"""Add a port."""
|
||||||
port_dict = {}
|
port_dict = {}
|
||||||
try:
|
try:
|
||||||
port = db.port_create(net_id)
|
port = db.port_create(net_id)
|
||||||
@ -290,7 +290,7 @@ class QuantumDB(object):
|
|||||||
LOG.error("Failed to create port: %s" % str(exc))
|
LOG.error("Failed to create port: %s" % str(exc))
|
||||||
|
|
||||||
def delete_port(self, net_id, port_id):
|
def delete_port(self, net_id, port_id):
|
||||||
"""Delete a port"""
|
"""Delete a port."""
|
||||||
try:
|
try:
|
||||||
port = db.port_destroy(net_id, port_id)
|
port = db.port_destroy(net_id, port_id)
|
||||||
LOG.debug("Deleted port %s" % port.uuid)
|
LOG.debug("Deleted port %s" % port.uuid)
|
||||||
@ -301,7 +301,7 @@ class QuantumDB(object):
|
|||||||
raise Exception("Failed to delete port: %s" % str(exc))
|
raise Exception("Failed to delete port: %s" % str(exc))
|
||||||
|
|
||||||
def update_port(self, net_id, port_id, port_state):
|
def update_port(self, net_id, port_id, port_state):
|
||||||
"""Update a port"""
|
"""Update a port."""
|
||||||
try:
|
try:
|
||||||
port = db.port_set_state(net_id, port_id, port_state)
|
port = db.port_set_state(net_id, port_id, port_state)
|
||||||
LOG.debug("Updated port %s" % port.uuid)
|
LOG.debug("Updated port %s" % port.uuid)
|
||||||
@ -315,7 +315,7 @@ class QuantumDB(object):
|
|||||||
raise Exception("Failed to update port state: %s" % str(exc))
|
raise Exception("Failed to update port state: %s" % str(exc))
|
||||||
|
|
||||||
def plug_interface(self, net_id, port_id, int_id):
|
def plug_interface(self, net_id, port_id, int_id):
|
||||||
"""Plug interface to a port"""
|
"""Plug interface to a port."""
|
||||||
try:
|
try:
|
||||||
port = db.port_set_attachment(net_id, port_id, int_id)
|
port = db.port_set_attachment(net_id, port_id, int_id)
|
||||||
LOG.debug("Attached interface to port %s" % port.uuid)
|
LOG.debug("Attached interface to port %s" % port.uuid)
|
||||||
@ -329,7 +329,7 @@ class QuantumDB(object):
|
|||||||
raise Exception("Failed to plug interface: %s" % str(exc))
|
raise Exception("Failed to plug interface: %s" % str(exc))
|
||||||
|
|
||||||
def unplug_interface(self, net_id, port_id):
|
def unplug_interface(self, net_id, port_id):
|
||||||
"""Unplug interface to a port"""
|
"""Unplug interface to a port."""
|
||||||
try:
|
try:
|
||||||
port = db.port_unset_attachment(net_id, port_id)
|
port = db.port_unset_attachment(net_id, port_id)
|
||||||
LOG.debug("Detached interface from port %s" % port.uuid)
|
LOG.debug("Detached interface from port %s" % port.uuid)
|
||||||
@ -344,23 +344,23 @@ class QuantumDB(object):
|
|||||||
|
|
||||||
|
|
||||||
class NexusDBTest(base.BaseTestCase):
|
class NexusDBTest(base.BaseTestCase):
|
||||||
"""Class conisting of nexus DB unit tests"""
|
"""Class conisting of nexus DB unit tests."""
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(NexusDBTest, self).setUp()
|
super(NexusDBTest, self).setUp()
|
||||||
"""Setup for nexus db tests"""
|
"""Setup for nexus db tests."""
|
||||||
l2network_db.initialize()
|
l2network_db.initialize()
|
||||||
self.addCleanup(db.clear_db)
|
self.addCleanup(db.clear_db)
|
||||||
self.dbtest = NexusDB()
|
self.dbtest = NexusDB()
|
||||||
LOG.debug("Setup")
|
LOG.debug("Setup")
|
||||||
|
|
||||||
def testa_create_nexusportbinding(self):
|
def testa_create_nexusportbinding(self):
|
||||||
"""create nexus port binding"""
|
"""create nexus port binding."""
|
||||||
binding1 = self.dbtest.create_nexusportbinding("port1", 10)
|
binding1 = self.dbtest.create_nexusportbinding("port1", 10)
|
||||||
self.assertTrue(binding1["port-id"] == "port1")
|
self.assertTrue(binding1["port-id"] == "port1")
|
||||||
self.tearDown_nexusportbinding()
|
self.tearDown_nexusportbinding()
|
||||||
|
|
||||||
def testb_getall_nexusportbindings(self):
|
def testb_getall_nexusportbindings(self):
|
||||||
"""get all nexus port binding"""
|
"""get all nexus port binding."""
|
||||||
self.dbtest.create_nexusportbinding("port1", 10)
|
self.dbtest.create_nexusportbinding("port1", 10)
|
||||||
self.dbtest.create_nexusportbinding("port2", 10)
|
self.dbtest.create_nexusportbinding("port2", 10)
|
||||||
bindings = self.dbtest.get_all_nexusportbindings()
|
bindings = self.dbtest.get_all_nexusportbindings()
|
||||||
@ -372,7 +372,7 @@ class NexusDBTest(base.BaseTestCase):
|
|||||||
self.tearDown_nexusportbinding()
|
self.tearDown_nexusportbinding()
|
||||||
|
|
||||||
def testc_delete_nexusportbinding(self):
|
def testc_delete_nexusportbinding(self):
|
||||||
"""delete nexus port binding"""
|
"""delete nexus port binding."""
|
||||||
self.dbtest.create_nexusportbinding("port1", 10)
|
self.dbtest.create_nexusportbinding("port1", 10)
|
||||||
self.dbtest.delete_nexusportbinding(10)
|
self.dbtest.delete_nexusportbinding(10)
|
||||||
bindings = self.dbtest.get_all_nexusportbindings()
|
bindings = self.dbtest.get_all_nexusportbindings()
|
||||||
@ -384,7 +384,7 @@ class NexusDBTest(base.BaseTestCase):
|
|||||||
self.tearDown_nexusportbinding()
|
self.tearDown_nexusportbinding()
|
||||||
|
|
||||||
def testd_update_nexusportbinding(self):
|
def testd_update_nexusportbinding(self):
|
||||||
"""update nexus port binding"""
|
"""update nexus port binding."""
|
||||||
binding1 = self.dbtest.create_nexusportbinding("port1", 10)
|
binding1 = self.dbtest.create_nexusportbinding("port1", 10)
|
||||||
binding1 = self.dbtest.update_nexusport_binding(binding1["port-id"],
|
binding1 = self.dbtest.update_nexusport_binding(binding1["port-id"],
|
||||||
20)
|
20)
|
||||||
@ -397,7 +397,7 @@ class NexusDBTest(base.BaseTestCase):
|
|||||||
self.tearDown_nexusportbinding()
|
self.tearDown_nexusportbinding()
|
||||||
|
|
||||||
def tearDown_nexusportbinding(self):
|
def tearDown_nexusportbinding(self):
|
||||||
"""tear down nexusport binding table"""
|
"""tear down nexusport binding table."""
|
||||||
LOG.debug("Tearing Down Nexus port Bindings")
|
LOG.debug("Tearing Down Nexus port Bindings")
|
||||||
binds = self.dbtest.get_all_nexusportbindings()
|
binds = self.dbtest.get_all_nexusportbindings()
|
||||||
for bind in binds:
|
for bind in binds:
|
||||||
@ -406,9 +406,9 @@ class NexusDBTest(base.BaseTestCase):
|
|||||||
|
|
||||||
|
|
||||||
class L2networkDBTest(base.BaseTestCase):
|
class L2networkDBTest(base.BaseTestCase):
|
||||||
"""Class conisting of L2network DB unit tests"""
|
"""Class conisting of L2network DB unit tests."""
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""Setup for tests"""
|
"""Setup for tests."""
|
||||||
super(L2networkDBTest, self).setUp()
|
super(L2networkDBTest, self).setUp()
|
||||||
l2network_db.initialize()
|
l2network_db.initialize()
|
||||||
self.dbtest = L2networkDB()
|
self.dbtest = L2networkDB()
|
||||||
@ -417,7 +417,7 @@ class L2networkDBTest(base.BaseTestCase):
|
|||||||
LOG.debug("Setup")
|
LOG.debug("Setup")
|
||||||
|
|
||||||
def testa_create_vlanbinding(self):
|
def testa_create_vlanbinding(self):
|
||||||
"""test add vlan binding"""
|
"""test add vlan binding."""
|
||||||
net1 = self.quantum.create_network("t1", "netid1")
|
net1 = self.quantum.create_network("t1", "netid1")
|
||||||
vlan1 = self.dbtest.create_vlan_binding(10, "vlan1", net1["net-id"])
|
vlan1 = self.dbtest.create_vlan_binding(10, "vlan1", net1["net-id"])
|
||||||
self.assertTrue(vlan1["vlan-id"] == "10")
|
self.assertTrue(vlan1["vlan-id"] == "10")
|
||||||
@ -425,7 +425,7 @@ class L2networkDBTest(base.BaseTestCase):
|
|||||||
self.teardown_network()
|
self.teardown_network()
|
||||||
|
|
||||||
def testb_getall_vlanbindings(self):
|
def testb_getall_vlanbindings(self):
|
||||||
"""test get all vlan binding"""
|
"""test get all vlan binding."""
|
||||||
net1 = self.quantum.create_network("t1", "netid1")
|
net1 = self.quantum.create_network("t1", "netid1")
|
||||||
net2 = self.quantum.create_network("t1", "netid2")
|
net2 = self.quantum.create_network("t1", "netid2")
|
||||||
vlan1 = self.dbtest.create_vlan_binding(10, "vlan1", net1["net-id"])
|
vlan1 = self.dbtest.create_vlan_binding(10, "vlan1", net1["net-id"])
|
||||||
@ -442,7 +442,7 @@ class L2networkDBTest(base.BaseTestCase):
|
|||||||
self.teardown_network()
|
self.teardown_network()
|
||||||
|
|
||||||
def testc_delete_vlanbinding(self):
|
def testc_delete_vlanbinding(self):
|
||||||
"""test delete vlan binding"""
|
"""test delete vlan binding."""
|
||||||
net1 = self.quantum.create_network("t1", "netid1")
|
net1 = self.quantum.create_network("t1", "netid1")
|
||||||
vlan1 = self.dbtest.create_vlan_binding(10, "vlan1", net1["net-id"])
|
vlan1 = self.dbtest.create_vlan_binding(10, "vlan1", net1["net-id"])
|
||||||
self.assertTrue(vlan1["vlan-id"] == "10")
|
self.assertTrue(vlan1["vlan-id"] == "10")
|
||||||
@ -457,7 +457,7 @@ class L2networkDBTest(base.BaseTestCase):
|
|||||||
self.teardown_network()
|
self.teardown_network()
|
||||||
|
|
||||||
def testd_update_vlanbinding(self):
|
def testd_update_vlanbinding(self):
|
||||||
"""test update vlan binding"""
|
"""test update vlan binding."""
|
||||||
net1 = self.quantum.create_network("t1", "netid1")
|
net1 = self.quantum.create_network("t1", "netid1")
|
||||||
vlan1 = self.dbtest.create_vlan_binding(10, "vlan1", net1["net-id"])
|
vlan1 = self.dbtest.create_vlan_binding(10, "vlan1", net1["net-id"])
|
||||||
self.assertTrue(vlan1["vlan-id"] == "10")
|
self.assertTrue(vlan1["vlan-id"] == "10")
|
||||||
@ -472,7 +472,7 @@ class L2networkDBTest(base.BaseTestCase):
|
|||||||
self.teardown_network()
|
self.teardown_network()
|
||||||
|
|
||||||
def testm_test_vlanids(self):
|
def testm_test_vlanids(self):
|
||||||
"""test vlanid methods"""
|
"""test vlanid methods."""
|
||||||
l2network_db.create_vlanids()
|
l2network_db.create_vlanids()
|
||||||
vlanids = l2network_db.get_all_vlanids()
|
vlanids = l2network_db.get_all_vlanids()
|
||||||
self.assertTrue(len(vlanids) > 0)
|
self.assertTrue(len(vlanids) > 0)
|
||||||
@ -484,7 +484,7 @@ class L2networkDBTest(base.BaseTestCase):
|
|||||||
#counting on default teardown here to clear db
|
#counting on default teardown here to clear db
|
||||||
|
|
||||||
def teardown_network(self):
|
def teardown_network(self):
|
||||||
"""tearDown Network table"""
|
"""tearDown Network table."""
|
||||||
LOG.debug("Tearing Down Network")
|
LOG.debug("Tearing Down Network")
|
||||||
nets = self.quantum.get_all_networks("t1")
|
nets = self.quantum.get_all_networks("t1")
|
||||||
for net in nets:
|
for net in nets:
|
||||||
@ -492,7 +492,7 @@ class L2networkDBTest(base.BaseTestCase):
|
|||||||
self.quantum.delete_network(netid)
|
self.quantum.delete_network(netid)
|
||||||
|
|
||||||
def teardown_port(self):
|
def teardown_port(self):
|
||||||
"""tearDown Port table"""
|
"""tearDown Port table."""
|
||||||
LOG.debug("Tearing Down Port")
|
LOG.debug("Tearing Down Port")
|
||||||
nets = self.quantum.get_all_networks("t1")
|
nets = self.quantum.get_all_networks("t1")
|
||||||
for net in nets:
|
for net in nets:
|
||||||
@ -503,7 +503,7 @@ class L2networkDBTest(base.BaseTestCase):
|
|||||||
self.quantum.delete_port(netid, portid)
|
self.quantum.delete_port(netid, portid)
|
||||||
|
|
||||||
def teardown_vlanbinding(self):
|
def teardown_vlanbinding(self):
|
||||||
"""tearDown VlanBinding table"""
|
"""tearDown VlanBinding table."""
|
||||||
LOG.debug("Tearing Down Vlan Binding")
|
LOG.debug("Tearing Down Vlan Binding")
|
||||||
vlans = self.dbtest.get_all_vlan_bindings()
|
vlans = self.dbtest.get_all_vlan_bindings()
|
||||||
for vlan in vlans:
|
for vlan in vlans:
|
||||||
@ -512,9 +512,9 @@ class L2networkDBTest(base.BaseTestCase):
|
|||||||
|
|
||||||
|
|
||||||
class QuantumDBTest(base.BaseTestCase):
|
class QuantumDBTest(base.BaseTestCase):
|
||||||
"""Class conisting of Quantum DB unit tests"""
|
"""Class conisting of Quantum DB unit tests."""
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""Setup for tests"""
|
"""Setup for tests."""
|
||||||
super(QuantumDBTest, self).setUp()
|
super(QuantumDBTest, self).setUp()
|
||||||
l2network_db.initialize()
|
l2network_db.initialize()
|
||||||
self.addCleanup(db.clear_db)
|
self.addCleanup(db.clear_db)
|
||||||
@ -523,13 +523,13 @@ class QuantumDBTest(base.BaseTestCase):
|
|||||||
LOG.debug("Setup")
|
LOG.debug("Setup")
|
||||||
|
|
||||||
def testa_create_network(self):
|
def testa_create_network(self):
|
||||||
"""test to create network"""
|
"""test to create network."""
|
||||||
net1 = self.dbtest.create_network(self.tenant_id, "plugin_test1")
|
net1 = self.dbtest.create_network(self.tenant_id, "plugin_test1")
|
||||||
self.assertTrue(net1["net-name"] == "plugin_test1")
|
self.assertTrue(net1["net-name"] == "plugin_test1")
|
||||||
self.teardown_network_port()
|
self.teardown_network_port()
|
||||||
|
|
||||||
def testb_get_networks(self):
|
def testb_get_networks(self):
|
||||||
"""test to get all networks"""
|
"""test to get all networks."""
|
||||||
net1 = self.dbtest.create_network(self.tenant_id, "plugin_test1")
|
net1 = self.dbtest.create_network(self.tenant_id, "plugin_test1")
|
||||||
self.assertTrue(net1["net-name"] == "plugin_test1")
|
self.assertTrue(net1["net-name"] == "plugin_test1")
|
||||||
net2 = self.dbtest.create_network(self.tenant_id, "plugin_test2")
|
net2 = self.dbtest.create_network(self.tenant_id, "plugin_test2")
|
||||||
@ -543,7 +543,7 @@ class QuantumDBTest(base.BaseTestCase):
|
|||||||
self.teardown_network_port()
|
self.teardown_network_port()
|
||||||
|
|
||||||
def testc_delete_network(self):
|
def testc_delete_network(self):
|
||||||
"""test to delete network"""
|
"""test to delete network."""
|
||||||
net1 = self.dbtest.create_network(self.tenant_id, "plugin_test1")
|
net1 = self.dbtest.create_network(self.tenant_id, "plugin_test1")
|
||||||
self.assertTrue(net1["net-name"] == "plugin_test1")
|
self.assertTrue(net1["net-name"] == "plugin_test1")
|
||||||
self.dbtest.delete_network(net1["net-id"])
|
self.dbtest.delete_network(net1["net-id"])
|
||||||
@ -556,7 +556,7 @@ class QuantumDBTest(base.BaseTestCase):
|
|||||||
self.teardown_network_port()
|
self.teardown_network_port()
|
||||||
|
|
||||||
def testd_update_network(self):
|
def testd_update_network(self):
|
||||||
"""test to update (rename) network"""
|
"""test to update (rename) network."""
|
||||||
net1 = self.dbtest.create_network(self.tenant_id, "plugin_test1")
|
net1 = self.dbtest.create_network(self.tenant_id, "plugin_test1")
|
||||||
self.assertTrue(net1["net-name"] == "plugin_test1")
|
self.assertTrue(net1["net-name"] == "plugin_test1")
|
||||||
net = self.dbtest.update_network(self.tenant_id, net1["net-id"],
|
net = self.dbtest.update_network(self.tenant_id, net1["net-id"],
|
||||||
@ -565,7 +565,7 @@ class QuantumDBTest(base.BaseTestCase):
|
|||||||
self.teardown_network_port()
|
self.teardown_network_port()
|
||||||
|
|
||||||
def teste_create_port(self):
|
def teste_create_port(self):
|
||||||
"""test to create port"""
|
"""test to create port."""
|
||||||
net1 = self.dbtest.create_network(self.tenant_id, "plugin_test1")
|
net1 = self.dbtest.create_network(self.tenant_id, "plugin_test1")
|
||||||
port = self.dbtest.create_port(net1["net-id"])
|
port = self.dbtest.create_port(net1["net-id"])
|
||||||
self.assertTrue(port["net-id"] == net1["net-id"])
|
self.assertTrue(port["net-id"] == net1["net-id"])
|
||||||
@ -577,7 +577,7 @@ class QuantumDBTest(base.BaseTestCase):
|
|||||||
self.teardown_network_port()
|
self.teardown_network_port()
|
||||||
|
|
||||||
def testf_delete_port(self):
|
def testf_delete_port(self):
|
||||||
"""test to delete port"""
|
"""test to delete port."""
|
||||||
net1 = self.dbtest.create_network(self.tenant_id, "plugin_test1")
|
net1 = self.dbtest.create_network(self.tenant_id, "plugin_test1")
|
||||||
port = self.dbtest.create_port(net1["net-id"])
|
port = self.dbtest.create_port(net1["net-id"])
|
||||||
self.assertTrue(port["net-id"] == net1["net-id"])
|
self.assertTrue(port["net-id"] == net1["net-id"])
|
||||||
@ -596,7 +596,7 @@ class QuantumDBTest(base.BaseTestCase):
|
|||||||
self.teardown_network_port()
|
self.teardown_network_port()
|
||||||
|
|
||||||
def testg_plug_unplug_interface(self):
|
def testg_plug_unplug_interface(self):
|
||||||
"""test to plug/unplug interface"""
|
"""test to plug/unplug interface."""
|
||||||
net1 = self.dbtest.create_network(self.tenant_id, "plugin_test1")
|
net1 = self.dbtest.create_network(self.tenant_id, "plugin_test1")
|
||||||
port1 = self.dbtest.create_port(net1["net-id"])
|
port1 = self.dbtest.create_port(net1["net-id"])
|
||||||
self.dbtest.plug_interface(net1["net-id"], port1["port-id"], "vif1.1")
|
self.dbtest.plug_interface(net1["net-id"], port1["port-id"], "vif1.1")
|
||||||
@ -608,7 +608,7 @@ class QuantumDBTest(base.BaseTestCase):
|
|||||||
self.teardown_network_port()
|
self.teardown_network_port()
|
||||||
|
|
||||||
def testh_joined_test(self):
|
def testh_joined_test(self):
|
||||||
"""test to get network and port"""
|
"""test to get network and port."""
|
||||||
net1 = self.dbtest.create_network("t1", "net1")
|
net1 = self.dbtest.create_network("t1", "net1")
|
||||||
port1 = self.dbtest.create_port(net1["net-id"])
|
port1 = self.dbtest.create_port(net1["net-id"])
|
||||||
self.assertTrue(port1["net-id"] == net1["net-id"])
|
self.assertTrue(port1["net-id"] == net1["net-id"])
|
||||||
@ -621,7 +621,7 @@ class QuantumDBTest(base.BaseTestCase):
|
|||||||
self.teardown_joined_test()
|
self.teardown_joined_test()
|
||||||
|
|
||||||
def teardown_network_port(self):
|
def teardown_network_port(self):
|
||||||
"""tearDown for Network and Port table"""
|
"""tearDown for Network and Port table."""
|
||||||
networks = self.dbtest.get_all_networks(self.tenant_id)
|
networks = self.dbtest.get_all_networks(self.tenant_id)
|
||||||
for net in networks:
|
for net in networks:
|
||||||
netid = net["net-id"]
|
netid = net["net-id"]
|
||||||
@ -633,7 +633,7 @@ class QuantumDBTest(base.BaseTestCase):
|
|||||||
self.dbtest.delete_network(netid)
|
self.dbtest.delete_network(netid)
|
||||||
|
|
||||||
def teardown_joined_test(self):
|
def teardown_joined_test(self):
|
||||||
"""tearDown for joined Network and Port test"""
|
"""tearDown for joined Network and Port test."""
|
||||||
LOG.debug("Tearing Down Network and Ports")
|
LOG.debug("Tearing Down Network and Ports")
|
||||||
nets = self.dbtest.get_all_networks("t1")
|
nets = self.dbtest.get_all_networks("t1")
|
||||||
for net in nets:
|
for net in nets:
|
||||||
|
@ -156,13 +156,14 @@ class HyperVQuantumAgent(object):
|
|||||||
#Nothing to do
|
#Nothing to do
|
||||||
pass
|
pass
|
||||||
elif network_type == constants.TYPE_LOCAL:
|
elif network_type == constants.TYPE_LOCAL:
|
||||||
#TODO (alexpilotti): Check that the switch type is private
|
#TODO(alexpilotti): Check that the switch type is private
|
||||||
#or create it if not existing
|
#or create it if not existing
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
raise utils.HyperVException(_("Cannot provision unknown network "
|
raise utils.HyperVException(
|
||||||
"type %s for network %s"),
|
_("Cannot provision unknown network type %(network_type)s "
|
||||||
network_type, net_uuid)
|
"for network %(net_uuid)s"),
|
||||||
|
dict(network_type=network_type, net_uuid=net_uuid))
|
||||||
|
|
||||||
map = {
|
map = {
|
||||||
'network_type': network_type,
|
'network_type': network_type,
|
||||||
@ -193,8 +194,9 @@ class HyperVQuantumAgent(object):
|
|||||||
self._utils.connect_vnic_to_vswitch(map['vswitch_name'], port_id)
|
self._utils.connect_vnic_to_vswitch(map['vswitch_name'], port_id)
|
||||||
|
|
||||||
if network_type == constants.TYPE_VLAN:
|
if network_type == constants.TYPE_VLAN:
|
||||||
LOG.info(_('Binding VLAN ID %s to switch port %s'),
|
LOG.info(_('Binding VLAN ID %(segmentation_id)s '
|
||||||
segmentation_id, port_id)
|
'to switch port %(port_id)s'),
|
||||||
|
dict(segmentation_id=segmentation_id, port_id=port_id))
|
||||||
self._utils.set_vswitch_port_vlan_id(
|
self._utils.set_vswitch_port_vlan_id(
|
||||||
segmentation_id,
|
segmentation_id,
|
||||||
port_id)
|
port_id)
|
||||||
@ -253,14 +255,14 @@ class HyperVQuantumAgent(object):
|
|||||||
self.agent_id)
|
self.agent_id)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
LOG.debug(_(
|
LOG.debug(_(
|
||||||
"Unable to get port details for device %s: %s"),
|
"Unable to get port details for device %(device)s: %(e)s"),
|
||||||
device, e)
|
dict(device=device, e=e))
|
||||||
resync = True
|
resync = True
|
||||||
continue
|
continue
|
||||||
if 'port_id' in device_details:
|
if 'port_id' in device_details:
|
||||||
LOG.info(_(
|
LOG.info(_(
|
||||||
"Port %(device)s updated. Details: %(device_details)s") %
|
"Port %(device)s updated. Details: %(device_details)s") %
|
||||||
locals())
|
dict(device=device, device_details=device_details))
|
||||||
self._treat_vif_port(
|
self._treat_vif_port(
|
||||||
device_details['port_id'],
|
device_details['port_id'],
|
||||||
device_details['network_id'],
|
device_details['network_id'],
|
||||||
@ -279,8 +281,9 @@ class HyperVQuantumAgent(object):
|
|||||||
device,
|
device,
|
||||||
self.agent_id)
|
self.agent_id)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
LOG.debug(_("Removing port failed for device %s: %s"),
|
LOG.debug(
|
||||||
device, e)
|
_("Removing port failed for device %(device)s: %(e)s"),
|
||||||
|
dict(device=device, e=e))
|
||||||
resync = True
|
resync = True
|
||||||
continue
|
continue
|
||||||
self._port_unbound(device)
|
self._port_unbound(device)
|
||||||
|
@ -105,11 +105,11 @@ class HyperVUtils(object):
|
|||||||
self._check_job_status(ret_val, job_path)
|
self._check_job_status(ret_val, job_path)
|
||||||
|
|
||||||
def _check_job_status(self, ret_val, jobpath):
|
def _check_job_status(self, ret_val, jobpath):
|
||||||
"""Poll WMI job state for completion"""
|
"""Poll WMI job state for completion."""
|
||||||
if not ret_val:
|
if not ret_val:
|
||||||
return
|
return
|
||||||
elif ret_val != WMI_JOB_STATE_RUNNING:
|
elif ret_val != WMI_JOB_STATE_RUNNING:
|
||||||
raise HyperVException(msg=_('Job failed with error %d' % ret_val))
|
raise HyperVException(msg=_('Job failed with error %d') % ret_val)
|
||||||
|
|
||||||
job_wmi_path = jobpath.replace('\\', '/')
|
job_wmi_path = jobpath.replace('\\', '/')
|
||||||
job = wmi.WMI(moniker=job_wmi_path)
|
job = wmi.WMI(moniker=job_wmi_path)
|
||||||
@ -144,7 +144,7 @@ class HyperVUtils(object):
|
|||||||
locals())
|
locals())
|
||||||
|
|
||||||
def _create_switch_port(self, vswitch_name, switch_port_name):
|
def _create_switch_port(self, vswitch_name, switch_port_name):
|
||||||
""" Creates a switch port """
|
"""Creates a switch port."""
|
||||||
switch_svc = self._conn.Msvm_VirtualSwitchManagementService()[0]
|
switch_svc = self._conn.Msvm_VirtualSwitchManagementService()[0]
|
||||||
vswitch_path = self._get_vswitch(vswitch_name).path_()
|
vswitch_path = self._get_vswitch(vswitch_name).path_()
|
||||||
(new_port, ret_val) = switch_svc.CreateSwitchPort(
|
(new_port, ret_val) = switch_svc.CreateSwitchPort(
|
||||||
@ -159,7 +159,7 @@ class HyperVUtils(object):
|
|||||||
|
|
||||||
def disconnect_switch_port(
|
def disconnect_switch_port(
|
||||||
self, vswitch_name, switch_port_name, delete_port):
|
self, vswitch_name, switch_port_name, delete_port):
|
||||||
""" Disconnects the switch port """
|
"""Disconnects the switch port."""
|
||||||
switch_svc = self._conn.Msvm_VirtualSwitchManagementService()[0]
|
switch_svc = self._conn.Msvm_VirtualSwitchManagementService()[0]
|
||||||
switch_port_path = self._get_switch_port_path_by_name(
|
switch_port_path = self._get_switch_port_path_by_name(
|
||||||
switch_port_name)
|
switch_port_name)
|
||||||
|
@ -180,7 +180,7 @@ class HyperVPluginDB(object):
|
|||||||
session.delete(alloc)
|
session.delete(alloc)
|
||||||
|
|
||||||
def sync_vlan_allocations(self, network_vlan_ranges):
|
def sync_vlan_allocations(self, network_vlan_ranges):
|
||||||
"""Synchronize vlan_allocations table with configured VLAN ranges"""
|
"""Synchronize vlan_allocations table with configured VLAN ranges."""
|
||||||
|
|
||||||
session = db_api.get_session()
|
session = db_api.get_session()
|
||||||
with session.begin():
|
with session.begin():
|
||||||
|
@ -22,7 +22,7 @@ from quantum.db.models_v2 import model_base
|
|||||||
|
|
||||||
|
|
||||||
class VlanAllocation(model_base.BASEV2):
|
class VlanAllocation(model_base.BASEV2):
|
||||||
"""Represents allocation state of vlan_id on physical network"""
|
"""Represents allocation state of vlan_id on physical network."""
|
||||||
__tablename__ = 'hyperv_vlan_allocations'
|
__tablename__ = 'hyperv_vlan_allocations'
|
||||||
|
|
||||||
physical_network = Column(String(64), nullable=False, primary_key=True)
|
physical_network = Column(String(64), nullable=False, primary_key=True)
|
||||||
@ -37,7 +37,7 @@ class VlanAllocation(model_base.BASEV2):
|
|||||||
|
|
||||||
|
|
||||||
class NetworkBinding(model_base.BASEV2):
|
class NetworkBinding(model_base.BASEV2):
|
||||||
"""Represents binding of virtual network to physical realization"""
|
"""Represents binding of virtual network to physical realization."""
|
||||||
__tablename__ = 'hyperv_network_bindings'
|
__tablename__ = 'hyperv_network_bindings'
|
||||||
|
|
||||||
network_id = Column(String(36),
|
network_id = Column(String(36),
|
||||||
|
@ -47,7 +47,7 @@ class HyperVRpcCallbacks(
|
|||||||
return q_rpc.PluginRpcDispatcher([self])
|
return q_rpc.PluginRpcDispatcher([self])
|
||||||
|
|
||||||
def get_device_details(self, rpc_context, **kwargs):
|
def get_device_details(self, rpc_context, **kwargs):
|
||||||
"""Agent requests device details"""
|
"""Agent requests device details."""
|
||||||
agent_id = kwargs.get('agent_id')
|
agent_id = kwargs.get('agent_id')
|
||||||
device = kwargs.get('device')
|
device = kwargs.get('device')
|
||||||
LOG.debug(_("Device %(device)s details requested from %(agent_id)s"),
|
LOG.debug(_("Device %(device)s details requested from %(agent_id)s"),
|
||||||
@ -70,8 +70,8 @@ class HyperVRpcCallbacks(
|
|||||||
return entry
|
return entry
|
||||||
|
|
||||||
def update_device_down(self, rpc_context, **kwargs):
|
def update_device_down(self, rpc_context, **kwargs):
|
||||||
"""Device no longer exists on agent"""
|
"""Device no longer exists on agent."""
|
||||||
# (TODO) garyk - live migration and port status
|
# TODO(garyk) - live migration and port status
|
||||||
agent_id = kwargs.get('agent_id')
|
agent_id = kwargs.get('agent_id')
|
||||||
device = kwargs.get('device')
|
device = kwargs.get('device')
|
||||||
LOG.debug(_("Device %(device)s no longer exists on %(agent_id)s"),
|
LOG.debug(_("Device %(device)s no longer exists on %(agent_id)s"),
|
||||||
@ -90,7 +90,8 @@ class HyperVRpcCallbacks(
|
|||||||
|
|
||||||
def tunnel_sync(self, rpc_context, **kwargs):
|
def tunnel_sync(self, rpc_context, **kwargs):
|
||||||
"""Dummy function for ovs agent running on Linux to
|
"""Dummy function for ovs agent running on Linux to
|
||||||
work with Hyper-V plugin and agent."""
|
work with Hyper-V plugin and agent.
|
||||||
|
"""
|
||||||
entry = dict()
|
entry = dict()
|
||||||
entry['tunnels'] = {}
|
entry['tunnels'] = {}
|
||||||
# Return the list of tunnels IP's to the agent
|
# Return the list of tunnels IP's to the agent
|
||||||
|
@ -93,7 +93,7 @@ def sync_network_states(network_vlan_ranges):
|
|||||||
|
|
||||||
|
|
||||||
def get_network_state(physical_network, vlan_id):
|
def get_network_state(physical_network, vlan_id):
|
||||||
"""Get state of specified network"""
|
"""Get state of specified network."""
|
||||||
|
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
@ -193,7 +193,7 @@ def get_network_binding(session, network_id):
|
|||||||
|
|
||||||
|
|
||||||
def get_port_from_device(device):
|
def get_port_from_device(device):
|
||||||
"""Get port from database"""
|
"""Get port from database."""
|
||||||
LOG.debug(_("get_port_from_device() called"))
|
LOG.debug(_("get_port_from_device() called"))
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
sg_binding_port = sg_db.SecurityGroupPortBinding.port_id
|
sg_binding_port = sg_db.SecurityGroupPortBinding.port_id
|
||||||
@ -221,7 +221,7 @@ def get_port_from_device(device):
|
|||||||
|
|
||||||
|
|
||||||
def set_port_status(port_id, status):
|
def set_port_status(port_id, status):
|
||||||
"""Set the port status"""
|
"""Set the port status."""
|
||||||
LOG.debug(_("set_port_status as %s called"), status)
|
LOG.debug(_("set_port_status as %s called"), status)
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
|
@ -19,7 +19,7 @@ from quantum.db import model_base
|
|||||||
|
|
||||||
|
|
||||||
class NetworkState(model_base.BASEV2):
|
class NetworkState(model_base.BASEV2):
|
||||||
"""Represents state of vlan_id on physical network"""
|
"""Represents state of vlan_id on physical network."""
|
||||||
__tablename__ = 'network_states'
|
__tablename__ = 'network_states'
|
||||||
|
|
||||||
physical_network = sa.Column(sa.String(64), nullable=False,
|
physical_network = sa.Column(sa.String(64), nullable=False,
|
||||||
@ -39,7 +39,7 @@ class NetworkState(model_base.BASEV2):
|
|||||||
|
|
||||||
|
|
||||||
class NetworkBinding(model_base.BASEV2):
|
class NetworkBinding(model_base.BASEV2):
|
||||||
"""Represents binding of virtual network to physical_network and vlan_id"""
|
"""Represents binding of virtual network to physical network and vlan."""
|
||||||
__tablename__ = 'network_bindings'
|
__tablename__ = 'network_bindings'
|
||||||
|
|
||||||
network_id = sa.Column(sa.String(36),
|
network_id = sa.Column(sa.String(36),
|
||||||
|
@ -76,7 +76,7 @@ class LinuxBridgeRpcCallbacks(dhcp_rpc_base.DhcpRpcCallbackMixin,
|
|||||||
return port
|
return port
|
||||||
|
|
||||||
def get_device_details(self, rpc_context, **kwargs):
|
def get_device_details(self, rpc_context, **kwargs):
|
||||||
"""Agent requests device details"""
|
"""Agent requests device details."""
|
||||||
agent_id = kwargs.get('agent_id')
|
agent_id = kwargs.get('agent_id')
|
||||||
device = kwargs.get('device')
|
device = kwargs.get('device')
|
||||||
LOG.debug(_("Device %(device)s details requested from %(agent_id)s"),
|
LOG.debug(_("Device %(device)s details requested from %(agent_id)s"),
|
||||||
@ -101,8 +101,8 @@ class LinuxBridgeRpcCallbacks(dhcp_rpc_base.DhcpRpcCallbackMixin,
|
|||||||
return entry
|
return entry
|
||||||
|
|
||||||
def update_device_down(self, rpc_context, **kwargs):
|
def update_device_down(self, rpc_context, **kwargs):
|
||||||
"""Device no longer exists on agent"""
|
"""Device no longer exists on agent."""
|
||||||
# (TODO) garyk - live migration and port status
|
# TODO(garyk) - live migration and port status
|
||||||
agent_id = kwargs.get('agent_id')
|
agent_id = kwargs.get('agent_id')
|
||||||
device = kwargs.get('device')
|
device = kwargs.get('device')
|
||||||
LOG.debug(_("Device %(device)s no longer exists on %(agent_id)s"),
|
LOG.debug(_("Device %(device)s no longer exists on %(agent_id)s"),
|
||||||
@ -121,7 +121,7 @@ class LinuxBridgeRpcCallbacks(dhcp_rpc_base.DhcpRpcCallbackMixin,
|
|||||||
return entry
|
return entry
|
||||||
|
|
||||||
def update_device_up(self, rpc_context, **kwargs):
|
def update_device_up(self, rpc_context, **kwargs):
|
||||||
"""Device is up on agent"""
|
"""Device is up on agent."""
|
||||||
agent_id = kwargs.get('agent_id')
|
agent_id = kwargs.get('agent_id')
|
||||||
device = kwargs.get('device')
|
device = kwargs.get('device')
|
||||||
LOG.debug(_("Device %(device)s up %(agent_id)s"),
|
LOG.debug(_("Device %(device)s up %(agent_id)s"),
|
||||||
|
@ -166,7 +166,7 @@ class MetaPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
|
|||||||
try:
|
try:
|
||||||
meta_db_v2.add_network_flavor_binding(context.session,
|
meta_db_v2.add_network_flavor_binding(context.session,
|
||||||
flavor, str(net['id']))
|
flavor, str(net['id']))
|
||||||
except:
|
except Exception:
|
||||||
LOG.exception(_('Failed to add flavor bindings'))
|
LOG.exception(_('Failed to add flavor bindings'))
|
||||||
plugin.delete_network(context, net['id'])
|
plugin.delete_network(context, net['id'])
|
||||||
raise FaildToAddFlavorBinding()
|
raise FaildToAddFlavorBinding()
|
||||||
|
@ -54,7 +54,7 @@ class ProxyPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
|
|||||||
try:
|
try:
|
||||||
subnet_in_db = super(ProxyPluginV2, self).create_subnet(
|
subnet_in_db = super(ProxyPluginV2, self).create_subnet(
|
||||||
context, subnet)
|
context, subnet)
|
||||||
except:
|
except Exception:
|
||||||
self._get_client().delete_subnet(subnet_remote['id'])
|
self._get_client().delete_subnet(subnet_remote['id'])
|
||||||
return subnet_in_db
|
return subnet_in_db
|
||||||
|
|
||||||
@ -82,7 +82,7 @@ class ProxyPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
|
|||||||
try:
|
try:
|
||||||
network_in_db = super(ProxyPluginV2, self).create_network(
|
network_in_db = super(ProxyPluginV2, self).create_network(
|
||||||
context, network)
|
context, network)
|
||||||
except:
|
except Exception:
|
||||||
self._get_client().delete_network(network_remote['id'])
|
self._get_client().delete_network(network_remote['id'])
|
||||||
return network_in_db
|
return network_in_db
|
||||||
|
|
||||||
@ -110,7 +110,7 @@ class ProxyPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
|
|||||||
try:
|
try:
|
||||||
port_in_db = super(ProxyPluginV2, self).create_port(
|
port_in_db = super(ProxyPluginV2, self).create_port(
|
||||||
context, port)
|
context, port)
|
||||||
except:
|
except Exception:
|
||||||
self._get_client().delete_port(port_remote['id'])
|
self._get_client().delete_port(port_remote['id'])
|
||||||
return port_in_db
|
return port_in_db
|
||||||
|
|
||||||
|
@ -522,7 +522,7 @@ class MidonetPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
|
|||||||
LOG.debug(_("MidonetPluginV2.create_router called: router=%r"), router)
|
LOG.debug(_("MidonetPluginV2.create_router called: router=%r"), router)
|
||||||
|
|
||||||
if router['router']['admin_state_up'] is False:
|
if router['router']['admin_state_up'] is False:
|
||||||
LOG.warning(_('Ignoreing admin_state_up=False for router=%r',
|
LOG.warning(_('Ignoring admin_state_up=False for router=%r. '
|
||||||
'Overriding with True'), router)
|
'Overriding with True'), router)
|
||||||
router['router']['admin_state_up'] = True
|
router['router']['admin_state_up'] = True
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ class NECPluginApi(agent_rpc.PluginApi):
|
|||||||
|
|
||||||
def update_ports(self, context, agent_id, datapath_id,
|
def update_ports(self, context, agent_id, datapath_id,
|
||||||
port_added, port_removed):
|
port_added, port_removed):
|
||||||
"""RPC to update information of ports on Quantum Server"""
|
"""RPC to update information of ports on Quantum Server."""
|
||||||
LOG.info(_("Update ports: added=%(added)s, "
|
LOG.info(_("Update ports: added=%(added)s, "
|
||||||
"removed=%(removed)s"),
|
"removed=%(removed)s"),
|
||||||
{'added': port_added, 'removed': port_removed})
|
{'added': port_added, 'removed': port_removed})
|
||||||
|
@ -27,7 +27,7 @@ LOG = logging.getLogger(__name__)
|
|||||||
|
|
||||||
|
|
||||||
class OFCClient(object):
|
class OFCClient(object):
|
||||||
"""A HTTP/HTTPS client for OFC Drivers"""
|
"""A HTTP/HTTPS client for OFC Drivers."""
|
||||||
|
|
||||||
def __init__(self, host="127.0.0.1", port=8888, use_ssl=False,
|
def __init__(self, host="127.0.0.1", port=8888, use_ssl=False,
|
||||||
key_file=None, cert_file=None):
|
key_file=None, cert_file=None):
|
||||||
@ -47,7 +47,7 @@ class OFCClient(object):
|
|||||||
self.connection = None
|
self.connection = None
|
||||||
|
|
||||||
def get_connection_type(self):
|
def get_connection_type(self):
|
||||||
"""Returns the proper connection type"""
|
"""Returns the proper connection type."""
|
||||||
if self.use_ssl:
|
if self.use_ssl:
|
||||||
return httplib.HTTPSConnection
|
return httplib.HTTPSConnection
|
||||||
else:
|
else:
|
||||||
|
@ -203,7 +203,7 @@ def del_portinfo(session, id):
|
|||||||
|
|
||||||
|
|
||||||
def get_port_from_device(port_id):
|
def get_port_from_device(port_id):
|
||||||
"""Get port from database"""
|
"""Get port from database."""
|
||||||
LOG.debug(_("get_port_with_securitygroups() called:port_id=%s"), port_id)
|
LOG.debug(_("get_port_with_securitygroups() called:port_id=%s"), port_id)
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
sg_binding_port = sg_db.SecurityGroupPortBinding.port_id
|
sg_binding_port = sg_db.SecurityGroupPortBinding.port_id
|
||||||
|
@ -21,16 +21,16 @@ from quantum.db import model_base
|
|||||||
from quantum.db import models_v2
|
from quantum.db import models_v2
|
||||||
|
|
||||||
|
|
||||||
"""New mapping tables"""
|
"""New mapping tables."""
|
||||||
|
|
||||||
|
|
||||||
class OFCId(object):
|
class OFCId(object):
|
||||||
"""Resource ID on OpenFlow Controller"""
|
"""Resource ID on OpenFlow Controller."""
|
||||||
ofc_id = sa.Column(sa.String(255), unique=True, nullable=False)
|
ofc_id = sa.Column(sa.String(255), unique=True, nullable=False)
|
||||||
|
|
||||||
|
|
||||||
class QuantumId(object):
|
class QuantumId(object):
|
||||||
"""Logical ID on Quantum"""
|
"""Logical ID on Quantum."""
|
||||||
quantum_id = sa.Column(sa.String(36), primary_key=True)
|
quantum_id = sa.Column(sa.String(36), primary_key=True)
|
||||||
|
|
||||||
|
|
||||||
@ -50,11 +50,11 @@ class OFCFilterMapping(model_base.BASEV2, QuantumId, OFCId):
|
|||||||
"""Represents a Filter on OpenFlow Network/Controller."""
|
"""Represents a Filter on OpenFlow Network/Controller."""
|
||||||
|
|
||||||
|
|
||||||
"""Old mapping tables"""
|
"""Old mapping tables."""
|
||||||
|
|
||||||
|
|
||||||
class HasQuantumId(object):
|
class HasQuantumId(object):
|
||||||
"""Logical ID on Quantum"""
|
"""Logical ID on Quantum."""
|
||||||
quantum_id = sa.Column(sa.String(36), nullable=False)
|
quantum_id = sa.Column(sa.String(36), nullable=False)
|
||||||
|
|
||||||
|
|
||||||
@ -83,7 +83,7 @@ class PortInfo(model_base.BASEV2, models_v2.HasId):
|
|||||||
|
|
||||||
|
|
||||||
class PacketFilter(model_base.BASEV2, models_v2.HasId, models_v2.HasTenant):
|
class PacketFilter(model_base.BASEV2, models_v2.HasId, models_v2.HasTenant):
|
||||||
"""Represents a packet filter"""
|
"""Represents a packet filter."""
|
||||||
network_id = sa.Column(sa.String(36),
|
network_id = sa.Column(sa.String(36),
|
||||||
sa.ForeignKey('networks.id', ondelete="CASCADE"),
|
sa.ForeignKey('networks.id', ondelete="CASCADE"),
|
||||||
nullable=False)
|
nullable=False)
|
||||||
|
@ -30,7 +30,7 @@ LOG = logging.getLogger(__name__)
|
|||||||
|
|
||||||
class NECPluginV2Base(db_base_plugin_v2.QuantumDbPluginV2):
|
class NECPluginV2Base(db_base_plugin_v2.QuantumDbPluginV2):
|
||||||
|
|
||||||
""" Base class of plugins that handle packet filters. """
|
"""Base class of plugins that handle packet filters."""
|
||||||
|
|
||||||
def _make_packet_filter_dict(self, packet_filter, fields=None):
|
def _make_packet_filter_dict(self, packet_filter, fields=None):
|
||||||
res = {'id': packet_filter['id'],
|
res = {'id': packet_filter['id'],
|
||||||
|
@ -45,7 +45,7 @@ class PFCDriverBase(ofc_driver_base.OFCDriverBase):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
def _generate_pfc_str(self, raw_str):
|
def _generate_pfc_str(self, raw_str):
|
||||||
"""Generate PFC acceptable String"""
|
"""Generate PFC acceptable String."""
|
||||||
return re.sub(r'[^0-9a-zA-Z]', '_', raw_str)
|
return re.sub(r'[^0-9a-zA-Z]', '_', raw_str)
|
||||||
|
|
||||||
def _generate_pfc_id(self, id_str):
|
def _generate_pfc_id(self, id_str):
|
||||||
@ -63,7 +63,7 @@ class PFCDriverBase(ofc_driver_base.OFCDriverBase):
|
|||||||
uuid_str = str(uuid.UUID(id_str)).replace('-', '')
|
uuid_str = str(uuid.UUID(id_str)).replace('-', '')
|
||||||
uuid_no_version = uuid_str[:12] + uuid_str[13:]
|
uuid_no_version = uuid_str[:12] + uuid_str[13:]
|
||||||
return uuid_no_version[:31]
|
return uuid_no_version[:31]
|
||||||
except:
|
except Exception:
|
||||||
return self._generate_pfc_str(id_str)[:31]
|
return self._generate_pfc_str(id_str)[:31]
|
||||||
|
|
||||||
def _generate_pfc_description(self, desc):
|
def _generate_pfc_description(self, desc):
|
||||||
|
@ -23,7 +23,7 @@ from quantum.plugins.nec import ofc_driver_base
|
|||||||
|
|
||||||
|
|
||||||
class TremaDriverBase(ofc_driver_base.OFCDriverBase):
|
class TremaDriverBase(ofc_driver_base.OFCDriverBase):
|
||||||
"""Common class for Trema (Sliceable Switch) Drivers"""
|
"""Common class for Trema (Sliceable Switch) Drivers."""
|
||||||
networks_path = "/networks"
|
networks_path = "/networks"
|
||||||
network_path = "/networks/%s"
|
network_path = "/networks/%s"
|
||||||
|
|
||||||
@ -75,7 +75,7 @@ class TremaDriverBase(ofc_driver_base.OFCDriverBase):
|
|||||||
|
|
||||||
|
|
||||||
class TremaFilterDriver(object):
|
class TremaFilterDriver(object):
|
||||||
"""Trema (Sliceable Switch) PacketFilter Driver Mixin"""
|
"""Trema (Sliceable Switch) PacketFilter Driver Mixin."""
|
||||||
filters_path = "/filters"
|
filters_path = "/filters"
|
||||||
filter_path = "/filters/%s"
|
filter_path = "/filters/%s"
|
||||||
|
|
||||||
|
@ -595,7 +595,7 @@ class NECPluginV2(nec_plugin_base.NECPluginV2Base,
|
|||||||
|
|
||||||
class NECPluginV2AgentNotifierApi(proxy.RpcProxy,
|
class NECPluginV2AgentNotifierApi(proxy.RpcProxy,
|
||||||
sg_rpc.SecurityGroupAgentRpcApiMixin):
|
sg_rpc.SecurityGroupAgentRpcApiMixin):
|
||||||
'''RPC API for NEC plugin agent'''
|
'''RPC API for NEC plugin agent.'''
|
||||||
|
|
||||||
BASE_RPC_API_VERSION = '1.0'
|
BASE_RPC_API_VERSION = '1.0'
|
||||||
|
|
||||||
|
@ -31,10 +31,10 @@ from quantum.api.rpc.agentnotifiers import dhcp_rpc_agent_api
|
|||||||
from quantum.api.v2 import attributes as attr
|
from quantum.api.v2 import attributes as attr
|
||||||
from quantum.api.v2 import base
|
from quantum.api.v2 import base
|
||||||
from quantum.common import constants
|
from quantum.common import constants
|
||||||
from quantum import context as q_context
|
|
||||||
from quantum.common import exceptions as q_exc
|
from quantum.common import exceptions as q_exc
|
||||||
from quantum.common import rpc as q_rpc
|
from quantum.common import rpc as q_rpc
|
||||||
from quantum.common import topics
|
from quantum.common import topics
|
||||||
|
from quantum import context as q_context
|
||||||
from quantum.db import agents_db
|
from quantum.db import agents_db
|
||||||
from quantum.db import agentschedulers_db
|
from quantum.db import agentschedulers_db
|
||||||
from quantum.db import api as db
|
from quantum.db import api as db
|
||||||
@ -51,11 +51,10 @@ from quantum.extensions import providernet as pnet
|
|||||||
from quantum.extensions import securitygroup as ext_sg
|
from quantum.extensions import securitygroup as ext_sg
|
||||||
from quantum.openstack.common import importutils
|
from quantum.openstack.common import importutils
|
||||||
from quantum.openstack.common import rpc
|
from quantum.openstack.common import rpc
|
||||||
from quantum.plugins.nicira.common import metadata_access as nvp_meta
|
|
||||||
from quantum.plugins.nicira.common import securitygroups as nvp_sec
|
|
||||||
from quantum import policy
|
|
||||||
from quantum.plugins.nicira.common import config
|
from quantum.plugins.nicira.common import config
|
||||||
from quantum.plugins.nicira.common import exceptions as nvp_exc
|
from quantum.plugins.nicira.common import exceptions as nvp_exc
|
||||||
|
from quantum.plugins.nicira.common import metadata_access as nvp_meta
|
||||||
|
from quantum.plugins.nicira.common import securitygroups as nvp_sec
|
||||||
from quantum.plugins.nicira.extensions import nvp_networkgw as networkgw
|
from quantum.plugins.nicira.extensions import nvp_networkgw as networkgw
|
||||||
from quantum.plugins.nicira.extensions import nvp_qos as ext_qos
|
from quantum.plugins.nicira.extensions import nvp_qos as ext_qos
|
||||||
from quantum.plugins.nicira import nicira_db
|
from quantum.plugins.nicira import nicira_db
|
||||||
@ -65,6 +64,7 @@ from quantum.plugins.nicira import nvp_cluster
|
|||||||
from quantum.plugins.nicira.nvp_plugin_version import PLUGIN_VERSION
|
from quantum.plugins.nicira.nvp_plugin_version import PLUGIN_VERSION
|
||||||
from quantum.plugins.nicira import NvpApiClient
|
from quantum.plugins.nicira import NvpApiClient
|
||||||
from quantum.plugins.nicira import nvplib
|
from quantum.plugins.nicira import nvplib
|
||||||
|
from quantum import policy
|
||||||
|
|
||||||
LOG = logging.getLogger("QuantumPlugin")
|
LOG = logging.getLogger("QuantumPlugin")
|
||||||
NVP_NOSNAT_RULES_ORDER = 10
|
NVP_NOSNAT_RULES_ORDER = 10
|
||||||
@ -74,7 +74,7 @@ NVP_EXTGW_NAT_RULES_ORDER = 255
|
|||||||
|
|
||||||
# Provider network extension - allowed network types for the NVP Plugin
|
# Provider network extension - allowed network types for the NVP Plugin
|
||||||
class NetworkTypes:
|
class NetworkTypes:
|
||||||
""" Allowed provider network types for the NVP Plugin """
|
"""Allowed provider network types for the NVP Plugin."""
|
||||||
L3_EXT = 'l3_ext'
|
L3_EXT = 'l3_ext'
|
||||||
STT = 'stt'
|
STT = 'stt'
|
||||||
GRE = 'gre'
|
GRE = 'gre'
|
||||||
@ -315,7 +315,7 @@ class NvpPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
|
|||||||
raise
|
raise
|
||||||
|
|
||||||
def _build_ip_address_list(self, context, fixed_ips, subnet_ids=None):
|
def _build_ip_address_list(self, context, fixed_ips, subnet_ids=None):
|
||||||
""" Build ip_addresses data structure for logical router port
|
"""Build ip_addresses data structure for logical router port
|
||||||
|
|
||||||
No need to perform validation on IPs - this has already been
|
No need to perform validation on IPs - this has already been
|
||||||
done in the l3_db mixin class
|
done in the l3_db mixin class
|
||||||
@ -392,7 +392,7 @@ class NvpPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
|
|||||||
'router_id': router_id}))
|
'router_id': router_id}))
|
||||||
|
|
||||||
def _get_port_by_device_id(self, context, device_id, device_owner):
|
def _get_port_by_device_id(self, context, device_id, device_owner):
|
||||||
""" Retrieve ports associated with a specific device id.
|
"""Retrieve ports associated with a specific device id.
|
||||||
|
|
||||||
Used for retrieving all quantum ports attached to a given router.
|
Used for retrieving all quantum ports attached to a given router.
|
||||||
"""
|
"""
|
||||||
@ -402,7 +402,7 @@ class NvpPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
|
|||||||
device_owner=device_owner,).all()
|
device_owner=device_owner,).all()
|
||||||
|
|
||||||
def _find_router_subnets_cidrs(self, context, router_id):
|
def _find_router_subnets_cidrs(self, context, router_id):
|
||||||
""" Retrieve subnets attached to the specified router """
|
"""Retrieve subnets attached to the specified router."""
|
||||||
ports = self._get_port_by_device_id(context, router_id,
|
ports = self._get_port_by_device_id(context, router_id,
|
||||||
l3_db.DEVICE_OWNER_ROUTER_INTF)
|
l3_db.DEVICE_OWNER_ROUTER_INTF)
|
||||||
# No need to check for overlapping CIDRs
|
# No need to check for overlapping CIDRs
|
||||||
@ -430,8 +430,8 @@ class NvpPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
|
|||||||
cluster, network, network_binding, max_ports,
|
cluster, network, network_binding, max_ports,
|
||||||
allow_extra_lswitches)
|
allow_extra_lswitches)
|
||||||
except NvpApiClient.NvpApiException:
|
except NvpApiClient.NvpApiException:
|
||||||
err_desc = _(("An exception occured while selecting logical "
|
err_desc = _("An exception occured while selecting logical "
|
||||||
"switch for the port"))
|
"switch for the port")
|
||||||
LOG.exception(err_desc)
|
LOG.exception(err_desc)
|
||||||
raise nvp_exc.NvpPluginException(err_msg=err_desc)
|
raise nvp_exc.NvpPluginException(err_msg=err_desc)
|
||||||
|
|
||||||
@ -448,7 +448,7 @@ class NvpPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
|
|||||||
port_data[ext_qos.QUEUE])
|
port_data[ext_qos.QUEUE])
|
||||||
|
|
||||||
def _nvp_create_port(self, context, port_data):
|
def _nvp_create_port(self, context, port_data):
|
||||||
""" Driver for creating a logical switch port on NVP platform """
|
"""Driver for creating a logical switch port on NVP platform."""
|
||||||
# FIXME(salvatore-orlando): On the NVP platform we do not really have
|
# FIXME(salvatore-orlando): On the NVP platform we do not really have
|
||||||
# external networks. So if as user tries and create a "regular" VIF
|
# external networks. So if as user tries and create a "regular" VIF
|
||||||
# port on an external network we are unable to actually create.
|
# port on an external network we are unable to actually create.
|
||||||
@ -540,7 +540,7 @@ class NvpPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
|
|||||||
self._nvp_delete_port(context, port_data)
|
self._nvp_delete_port(context, port_data)
|
||||||
|
|
||||||
def _nvp_create_router_port(self, context, port_data):
|
def _nvp_create_router_port(self, context, port_data):
|
||||||
""" Driver for creating a switch port to be connected to a router """
|
"""Driver for creating a switch port to be connected to a router."""
|
||||||
# No router ports on external networks!
|
# No router ports on external networks!
|
||||||
if self._network_is_external(context, port_data['network_id']):
|
if self._network_is_external(context, port_data['network_id']):
|
||||||
raise nvp_exc.NvpPluginException(
|
raise nvp_exc.NvpPluginException(
|
||||||
@ -586,7 +586,7 @@ class NvpPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
|
|||||||
return lr_port
|
return lr_port
|
||||||
|
|
||||||
def _nvp_create_ext_gw_port(self, context, port_data):
|
def _nvp_create_ext_gw_port(self, context, port_data):
|
||||||
""" Driver for creating an external gateway port on NVP platform """
|
"""Driver for creating an external gateway port on NVP platform."""
|
||||||
# TODO(salvatore-orlando): Handle NVP resource
|
# TODO(salvatore-orlando): Handle NVP resource
|
||||||
# rollback when something goes not quite as expected
|
# rollback when something goes not quite as expected
|
||||||
lr_port = self._find_router_gw_port(context, port_data)
|
lr_port = self._find_router_gw_port(context, port_data)
|
||||||
@ -677,7 +677,7 @@ class NvpPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
|
|||||||
'router_id': router_id})
|
'router_id': router_id})
|
||||||
|
|
||||||
def _nvp_create_l2_gw_port(self, context, port_data):
|
def _nvp_create_l2_gw_port(self, context, port_data):
|
||||||
""" Create a switch port, and attach it to a L2 gateway attachment """
|
"""Create a switch port, and attach it to a L2 gateway attachment."""
|
||||||
# FIXME(salvatore-orlando): On the NVP platform we do not really have
|
# FIXME(salvatore-orlando): On the NVP platform we do not really have
|
||||||
# external networks. So if as user tries and create a "regular" VIF
|
# external networks. So if as user tries and create a "regular" VIF
|
||||||
# port on an external network we are unable to actually create.
|
# port on an external network we are unable to actually create.
|
||||||
@ -727,10 +727,11 @@ class NvpPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def _nvp_get_port_id(self, context, cluster, quantum_port):
|
def _nvp_get_port_id(self, context, cluster, quantum_port):
|
||||||
""" Return the NVP port uuid for a given quantum port.
|
"""Return the NVP port uuid for a given quantum port.
|
||||||
First, look up the Quantum database. If not found, execute
|
First, look up the Quantum database. If not found, execute
|
||||||
a query on NVP platform as the mapping might be missing because
|
a query on NVP platform as the mapping might be missing because
|
||||||
the port was created before upgrading to grizzly. """
|
the port was created before upgrading to grizzly.
|
||||||
|
"""
|
||||||
nvp_port_id = nicira_db.get_nvp_port_id(context.session,
|
nvp_port_id = nicira_db.get_nvp_port_id(context.session,
|
||||||
quantum_port['id'])
|
quantum_port['id'])
|
||||||
if nvp_port_id:
|
if nvp_port_id:
|
||||||
@ -747,12 +748,12 @@ class NvpPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
|
|||||||
quantum_port['id'],
|
quantum_port['id'],
|
||||||
nvp_port['uuid'])
|
nvp_port['uuid'])
|
||||||
return nvp_port['uuid']
|
return nvp_port['uuid']
|
||||||
except:
|
except Exception:
|
||||||
LOG.exception(_("Unable to find NVP uuid for Quantum port %s"),
|
LOG.exception(_("Unable to find NVP uuid for Quantum port %s"),
|
||||||
quantum_port['id'])
|
quantum_port['id'])
|
||||||
|
|
||||||
def _extend_fault_map(self):
|
def _extend_fault_map(self):
|
||||||
""" Extends the Quantum Fault Map
|
"""Extends the Quantum Fault Map
|
||||||
|
|
||||||
Exceptions specific to the NVP Plugin are mapped to standard
|
Exceptions specific to the NVP Plugin are mapped to standard
|
||||||
HTTP Exceptions
|
HTTP Exceptions
|
||||||
@ -777,7 +778,7 @@ class NvpPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
|
|||||||
raise nvp_exc.NvpInvalidNovaZone(nova_zone=novazone_id)
|
raise nvp_exc.NvpInvalidNovaZone(nova_zone=novazone_id)
|
||||||
|
|
||||||
def _find_target_cluster(self, resource):
|
def _find_target_cluster(self, resource):
|
||||||
""" Return cluster where configuration should be applied
|
"""Return cluster where configuration should be applied
|
||||||
|
|
||||||
If the resource being configured has a paremeter expressing
|
If the resource being configured has a paremeter expressing
|
||||||
the zone id (nova_id), then select corresponding cluster,
|
the zone id (nova_id), then select corresponding cluster,
|
||||||
@ -863,7 +864,7 @@ class NvpPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
|
|||||||
allow_extra_lswitches):
|
allow_extra_lswitches):
|
||||||
lswitches = nvplib.get_lswitches(cluster, network.id)
|
lswitches = nvplib.get_lswitches(cluster, network.id)
|
||||||
try:
|
try:
|
||||||
# TODO find main_ls too!
|
# TODO(savatore-orlando) Find main_ls too!
|
||||||
return [ls for ls in lswitches
|
return [ls for ls in lswitches
|
||||||
if (ls['_relations']['LogicalSwitchStatus']
|
if (ls['_relations']['LogicalSwitchStatus']
|
||||||
['lport_count'] < max_ports)].pop(0)
|
['lport_count'] < max_ports)].pop(0)
|
||||||
@ -1025,7 +1026,8 @@ class NvpPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
|
|||||||
|
|
||||||
def _get_lswitch_cluster_pairs(self, netw_id, tenant_id):
|
def _get_lswitch_cluster_pairs(self, netw_id, tenant_id):
|
||||||
"""Figure out the set of lswitches on each cluster that maps to this
|
"""Figure out the set of lswitches on each cluster that maps to this
|
||||||
network id"""
|
network id
|
||||||
|
"""
|
||||||
pairs = []
|
pairs = []
|
||||||
for c in self.clusters.itervalues():
|
for c in self.clusters.itervalues():
|
||||||
lswitches = []
|
lswitches = []
|
||||||
@ -1454,7 +1456,7 @@ class NvpPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
|
|||||||
try:
|
try:
|
||||||
ret_port['status'] = nvplib.get_port_status(
|
ret_port['status'] = nvplib.get_port_status(
|
||||||
self.default_cluster, ret_port['network_id'], nvp_port_id)
|
self.default_cluster, ret_port['network_id'], nvp_port_id)
|
||||||
except:
|
except Exception:
|
||||||
LOG.warn(_("Unable to retrieve port status for:%s."), nvp_port_id)
|
LOG.warn(_("Unable to retrieve port status for:%s."), nvp_port_id)
|
||||||
return ret_port
|
return ret_port
|
||||||
|
|
||||||
@ -1520,7 +1522,7 @@ class NvpPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
|
|||||||
# If there's no nvp IP do not bother going to NVP and put
|
# If there's no nvp IP do not bother going to NVP and put
|
||||||
# the port in error state
|
# the port in error state
|
||||||
if nvp_id:
|
if nvp_id:
|
||||||
#TODO: pass the appropriate cluster here
|
#TODO(salvatore-orlando): pass the appropriate cluster here
|
||||||
try:
|
try:
|
||||||
port = nvplib.get_logical_port_status(
|
port = nvplib.get_logical_port_status(
|
||||||
self.default_cluster, quantum_db_port['network_id'],
|
self.default_cluster, quantum_db_port['network_id'],
|
||||||
@ -1930,7 +1932,7 @@ class NvpPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
|
|||||||
ips_to_remove=nvp_floating_ips)
|
ips_to_remove=nvp_floating_ips)
|
||||||
|
|
||||||
def _update_fip_assoc(self, context, fip, floatingip_db, external_port):
|
def _update_fip_assoc(self, context, fip, floatingip_db, external_port):
|
||||||
""" Update floating IP association data.
|
"""Update floating IP association data.
|
||||||
|
|
||||||
Overrides method from base class.
|
Overrides method from base class.
|
||||||
The method is augmented for creating NAT rules in the process.
|
The method is augmented for creating NAT rules in the process.
|
||||||
@ -2048,7 +2050,7 @@ class NvpPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
|
|||||||
super(NvpPluginV2, self).disassociate_floatingips(context, port_id)
|
super(NvpPluginV2, self).disassociate_floatingips(context, port_id)
|
||||||
|
|
||||||
def create_network_gateway(self, context, network_gateway):
|
def create_network_gateway(self, context, network_gateway):
|
||||||
""" Create a layer-2 network gateway
|
"""Create a layer-2 network gateway
|
||||||
|
|
||||||
Create the gateway service on NVP platform and corresponding data
|
Create the gateway service on NVP platform and corresponding data
|
||||||
structures in Quantum datase
|
structures in Quantum datase
|
||||||
@ -2077,7 +2079,7 @@ class NvpPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
|
|||||||
network_gateway)
|
network_gateway)
|
||||||
|
|
||||||
def delete_network_gateway(self, context, id):
|
def delete_network_gateway(self, context, id):
|
||||||
""" Remove a layer-2 network gateway
|
"""Remove a layer-2 network gateway
|
||||||
|
|
||||||
Remove the gateway service from NVP platform and corresponding data
|
Remove the gateway service from NVP platform and corresponding data
|
||||||
structures in Quantum datase
|
structures in Quantum datase
|
||||||
@ -2156,12 +2158,12 @@ class NvpPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
|
|||||||
context, security_group_id)
|
context, security_group_id)
|
||||||
|
|
||||||
def create_security_group_rule(self, context, security_group_rule):
|
def create_security_group_rule(self, context, security_group_rule):
|
||||||
"""create a single security group rule"""
|
"""create a single security group rule."""
|
||||||
bulk_rule = {'security_group_rules': [security_group_rule]}
|
bulk_rule = {'security_group_rules': [security_group_rule]}
|
||||||
return self.create_security_group_rule_bulk(context, bulk_rule)[0]
|
return self.create_security_group_rule_bulk(context, bulk_rule)[0]
|
||||||
|
|
||||||
def create_security_group_rule_bulk(self, context, security_group_rule):
|
def create_security_group_rule_bulk(self, context, security_group_rule):
|
||||||
""" create security group rules
|
"""create security group rules
|
||||||
:param security_group_rule: list of rules to create
|
:param security_group_rule: list of rules to create
|
||||||
"""
|
"""
|
||||||
s = security_group_rule.get('security_group_rules')
|
s = security_group_rule.get('security_group_rules')
|
||||||
@ -2194,7 +2196,7 @@ class NvpPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
|
|||||||
context, security_group_rule)
|
context, security_group_rule)
|
||||||
|
|
||||||
def delete_security_group_rule(self, context, sgrid):
|
def delete_security_group_rule(self, context, sgrid):
|
||||||
""" Delete a security group rule
|
"""Delete a security group rule
|
||||||
:param sgrid: security group id to remove.
|
:param sgrid: security group id to remove.
|
||||||
"""
|
"""
|
||||||
with context.session.begin(subtransactions=True):
|
with context.session.begin(subtransactions=True):
|
||||||
|
@ -21,8 +21,8 @@
|
|||||||
|
|
||||||
from abc import ABCMeta
|
from abc import ABCMeta
|
||||||
import httplib
|
import httplib
|
||||||
import time
|
|
||||||
import logging
|
import logging
|
||||||
|
import time
|
||||||
|
|
||||||
|
|
||||||
from quantum.plugins.nicira.api_client.common import (
|
from quantum.plugins.nicira.api_client.common import (
|
||||||
|
@ -23,8 +23,7 @@ import logging
|
|||||||
import time
|
import time
|
||||||
|
|
||||||
from quantum.plugins.nicira.api_client import client
|
from quantum.plugins.nicira.api_client import client
|
||||||
from quantum.plugins.nicira.api_client import (
|
from quantum.plugins.nicira.api_client import request_eventlet
|
||||||
request_eventlet)
|
|
||||||
|
|
||||||
eventlet.monkey_patch()
|
eventlet.monkey_patch()
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
""" NVP Plugin exceptions """
|
"""NVP Plugin exceptions"""
|
||||||
|
|
||||||
from quantum.common import exceptions as q_exc
|
from quantum.common import exceptions as q_exc
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ class NVPSecurityGroups(object):
|
|||||||
return self._convert_to_nvp_rules(rules, with_id)
|
return self._convert_to_nvp_rules(rules, with_id)
|
||||||
|
|
||||||
def _get_profile_uuid(self, context, remote_group_id):
|
def _get_profile_uuid(self, context, remote_group_id):
|
||||||
"""Return profile id from novas group id. """
|
"""Return profile id from novas group id."""
|
||||||
security_group = self.get_security_group(context, remote_group_id)
|
security_group = self.get_security_group(context, remote_group_id)
|
||||||
if not security_group:
|
if not security_group:
|
||||||
raise ext_sg.SecurityGroupNotFound(id=remote_group_id)
|
raise ext_sg.SecurityGroupNotFound(id=remote_group_id)
|
||||||
|
@ -55,7 +55,7 @@ RESOURCE_ATTRIBUTE_MAP = {
|
|||||||
|
|
||||||
|
|
||||||
def _validate_device_list(data, valid_values=None):
|
def _validate_device_list(data, valid_values=None):
|
||||||
""" Validate the list of service definitions. """
|
"""Validate the list of service definitions."""
|
||||||
if not data:
|
if not data:
|
||||||
# Devices must be provided
|
# Devices must be provided
|
||||||
msg = _("Cannot create a gateway with an empty device list")
|
msg = _("Cannot create a gateway with an empty device list")
|
||||||
@ -89,7 +89,7 @@ attributes.validators['type:device_list'] = _validate_device_list
|
|||||||
|
|
||||||
|
|
||||||
class Nvp_networkgw(object):
|
class Nvp_networkgw(object):
|
||||||
""" API extension for Layer-2 Gateway support.
|
"""API extension for Layer-2 Gateway support.
|
||||||
|
|
||||||
The Layer-2 gateway feature allows for connecting quantum networks
|
The Layer-2 gateway feature allows for connecting quantum networks
|
||||||
with external networks at the layer-2 level. No assumption is made on
|
with external networks at the layer-2 level. No assumption is made on
|
||||||
@ -122,7 +122,7 @@ class Nvp_networkgw(object):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_resources(cls):
|
def get_resources(cls):
|
||||||
""" Returns Ext Resources """
|
"""Returns Ext Resources."""
|
||||||
plugin = manager.QuantumManager.get_plugin()
|
plugin = manager.QuantumManager.get_plugin()
|
||||||
params = RESOURCE_ATTRIBUTE_MAP.get(COLLECTION_NAME, dict())
|
params = RESOURCE_ATTRIBUTE_MAP.get(COLLECTION_NAME, dict())
|
||||||
|
|
||||||
|
@ -20,9 +20,9 @@
|
|||||||
|
|
||||||
from abc import abstractmethod
|
from abc import abstractmethod
|
||||||
|
|
||||||
|
from quantum.api import extensions
|
||||||
from quantum.api.v2 import attributes as attr
|
from quantum.api.v2 import attributes as attr
|
||||||
from quantum.api.v2 import base
|
from quantum.api.v2 import base
|
||||||
from quantum.api import extensions
|
|
||||||
from quantum.common import exceptions as qexception
|
from quantum.common import exceptions as qexception
|
||||||
from quantum import manager
|
from quantum import manager
|
||||||
|
|
||||||
@ -137,7 +137,7 @@ EXTENDED_ATTRIBUTES_2_0 = {
|
|||||||
|
|
||||||
|
|
||||||
class Nvp_qos(object):
|
class Nvp_qos(object):
|
||||||
"""Port Queue extension"""
|
"""Port Queue extension."""
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_name(cls):
|
def get_name(cls):
|
||||||
@ -161,7 +161,7 @@ class Nvp_qos(object):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_resources(cls):
|
def get_resources(cls):
|
||||||
""" Returns Ext Resources """
|
"""Returns Ext Resources."""
|
||||||
exts = []
|
exts = []
|
||||||
plugin = manager.QuantumManager.get_plugin()
|
plugin = manager.QuantumManager.get_plugin()
|
||||||
resource_name = 'qos_queue'
|
resource_name = 'qos_queue'
|
||||||
|
@ -82,7 +82,7 @@ base.FAULT_MAP.update({GatewayInUse: web_exc.HTTPConflict,
|
|||||||
|
|
||||||
|
|
||||||
class NetworkConnection(model_base.BASEV2, models_v2.HasTenant):
|
class NetworkConnection(model_base.BASEV2, models_v2.HasTenant):
|
||||||
""" Defines a connection between a network gateway and a network """
|
"""Defines a connection between a network gateway and a network."""
|
||||||
# We use port_id as the primary key as one can connect a gateway
|
# We use port_id as the primary key as one can connect a gateway
|
||||||
# to a network in multiple ways (and we cannot use the same port form
|
# to a network in multiple ways (and we cannot use the same port form
|
||||||
# more than a single gateway)
|
# more than a single gateway)
|
||||||
@ -115,7 +115,7 @@ class NetworkGatewayDevice(model_base.BASEV2):
|
|||||||
|
|
||||||
class NetworkGateway(model_base.BASEV2, models_v2.HasId,
|
class NetworkGateway(model_base.BASEV2, models_v2.HasId,
|
||||||
models_v2.HasTenant):
|
models_v2.HasTenant):
|
||||||
""" Defines the data model for a network gateway """
|
"""Defines the data model for a network gateway."""
|
||||||
name = sa.Column(sa.String(255))
|
name = sa.Column(sa.String(255))
|
||||||
# Tenant id is nullable for this resource
|
# Tenant id is nullable for this resource
|
||||||
tenant_id = sa.Column(sa.String(36))
|
tenant_id = sa.Column(sa.String(36))
|
||||||
@ -194,7 +194,7 @@ class NetworkGatewayMixin(nvp_networkgw.NetworkGatewayPluginBase):
|
|||||||
gw['default'] = True
|
gw['default'] = True
|
||||||
|
|
||||||
def prevent_network_gateway_port_deletion(self, context, port):
|
def prevent_network_gateway_port_deletion(self, context, port):
|
||||||
""" Pre-deletion check.
|
"""Pre-deletion check.
|
||||||
|
|
||||||
Ensures a port will not be deleted if is being used by a network
|
Ensures a port will not be deleted if is being used by a network
|
||||||
gateway. In that case an exception will be raised.
|
gateway. In that case an exception will be raised.
|
||||||
|
@ -153,7 +153,7 @@ def _check_and_truncate_name(display_name):
|
|||||||
|
|
||||||
|
|
||||||
def get_cluster_version(cluster):
|
def get_cluster_version(cluster):
|
||||||
"""Return major/minor version #"""
|
"""Return major/minor version #."""
|
||||||
# Get control-cluster nodes
|
# Get control-cluster nodes
|
||||||
uri = "/ws.v1/control-cluster/node?_page_length=1&fields=uuid"
|
uri = "/ws.v1/control-cluster/node?_page_length=1&fields=uuid"
|
||||||
try:
|
try:
|
||||||
@ -199,7 +199,8 @@ def get_all_query_pages(path, c):
|
|||||||
|
|
||||||
def do_single_request(*args, **kwargs):
|
def do_single_request(*args, **kwargs):
|
||||||
"""Issue a request to a specified cluster if specified via kwargs
|
"""Issue a request to a specified cluster if specified via kwargs
|
||||||
(cluster=<cluster>)."""
|
(cluster=<cluster>).
|
||||||
|
"""
|
||||||
cluster = kwargs["cluster"]
|
cluster = kwargs["cluster"]
|
||||||
try:
|
try:
|
||||||
req = cluster.api_client.request(*args)
|
req = cluster.api_client.request(*args)
|
||||||
@ -209,7 +210,7 @@ def do_single_request(*args, **kwargs):
|
|||||||
|
|
||||||
|
|
||||||
def do_multi_request(*args, **kwargs):
|
def do_multi_request(*args, **kwargs):
|
||||||
"""Issue a request to all clusters"""
|
"""Issue a request to all clusters."""
|
||||||
results = []
|
results = []
|
||||||
clusters = kwargs["clusters"]
|
clusters = kwargs["clusters"]
|
||||||
for x in clusters:
|
for x in clusters:
|
||||||
@ -343,7 +344,7 @@ def update_lswitch(cluster, lswitch_id, display_name,
|
|||||||
|
|
||||||
|
|
||||||
def create_l2_gw_service(cluster, tenant_id, display_name, devices):
|
def create_l2_gw_service(cluster, tenant_id, display_name, devices):
|
||||||
""" Create a NVP Layer-2 Network Gateway Service.
|
"""Create a NVP Layer-2 Network Gateway Service.
|
||||||
|
|
||||||
:param cluster: The target NVP cluster
|
:param cluster: The target NVP cluster
|
||||||
:param tenant_id: Identifier of the Openstack tenant for which
|
:param tenant_id: Identifier of the Openstack tenant for which
|
||||||
@ -379,7 +380,7 @@ def create_l2_gw_service(cluster, tenant_id, display_name, devices):
|
|||||||
|
|
||||||
|
|
||||||
def create_lrouter(cluster, tenant_id, display_name, nexthop):
|
def create_lrouter(cluster, tenant_id, display_name, nexthop):
|
||||||
""" Create a NVP logical router on the specified cluster.
|
"""Create a NVP logical router on the specified cluster.
|
||||||
|
|
||||||
:param cluster: The target NVP cluster
|
:param cluster: The target NVP cluster
|
||||||
:param tenant_id: Identifier of the Openstack tenant for which
|
:param tenant_id: Identifier of the Openstack tenant for which
|
||||||
@ -776,7 +777,7 @@ def create_lport(cluster, lswitch_uuid, tenant_id, quantum_port_id,
|
|||||||
display_name, device_id, admin_status_enabled,
|
display_name, device_id, admin_status_enabled,
|
||||||
mac_address=None, fixed_ips=None, port_security_enabled=None,
|
mac_address=None, fixed_ips=None, port_security_enabled=None,
|
||||||
security_profiles=None, queue_id=None):
|
security_profiles=None, queue_id=None):
|
||||||
""" Creates a logical port on the assigned logical switch """
|
"""Creates a logical port on the assigned logical switch."""
|
||||||
# device_id can be longer than 40 so we rehash it
|
# device_id can be longer than 40 so we rehash it
|
||||||
hashed_device_id = hashlib.sha1(device_id).hexdigest()
|
hashed_device_id = hashlib.sha1(device_id).hexdigest()
|
||||||
display_name = _check_and_truncate_name(display_name)
|
display_name = _check_and_truncate_name(display_name)
|
||||||
@ -810,7 +811,7 @@ def create_lport(cluster, lswitch_uuid, tenant_id, quantum_port_id,
|
|||||||
|
|
||||||
def create_router_lport(cluster, lrouter_uuid, tenant_id, quantum_port_id,
|
def create_router_lport(cluster, lrouter_uuid, tenant_id, quantum_port_id,
|
||||||
display_name, admin_status_enabled, ip_addresses):
|
display_name, admin_status_enabled, ip_addresses):
|
||||||
""" Creates a logical port on the assigned logical router """
|
"""Creates a logical port on the assigned logical router."""
|
||||||
tags = [dict(scope='os_tid', tag=tenant_id),
|
tags = [dict(scope='os_tid', tag=tenant_id),
|
||||||
dict(scope='q_port_id', tag=quantum_port_id)]
|
dict(scope='q_port_id', tag=quantum_port_id)]
|
||||||
lport_obj = dict(
|
lport_obj = dict(
|
||||||
@ -841,7 +842,7 @@ def create_router_lport(cluster, lrouter_uuid, tenant_id, quantum_port_id,
|
|||||||
def update_router_lport(cluster, lrouter_uuid, lrouter_port_uuid,
|
def update_router_lport(cluster, lrouter_uuid, lrouter_port_uuid,
|
||||||
tenant_id, quantum_port_id, display_name,
|
tenant_id, quantum_port_id, display_name,
|
||||||
admin_status_enabled, ip_addresses):
|
admin_status_enabled, ip_addresses):
|
||||||
""" Updates a logical port on the assigned logical router """
|
"""Updates a logical port on the assigned logical router."""
|
||||||
lport_obj = dict(
|
lport_obj = dict(
|
||||||
admin_status_enabled=admin_status_enabled,
|
admin_status_enabled=admin_status_enabled,
|
||||||
display_name=display_name,
|
display_name=display_name,
|
||||||
@ -874,7 +875,7 @@ def update_router_lport(cluster, lrouter_uuid, lrouter_port_uuid,
|
|||||||
|
|
||||||
|
|
||||||
def delete_router_lport(cluster, lrouter_uuid, lport_uuid):
|
def delete_router_lport(cluster, lrouter_uuid, lport_uuid):
|
||||||
""" Creates a logical port on the assigned logical router """
|
"""Creates a logical port on the assigned logical router."""
|
||||||
path = _build_uri_path(LROUTERPORT_RESOURCE, lport_uuid, lrouter_uuid)
|
path = _build_uri_path(LROUTERPORT_RESOURCE, lport_uuid, lrouter_uuid)
|
||||||
try:
|
try:
|
||||||
do_single_request(HTTP_DELETE, path, cluster=cluster)
|
do_single_request(HTTP_DELETE, path, cluster=cluster)
|
||||||
@ -906,7 +907,7 @@ def delete_peer_router_lport(cluster, lr_uuid, ls_uuid, lp_uuid):
|
|||||||
|
|
||||||
|
|
||||||
def find_router_gw_port(context, cluster, router_id):
|
def find_router_gw_port(context, cluster, router_id):
|
||||||
""" Retrieves the external gateway port for a NVP logical router """
|
"""Retrieves the external gateway port for a NVP logical router."""
|
||||||
|
|
||||||
# Find the uuid of nvp ext gw logical router port
|
# Find the uuid of nvp ext gw logical router port
|
||||||
# TODO(salvatore-orlando): Consider storing it in Quantum DB
|
# TODO(salvatore-orlando): Consider storing it in Quantum DB
|
||||||
@ -959,7 +960,7 @@ def plug_router_port_attachment(cluster, router_id, port_id,
|
|||||||
|
|
||||||
|
|
||||||
def get_port_status(cluster, lswitch_id, port_id):
|
def get_port_status(cluster, lswitch_id, port_id):
|
||||||
"""Retrieve the operational status of the port"""
|
"""Retrieve the operational status of the port."""
|
||||||
try:
|
try:
|
||||||
r = do_single_request(HTTP_GET,
|
r = do_single_request(HTTP_GET,
|
||||||
"/ws.v1/lswitch/%s/lport/%s/status" %
|
"/ws.v1/lswitch/%s/lport/%s/status" %
|
||||||
@ -996,7 +997,7 @@ def _plug_interface(cluster, lswitch_id, lport_id, att_obj):
|
|||||||
|
|
||||||
def plug_l2_gw_service(cluster, lswitch_id, lport_id,
|
def plug_l2_gw_service(cluster, lswitch_id, lport_id,
|
||||||
gateway_id, vlan_id=None):
|
gateway_id, vlan_id=None):
|
||||||
""" Plug a Layer-2 Gateway Attachment object in a logical port """
|
"""Plug a Layer-2 Gateway Attachment object in a logical port."""
|
||||||
att_obj = {'type': 'L2GatewayAttachment',
|
att_obj = {'type': 'L2GatewayAttachment',
|
||||||
'l2_gateway_service_uuid': gateway_id}
|
'l2_gateway_service_uuid': gateway_id}
|
||||||
if vlan_id:
|
if vlan_id:
|
||||||
@ -1005,7 +1006,7 @@ def plug_l2_gw_service(cluster, lswitch_id, lport_id,
|
|||||||
|
|
||||||
|
|
||||||
def plug_interface(cluster, lswitch_id, port, type, attachment=None):
|
def plug_interface(cluster, lswitch_id, port, type, attachment=None):
|
||||||
""" Plug a VIF Attachment object in a logical port """
|
"""Plug a VIF Attachment object in a logical port."""
|
||||||
lport_obj = {}
|
lport_obj = {}
|
||||||
if attachment:
|
if attachment:
|
||||||
lport_obj["vif_uuid"] = attachment
|
lport_obj["vif_uuid"] = attachment
|
||||||
@ -1044,7 +1045,8 @@ def do_request(*args, **kwargs):
|
|||||||
:param args: a list of positional arguments.
|
:param args: a list of positional arguments.
|
||||||
:param kwargs: a list of keyworkds arguments.
|
:param kwargs: a list of keyworkds arguments.
|
||||||
:returns: the result of do_single_request loaded into a python object
|
:returns: the result of do_single_request loaded into a python object
|
||||||
or None."""
|
or None.
|
||||||
|
"""
|
||||||
res = do_single_request(*args, **kwargs)
|
res = do_single_request(*args, **kwargs)
|
||||||
if res:
|
if res:
|
||||||
return json.loads(res)
|
return json.loads(res)
|
||||||
@ -1055,7 +1057,8 @@ def mk_body(**kwargs):
|
|||||||
"""Convenience function creates and dumps dictionary to string.
|
"""Convenience function creates and dumps dictionary to string.
|
||||||
|
|
||||||
:param kwargs: the key/value pirs to be dumped into a json string.
|
:param kwargs: the key/value pirs to be dumped into a json string.
|
||||||
:returns: a json string."""
|
:returns: a json string.
|
||||||
|
"""
|
||||||
return json.dumps(kwargs, ensure_ascii=False)
|
return json.dumps(kwargs, ensure_ascii=False)
|
||||||
|
|
||||||
|
|
||||||
@ -1065,7 +1068,8 @@ def set_tenant_id_tag(tenant_id, taglist=None):
|
|||||||
:param tenant_id: the tenant_id to set.
|
:param tenant_id: the tenant_id to set.
|
||||||
:param taglist: the taglist to append to (or None).
|
:param taglist: the taglist to append to (or None).
|
||||||
:returns: a new taglist that includes the old taglist with the new
|
:returns: a new taglist that includes the old taglist with the new
|
||||||
tenant_id tag set."""
|
tenant_id tag set.
|
||||||
|
"""
|
||||||
new_taglist = []
|
new_taglist = []
|
||||||
if taglist:
|
if taglist:
|
||||||
new_taglist = [x for x in taglist if x['scope'] != TENANT_ID_SCOPE]
|
new_taglist = [x for x in taglist if x['scope'] != TENANT_ID_SCOPE]
|
||||||
@ -1402,7 +1406,7 @@ def delete_lqueue(cluster, id):
|
|||||||
# NVP API Calls for check_nvp_config utility
|
# NVP API Calls for check_nvp_config utility
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
def check_cluster_connectivity(cluster):
|
def check_cluster_connectivity(cluster):
|
||||||
"""Make sure that we can issue a request to each of the cluster nodes"""
|
"""Make sure that we can issue a request to each of the cluster nodes."""
|
||||||
try:
|
try:
|
||||||
resp = do_single_request(HTTP_GET, "/ws.v1/control-cluster",
|
resp = do_single_request(HTTP_GET, "/ws.v1/control-cluster",
|
||||||
cluster=cluster)
|
cluster=cluster)
|
||||||
|
@ -89,7 +89,7 @@ class Port(object):
|
|||||||
return (self and other
|
return (self and other
|
||||||
and self.id == other.id
|
and self.id == other.id
|
||||||
and self.admin_state_up == other.admin_state_up)
|
and self.admin_state_up == other.admin_state_up)
|
||||||
except:
|
except Exception:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def __ne__(self, other):
|
def __ne__(self, other):
|
||||||
@ -378,7 +378,8 @@ class OVSQuantumAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin):
|
|||||||
|
|
||||||
:param net_uuid: the network uuid associated with this vlan.
|
:param net_uuid: the network uuid associated with this vlan.
|
||||||
:param lvm: a LocalVLANMapping object that tracks (vlan, lsw_id,
|
:param lvm: a LocalVLANMapping object that tracks (vlan, lsw_id,
|
||||||
vif_ids) mapping.'''
|
vif_ids) mapping.
|
||||||
|
'''
|
||||||
LOG.info(_("Reclaiming vlan = %(vlan_id)s from net-id = %(net_uuid)s"),
|
LOG.info(_("Reclaiming vlan = %(vlan_id)s from net-id = %(net_uuid)s"),
|
||||||
{'vlan_id': lvm.vlan,
|
{'vlan_id': lvm.vlan,
|
||||||
'net_uuid': net_uuid})
|
'net_uuid': net_uuid})
|
||||||
@ -458,7 +459,8 @@ class OVSQuantumAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin):
|
|||||||
VIF.
|
VIF.
|
||||||
|
|
||||||
:param vif_id: the id of the vif
|
:param vif_id: the id of the vif
|
||||||
:param net_uuid: the net_uuid this port is associated with.'''
|
:param net_uuid: the net_uuid this port is associated with.
|
||||||
|
'''
|
||||||
if net_uuid is None:
|
if net_uuid is None:
|
||||||
net_uuid = self.get_net_uuid(vif_id)
|
net_uuid = self.get_net_uuid(vif_id)
|
||||||
|
|
||||||
@ -485,7 +487,8 @@ class OVSQuantumAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin):
|
|||||||
def port_dead(self, port):
|
def port_dead(self, port):
|
||||||
'''Once a port has no binding, put it on the "dead vlan".
|
'''Once a port has no binding, put it on the "dead vlan".
|
||||||
|
|
||||||
:param port: a ovs_lib.VifPort object.'''
|
:param port: a ovs_lib.VifPort object.
|
||||||
|
'''
|
||||||
self.int_br.set_db_attribute("Port", port.port_name, "tag",
|
self.int_br.set_db_attribute("Port", port.port_name, "tag",
|
||||||
DEAD_VLAN_TAG)
|
DEAD_VLAN_TAG)
|
||||||
self.int_br.add_flow(priority=2, in_port=port.ofport, actions="drop")
|
self.int_br.add_flow(priority=2, in_port=port.ofport, actions="drop")
|
||||||
@ -511,7 +514,8 @@ class OVSQuantumAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin):
|
|||||||
Creates tunnel bridge, and links it to the integration bridge
|
Creates tunnel bridge, and links it to the integration bridge
|
||||||
using a patch port.
|
using a patch port.
|
||||||
|
|
||||||
:param tun_br: the name of the tunnel bridge.'''
|
:param tun_br: the name of the tunnel bridge.
|
||||||
|
'''
|
||||||
self.tun_br = ovs_lib.OVSBridge(tun_br, self.root_helper)
|
self.tun_br = ovs_lib.OVSBridge(tun_br, self.root_helper)
|
||||||
self.tun_br.reset_bridge()
|
self.tun_br.reset_bridge()
|
||||||
self.patch_tun_ofport = self.int_br.add_patch_port(
|
self.patch_tun_ofport = self.int_br.add_patch_port(
|
||||||
@ -533,7 +537,8 @@ class OVSQuantumAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin):
|
|||||||
Creates physical network bridges and links them to the
|
Creates physical network bridges and links them to the
|
||||||
integration bridge using veths.
|
integration bridge using veths.
|
||||||
|
|
||||||
:param bridge_mappings: map physical network names to bridge names.'''
|
:param bridge_mappings: map physical network names to bridge names.
|
||||||
|
'''
|
||||||
self.phys_brs = {}
|
self.phys_brs = {}
|
||||||
self.int_ofports = {}
|
self.int_ofports = {}
|
||||||
self.phys_ofports = {}
|
self.phys_ofports = {}
|
||||||
@ -703,7 +708,7 @@ class OVSQuantumAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin):
|
|||||||
sync = self.process_network_ports(port_info)
|
sync = self.process_network_ports(port_info)
|
||||||
ports = port_info['current']
|
ports = port_info['current']
|
||||||
|
|
||||||
except:
|
except Exception:
|
||||||
LOG.exception(_("Error in agent event loop"))
|
LOG.exception(_("Error in agent event loop"))
|
||||||
sync = True
|
sync = True
|
||||||
tunnel_sync = True
|
tunnel_sync = True
|
||||||
|
@ -56,7 +56,7 @@ def add_network_binding(session, network_id, network_type,
|
|||||||
|
|
||||||
|
|
||||||
def sync_vlan_allocations(network_vlan_ranges):
|
def sync_vlan_allocations(network_vlan_ranges):
|
||||||
"""Synchronize vlan_allocations table with configured VLAN ranges"""
|
"""Synchronize vlan_allocations table with configured VLAN ranges."""
|
||||||
|
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
with session.begin():
|
with session.begin():
|
||||||
@ -197,7 +197,7 @@ def release_vlan(session, physical_network, vlan_id, network_vlan_ranges):
|
|||||||
|
|
||||||
|
|
||||||
def sync_tunnel_allocations(tunnel_id_ranges):
|
def sync_tunnel_allocations(tunnel_id_ranges):
|
||||||
"""Synchronize tunnel_allocations table with configured tunnel ranges"""
|
"""Synchronize tunnel_allocations table with configured tunnel ranges."""
|
||||||
|
|
||||||
# determine current configured allocatable tunnels
|
# determine current configured allocatable tunnels
|
||||||
tunnel_ids = set()
|
tunnel_ids = set()
|
||||||
@ -310,7 +310,7 @@ def get_port(port_id):
|
|||||||
|
|
||||||
|
|
||||||
def get_port_from_device(port_id):
|
def get_port_from_device(port_id):
|
||||||
"""Get port from database"""
|
"""Get port from database."""
|
||||||
LOG.debug(_("get_port_with_securitygroups() called:port_id=%s"), port_id)
|
LOG.debug(_("get_port_with_securitygroups() called:port_id=%s"), port_id)
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
sg_binding_port = sg_db.SecurityGroupPortBinding.port_id
|
sg_binding_port = sg_db.SecurityGroupPortBinding.port_id
|
||||||
|
@ -23,7 +23,7 @@ from quantum.db.models_v2 import model_base
|
|||||||
|
|
||||||
|
|
||||||
class VlanAllocation(model_base.BASEV2):
|
class VlanAllocation(model_base.BASEV2):
|
||||||
"""Represents allocation state of vlan_id on physical network"""
|
"""Represents allocation state of vlan_id on physical network."""
|
||||||
__tablename__ = 'ovs_vlan_allocations'
|
__tablename__ = 'ovs_vlan_allocations'
|
||||||
|
|
||||||
physical_network = Column(String(64), nullable=False, primary_key=True)
|
physical_network = Column(String(64), nullable=False, primary_key=True)
|
||||||
@ -42,7 +42,7 @@ class VlanAllocation(model_base.BASEV2):
|
|||||||
|
|
||||||
|
|
||||||
class TunnelAllocation(model_base.BASEV2):
|
class TunnelAllocation(model_base.BASEV2):
|
||||||
"""Represents allocation state of tunnel_id"""
|
"""Represents allocation state of tunnel_id."""
|
||||||
__tablename__ = 'ovs_tunnel_allocations'
|
__tablename__ = 'ovs_tunnel_allocations'
|
||||||
|
|
||||||
tunnel_id = Column(Integer, nullable=False, primary_key=True,
|
tunnel_id = Column(Integer, nullable=False, primary_key=True,
|
||||||
@ -58,7 +58,7 @@ class TunnelAllocation(model_base.BASEV2):
|
|||||||
|
|
||||||
|
|
||||||
class NetworkBinding(model_base.BASEV2):
|
class NetworkBinding(model_base.BASEV2):
|
||||||
"""Represents binding of virtual network to physical realization"""
|
"""Represents binding of virtual network to physical realization."""
|
||||||
__tablename__ = 'ovs_network_bindings'
|
__tablename__ = 'ovs_network_bindings'
|
||||||
|
|
||||||
network_id = Column(String(36),
|
network_id = Column(String(36),
|
||||||
@ -84,7 +84,7 @@ class NetworkBinding(model_base.BASEV2):
|
|||||||
|
|
||||||
|
|
||||||
class TunnelIP(model_base.BASEV2):
|
class TunnelIP(model_base.BASEV2):
|
||||||
"""Represents tunnel endpoint in DB mode"""
|
"""Represents tunnel endpoint in DB mode."""
|
||||||
__tablename__ = 'ovs_tunnel_ips'
|
__tablename__ = 'ovs_tunnel_ips'
|
||||||
|
|
||||||
ip_address = Column(String(255), primary_key=True)
|
ip_address = Column(String(255), primary_key=True)
|
||||||
@ -97,7 +97,7 @@ class TunnelIP(model_base.BASEV2):
|
|||||||
|
|
||||||
|
|
||||||
class TunnelEndpoint(model_base.BASEV2):
|
class TunnelEndpoint(model_base.BASEV2):
|
||||||
"""Represents tunnel endpoint in RPC mode"""
|
"""Represents tunnel endpoint in RPC mode."""
|
||||||
__tablename__ = 'ovs_tunnel_endpoints'
|
__tablename__ = 'ovs_tunnel_endpoints'
|
||||||
|
|
||||||
ip_address = Column(String(64), primary_key=True)
|
ip_address = Column(String(64), primary_key=True)
|
||||||
|
@ -85,7 +85,7 @@ class OVSRpcCallbacks(dhcp_rpc_base.DhcpRpcCallbackMixin,
|
|||||||
return port
|
return port
|
||||||
|
|
||||||
def get_device_details(self, rpc_context, **kwargs):
|
def get_device_details(self, rpc_context, **kwargs):
|
||||||
"""Agent requests device details"""
|
"""Agent requests device details."""
|
||||||
agent_id = kwargs.get('agent_id')
|
agent_id = kwargs.get('agent_id')
|
||||||
device = kwargs.get('device')
|
device = kwargs.get('device')
|
||||||
LOG.debug(_("Device %(device)s details requested from %(agent_id)s"),
|
LOG.debug(_("Device %(device)s details requested from %(agent_id)s"),
|
||||||
@ -110,8 +110,8 @@ class OVSRpcCallbacks(dhcp_rpc_base.DhcpRpcCallbackMixin,
|
|||||||
return entry
|
return entry
|
||||||
|
|
||||||
def update_device_down(self, rpc_context, **kwargs):
|
def update_device_down(self, rpc_context, **kwargs):
|
||||||
"""Device no longer exists on agent"""
|
"""Device no longer exists on agent."""
|
||||||
# (TODO) garyk - live migration and port status
|
# TODO(garyk) - live migration and port status
|
||||||
agent_id = kwargs.get('agent_id')
|
agent_id = kwargs.get('agent_id')
|
||||||
device = kwargs.get('device')
|
device = kwargs.get('device')
|
||||||
LOG.debug(_("Device %(device)s no longer exists on %(agent_id)s"),
|
LOG.debug(_("Device %(device)s no longer exists on %(agent_id)s"),
|
||||||
@ -130,7 +130,7 @@ class OVSRpcCallbacks(dhcp_rpc_base.DhcpRpcCallbackMixin,
|
|||||||
return entry
|
return entry
|
||||||
|
|
||||||
def update_device_up(self, rpc_context, **kwargs):
|
def update_device_up(self, rpc_context, **kwargs):
|
||||||
"""Device is up on agent"""
|
"""Device is up on agent."""
|
||||||
agent_id = kwargs.get('agent_id')
|
agent_id = kwargs.get('agent_id')
|
||||||
device = kwargs.get('device')
|
device = kwargs.get('device')
|
||||||
LOG.debug(_("Device %(device)s up on %(agent_id)s"),
|
LOG.debug(_("Device %(device)s up on %(agent_id)s"),
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
# @author: Edgar Magana, emagana@plumgrid.com, PLUMgrid, Inc.
|
# @author: Edgar Magana, emagana@plumgrid.com, PLUMgrid, Inc.
|
||||||
|
|
||||||
|
|
||||||
""" Quantum PLUMgrid Plugin exceptions """
|
"""Quantum PLUMgrid Plugin exceptions"""
|
||||||
|
|
||||||
from quantum.common import exceptions as base_exec
|
from quantum.common import exceptions as base_exec
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ class QuantumPluginPLUMgridV2(db_base_plugin_v2.QuantumDbPluginV2):
|
|||||||
self.topology_name = cfg.CONF.PLUMgridNOS.topologyname
|
self.topology_name = cfg.CONF.PLUMgridNOS.topologyname
|
||||||
self.snippets = plumgrid_nos_snippets.DataNOSPLUMgrid()
|
self.snippets = plumgrid_nos_snippets.DataNOSPLUMgrid()
|
||||||
|
|
||||||
# TODO: (Edgar) These are placeholders for next PLUMgrid release
|
# TODO(Edgar) These are placeholders for next PLUMgrid release
|
||||||
cfg.CONF.PLUMgridNOS.username
|
cfg.CONF.PLUMgridNOS.username
|
||||||
cfg.CONF.PLUMgridNOS.password
|
cfg.CONF.PLUMgridNOS.password
|
||||||
self.rest_conn = rest_connection.RestConnection(nos_plumgrid,
|
self.rest_conn = rest_connection.RestConnection(nos_plumgrid,
|
||||||
@ -104,15 +104,20 @@ class QuantumPluginPLUMgridV2(db_base_plugin_v2.QuantumDbPluginV2):
|
|||||||
network)
|
network)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
LOG.debug(_('QuantumPluginPLUMgrid Status: %s, %s, %s'),
|
LOG.debug(_('QuantumPluginPLUMgrid Status: %(tenant_id)s, '
|
||||||
tenant_id, network["network"], net["id"])
|
'%(network)s, %(network_id)s'),
|
||||||
|
dict(
|
||||||
|
tenant_id=tenant_id,
|
||||||
|
network=network["network"],
|
||||||
|
network_id=net["id"],
|
||||||
|
))
|
||||||
nos_url = self.snippets.BASE_NOS_URL + net["id"]
|
nos_url = self.snippets.BASE_NOS_URL + net["id"]
|
||||||
headers = {}
|
headers = {}
|
||||||
body_data = self.snippets.create_domain_body_data(tenant_id)
|
body_data = self.snippets.create_domain_body_data(tenant_id)
|
||||||
self.rest_conn.nos_rest_conn(nos_url,
|
self.rest_conn.nos_rest_conn(nos_url,
|
||||||
'PUT', body_data, headers)
|
'PUT', body_data, headers)
|
||||||
|
|
||||||
except:
|
except Exception:
|
||||||
err_message = _("PLUMgrid NOS communication failed")
|
err_message = _("PLUMgrid NOS communication failed")
|
||||||
LOG.Exception(err_message)
|
LOG.Exception(err_message)
|
||||||
raise plum_excep.PLUMgridException(err_message)
|
raise plum_excep.PLUMgridException(err_message)
|
||||||
@ -146,7 +151,7 @@ class QuantumPluginPLUMgridV2(db_base_plugin_v2.QuantumDbPluginV2):
|
|||||||
body_data = self.snippets.create_domain_body_data(tenant_id)
|
body_data = self.snippets.create_domain_body_data(tenant_id)
|
||||||
self.rest_conn.nos_rest_conn(nos_url,
|
self.rest_conn.nos_rest_conn(nos_url,
|
||||||
'PUT', body_data, headers)
|
'PUT', body_data, headers)
|
||||||
except:
|
except Exception:
|
||||||
err_message = _("PLUMgrid NOS communication failed")
|
err_message = _("PLUMgrid NOS communication failed")
|
||||||
LOG.Exception(err_message)
|
LOG.Exception(err_message)
|
||||||
raise plum_excep.PLUMgridException(err_message)
|
raise plum_excep.PLUMgridException(err_message)
|
||||||
@ -172,7 +177,7 @@ class QuantumPluginPLUMgridV2(db_base_plugin_v2.QuantumDbPluginV2):
|
|||||||
body_data = {}
|
body_data = {}
|
||||||
self.rest_conn.nos_rest_conn(nos_url,
|
self.rest_conn.nos_rest_conn(nos_url,
|
||||||
'DELETE', body_data, headers)
|
'DELETE', body_data, headers)
|
||||||
except:
|
except Exception:
|
||||||
err_message = _("PLUMgrid NOS communication failed")
|
err_message = _("PLUMgrid NOS communication failed")
|
||||||
LOG.Exception(err_message)
|
LOG.Exception(err_message)
|
||||||
raise plum_excep.PLUMgridException(err_message)
|
raise plum_excep.PLUMgridException(err_message)
|
||||||
@ -240,7 +245,7 @@ class QuantumPluginPLUMgridV2(db_base_plugin_v2.QuantumDbPluginV2):
|
|||||||
tenant_id, self.topology_name)
|
tenant_id, self.topology_name)
|
||||||
self.rest_conn.nos_rest_conn(nos_url,
|
self.rest_conn.nos_rest_conn(nos_url,
|
||||||
'PUT', body_data, headers)
|
'PUT', body_data, headers)
|
||||||
except:
|
except Exception:
|
||||||
err_message = _("PLUMgrid NOS communication failed: ")
|
err_message = _("PLUMgrid NOS communication failed: ")
|
||||||
LOG.Exception(err_message)
|
LOG.Exception(err_message)
|
||||||
raise plum_excep.PLUMgridException(err_message)
|
raise plum_excep.PLUMgridException(err_message)
|
||||||
@ -265,7 +270,7 @@ class QuantumPluginPLUMgridV2(db_base_plugin_v2.QuantumDbPluginV2):
|
|||||||
body_data = {}
|
body_data = {}
|
||||||
net_id = subnet_details["network_id"]
|
net_id = subnet_details["network_id"]
|
||||||
self._cleaning_nos_subnet_structure(body_data, headers, net_id)
|
self._cleaning_nos_subnet_structure(body_data, headers, net_id)
|
||||||
except:
|
except Exception:
|
||||||
err_message = _("PLUMgrid NOS communication failed: ")
|
err_message = _("PLUMgrid NOS communication failed: ")
|
||||||
LOG.Exception(err_message)
|
LOG.Exception(err_message)
|
||||||
raise plum_excep.PLUMgridException(err_message)
|
raise plum_excep.PLUMgridException(err_message)
|
||||||
@ -299,7 +304,7 @@ class QuantumPluginPLUMgridV2(db_base_plugin_v2.QuantumDbPluginV2):
|
|||||||
self.rest_conn.nos_rest_conn(nos_url,
|
self.rest_conn.nos_rest_conn(nos_url,
|
||||||
'PUT', body_data, headers)
|
'PUT', body_data, headers)
|
||||||
|
|
||||||
except:
|
except Exception:
|
||||||
err_message = _("PLUMgrid NOS communication failed: ")
|
err_message = _("PLUMgrid NOS communication failed: ")
|
||||||
LOG.Exception(err_message)
|
LOG.Exception(err_message)
|
||||||
raise plum_excep.PLUMgridException(err_message)
|
raise plum_excep.PLUMgridException(err_message)
|
||||||
@ -309,7 +314,7 @@ class QuantumPluginPLUMgridV2(db_base_plugin_v2.QuantumDbPluginV2):
|
|||||||
"""
|
"""
|
||||||
Extension API implementation
|
Extension API implementation
|
||||||
"""
|
"""
|
||||||
# TODO: (Edgar) Complete extensions for PLUMgrid
|
# TODO(Edgar) Complete extensions for PLUMgrid
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Internal PLUMgrid fuctions
|
Internal PLUMgrid fuctions
|
||||||
@ -332,7 +337,7 @@ class QuantumPluginPLUMgridV2(db_base_plugin_v2.QuantumDbPluginV2):
|
|||||||
LOG.warning(_("Network with admin_state_up=False are not "
|
LOG.warning(_("Network with admin_state_up=False are not "
|
||||||
"supported yet by this plugin. Ignoring "
|
"supported yet by this plugin. Ignoring "
|
||||||
"setting for network %s"), network_name)
|
"setting for network %s"), network_name)
|
||||||
except:
|
except Exception:
|
||||||
err_message = _("Network Admin State Validation Falied: ")
|
err_message = _("Network Admin State Validation Falied: ")
|
||||||
LOG.Exception(err_message)
|
LOG.Exception(err_message)
|
||||||
raise plum_excep.PLUMgridException(err_message)
|
raise plum_excep.PLUMgridException(err_message)
|
||||||
|
@ -50,8 +50,8 @@ class RestConnection(object):
|
|||||||
headers['Content-type'] = 'application/json'
|
headers['Content-type'] = 'application/json'
|
||||||
headers['Accept'] = 'application/json'
|
headers['Accept'] = 'application/json'
|
||||||
|
|
||||||
LOG.debug(_("PLUMgrid_NOS_Server: %s %s %s"), self.server, self.port,
|
LOG.debug(_("PLUMgrid_NOS_Server: %(server)s %(port)s %(action)s"),
|
||||||
action)
|
dict(server=self.server, port=self.port, action=action))
|
||||||
|
|
||||||
conn = httplib.HTTPConnection(self.server, self.port,
|
conn = httplib.HTTPConnection(self.server, self.port,
|
||||||
timeout=self.timeout)
|
timeout=self.timeout)
|
||||||
@ -61,14 +61,19 @@ class RestConnection(object):
|
|||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
LOG.debug(_("PLUMgrid_NOS_Server Sending Data: %s %s %s"),
|
LOG.debug(_("PLUMgrid_NOS_Server Sending Data: %(nos_url)s "
|
||||||
nos_url, body_data, headers)
|
"%(body_data)s %(headers)s"),
|
||||||
|
dict(
|
||||||
|
nos_url=nos_url,
|
||||||
|
body_data=body_data,
|
||||||
|
headers=headers,
|
||||||
|
))
|
||||||
conn.request(action, nos_url, body_data, headers)
|
conn.request(action, nos_url, body_data, headers)
|
||||||
resp = conn.getresponse()
|
resp = conn.getresponse()
|
||||||
resp_str = resp.read()
|
resp_str = resp.read()
|
||||||
|
|
||||||
LOG.debug(_("PLUMgrid_NOS_Server Connection Data: %s, %s"),
|
LOG.debug(_("PLUMgrid_NOS_Server Connection Data: %(resp)s, "
|
||||||
resp, resp_str)
|
"%(resp_str)s"), dict(resp=resp, resp_str=resp_str))
|
||||||
|
|
||||||
if resp.status is httplib.OK:
|
if resp.status is httplib.OK:
|
||||||
try:
|
try:
|
||||||
|
@ -260,7 +260,7 @@ class OVSQuantumOFPRyuAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin):
|
|||||||
LOG.debug(_("Agent loop has new device"))
|
LOG.debug(_("Agent loop has new device"))
|
||||||
self._process_devices_filter(port_info)
|
self._process_devices_filter(port_info)
|
||||||
ports = port_info['current']
|
ports = port_info['current']
|
||||||
except:
|
except Exception:
|
||||||
LOG.exception(_("Error in agent event loop"))
|
LOG.exception(_("Error in agent event loop"))
|
||||||
|
|
||||||
elapsed = max(time.time() - start, 0)
|
elapsed = max(time.time() - start, 0)
|
||||||
|
@ -161,7 +161,7 @@ class RyuQuantumPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
|
|||||||
tunnel_key = self.tunnel_key.allocate(session, net['id'])
|
tunnel_key = self.tunnel_key.allocate(session, net['id'])
|
||||||
try:
|
try:
|
||||||
self._client_create_network(net['id'], tunnel_key)
|
self._client_create_network(net['id'], tunnel_key)
|
||||||
except:
|
except Exception:
|
||||||
self._client_delete_network(net['id'])
|
self._client_delete_network(net['id'])
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user