]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Docstrings formatted according to pep257
authorSergey Skripnick <sskripnick@mirantis.com>
Mon, 29 Apr 2013 13:46:51 +0000 (16:46 +0300)
committerSergey Skripnick <sskripnick@mirantis.com>
Tue, 30 Apr 2013 06:27:49 +0000 (09:27 +0300)
Bug #1020184

quantum/plugins/bigswitch/*
quantum/plugins/brocade/*

Change-Id: I9bf4381738319551a5993d4b279a5cec3425b7ef

quantum/plugins/bigswitch/plugin.py
quantum/plugins/bigswitch/tests/test_server.py
quantum/plugins/brocade/QuantumPlugin.py
quantum/plugins/brocade/db/models.py
quantum/plugins/brocade/nos/fake_nosdriver.py
quantum/plugins/brocade/nos/nctemplates.py
quantum/plugins/brocade/nos/nosdriver.py
quantum/plugins/brocade/tests/noscli.py
quantum/plugins/brocade/tests/nostest.py
quantum/plugins/brocade/vlanbm.py

index 16a66bf64b0904c69081bab9365a9d575c948bd2..7f608b9849a6a9ee12d9b085b135b5a9dbb5ef3a 100644 (file)
@@ -18,7 +18,7 @@
 # @author: Sumit Naiksatam, sumitnaiksatam@gmail.com, Big Switch Networks, Inc.
 
 """
-Quantum REST Proxy Plug-in for Big Switch and FloodLight Controllers
+Quantum REST Proxy Plug-in for Big Switch and FloodLight Controllers.
 
 QuantumRestProxy provides a generic quantum plugin that translates all plugin
 function calls to equivalent authenticated REST calls to a set of redundant
@@ -119,6 +119,7 @@ METADATA_SERVER_IP = '169.254.169.254'
 
 
 class RemoteRestError(exceptions.QuantumException):
+
     def __init__(self, message):
         if message is None:
             message = "None"
@@ -208,6 +209,7 @@ class ServerProxy(object):
 
 
 class ServerPool(object):
+
     def __init__(self, servers, ssl, auth, quantum_id, timeout=10,
                  base_uri='/quantum/v1.0', name='QuantumRestProxy'):
         self.base_uri = base_uri
@@ -226,6 +228,7 @@ class ServerPool(object):
 
     def server_failure(self, resp):
         """Define failure codes as required.
+
         Note: We assume 301-303 is a failure, and try the next server in
         the server pool.
         """
@@ -233,6 +236,7 @@ class ServerPool(object):
 
     def action_success(self, resp):
         """Defining success codes as required.
+
         Note: We assume any valid 2xx as being successful response.
         """
         return resp[0] in SUCCESS_CODES
@@ -335,8 +339,11 @@ class QuantumRestProxyV2(db_base_plugin_v2.QuantumDbPluginV2,
         LOG.debug(_("QuantumRestProxyV2: initialization done"))
 
     def create_network(self, context, network):
-        """Create a network, which represents an L2 network segment which
-        can have a set of subnets and ports associated with it.
+        """Create a network.
+
+        Network represents an L2 network segment which can have a set of
+        subnets and ports associated with it.
+
         :param context: quantum api request context
         :param network: dictionary describing the network
 
@@ -355,7 +362,6 @@ class QuantumRestProxyV2(db_base_plugin_v2.QuantumDbPluginV2,
 
         :raises: RemoteRestError
         """
-
         LOG.debug(_("QuantumRestProxyV2: create_network() called"))
 
         self._warn_on_state_status(network['network'])
@@ -393,6 +399,7 @@ class QuantumRestProxyV2(db_base_plugin_v2.QuantumDbPluginV2,
 
     def update_network(self, context, net_id, network):
         """Updates the properties of a particular Virtual Network.
+
         :param context: quantum api request context
         :param net_id: uuid of the network to update
         :param network: dictionary describing the updates
@@ -413,7 +420,6 @@ class QuantumRestProxyV2(db_base_plugin_v2.QuantumDbPluginV2,
         :raises: exceptions.NetworkNotFound
         :raises: RemoteRestError
         """
-
         LOG.debug(_("QuantumRestProxyV2.update_network() called"))
 
         self._warn_on_state_status(network['network'])
@@ -571,6 +577,7 @@ class QuantumRestProxyV2(db_base_plugin_v2.QuantumDbPluginV2,
 
     def update_port(self, context, port_id, port):
         """Update values of a port.
+
         :param context: quantum api request context
         :param id: UUID representing the port to update.
         :param port: dictionary with keys indicating fields to update.
@@ -640,6 +647,7 @@ class QuantumRestProxyV2(db_base_plugin_v2.QuantumDbPluginV2,
 
     def delete_port(self, context, port_id, l3_port_check=True):
         """Delete a port.
+
         :param context: quantum api request context
         :param id: UUID representing the port to delete.
 
@@ -648,7 +656,6 @@ class QuantumRestProxyV2(db_base_plugin_v2.QuantumDbPluginV2,
         :raises: exceptions.NetworkNotFound
         :raises: RemoteRestError
         """
-
         LOG.debug(_("QuantumRestProxyV2: delete_port() called"))
 
         # if needed, check to see if this is a port owned by
@@ -684,8 +691,10 @@ class QuantumRestProxyV2(db_base_plugin_v2.QuantumDbPluginV2,
 
     def _plug_interface(self, context, tenant_id, net_id, port_id,
                         remote_interface_id):
-        """Attaches a remote interface to the specified port on the
-        specified Virtual Network.
+        """Plug remote interface to the network.
+
+        Attaches a remote interface to the specified port on the specified
+        Virtual Network.
 
         :returns: None
 
@@ -716,8 +725,10 @@ class QuantumRestProxyV2(db_base_plugin_v2.QuantumDbPluginV2,
             raise
 
     def _unplug_interface(self, context, tenant_id, net_id, port_id):
-        """Detaches a remote interface from the specified port on the
-        network controller
+        """Detach interface from the network controller.
+
+        Detaches a remote interface from the specified port on the network
+        controller.
 
         :returns: None
 
@@ -1042,8 +1053,9 @@ class QuantumRestProxyV2(db_base_plugin_v2.QuantumDbPluginV2,
             raise
 
     def _send_all_data(self):
-        """Pushes all data to network ctrl (networks/ports, ports/attachments)
-        to give the controller an option to re-sync it's persistent store
+        """Pushes all data to network ctrl (networks/ports, ports/attachments).
+
+        This gives the controller an option to re-sync it's persistent store
         with quantum's current view of that data.
         """
         admin_context = qcontext.get_admin_context()
index 5b38dcb2a4830962916d1019d7062067ddaad7bc..ee7cb8f9a080aef80000035fac3ac9ffbab82738 100755 (executable)
@@ -18,8 +18,9 @@
 #
 # @author: Mandeep Dhami, Big Switch Networks, Inc.
 
-"""
-Test server mocking a REST based network ctrl. Used for QuantumRestProxy tests
+"""Test server mocking a REST based network ctrl.
+
+Used for QuantumRestProxy tests
 """
 
 import json
@@ -29,6 +30,7 @@ from wsgiref.simple_server import make_server
 
 
 class TestNetworkCtrl(object):
+
     def __init__(self, host='', port=8000,
                  default_status='404 Not Found',
                  default_response='404 Not Found',
@@ -44,9 +46,10 @@ class TestNetworkCtrl(object):
 
     def match(self, prior, method_regexp, uri_regexp, handler, data=None,
               multi=True):
-        """Adds to the list of exptected inputs. The incomming request is
-        matched in the order of priority. For same priority, match the
-        oldest match request first.
+        """Add to the list of exptected inputs.
+
+        The incoming request is matched in the order of priority. For same
+        priority, match the oldest match request first.
 
         :param prior: intgere priority of this match (e.g. 100)
         :param method_regexp: regexp to match method (e.g. 'PUT|POST')
index ee097f3a0b6066eda597fe95b605aecb69c3fecd..f24aa622a013193cf8fa9568b7a434dd9cfc953d 100644 (file)
@@ -23,9 +23,7 @@
 # TODO(shiv) need support for security groups
 
 
-"""
-Implentation of Brocade Quantum Plugin.
-"""
+"""Implentation of Brocade Quantum Plugin."""
 
 from oslo.config import cfg
 
@@ -86,11 +84,11 @@ class BridgeRpcCallbacks(dhcp_rpc_base.DhcpRpcCallbackMixin,
     TAP_PREFIX_LEN = 3
 
     def create_rpc_dispatcher(self):
-        '''Get the rpc dispatcher for this manager.
+        """Get the rpc dispatcher for this manager.
 
         If a manager would like to set an rpc API version, or support more than
         one class as the target of rpc messages, override this method.
-        '''
+        """
         return q_rpc.PluginRpcDispatcher([self,
                                           agents_db.AgentExtRpcCallback()])
 
@@ -161,12 +159,12 @@ class BridgeRpcCallbacks(dhcp_rpc_base.DhcpRpcCallbackMixin,
 
 class AgentNotifierApi(proxy.RpcProxy,
                        sg_rpc.SecurityGroupAgentRpcApiMixin):
-    '''Agent side of the linux bridge rpc API.
+    """Agent side of the linux bridge rpc API.
 
     API version history:
         1.0 - Initial version.
 
-    '''
+    """
 
     BASE_RPC_API_VERSION = '1.0'
 
@@ -207,8 +205,9 @@ class BrocadePluginV2(db_base_plugin_v2.QuantumDbPluginV2,
     """
 
     def __init__(self):
-        """Initialize Brocade Plugin, specify switch address
-        and db configuration.
+        """Initialize Brocade Plugin.
+
+        Specify switch address and db configuration.
         """
 
         self.supported_extension_aliases = ["binding", "security-group",
@@ -255,8 +254,10 @@ class BrocadePluginV2(db_base_plugin_v2.QuantumDbPluginV2,
         self.l3_agent_notifier = l3_rpc_agent_api.L3AgentNotify
 
     def create_network(self, context, network):
-        """This call to create network translates to creation of
-        port-profile on the physical switch.
+        """Create network.
+
+        This call to create network translates to creation of port-profile on
+        the physical switch.
         """
 
         with context.session.begin(subtransactions=True):
@@ -284,8 +285,10 @@ class BrocadePluginV2(db_base_plugin_v2.QuantumDbPluginV2,
         return net
 
     def delete_network(self, context, net_id):
-        """This call to delete the network translates to removing
-        the port-profile on the physical switch.
+        """Delete network.
+
+        This call to delete the network translates to removing the
+        port-profile on the physical switch.
         """
 
         with context.session.begin(subtransactions=True):
@@ -460,7 +463,6 @@ class BrocadePluginV2(db_base_plugin_v2.QuantumDbPluginV2,
         :type interface_mac: string
         :returns: MAC address in the format xxxx.xxxx.xxxx
         :rtype: string
-
         """
 
         mac = interface_mac.replace(":", "")
index ee2dd4b25da69aeaec49cb666f28a2b4257f9615..dd511420a202637810c75f44f6cc59711b084ccb 100644 (file)
@@ -20,9 +20,7 @@
 # Varma Bhupatiraju (vbhupati@#brocade.com)
 
 
-"""
-Brocade specific database schema/model.
-"""
+"""Brocade specific database schema/model."""
 
 import sqlalchemy as sa
 
@@ -32,6 +30,7 @@ from quantum.db import models_v2
 
 class BrocadeNetwork(model_base.BASEV2, models_v2.HasId):
     """Schema for brocade network."""
+
     vlan = sa.Column(sa.String(10))
 
 
index 495d23a3c8e1e99eec380f1bc1968764dd4c94e1..5a911721aec51a262531f324a0d6208c5c3250a4 100644 (file)
 # Shiv Haris (sharis@brocade.com)
 
 
-"""
-FAKE DRIVER, for unit tests purposes
+"""FAKE DRIVER, for unit tests purposes.
+
 Brocade NOS Driver implements NETCONF over SSHv2 for
-Quantum network life-cycle management
+Quantum network life-cycle management.
 """
 
 
@@ -33,7 +33,6 @@ class NOSdriver():
     Fake: Handles life-cycle management of Quantum network,
     leverages AMPP on NOS
     (for use by unit tests, avoids touching any hardware)
-
     """
 
     def __init__(self):
index 1bbfc2218bcb5a69c0de5921257a327caf8641a3..01468d36224f7e59bd10fdf557f3a83bdaf72506 100644 (file)
 # Shiv Haris (sharis@brocade.com)
 
 
-"""
-NOS NETCONF XML Configuration Command Templates
+"""NOS NETCONF XML Configuration Command Templates.
+
 Interface Configuration Commands
 """
+
 # Create VLAN (vlan_id)
 CREATE_VLAN_INTERFACE = """
     <config xmlns:xc="urn:ietf:params:xml:ns:netconf:base:1.0">
index c8362a13b76f3a2e797db085e6aef432ffd333d3..028d14dbbcbefa18b7c8c3a58cc3ac695c98c7fd 100644 (file)
 # Shiv Haris (sharis@brocade.com)
 
 
+"""Brocade NOS Driver implements NETCONF over SSHv2 for
+Quantum network life-cycle management.
 """
-Brocade NOS Driver implements NETCONF over SSHv2 for
-Quantum network life-cycle management
-"""
+
 from ncclient import manager
 
 from quantum.openstack.common import log as logging
@@ -40,9 +40,7 @@ def nos_unknown_host_cb(host, fingerprint):
     Returns `True` if it finds the key acceptable,
     and `False` if not. This default callback for NOS always returns 'True'
     (i.e. trusts all hosts for now).
-
     """
-
     return True
 
 
@@ -50,7 +48,6 @@ class NOSdriver():
     """NOS NETCONF interface driver for Quantum network.
 
     Handles life-cycle management of Quantum network (leverages AMPP on NOS)
-
     """
 
     def __init__(self):
index 85d02c7569801ac95b8fc7c3df24cd3082411c55..9df8512b32112206c4e902d83a926e1627b8be06 100644 (file)
@@ -20,9 +20,8 @@
 # Shiv Haris (sharis@brocade.com)
 
 
-"""
-Brocade NOS Driver CLI
-"""
+"""Brocade NOS Driver CLI."""
+
 import argparse
 
 from quantum.openstack.common import log as logging
index a181eff70eee2106fe9347b05a50cdc8ae8e7786..c95bf3a16bb0e49ae151e639ded0b415aa54106d 100644 (file)
@@ -18,9 +18,7 @@
 # Shiv Haris (sharis@brocade.com)
 
 
-"""
-Brocade NOS Driver Test
-"""
+"""Brocade NOS Driver Test."""
 import sys
 
 from quantum.plugins.brocade.nos import nosdriver as nos
index baf4cbea6ed3926403535722f0c1e361a25adf1b..8dbf41e86c2af6c93f1e76d19b02ed98684b65e2 100644 (file)
@@ -20,9 +20,7 @@
 # Varma Bhupatiraju (vbhupati@#brocade.com)
 
 
-"""
-A Vlan Bitmap class to handle allocation/de-allocation of vlan ids.
-"""
+"""A Vlan Bitmap class to handle allocation/de-allocation of vlan ids."""
 from quantum.plugins.brocade.db import models as brocade_db
 
 
@@ -37,16 +35,14 @@ class VlanBitmap(object):
     # uses a bitmap to do this
 
     def __init__(self, ctxt):
-        """initialize the vlan as a set."""
+        """Initialize the vlan as a set."""
         self.vlans = set(int(net['vlan'])
                          for net in brocade_db.get_networks(ctxt)
                          if net['vlan']
                          )
 
     def get_next_vlan(self, vlan_id=None):
-        """try to get a specific vlan if requested
-        or get the next vlan.
-        """
+        """Try to get a specific vlan if requested or get the next vlan."""
         min_vlan_search = vlan_id or MIN_VLAN
         max_vlan_search = (vlan_id and vlan_id + 1) or MAX_VLAN
 
@@ -56,6 +52,6 @@ class VlanBitmap(object):
                 return vlan
 
     def release_vlan(self, vlan_id):
-        """return the vlan to the pool."""
+        """Return the vlan to the pool."""
         if vlan_id in self.vlans:
             self.vlans.remove(vlan_id)