fix pep8 issues
This commit is contained in:
parent
9ebab74220
commit
91b4918241
@ -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']))
|
||||
|
@ -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])
|
||||
|
@ -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):
|
||||
|
@ -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'],
|
||||
|
@ -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)
|
||||
|
@ -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 = {'schedule_host': "PUT",
|
||||
'associate_port': "PUT"}
|
||||
@ -78,13 +78,13 @@ class NovatenantsController(common.QuantumController):
|
||||
_Novatenant_ops_param_list = [{
|
||||
'param-name': 'novatenant_name',
|
||||
'required': True}]
|
||||
|
||||
|
||||
_schedule_host_ops_param_list = [{
|
||||
'param-name': 'instance_id',
|
||||
'required': True}, {
|
||||
'param-name': 'instance_desc',
|
||||
'required': True}]
|
||||
|
||||
|
||||
_serialization_metadata = {
|
||||
"application/xml": {
|
||||
"attributes": {
|
||||
@ -96,7 +96,7 @@ 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 show(self, request, tenant_id, id):
|
||||
@ -114,12 +114,11 @@ class NovatenantsController(common.QuantumController):
|
||||
def delete(self, request, tenant_id, id):
|
||||
""" Destroys the Novatenant with the given id """
|
||||
return "novatenant is a dummy resource"
|
||||
|
||||
|
||||
#added for cisco's extension
|
||||
def schedule_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,
|
||||
@ -127,20 +126,19 @@ 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.schedule_host(tenant_id, instance_id, instance_desc)
|
||||
host = self._plugin.\
|
||||
schedule_host(tenant_id, instance_id, instance_desc)
|
||||
builder = novatenant_view.get_view_builder(request)
|
||||
result = builder.build_host(host)
|
||||
return result
|
||||
except qexception.PortNotFound as exp:
|
||||
return faults.Fault(faults.PortNotFound(exp))
|
||||
|
||||
|
||||
def associate_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,
|
||||
@ -148,7 +146,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. \
|
||||
@ -156,6 +153,6 @@ 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))
|
||||
|
@ -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,
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user