From 71d40685d1b7230489b417c5552876e8a60bcad7 Mon Sep 17 00:00:00 2001 From: Ying Liu Date: Mon, 22 Aug 2011 13:02:00 -0700 Subject: [PATCH] clean code and fix some comments. --- extensions/_exceptions.py | 21 --------------------- extensions/_faults.py | 3 ++- extensions/credential.py | 7 ++----- extensions/novatenant.py | 12 +++++------- extensions/portprofile.py | 5 +---- 5 files changed, 10 insertions(+), 38 deletions(-) diff --git a/extensions/_exceptions.py b/extensions/_exceptions.py index aeae4b647..2310d44e6 100644 --- a/extensions/_exceptions.py +++ b/extensions/_exceptions.py @@ -109,27 +109,6 @@ class QosNotFound(NotFound): message = _("QoS %(_id)s could not be found") -""" - - -class PortprofileInUse(ExtensionException): - message = _("Unable to complete operation on Portprofile %(net_id)s. " \ - "There is one or more attachments plugged into its ports.") - - -class PortInUse(ExtensionException): - message = _("Unable to complete operation on port %(port_id)s " \ - "for Portprofile %(net_id)s. The attachment '%(att_id)s" \ - "is plugged into the logical port.") - -class AlreadyAttached(ExtensionException): - message = _("Unable to plug the attachment %(att_id)s into port " \ - "%(port_id)s for Portprofile %(net_id)s. The attachment is " \ - "already plugged into port %(att_port_id)s") - -""" - - class Duplicate(Error): """Duplication Error""" pass diff --git a/extensions/_faults.py b/extensions/_faults.py index 6bdd3a48b..18dd77864 100644 --- a/extensions/_faults.py +++ b/extensions/_faults.py @@ -49,7 +49,8 @@ class Fault(webob.exc.HTTPException): @webob.dec.wsgify(RequestClass=wsgi.Request) def __call__(self, req): - """Generate a WSGI response based on the exception passed to ctor.""" + """Generate a WSGI response based on the + exception passed to constructor.""" # Replace the body with fault details. code = self.wrapped_exc.status_int fault_name = self._fault_names.get(code, "quantumServiceFault") diff --git a/extensions/credential.py b/extensions/credential.py index 85043940b..0b6928481 100644 --- a/extensions/credential.py +++ b/extensions/credential.py @@ -23,7 +23,6 @@ import logging from webob import exc from extensions import _credential_view as credential_view from quantum.plugins.cisco.common import cisco_exceptions as exception -#from extensions import _exceptions as exception from extensions import _faults as faults from quantum.api import api_common as common @@ -60,7 +59,7 @@ class Credential(object): @classmethod def get_updated(cls): - """ Returns Ext Resource Name """ + """ Returns Ext Resource Update Time """ return "2011-07-25T13:25:27-06:00" @classmethod @@ -97,7 +96,6 @@ class CredentialController(common.QuantumController): def __init__(self, plugin): self._resource_name = 'credential' self._plugin = plugin - #super(CredentialController, self).__init__(plugin) def index(self, request, tenant_id): """ Returns a list of credential ids """ @@ -126,7 +124,6 @@ class CredentialController(common.QuantumController): def create(self, request, tenant_id): """ Creates a new credential for a given tenant """ - #look for credential name in request try: req_params = \ self._parse_request_params(request, @@ -168,4 +165,4 @@ class CredentialController(common.QuantumController): return exc.HTTPAccepted() except exception.CredentialNotFound as exp: return faults.Fault(faults.CredentialNotFound(exp)) - \ No newline at end of file + diff --git a/extensions/novatenant.py b/extensions/novatenant.py index 5cbfc4bd0..3eaa89c24 100644 --- a/extensions/novatenant.py +++ b/extensions/novatenant.py @@ -22,7 +22,6 @@ from webob import exc from extensions import _novatenant_view as novatenant_view from quantum.common import exceptions as qexception -#from extensions import _exceptions as exception from extensions import _faults as faults from quantum.api import api_common as common @@ -42,27 +41,27 @@ class Novatenant(object): @classmethod def get_alias(cls): - """ Returns Ext Resource Name """ + """ Returns Ext Resource alias""" return "Cisco Nova Tenant" @classmethod def get_description(cls): - """ Returns Ext Resource Name """ + """ Returns Ext Resource Description """ return "novatenant resource is used by nova side to invoke quantum api" @classmethod def get_namespace(cls): - """ Returns Ext Resource Name """ + """ Returns Ext Resource Namespace """ return "http://docs.ciscocloud.com/api/ext/novatenant/v1.0" @classmethod def get_updated(cls): - """ Returns Ext Resource Name """ + """ Returns Ext Resource Updated Time """ return "2011-08-09T13:25:27-06:00" @classmethod def get_resources(cls): - """ Returns Ext Resource Name """ + """ Returns Ext Resource """ parent_resource = dict(member_name="tenant", collection_name="extensions/csco/tenants") member_actions = {'get_host': "PUT", @@ -144,7 +143,6 @@ class NovatenantsController(common.QuantumController): builder = novatenant_view.get_view_builder(request) result = builder.build_host(host) return result - #return exc.HTTPAccepted() except qexception.PortNotFound as exp: return faults.Fault(faults.PortNotFound(exp)) diff --git a/extensions/portprofile.py b/extensions/portprofile.py index b0fbb65dd..8621c2ac7 100644 --- a/extensions/portprofile.py +++ b/extensions/portprofile.py @@ -24,7 +24,6 @@ from webob import exc from extensions import _pprofiles as pprofiles_view from quantum.plugins.cisco.common import cisco_exceptions as exception from quantum.common import exceptions as qexception -#from extensions import _exceptions as exception from extensions import _faults as faults from quantum.api import api_common as common @@ -59,7 +58,7 @@ class Portprofile(object): @classmethod def get_updated(cls): - """ Returns Ext Resource Updateed time """ + """ Returns Ext Resource Updated time """ return "2011-07-23T13:25:27-06:00" @classmethod @@ -130,7 +129,6 @@ class PortprofilesController(common.QuantumController): return dict(portprofiles=result) except exception.PortProfileNotFound as exp: return faults.Fault(faults.PortprofileNotFound(exp)) - #return faults.Fault(exp) def create(self, request, tenant_id): """ Creates a new portprofile for a given tenant """ @@ -188,7 +186,6 @@ class PortprofilesController(common.QuantumController): except exc.HTTPError as exp: return faults.Fault(exp) net_id = req_params['network-id'].strip() - #print "*****net id "+net_id port_id = req_params['port-id'].strip() try: self._plugin.associate_portprofile(tenant_id, -- 2.45.2