fix pep8 warnings

This commit is contained in:
Ying Liu 2011-08-26 11:21:46 -07:00
parent f1b68c5434
commit 329940fe4a
9 changed files with 64 additions and 72 deletions

View File

@ -28,7 +28,7 @@ def get_view_builder(req):
class ViewBuilder(object):
"""
ViewBuilder for Credential,
ViewBuilder for Credential,
derived from quantum.views.networks
"""
def __init__(self, base_url):
@ -39,20 +39,18 @@ class ViewBuilder(object):
def build(self, credential_data, is_detail=False):
"""Generic method used to generate a credential entity."""
if is_detail:
credential = self._build_detail(credential_data)
else:
credential = self._build_simple(credential_data)
return credential
def _build_simple(self, credential_data):
"""Return a simple description of credential."""
return dict(credential=dict(id=credential_data['credential_id']))
def _build_detail(self, credential_data):
"""Return a detailed description of credential."""
return dict(credential=dict(id=credential_data['credential_id'],
name=credential_data['user_name'],
password=credential_data['password']))

View File

@ -29,7 +29,7 @@ def get_view_builder(req):
class ViewBuilder(object):
"""
ViewBuilder for novatenant,
ViewBuilder for novatenant,
derived from quantum.views.networks
"""
def __init__(self, base_url):
@ -37,11 +37,11 @@ class ViewBuilder(object):
:param base_url: url of the root wsgi application
"""
self.base_url = base_url
def build_host(self, host_data):
"""Return host description."""
return dict(host_list=host_data[const.HOST_LIST])
def build_vif(self, vif_data):
"""Return VIF description."""
return dict(vif_desc=vif_data[const.VIF_DESC])
return dict(vif_desc=vif_data[const.VIF_DESC])

View File

@ -28,7 +28,7 @@ def get_view_builder(req):
class ViewBuilder(object):
"""
ViewBuilder for Portprofile,
ViewBuilder for Portprofile,
derived from quantum.views.networks
"""
def __init__(self, base_url):
@ -39,17 +39,16 @@ class ViewBuilder(object):
def build(self, portprofile_data, is_detail=False):
"""Generic method used to generate a portprofile entity."""
if is_detail:
portprofile = self._build_detail(portprofile_data)
else:
portprofile = self._build_simple(portprofile_data)
return portprofile
def _build_simple(self, portprofile_data):
"""Return a simple description of a portprofile"""
return dict(portprofile=dict(id=portprofile_data['profile_id']))
def _build_detail(self, portprofile_data):
"""Return a detailed info of a portprofile."""
if (portprofile_data['assignment'] == None):

View File

@ -28,7 +28,7 @@ def get_view_builder(req):
class ViewBuilder(object):
"""
ViewBuilder for QoS,
ViewBuilder for QoS,
derived from quantum.views.networks
"""
def __init__(self, base_url):
@ -44,11 +44,11 @@ class ViewBuilder(object):
else:
qos = self._build_simple(qos_data)
return qos
def _build_simple(self, qos_data):
"""Return a simple description of qos."""
return dict(qos=dict(id=qos_data['qos_id']))
def _build_detail(self, qos_data):
"""Return a detailed description of qos."""
return dict(qos=dict(id=qos_data['qos_id'],

View File

@ -125,7 +125,7 @@ class CredentialController(common.QuantumController):
""" Creates a new credential for a given tenant """
try:
req_params = \
self._parse_request_params(request,
self._parse_request_params(request,
self._credential_ops_param_list)
except exc.HTTPError as exp:
return faults.Fault(exp)
@ -142,7 +142,7 @@ class CredentialController(common.QuantumController):
""" Updates the name for the credential with the given id """
try:
req_params = \
self._parse_request_params(request,
self._parse_request_params(request,
self._credential_ops_param_list)
except exc.HTTPError as exp:
return faults.Fault(exp)

View File

@ -35,33 +35,33 @@ class Novatenant(object):
@classmethod
def get_name(cls):
""" Returns Ext Resource Name """
""" Returns Ext Resource Name """
return "Cisco Nova Tenant"
@classmethod
def get_alias(cls):
""" Returns Ext Resource alias"""
return "Cisco Nova Tenant"
@classmethod
def get_description(cls):
""" Returns Ext Resource Description """
return "novatenant resource is used by nova side to invoke quantum api"
@classmethod
def get_namespace(cls):
""" Returns Ext Resource Namespace """
return "http://docs.ciscocloud.com/api/ext/novatenant/v1.0"
@classmethod
def get_updated(cls):
""" Returns Ext Resource Updated Time """
return "2011-08-09T13:25:27-06:00"
@classmethod
def get_resources(cls):
""" Returns Ext Resource """
parent_resource = dict(member_name="tenant",
parent_resource = dict(member_name="tenant",
collection_name="extensions/csco/tenants")
member_actions = {'get_host': "PUT",
'get_instance_port': "PUT"}
@ -78,13 +78,13 @@ class NovatenantsController(common.QuantumController):
_Novatenant_ops_param_list = [{
'param-name': 'novatenant_name',
'required': True}]
_get_host_ops_param_list = [{
'param-name': 'instance_id',
'required': True}, {
'param-name': 'instance_desc',
'required': True}]
_serialization_metadata = {
"application/xml": {
"attributes": {
@ -96,13 +96,13 @@ class NovatenantsController(common.QuantumController):
def __init__(self, plugin):
self._resource_name = 'novatenant'
self._plugin = plugin
#added for cisco's extension
# pylint: disable-msg=E1101,W0613
def get_host(self, request, tenant_id, id):
content_type = request.best_match_content_type()
print "Content type:%s" % content_type
try:
req_params = \
self._parse_request_params(request,
@ -110,7 +110,6 @@ class NovatenantsController(common.QuantumController):
except exc.HTTPError as exp:
return faults.Fault(exp)
instance_id = req_params['instance_id']
instance_desc = req_params['instance_desc']
try:
host = self._plugin.get_host(tenant_id, instance_id, instance_desc)
@ -119,11 +118,10 @@ class NovatenantsController(common.QuantumController):
return result
except qexception.PortNotFound as exp:
return faults.Fault(faults.PortNotFound(exp))
def get_instance_port(self, request, tenant_id, id):
content_type = request.best_match_content_type()
print "Content type:%s" % content_type
try:
req_params = \
self._parse_request_params(request,
@ -131,7 +129,6 @@ class NovatenantsController(common.QuantumController):
except exc.HTTPError as exp:
return faults.Fault(exp)
instance_id = req_params['instance_id']
instance_desc = req_params['instance_desc']
try:
vif = self._plugin. \
@ -139,6 +136,5 @@ class NovatenantsController(common.QuantumController):
builder = novatenant_view.get_view_builder(request)
result = builder.build_vif(vif)
return result
except qexception.PortNotFound as exp:
return faults.Fault(faults.PortNotFound(exp))

View File

@ -34,36 +34,36 @@ class Portprofile(object):
"""extension class Portprofile"""
def __init__(self):
pass
@classmethod
def get_name(cls):
""" Returns Ext Resource Name """
return "Cisco Port Profile"
@classmethod
def get_alias(cls):
""" Returns Ext Resource alias """
return "Cisco Port Profile"
@classmethod
def get_description(cls):
""" Returns Ext Resource Description """
return "Portprofile include QoS information"
@classmethod
def get_namespace(cls):
""" Returns Ext Resource Namespace """
return "http://docs.ciscocloud.com/api/ext/portprofile/v1.0"
@classmethod
def get_updated(cls):
""" Returns Ext Resource Updated time """
return "2011-07-23T13:25:27-06:00"
@classmethod
def get_resources(cls):
""" Returns all defined resources """
parent_resource = dict(member_name="tenant",
parent_resource = dict(member_name="tenant",
collection_name="extensions/csco/tenants")
member_actions = {'associate_portprofile': "PUT",
'disassociate_portprofile': "PUT"}
@ -71,16 +71,16 @@ class Portprofile(object):
return [extensions.ResourceExtension('portprofiles', controller,
parent=parent_resource,
member_actions=member_actions)]
class PortprofilesController(common.QuantumController):
""" portprofile API controller
based on QuantumController """
def __init__(self, plugin):
self._resource_name = 'portprofile'
self._plugin = plugin
self._portprofile_ops_param_list = [{
'param-name': 'portprofile_name',
'required': True}, {
@ -88,13 +88,13 @@ class PortprofilesController(common.QuantumController):
'required': True}, {
'param-name': 'assignment',
'required': False}]
self._assignprofile_ops_param_list = [{
'param-name': 'network-id',
'required': True}, {
'param-name': 'port-id',
'required': True}]
self._serialization_metadata = {
"application/xml": {
"attributes": {
@ -102,7 +102,7 @@ class PortprofilesController(common.QuantumController):
},
},
}
def index(self, request, tenant_id):
""" Returns a list of portprofile ids """
return self._items(request, tenant_id, is_detail=False)
@ -114,7 +114,7 @@ class PortprofilesController(common.QuantumController):
result = [builder.build(portprofile, is_detail)['portprofile']
for portprofile in portprofiles]
return dict(portprofiles=result)
# pylint: disable-msg=E1101
def show(self, request, tenant_id, id):
""" Returns portprofile details for the given portprofile id """
@ -133,7 +133,7 @@ class PortprofilesController(common.QuantumController):
#look for portprofile name in request
try:
req_params = \
self._parse_request_params(request,
self._parse_request_params(request,
self._portprofile_ops_param_list)
except exc.HTTPError as exp:
return faults.Fault(exp)
@ -149,7 +149,7 @@ class PortprofilesController(common.QuantumController):
""" Updates the name for the portprofile with the given id """
try:
req_params = \
self._parse_request_params(request,
self._parse_request_params(request,
self._portprofile_ops_param_list)
except exc.HTTPError as exp:
return faults.Fault(exp)
@ -171,12 +171,12 @@ class PortprofilesController(common.QuantumController):
return exc.HTTPAccepted()
except exception.PortProfileNotFound as exp:
return faults.Fault(faults.PortprofileNotFound(exp))
def associate_portprofile(self, request, tenant_id, id):
""" associate a portprofile to the port """
content_type = request.best_match_content_type()
print "Content type:%s" % content_type
try:
req_params = \
self._parse_request_params(request,
@ -194,12 +194,11 @@ class PortprofilesController(common.QuantumController):
return faults.Fault(faults.PortprofileNotFound(exp))
except qexception.PortNotFound as exp:
return faults.Fault(faults.PortNotFound(exp))
def disassociate_portprofile(self, request, tenant_id, id):
""" Disassociate a portprofile from a port """
content_type = request.best_match_content_type()
print "Content type:%s" % content_type
try:
req_params = \
self._parse_request_params(request,

View File

@ -36,7 +36,7 @@ class Qos(object):
"""Qos extension file"""
def __init__(self):
pass
@classmethod
def get_name(cls):
""" Returns Ext Resource Name """
@ -56,7 +56,7 @@ class Qos(object):
def get_namespace(cls):
""" Returns Ext Resource Namespace """
return "http://docs.ciscocloud.com/api/ext/qos/v1.0"
@classmethod
def get_updated(cls):
""" Returns Ext Resource update """
@ -65,9 +65,9 @@ class Qos(object):
@classmethod
def get_resources(cls):
""" Returns Ext Resources """
parent_resource = dict(member_name="tenant",
parent_resource = dict(member_name="tenant",
collection_name="extensions/csco/tenants")
controller = QosController(QuantumManager.get_plugin())
return [extensions.ResourceExtension('qoss', controller,
parent=parent_resource)]
@ -93,7 +93,7 @@ class QosController(common.QuantumController):
def __init__(self, plugin):
self._resource_name = 'qos'
self._plugin = plugin
def index(self, request, tenant_id):
""" Returns a list of qos ids """
return self._items(request, tenant_id, is_detail=False)
@ -124,7 +124,7 @@ class QosController(common.QuantumController):
#look for qos name in request
try:
req_params = \
self._parse_request_params(request,
self._parse_request_params(request,
self._qos_ops_param_list)
except exc.HTTPError as exp:
return faults.Fault(exp)
@ -140,7 +140,7 @@ class QosController(common.QuantumController):
""" Updates the name for the qos with the given id """
try:
req_params = \
self._parse_request_params(request,
self._parse_request_params(request,
self._qos_ops_param_list)
except exc.HTTPError as exp:
return faults.Fault(exp)

View File

@ -71,7 +71,7 @@ class PortprofileNotFound(webob.exc.HTTPClientError):
"""
code = 450
title = 'Portprofile Not Found'
explanation = ('Unable to find a Portprofile with'
explanation = ('Unable to find a Portprofile with'
+ ' the specified identifier.')
@ -87,8 +87,8 @@ class PortNotFound(webob.exc.HTTPClientError):
code = 430
title = 'Port not Found'
explanation = ('Unable to find a port with the specified identifier.')
class CredentialNotFound(webob.exc.HTTPClientError):
"""
subclass of :class:`~HTTPClientError`
@ -100,10 +100,10 @@ class CredentialNotFound(webob.exc.HTTPClientError):
"""
code = 451
title = 'Credential Not Found'
explanation = ('Unable to find a Credential with'
explanation = ('Unable to find a Credential with'
+ ' the specified identifier.')
class QosNotFound(webob.exc.HTTPClientError):
"""
subclass of :class:`~HTTPClientError`
@ -115,10 +115,10 @@ class QosNotFound(webob.exc.HTTPClientError):
"""
code = 452
title = 'QoS Not Found'
explanation = ('Unable to find a QoS with'
explanation = ('Unable to find a QoS with'
+ ' the specified identifier.')
class NovatenantNotFound(webob.exc.HTTPClientError):
"""
subclass of :class:`~HTTPClientError`
@ -130,7 +130,7 @@ class NovatenantNotFound(webob.exc.HTTPClientError):
"""
code = 453
title = 'Nova tenant Not Found'
explanation = ('Unable to find a Novatenant with'
explanation = ('Unable to find a Novatenant with'
+ ' the specified identifier.')