clean code and fix some comments.

This commit is contained in:
Ying Liu
2011-08-22 13:02:00 -07:00
parent 69dfdc9575
commit 71d40685d1
5 changed files with 10 additions and 38 deletions

View File

@@ -109,27 +109,6 @@ class QosNotFound(NotFound):
message = _("QoS %(_id)s could not be found") 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): class Duplicate(Error):
"""Duplication Error""" """Duplication Error"""
pass pass

View File

@@ -49,7 +49,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 exception passed to ctor.""" """Generate a WSGI response based on the
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")

View File

@@ -23,7 +23,6 @@ import logging
from webob import exc from webob import exc
from extensions import _credential_view as credential_view from extensions import _credential_view as credential_view
from quantum.plugins.cisco.common import cisco_exceptions as exception from quantum.plugins.cisco.common import cisco_exceptions as exception
#from extensions import _exceptions as exception
from extensions import _faults as faults from extensions import _faults as faults
from quantum.api import api_common as common from quantum.api import api_common as common
@@ -60,7 +59,7 @@ class Credential(object):
@classmethod @classmethod
def get_updated(cls): def get_updated(cls):
""" Returns Ext Resource Name """ """ Returns Ext Resource Update Time """
return "2011-07-25T13:25:27-06:00" return "2011-07-25T13:25:27-06:00"
@classmethod @classmethod
@@ -97,7 +96,6 @@ class CredentialController(common.QuantumController):
def __init__(self, plugin): def __init__(self, plugin):
self._resource_name = 'credential' self._resource_name = 'credential'
self._plugin = plugin self._plugin = plugin
#super(CredentialController, self).__init__(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 """
@@ -126,7 +124,6 @@ class CredentialController(common.QuantumController):
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 """
#look for credential name in request
try: try:
req_params = \ req_params = \
self._parse_request_params(request, self._parse_request_params(request,
@@ -168,4 +165,4 @@ class CredentialController(common.QuantumController):
return exc.HTTPAccepted() return exc.HTTPAccepted()
except exception.CredentialNotFound as exp: except exception.CredentialNotFound as exp:
return faults.Fault(faults.CredentialNotFound(exp)) return faults.Fault(faults.CredentialNotFound(exp))

View File

@@ -22,7 +22,6 @@ from webob import exc
from extensions import _novatenant_view as novatenant_view from extensions import _novatenant_view as novatenant_view
from quantum.common import exceptions as qexception from quantum.common import exceptions as qexception
#from extensions import _exceptions as exception
from extensions import _faults as faults from extensions import _faults as faults
from quantum.api import api_common as common from quantum.api import api_common as common
@@ -42,27 +41,27 @@ class Novatenant(object):
@classmethod @classmethod
def get_alias(cls): def get_alias(cls):
""" Returns Ext Resource Name """ """ Returns Ext Resource alias"""
return "Cisco Nova Tenant" return "Cisco Nova Tenant"
@classmethod @classmethod
def get_description(cls): def get_description(cls):
""" Returns Ext Resource Name """ """ Returns Ext Resource Description """
return "novatenant resource is used by nova side to invoke quantum api" return "novatenant resource is used by nova side to invoke quantum api"
@classmethod @classmethod
def get_namespace(cls): def get_namespace(cls):
""" Returns Ext Resource Name """ """ Returns Ext Resource Namespace """
return "http://docs.ciscocloud.com/api/ext/novatenant/v1.0" return "http://docs.ciscocloud.com/api/ext/novatenant/v1.0"
@classmethod @classmethod
def get_updated(cls): def get_updated(cls):
""" Returns Ext Resource Name """ """ Returns Ext Resource Updated Time """
return "2011-08-09T13:25:27-06:00" return "2011-08-09T13:25:27-06:00"
@classmethod @classmethod
def get_resources(cls): def get_resources(cls):
""" Returns Ext Resource Name """ """ Returns Ext Resource """
parent_resource = dict(member_name="tenant", parent_resource = dict(member_name="tenant",
collection_name="extensions/csco/tenants") collection_name="extensions/csco/tenants")
member_actions = {'get_host': "PUT", member_actions = {'get_host': "PUT",
@@ -144,7 +143,6 @@ class NovatenantsController(common.QuantumController):
builder = novatenant_view.get_view_builder(request) builder = novatenant_view.get_view_builder(request)
result = builder.build_host(host) result = builder.build_host(host)
return result return result
#return exc.HTTPAccepted()
except qexception.PortNotFound as exp: except qexception.PortNotFound as exp:
return faults.Fault(faults.PortNotFound(exp)) return faults.Fault(faults.PortNotFound(exp))

View File

@@ -24,7 +24,6 @@ from webob import exc
from extensions import _pprofiles as pprofiles_view from extensions import _pprofiles as pprofiles_view
from quantum.plugins.cisco.common import cisco_exceptions as exception from quantum.plugins.cisco.common import cisco_exceptions as exception
from quantum.common import exceptions as qexception from quantum.common import exceptions as qexception
#from extensions import _exceptions as exception
from extensions import _faults as faults from extensions import _faults as faults
from quantum.api import api_common as common from quantum.api import api_common as common
@@ -59,7 +58,7 @@ class Portprofile(object):
@classmethod @classmethod
def get_updated(cls): def get_updated(cls):
""" Returns Ext Resource Updateed time """ """ Returns Ext Resource Updated time """
return "2011-07-23T13:25:27-06:00" return "2011-07-23T13:25:27-06:00"
@classmethod @classmethod
@@ -130,7 +129,6 @@ class PortprofilesController(common.QuantumController):
return dict(portprofiles=result) return dict(portprofiles=result)
except exception.PortProfileNotFound as exp: except exception.PortProfileNotFound as exp:
return faults.Fault(faults.PortprofileNotFound(exp)) return faults.Fault(faults.PortprofileNotFound(exp))
#return faults.Fault(exp)
def create(self, request, tenant_id): def create(self, request, tenant_id):
""" Creates a new portprofile for a given tenant """ """ Creates a new portprofile for a given tenant """
@@ -188,7 +186,6 @@ class PortprofilesController(common.QuantumController):
except exc.HTTPError as exp: except exc.HTTPError as exp:
return faults.Fault(exp) return faults.Fault(exp)
net_id = req_params['network-id'].strip() net_id = req_params['network-id'].strip()
#print "*****net id "+net_id
port_id = req_params['port-id'].strip() port_id = req_params['port-id'].strip()
try: try:
self._plugin.associate_portprofile(tenant_id, self._plugin.associate_portprofile(tenant_id,