return entry
def tunnel_sync(self, rpc_context, **kwargs):
- """Dummy function for ovs agent running on Linux to
+ """Tunnel sync.
+
+ Dummy function for ovs agent running on Linux to
work with Hyper-V plugin and agent.
"""
entry = dict()
def ensure_bridge(self, bridge_name, interface=None, ips=None,
gateway=None):
- """
- Create a bridge unless it already exists.
- """
+ """Create a bridge unless it already exists."""
if not self.device_exists(bridge_name):
LOG.debug(_("Starting bridge %(bridge_name)s for subinterface "
"%(interface)s"),
def add_tap_interface(self, network_id, physical_network, vlan_id,
tap_device_name):
- """
+ """Add tap interface.
+
If a VIF has been plugged into a network, this function will
- add the corresponding tap device to the relevant bridge
+ add the corresponding tap device to the relevant bridge.
"""
if not self.device_exists(tap_device_name):
LOG.debug(_("Tap device: %s does not exist on "
class PFCDriverBase(ofc_driver_base.OFCDriverBase):
- """Base Class for PDC Drivers
+ """Base Class for PDC Drivers.
PFCDriverBase provides methods to handle PFC resources through REST API.
This uses ofc resource path instead of ofc resource ID.
return re.sub(r'[^0-9a-zA-Z]', '_', raw_str)
def _generate_pfc_id(self, id_str):
- """Generate ID on PFC
+ """Generate ID on PFC.
Currently, PFC ID must be less than 32.
Shorten UUID string length from 36 to 31 by follows:
return self._generate_pfc_str(id_str)[:31]
def _generate_pfc_description(self, desc):
- """Generate Description on PFC
+ """Generate Description on PFC.
Currently, PFC Description must be less than 128.
"""
class TremaPortBaseDriver(TremaDriverBase, TremaFilterDriver):
- """Trema (Sliceable Switch) Driver for port base binding
+ """Trema (Sliceable Switch) Driver for port base binding.
TremaPortBaseDriver uses port base binding.
Ports are identified by datapath_id, port_no and vlan_id.
class TremaPortMACBaseDriver(TremaDriverBase, TremaFilterDriver):
- """Trema (Sliceable Switch) Driver for port-mac base binding
+ """Trema (Sliceable Switch) Driver for port-mac base binding.
TremaPortBaseDriver uses port-mac base binding.
Ports are identified by datapath_id, port_no, vlan_id and mac.
class TremaMACBaseDriver(TremaDriverBase):
- """Trema (Sliceable Switch) Driver for mac base binding
+ """Trema (Sliceable Switch) Driver for mac base binding.
TremaPortBaseDriver uses mac base binding.
Ports are identified by mac.
class NVPApiHelper(client_eventlet.NvpApiClientEventlet):
- '''
+ '''API helper class.
+
Helper class to do basic login, cookie management, and provide base
method to send HTTP requests.
class NvpApiException(Exception):
- '''
- Base NvpApiClient Exception
+ """Base NvpApiClient Exception.
To correctly use this class, inherit from it and define
a 'message' property. That message will get printf'd
with the keyword arguments provided to the constructor.
- '''
+ """
message = _("An unknown exception occurred.")
def __init__(self, **kwargs):
nvp_sec.NVPSecurityGroups,
nvp_meta.NvpMetadataAccess,
agentschedulers_db.AgentSchedulerDbMixin):
- """
+ """L2 Virtual network plugin.
+
NvpPluginV2 is a Quantum plugin that provides L2 Virtual Network
functionality using NVP.
"""
raise
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
- done in the l3_db mixin class
+ done in the l3_db mixin class.
"""
ip_addresses = []
for ip in fixed_ips:
def _nvp_get_port_id(self, context, cluster, quantum_port):
"""Return the NVP port uuid for a given quantum port.
+
First, look up the Quantum database. If not found, execute
a query on NVP platform as the mapping might be missing because
the port was created before upgrading to grizzly.
quantum_port['id'])
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
- HTTP Exceptions
+ HTTP Exceptions.
"""
base.FAULT_MAP.update({nvp_exc.NvpInvalidNovaZone:
webob.exc.HTTPBadRequest,
def delete_port(self, context, id, l3_port_check=True,
nw_gw_port_check=True):
- """
- Deletes a port on a specified Virtual Network,
- if the port contains a remote interface attachment,
- the remote interface is first un-plugged and then the port
- is deleted.
+ """Deletes a port on a specified Virtual Network.
+
+ If the port contains a remote interface attachment, the remote
+ interface is first un-plugged and then the port is deleted.
:returns: None
:raises: exception.PortInUse
super(NvpPluginV2, self).disassociate_floatingips(context, port_id)
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
- structures in Quantum datase
+ structures in Quantum datase.
"""
# Need to re-do authZ checks here in order to avoid creation on NVP
gw_data = network_gateway[networkgw.RESOURCE_NAME.replace('-', '_')]
network_gateway)
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
- structures in Quantum datase
+ structures in Quantum datase.
"""
with context.session.begin(subtransactions=True):
try:
def create_security_group(self, context, security_group, default_sg=False):
"""Create security group.
+
If default_sg is true that means a we are creating a default security
group and we don't need to check if one exists.
"""
context, security_group, default_sg)
def delete_security_group(self, context, security_group_id):
- """Delete a security group
+ """Delete a security group.
+
:param security_group_id: security group rule to remove.
"""
with context.session.begin(subtransactions=True):
context, security_group_id)
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]}
return self.create_security_group_rule_bulk(context, bulk_rule)[0]
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
"""
s = security_group_rule.get('security_group_rules')
def _get_security_group_rules_nvp_format(self, context, security_group_id,
with_id=False):
- """Query quantum db for security group rules.
- """
+ """Query quantum db for security group rules."""
fields = ['remote_ip_prefix', 'remote_group_id', 'protocol',
'port_range_min', 'port_range_max', 'protocol', 'ethertype']
if with_id:
return merged_rules
def _remove_security_group_with_id_and_id_field(self, rules, rule_id):
- """This function receives all of the current rule associated with a
+ """Remove rule by rule_id.
+
+ This function receives all of the current rule associated with a
security group and then removes the rule that matches the rule_id. In
addition it removes the id field in the dict with each rule since that
should not be passed to nvp.
return self._fields(res, fields)
def _check_for_queue_and_create(self, context, port):
- """This function determines if a port should be associated with a
+ """Check for queue and create.
+
+ This function determines if a port should be associated with a
queue. It works by first querying NetworkQueueMapping to determine
if the network is associated with a queue. If so, then it queries
NetworkQueueMapping for all the networks that are associated with
class NVPCluster(object):
- """Encapsulates controller connections and the Api client for a
- NVP cluster. Accessed within the NvpPluginV2 class.
+ """NVP cluster class.
+
+ Encapsulates controller connections and the API client for a NVP cluster.
+ Accessed within the NvpPluginV2 class.
Controller-specific parameters, such as timeouts are stored in the
elements of the controllers attribute, which are dicts.
# Network functions
# -------------------------------------------------------------------
def find_port_and_cluster(clusters, port_id):
- """Return (url, cluster_id) of port or (None, None) if port does not exist.
+ """Find port and cluster.
+
+ Returns (url, cluster_id) of port or (None, None) if port does not exist.
"""
for c in clusters:
query = "/ws.v1/lswitch/*/lport?uuid=%s&fields=*" % port_id
def get_all_networks(cluster, tenant_id, networks):
- """Append the quantum network uuids we can find in the given cluster to
- "networks"
- """
+ """Get all networks.
+
+ Append the quantum network uuids we can find in the given cluster
+ to "networks".
+ """
uri = "/ws.v1/lswitch?fields=*&tag=%s&tag_scope=os_tid" % tenant_id
try:
resp_obj = do_single_request(HTTP_GET, uri, cluster=cluster)
def get_port_by_display_name(clusters, lswitch, display_name):
- """Return (url, cluster_id) of port or raises ResourceNotFound
- """
+ """Return (url, cluster_id) of port or raises PortNotFound."""
query = ("/ws.v1/lswitch/%s/lport?display_name=%s&fields=*" %
(lswitch, display_name))
LOG.debug(_("Looking for port with display_name "
def get_port_by_quantum_tag(cluster, lswitch_uuid, quantum_port_id):
- """Return the NVP UUID of the logical port with tag q_port_id
- equal to quantum_port_id or None if the port is not Found.
+ """Get port by quantum tag.
+
+ Returns the NVP UUID of the logical port with tag q_port_id equal to
+ quantum_port_id or None if the port is not Found.
"""
uri = _build_uri_path(LSWITCHPORT_RESOURCE,
parent_resource_id=lswitch_uuid,
attachment_uuid, nvp_attachment_type,
attachment_vlan=None):
"""Attach a router port to the given attachment.
- Current attachment types:
+
+ Current attachment types:
- PatchAttachment [-> logical switch port uuid]
- L3GatewayAttachment [-> L3GatewayService uuid]
- For the latter attachment type a VLAN ID can be specified as well
+ For the latter attachment type a VLAN ID can be specified as well.
"""
uri = _build_uri_path(LROUTERPORT_RESOURCE, port_id, router_id,
is_attachment=True)
def format_exception(etype, e, execption_locals, request=None):
"""Consistent formatting for exceptions.
+
:param etype: a string describing the exception type.
:param e: the exception.
:param request: the request object.
'PLUMgrid Plugin has started'))
def create_network(self, context, network):
- """
- Create network core Quantum API
- """
+ """Create network core Quantum API."""
LOG.debug(_('QuantumPluginPLUMgrid Status: create_network() called'))
return net
def update_network(self, context, net_id, network):
- """
- Update network core Quantum API
- """
+ """Update network core Quantum API."""
LOG.debug(_("QuantumPluginPLUMgridV2.update_network() called"))
self._network_admin_state(network)
return new_network
def delete_network(self, context, net_id):
- """
- Delete network core Quantum API
- """
+ """Delete network core Quantum API."""
LOG.debug(_("QuantumPluginPLUMgrid Status: delete_network() called"))
super(QuantumPluginPLUMgridV2, self).get_network(context, net_id)
raise plum_excep.PLUMgridException(err_message)
def create_port(self, context, port):
- """
- Create port core Quantum API
- """
+ """Create port core Quantum API."""
LOG.debug(_("QuantumPluginPLUMgrid Status: create_port() called"))
# Port operations on PLUMgrid NOS is an automatic operation from the
port)
def update_port(self, context, port_id, port):
- """
- Update port core Quantum API
-
- """
+ """Update port core Quantum API."""
LOG.debug(_("QuantumPluginPLUMgrid Status: update_port() called"))
# Port operations on PLUMgrid NOS is an automatic operation from the
context, port_id, port)
def delete_port(self, context, port_id):
- """
- Delete port core Quantum API
- """
+ """Delete port core Quantum API."""
LOG.debug(_("QuantumPluginPLUMgrid Status: delete_port() called"))
super(QuantumPluginPLUMgridV2, self).delete_port(context, port_id)
def create_subnet(self, context, subnet):
- """
- Create subnet core Quantum API
- """
+ """Create subnet core Quantum API."""
LOG.debug(_("QuantumPluginPLUMgrid Status: create_subnet() called"))
return subnet
def delete_subnet(self, context, subnet_id):
- """
- Delete subnet core Quantum API
- """
+ """Delete subnet core Quantum API."""
LOG.debug(_("QuantumPluginPLUMgrid Status: delete_subnet() called"))
#Collecting subnet info
return del_subnet
def update_subnet(self, context, subnet_id, subnet):
- """
- Update subnet core Quantum API
- """
+ """Update subnet core Quantum API."""
LOG.debug(_("update_subnet() called"))
#Collecting subnet info
# This is copied of nova.flags._get_my_ip()
# Agent shouldn't depend on nova module
def _get_my_ip():
- """
- Returns the actual ip of the local machine.
+ """Return the actual ip of the local machine.
This code figures out what source address would be used if some traffic
were to be sent out to some well known address on the Internet. In this
return session.query(ryu_models_v2.TunnelKeyLast).one()
def _find_key(self, session, last_key):
- """
- Try to find unused tunnel key in TunnelKey table starting
+ """Try to find unused tunnel key.
+
+ Trying to find unused tunnel key in TunnelKey table starting
from last_key + 1.
When all keys are used, raise sqlalchemy.orm.exc.NoResultFound
"""
class TunnelKeyLast(model_base.BASEV2):
- """Lastly allocated Tunnel key. The next key allocation will be started
- from this value + 1
+ """Last allocated Tunnel key.
+
+ The next key allocation will be started from this value + 1
"""
last_key = sa.Column(sa.Integer, primary_key=True)
def pool_destroyed(self, context, pool_id=None, host=None):
"""Agent confirmation hook that a pool has been destroyed.
- This method exists for subclasses to change the deletion
- behavior.
+ This method exists for subclasses to change the deletion
+ behavior.
"""
pass
class LoadBalancerPlugin(loadbalancer_db.LoadBalancerPluginDb):
- """
- Implementation of the Quantum Loadbalancer Service Plugin.
+ """Implementation of the Quantum Loadbalancer Service Plugin.
This class manages the workflow of LBaaS request/response.
Most DB related works are implemented in class
supported_extension_aliases = ["lbaas"]
def __init__(self):
- """
- Do the initialization for the loadbalancer service plugin here.
- """
+ """Do the initialization for the loadbalancer service plugin here."""
qdbapi.register_models()
self.callbacks = LoadBalancerCallbacks(self)
class ServicePluginBase(extensions.PluginInterface):
- """defines base interface for any Advanced Service plugin."""
+ """Define base interface for any Advanced Service plugin."""
__metaclass__ = abc.ABCMeta
supported_extension_aliases = []
@abc.abstractmethod
def get_plugin_type(self):
- """returns one of predefine service types. see
- quantum/plugins/common/constants.py
+ """Return one of predefined service types.
+
+ See quantum/plugins/common/constants.py
"""
pass
@abc.abstractmethod
def get_plugin_name(self):
- """return a symbolic name for the plugin.
+ """Return a symbolic name for the plugin.
Each service plugin should have a symbolic name. This name
will be used, for instance, by service definitions in service types
@abc.abstractmethod
def get_plugin_description(self):
- """returns string description of the plugin."""
+ """Return string description of the plugin."""
pass