Bug #1013967 - Quantum is breaking on tests with pep 1.3

Fixing files

93/93 files fixed

Change-Id: Ia30f2e2253806fa5f447d44208d13d2c0beba9cd
changes/32/8632/5
Juliano Martinez 10 years ago
parent 7b9a0b7147
commit 2fcb3ecacf
  1. 12
      quantum/agent/linux/ovs_lib.py
  2. 10
      quantum/api/attachments.py
  3. 150
      quantum/api/faults.py
  4. 16
      quantum/api/networks.py
  5. 16
      quantum/api/ports.py
  6. 14
      quantum/api/v2/base.py
  7. 12
      quantum/api/v2/router.py
  8. 4
      quantum/api/versions.py
  9. 7
      quantum/api/views/filters.py
  10. 4
      quantum/api/views/networks.py
  11. 3
      quantum/api/views/ports.py
  12. 27
      quantum/common/config.py
  13. 16
      quantum/common/test_lib.py
  14. 3
      quantum/common/utils.py
  15. 4
      quantum/context.py
  16. 2
      quantum/db/db_base_plugin_v2.py
  17. 4
      quantum/db/models.py
  18. 4
      quantum/db/models_v2.py
  19. 16
      quantum/extensions/_pprofiles.py
  20. 2
      quantum/extensions/credential.py
  21. 8
      quantum/extensions/extensions.py
  22. 2
      quantum/extensions/multiport.py
  23. 4
      quantum/extensions/novatenant.py
  24. 58
      quantum/extensions/portprofile.py
  25. 6
      quantum/extensions/portstats.py
  26. 2
      quantum/extensions/qos.py
  27. 35
      quantum/openstack/common/cfg.py
  28. 2
      quantum/openstack/common/importutils.py
  29. 12
      quantum/plugins/cisco/client/cli.py
  30. 4
      quantum/plugins/cisco/common/cisco_exceptions.py
  31. 21
      quantum/plugins/cisco/common/cisco_faults.py
  32. 4
      quantum/plugins/cisco/common/cisco_utils.py
  33. 78
      quantum/plugins/cisco/db/api.py
  34. 206
      quantum/plugins/cisco/db/l2network_db.py
  35. 37
      quantum/plugins/cisco/db/l2network_models.py
  36. 7
      quantum/plugins/cisco/db/models.py
  37. 18
      quantum/plugins/cisco/db/nexus_db.py
  38. 3
      quantum/plugins/cisco/db/nexus_models.py
  39. 13
      quantum/plugins/cisco/db/services_db.py
  40. 4
      quantum/plugins/cisco/db/services_models.py
  41. 40
      quantum/plugins/cisco/db/ucs_db.py
  42. 6
      quantum/plugins/cisco/db/ucs_models.py
  43. 2
      quantum/plugins/cisco/l2network_plugin.py
  44. 4
      quantum/plugins/cisco/models/l2network_single_blade.py
  45. 2
      quantum/plugins/cisco/nova/quantum_port_aware_scheduler.py
  46. 2
      quantum/plugins/cisco/nova/vifdirect.py
  47. 2
      quantum/plugins/cisco/segmentation/l2network_vlan_mgr.py
  48. 10
      quantum/plugins/cisco/services/service_insertion.py
  49. 100
      quantum/plugins/cisco/tests/unit/test_cisco_extension.py
  50. 8
      quantum/plugins/cisco/tests/unit/test_database.py
  51. 51
      quantum/plugins/cisco/tests/unit/test_l2networkApi.py
  52. 4
      quantum/plugins/cisco/tests/unit/test_l2network_multi_blade.py
  53. 114
      quantum/plugins/cisco/tests/unit/test_ucs_driver.py
  54. 2
      quantum/plugins/cisco/tests/unit/test_vlan_mgr.py
  55. 30
      quantum/plugins/cisco/ucs/cisco_ucs_inventory.py
  56. 178
      quantum/plugins/cisco/ucs/cisco_ucs_network_driver.py
  57. 4
      quantum/plugins/cisco/ucs/cisco_ucs_plugin.py
  58. 2
      quantum/plugins/linuxbridge/LinuxBridgePlugin.py
  59. 19
      quantum/plugins/linuxbridge/agent/linuxbridge_quantum_agent.py
  60. 4
      quantum/plugins/linuxbridge/common/utils.py
  61. 5
      quantum/plugins/linuxbridge/db/l2network_db.py
  62. 84
      quantum/plugins/linuxbridge/tests/unit/_test_linuxbridgeAgent.py
  63. 6
      quantum/plugins/nicira/nicira_nvp_plugin/NvpApiClient.py
  64. 37
      quantum/plugins/nicira/nicira_nvp_plugin/QuantumPlugin.py
  65. 2
      quantum/plugins/nicira/nicira_nvp_plugin/api_client/client_eventlet.py
  66. 12
      quantum/plugins/nicira/nicira_nvp_plugin/api_client/request_eventlet.py
  67. 38
      quantum/plugins/nicira/nicira_nvp_plugin/cli.py
  68. 22
      quantum/plugins/nicira/nicira_nvp_plugin/nvplib.py
  69. 2
      quantum/plugins/nicira/nicira_nvp_plugin/tests/test_config.py
  70. 8
      quantum/plugins/nicira/nicira_nvp_plugin/tests/test_network.py
  71. 2
      quantum/plugins/nicira/nicira_nvp_plugin/tests/test_nvp_api_request_eventlet.py
  72. 24
      quantum/plugins/nicira/nicira_nvp_plugin/tests/test_port.py
  73. 11
      quantum/plugins/openvswitch/agent/ovs_quantum_agent.py
  74. 3
      quantum/plugins/openvswitch/ovs_models.py
  75. 4
      quantum/plugins/openvswitch/ovs_quantum_plugin.py
  76. 10
      quantum/plugins/openvswitch/tests/unit/test_tunnel.py
  77. 2
      quantum/plugins/openvswitch/tests/unit/test_vlan_map.py
  78. 5
      quantum/plugins/ryu/agent/ryu_quantum_agent.py
  79. 6
      quantum/rootwrap/filters.py
  80. 2
      quantum/rootwrap/linuxbridge-agent.py
  81. 2
      quantum/rootwrap/openvswitch-agent.py
  82. 2
      quantum/rootwrap/ryu-agent.py
  83. 3
      quantum/rootwrap/wrapper.py
  84. 9
      quantum/tests/unit/_test_api.py
  85. 8
      quantum/tests/unit/extensions/foxinsocks.py
  86. 2
      quantum/tests/unit/test_agent_utils.py
  87. 9
      quantum/tests/unit/test_api.py
  88. 3
      quantum/tests/unit/test_db_plugin.py
  89. 6
      quantum/tests/unit/test_extensions.py
  90. 64
      quantum/tests/unit/test_ovs_lib.py
  91. 6
      quantum/tests/unit/test_setup.py
  92. 6
      quantum/wsgi.py
  93. 6
      tools/install_venv.py

@ -58,7 +58,7 @@ class OVSBridge:
def delete_port(self, port_name):
self.run_vsctl(["--", "--if-exists", "del-port", self.br_name,
port_name])
port_name])
def set_db_attribute(self, table_name, record, column, value):
args = ["set", table_name, record, "%s=%s" % (column, value)]
@ -87,10 +87,10 @@ class OVSBridge:
is_delete_expr = kwargs.get('delete', False)
print "kwargs = %s" % kwargs
if not is_delete_expr:
prefix = ("hard_timeout=%s,idle_timeout=%s,priority=%s"
% (kwargs.get('hard_timeout', '0'),
kwargs.get('idle_timeout', '0'),
kwargs.get('priority', '1')))
prefix = ("hard_timeout=%s,idle_timeout=%s,priority=%s" %
(kwargs.get('hard_timeout', '0'),
kwargs.get('idle_timeout', '0'),
kwargs.get('priority', '1')))
flow_expr_arr.append(prefix)
elif 'priority' in kwargs:
raise Exception("Cannot match priority on flow deletion")
@ -179,7 +179,7 @@ class OVSBridge:
return utils.execute(["xe", "vif-param-get", "param-name=other-config",
"param-key=nicira-iface-id",
"uuid=%s" % xs_vif_uuid],
root_helper=self.root_helper).strip()
root_helper=self.root_helper).strip()
# returns a VIF object for each VIF port
def get_vif_ports(self):

@ -31,7 +31,7 @@ def create_resource(plugin, version):
'1.1': [ControllerV11(plugin),
ControllerV11._serialization_metadata,
common.XML_NS_V11],
}
}
return common.create_resource(version, controller_dict)
@ -44,16 +44,16 @@ class Controller(common.QuantumController):
{
'param-name': 'id',
'required': True,
},
]
},
]
_serialization_metadata = {
"application/xml": {
"attributes": {
"attachment": ["id"],
},
},
}
},
}
@common.APIFaultWrapper([exception.NetworkNotFound,
exception.PortNotFound])

@ -47,8 +47,8 @@ def fault_body_function_v10(wrapped_exc):
'code': code,
'message': wrapped_exc.explanation,
'detail': str(wrapped_exc.detail),
},
}
},
}
metadata = {'attributes': {fault_name: ['code']}}
return fault_data, metadata
@ -71,8 +71,8 @@ def fault_body_function_v11(wrapped_exc):
'type': fault_name,
'message': wrapped_exc.explanation,
'detail': str(wrapped_exc.detail),
},
}
},
}
# Metadata not required for v11
return fault_data, None
@ -90,41 +90,41 @@ def fault_body_function(version):
class Quantum10HTTPError(webob.exc.HTTPClientError):
_fault_dict = {
exceptions.NetworkNotFound: {
'code': 420,
'title': 'networkNotFound',
'explanation': _NETNOTFOUND_EXPL
},
exceptions.NetworkInUse: {
'code': 421,
'title': 'networkInUse',
'explanation': _NETINUSE_EXPL
},
exceptions.PortNotFound: {
'code': 430,
'title': 'portNotFound',
'explanation': _PORTNOTFOUND_EXPL
},
exceptions.StateInvalid: {
'code': 431,
'title': 'requestedStateInvalid',
'explanation': _STATEINVALID_EXPL
},
exceptions.PortInUse: {
'code': 432,
'title': 'portInUse',
'explanation': _PORTINUSE_EXPL
},
exceptions.AlreadyAttached: {
'code': 440,
'title': 'alreadyAttached',
'explanation': _ALREADYATTACHED_EXPL
},
exceptions.NotImplementedError: {
'code': 501,
'title': 'notImplemented',
'explanation': _NOTIMPLEMENTED_EXPL
}
exceptions.NetworkNotFound: {
'code': 420,
'title': 'networkNotFound',
'explanation': _NETNOTFOUND_EXPL
},
exceptions.NetworkInUse: {
'code': 421,
'title': 'networkInUse',
'explanation': _NETINUSE_EXPL
},
exceptions.PortNotFound: {
'code': 430,
'title': 'portNotFound',
'explanation': _PORTNOTFOUND_EXPL
},
exceptions.StateInvalid: {
'code': 431,
'title': 'requestedStateInvalid',
'explanation': _STATEINVALID_EXPL
},
exceptions.PortInUse: {
'code': 432,
'title': 'portInUse',
'explanation': _PORTINUSE_EXPL
},
exceptions.AlreadyAttached: {
'code': 440,
'title': 'alreadyAttached',
'explanation': _ALREADYATTACHED_EXPL
},
exceptions.NotImplementedError: {
'code': 501,
'title': 'notImplemented',
'explanation': _NOTIMPLEMENTED_EXPL
}
}
def __init__(self, inner_exc):
@ -139,42 +139,42 @@ class Quantum10HTTPError(webob.exc.HTTPClientError):
class Quantum11HTTPError(webob.exc.HTTPClientError):
_fault_dict = {
exceptions.NetworkNotFound: {
'code': webob.exc.HTTPNotFound.code,
'title': webob.exc.HTTPNotFound.title,
'type': 'NetworkNotFound',
'explanation': _NETNOTFOUND_EXPL
},
exceptions.NetworkInUse: {
'code': webob.exc.HTTPConflict.code,
'title': webob.exc.HTTPConflict.title,
'type': 'NetworkInUse',
'explanation': _NETINUSE_EXPL
},
exceptions.PortNotFound: {
'code': webob.exc.HTTPNotFound.code,
'title': webob.exc.HTTPNotFound.title,
'type': 'PortNotFound',
'explanation': _PORTNOTFOUND_EXPL
},
exceptions.StateInvalid: {
'code': webob.exc.HTTPBadRequest.code,
'title': webob.exc.HTTPBadRequest.title,
'type': 'RequestedStateInvalid',
'explanation': _STATEINVALID_EXPL
},
exceptions.PortInUse: {
'code': webob.exc.HTTPConflict.code,
'title': webob.exc.HTTPConflict.title,
'type': 'PortInUse',
'explanation': _PORTINUSE_EXPL
},
exceptions.AlreadyAttached: {
'code': webob.exc.HTTPConflict.code,
'title': webob.exc.HTTPConflict.title,
'type': 'AlreadyAttached',
'explanation': _ALREADYATTACHED_EXPL
}
exceptions.NetworkNotFound: {
'code': webob.exc.HTTPNotFound.code,
'title': webob.exc.HTTPNotFound.title,
'type': 'NetworkNotFound',
'explanation': _NETNOTFOUND_EXPL
},
exceptions.NetworkInUse: {
'code': webob.exc.HTTPConflict.code,
'title': webob.exc.HTTPConflict.title,
'type': 'NetworkInUse',
'explanation': _NETINUSE_EXPL
},
exceptions.PortNotFound: {
'code': webob.exc.HTTPNotFound.code,
'title': webob.exc.HTTPNotFound.title,
'type': 'PortNotFound',
'explanation': _PORTNOTFOUND_EXPL
},
exceptions.StateInvalid: {
'code': webob.exc.HTTPBadRequest.code,
'title': webob.exc.HTTPBadRequest.title,
'type': 'RequestedStateInvalid',
'explanation': _STATEINVALID_EXPL
},
exceptions.PortInUse: {
'code': webob.exc.HTTPConflict.code,
'title': webob.exc.HTTPConflict.title,
'type': 'PortInUse',
'explanation': _PORTINUSE_EXPL
},
exceptions.AlreadyAttached: {
'code': webob.exc.HTTPConflict.code,
'title': webob.exc.HTTPConflict.title,
'type': 'AlreadyAttached',
'explanation': _ALREADYATTACHED_EXPL
}
}
def __init__(self, inner_exc):

@ -33,7 +33,7 @@ def create_resource(plugin, version):
'1.1': [ControllerV11(plugin),
ControllerV11._serialization_metadata,
common.XML_NS_V11],
}
}
return common.create_resource(version, controller_dict)
@ -44,7 +44,7 @@ class Controller(common.QuantumController):
version = None
_network_ops_param_list = [
{'param-name': 'name', 'required': True},
]
]
def _item(self, request, tenant_id, network_id,
net_details=True, port_details=False):
@ -154,12 +154,12 @@ class ControllerV10(Controller):
"network": ["id", "name"],
"port": ["id", "state"],
"attachment": ["id"],
},
},
"plurals": {
"networks": "network",
"ports": "port",
},
}
},
}
version = "1.0"
@ -178,11 +178,11 @@ class ControllerV11(Controller):
"network": ["id", "name", "op-status"],
"port": ["id", "state", "op-status"],
"attachment": ["id"],
},
},
"plurals": {
"networks": "network",
"ports": "port",
},
}
},
}
version = "1.1"

@ -32,7 +32,7 @@ def create_resource(plugin, version):
'1.1': [ControllerV11(plugin),
ControllerV11._serialization_metadata,
common.XML_NS_V11],
}
}
return common.create_resource(version, controller_dict)
@ -43,7 +43,7 @@ class Controller(common.QuantumController):
version = None
_port_ops_param_list = [
{'param-name': 'state', 'default-value': 'DOWN', 'required': False},
]
]
def _items(self, request, tenant_id, network_id,
port_details=False):
@ -160,11 +160,11 @@ class ControllerV10(Controller):
"attributes": {
"port": ["id", "state"],
"attachment": ["id"],
},
},
"plurals": {
"ports": "port",
},
}
},
}
version = "1.0"
@ -176,10 +176,10 @@ class ControllerV11(Controller):
"attributes": {
"port": ["id", "state", "op-status"],
"attachment": ["id"],
},
},
"plurals": {
"ports": "port",
},
}
},
}
version = "1.1"

@ -158,9 +158,9 @@ class Controller(object):
if self._resource not in ['network', 'port']:
return
if ('tenant_id' in res_dict and
res_dict['tenant_id'] != context.tenant_id and
not context.is_admin):
if (('tenant_id' in res_dict and
res_dict['tenant_id'] != context.tenant_id and
not context.is_admin)):
msg = _("Specifying 'tenant_id' other than authenticated"
"tenant in request requires admin privileges")
raise webob.exc.HTTPBadRequest(msg)
@ -170,7 +170,7 @@ class Controller(object):
res_dict['tenant_id'] = context.tenant_id
else:
msg = _("Running without keystyone AuthN requires "
" that tenant_id is specified")
" that tenant_id is specified")
raise webob.exc.HTTPBadRequest(msg)
def _prepare_request_body(self, context, body, is_create,
@ -242,13 +242,11 @@ def create_resource(collection, resource, plugin, conf, params):
# NOTE(jkoelker) To anyone wishing to add "proper" xml support
# this is where you do it
serializers = {
serializers = {}
# 'application/xml': wsgi.XMLDictSerializer(metadata, XML_NS_V20),
}
deserializers = {
deserializers = {}
# 'application/xml': wsgi.XMLDeserializer(metadata),
}
return wsgi_resource.Resource(controller, FAULT_MAP, deserializers,
serializers)

@ -95,13 +95,9 @@ class Index(wsgi.Application):
@webob.dec.wsgify(RequestClass=wsgi.Request)
def __call__(self, req):
metadata = {'application/xml': {
'attributes': {
'resource': ['name', 'collection'],
'link': ['href', 'rel'],
}
}
}
metadata = {'application/xml': {'attributes': {
'resource': ['name', 'collection'],
'link': ['href', 'rel']}}}
layout = []
for name, collection in self.resources.iteritems():
@ -153,6 +149,6 @@ class APIRouter(wsgi.Router):
for resource in resources:
_map_resource(resources[resource], resource,
RESOURCE_ATTRIBUTE_MAP.get(resources[resource],
dict()))
dict()))
super(APIRouter, self).__init__(mapper)

@ -65,8 +65,8 @@ class Versions(object):
}
content_type = req.best_match_content_type()
body = wsgi.Serializer(metadata=metadata). \
serialize(response, content_type)
body = (wsgi.Serializer(metadata=metadata).
serialize(response, content_type))
response = webob.Response()
response.content_type = content_type

@ -30,8 +30,8 @@ def _load_network_ports_details(network, **kwargs):
# Don't pass filter options, don't care about unused filters
port_list = plugin.get_all_ports(tenant_id, network['net-id'])
ports_data = [plugin.get_port_details(
tenant_id, network['net-id'],
port['port-id'])
tenant_id, network['net-id'],
port['port-id'])
for port in port_list]
network['net-ports'] = ports_data
@ -150,8 +150,7 @@ def filter_ports(ports, plugin, tenant_id, network_id, filter_opts):
'attachment': _filter_port_by_interface}
# port details are need for filtering
ports = [plugin.get_port_details(tenant_id, network_id,
port['port-id'])
for port in ports]
port['port-id']) for port in ports]
# filter ports
return _do_filtering(ports,
filters,

@ -54,7 +54,7 @@ class ViewBuilder10(object):
def _build_detail(self, network_data):
"""Return a detailed model of a network."""
return dict(network=dict(id=network_data['net-id'],
name=network_data['net-name']))
name=network_data['net-name']))
def _build_port(self, port_data):
"""Return details about a specific logical port."""
@ -82,7 +82,7 @@ class ViewBuilder11(ViewBuilder10):
def _build_port(self, port_data):
"""Return details about a specific logical port."""
op_status = port_data.get('port-op-status',
OperationalStatus.UNKNOWN)
OperationalStatus.UNKNOWN)
port_dict = {'id': port_data['port-id'],
'state': port_data['port-state'],
'op-status': op_status}

@ -53,7 +53,8 @@ class ViewBuilder11(ViewBuilder10):
if port_details:
port['port']['state'] = port_data['port-state']
port['port']['op-status'] = port_data.get('port-op-status',
OperationalStatus.UNKNOWN)
OperationalStatus.
UNKNOWN)
if att_details and port_data['attachment']:
port['port']['attachment'] = dict(id=port_data['attachment'])
return port

@ -106,18 +106,18 @@ def add_log_options(parser):
"the Python logging module documentation for "
"details on logging configuration files.")
group.add_option('--log-date-format', metavar="FORMAT",
default=DEFAULT_LOG_DATE_FORMAT,
help="Format string for %(asctime)s in log records. "
"Default: %default")
default=DEFAULT_LOG_DATE_FORMAT,
help="Format string for %(asctime)s in log records. "
"Default: %default")
group.add_option('--use-syslog', default=False,
action="store_true",
help="Output logs to syslog.")
action="store_true",
help="Output logs to syslog.")
group.add_option('--log-file', default=None, metavar="PATH",
help="(Optional) Name of log file to output to. "
"If not set, logging will go to stdout.")
help="(Optional) Name of log file to output to. "
"If not set, logging will go to stdout.")
group.add_option("--log-dir", default=None,
help="(Optional) The directory to keep log files in "
"(will be prepended to --logfile)")
help="(Optional) The directory to keep log files in "
"(will be prepended to --logfile)")
parser.add_option_group(group)
@ -237,10 +237,9 @@ def find_config_file(options, args, config_file='quantum.conf'):
'/etc']
if 'plugin' in options:
config_file_dirs = [
os.path.join(x, 'quantum', 'plugins', options['plugin'])
for x in config_file_dirs
]
config_file_dirs = [os.path.join(x, 'quantum',
'plugins', options['plugin'])
for x in config_file_dirs]
if os.path.exists(os.path.join(root, 'plugins')):
plugins = [fix_path(os.path.join(root, 'plugins', p, 'etc'))
@ -282,7 +281,7 @@ def load_paste_config(app_name, options, args):
conf_file = find_config_file(options, args)
if not conf_file:
raise RuntimeError("Unable to locate any configuration file. "
"Cannot load application %s" % app_name)
"Cannot load application %s" % app_name)
try:
conf = deploy.appconfig("config:%s" % conf_file, name=app_name)
return conf_file, conf

@ -99,9 +99,9 @@ class _Win32Colorizer(object):
See _AnsiColorizer docstring.
"""
def __init__(self, stream):
from win32console import GetStdHandle, STD_OUT_HANDLE, \
FOREGROUND_RED, FOREGROUND_BLUE, FOREGROUND_GREEN, \
FOREGROUND_INTENSITY
from win32console import GetStdHandle, STD_OUT_HANDLE
from win32console import FOREGROUND_RED, FOREGROUND_BLUE
from win32console import FOREGROUND_GREEN, FOREGROUND_INTENSITY
red, green, blue, bold = (FOREGROUND_RED, FOREGROUND_GREEN,
FOREGROUND_BLUE, FOREGROUND_INTENSITY)
self.stream = stream
@ -251,9 +251,9 @@ class QuantumTestResult(result.TextTestResult):
class QuantumTestRunner(core.TextTestRunner):
def _makeResult(self):
return QuantumTestResult(self.stream,
self.descriptions,
self.verbosity,
self.config)
self.descriptions,
self.verbosity,
self.config)
def run_tests(c=None):
@ -273,8 +273,8 @@ def run_tests(c=None):
return True
runner = QuantumTestRunner(stream=c.stream,
verbosity=c.verbosity,
config=c)
verbosity=c.verbosity,
config=c)
return not core.run(config=c, testRunner=runner)
# describes parameters used by different unit/functional tests

@ -91,7 +91,8 @@ def execute(cmd, process_input=None, addl_env=None, check_exit_code=True):
if addl_env:
env.update(addl_env)
obj = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE,
stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env)
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
env=env)
result = None
if process_input is not None:
result = obj.communicate(process_input)

@ -42,8 +42,8 @@ class Context(object):
*only* deleted records are visible.
"""
if kwargs:
LOG.warn(_('Arguments dropped when creating context: %s') %
str(kwargs))
LOG.warn(_('Arguments dropped when creating '
'context: %s') % str(kwargs))
self.user_id = user_id
self.tenant_id = tenant_id

@ -137,7 +137,7 @@ class QuantumDbPluginV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
'admin_state_up': network['admin_state_up'],
'status': network['status'],
'subnets': [subnet['id']
for subnet in network['subnets']]}
for subnet in network['subnets']]}
return self._fields(res, fields)

@ -73,5 +73,5 @@ class Network(model_base.BASE):
self.op_status = op_status
def __repr__(self):
return "<Network(%s,%s,%s,%s)>" % \
(self.uuid, self.name, self.op_status, self.tenant_id)
return "<Network(%s,%s,%s,%s)>" % (self.uuid, self.name,
self.op_status, self.tenant_id)

@ -32,14 +32,14 @@ class IPAllocation(model_base.BASEV2):
port_id = sa.Column(sa.String(36), sa.ForeignKey('ports.id'))
address = sa.Column(sa.String(16), nullable=False, primary_key=True)
subnet_id = sa.Column(sa.String(36), sa.ForeignKey('subnets.id'),
primary_key=True)
primary_key=True)
allocated = sa.Column(sa.Boolean(), nullable=False)
class Port(model_base.BASEV2, HasTenant):
"""Represents a port on a quantum v2 network"""
network_id = sa.Column(sa.String(36), sa.ForeignKey("networks.id"),
nullable=False)
nullable=False)
fixed_ips = orm.relationship(IPAllocation, backref='ports')
mac_address = sa.Column(sa.String(32), nullable=False)
admin_state_up = sa.Column(sa.Boolean(), nullable=False)

@ -50,14 +50,12 @@ class ViewBuilder(object):
"""Return a detailed info of a portprofile."""
if (portprofile_data['assignment'] is None):
return dict(portprofile=dict(
id=portprofile_data['profile_id'],
name=portprofile_data['profile_name'],
qos_name=portprofile_data['qos_name'],
))
id=portprofile_data['profile_id'],
name=portprofile_data['profile_name'],
qos_name=portprofile_data['qos_name']))
else:
return dict(portprofile=dict(
id=portprofile_data['profile_id'],
name=portprofile_data['profile_name'],
qos_name=portprofile_data['qos_name'],
assignment=portprofile_data['assignment'],
))
id=portprofile_data['profile_id'],
name=portprofile_data['profile_name'],
qos_name=portprofile_data['qos_name'],
assignment=portprofile_data['assignment']))

@ -80,7 +80,7 @@ class CredentialController(common.QuantumController, wsgi.Controller):
{'param-name': 'credential_name', 'required': True},
{'param-name': 'user_name', 'required': True},
{'param-name': 'password', 'required': True},
]
]
_serialization_metadata = {
"application/xml": {

@ -228,7 +228,7 @@ class ExtensionMiddleware(wsgi.Middleware):
# extended resources
for resource in self.ext_mgr.get_resources():
LOG.debug(_('Extended resource: %s'),
resource.collection)
resource.collection)
for action, method in resource.collection_actions.iteritems():
path_prefix = ""
parent = resource.parent
@ -459,8 +459,8 @@ class ExtensionManager(object):
LOG.warn(_('Loaded extension: %s'), alias)
if alias in self.extensions:
raise exceptions.Error("Found duplicate extension: %s"
% alias)
raise exceptions.Error("Found duplicate extension: %s" %
alias)
self.extensions[alias] = ext
@ -474,7 +474,7 @@ class PluginAwareExtensionManager(ExtensionManager):
"""Checks if plugin supports extension and implements the
extension contract."""
extension_is_valid = super(PluginAwareExtensionManager,
self)._check_extension(extension)
self)._check_extension(extension)
return (extension_is_valid and
self._plugin_supports(extension) and
self._plugin_implements_interface(extension))

@ -79,7 +79,7 @@ class MultiportController(common.QuantumController, wsgi.Controller):
{'param-name': 'net_id_list', 'required': True},
{'param-name': 'status', 'required': True},
{'param-name': 'ports_desc', 'required': True},
]
]
_serialization_metadata = {
"application/xml": {

@ -77,12 +77,12 @@ class NovatenantsController(common.QuantumController, wsgi.Controller):
_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": {

@ -80,26 +80,28 @@ class PortprofilesController(common.QuantumController, wsgi.Controller):
self._plugin = plugin
self._portprofile_ops_param_list = [{
'param-name': 'portprofile_name',
'required': True}, {
'param-name': 'qos_name',
'required': True}, {
'param-name': 'assignment',
'required': False}]
'param-name': 'portprofile_name',
'required': True}, {
'param-name': 'qos_name',
'required': True}, {
'param-name': 'assignment',
'required': False}
]
self._assignprofile_ops_param_list = [{
'param-name': 'network-id',
'required': True}, {
'param-name': 'port-id',
'required': True}]
'param-name': 'network-id',
'required': True}, {
'param-name': 'port-id',
'required': True}
]
self._serialization_metadata = {
"application/xml": {
"attributes": {
"portprofile": ["id", "name"],
"application/xml": {
"attributes": {
"portprofile": ["id", "name"],
},
},
},
}
}
def index(self, request, tenant_id):
""" Returns a list of portprofile ids """
@ -117,8 +119,7 @@ class PortprofilesController(common.QuantumController, wsgi.Controller):
def show(self, request, tenant_id, id):
""" Returns portprofile details for the given portprofile id """
try:
portprofile = self._plugin.get_portprofile_details(
tenant_id, id)
portprofile = self._plugin.get_portprofile_details(tenant_id, id)
builder = pprofiles_view.get_view_builder(request)
#build response with details
result = builder.build(portprofile, True)
@ -137,10 +138,10 @@ class PortprofilesController(common.QuantumController, wsgi.Controller):
req_params = req_body[self._resource_name]
except exc.HTTPError as exp:
return faults.Fault(exp)
portprofile = self._plugin.\
create_portprofile(tenant_id,
req_params['portprofile_name'],
req_params['qos_name'])
portprofile = \
self._plugin.create_portprofile(tenant_id,
req_params['portprofile_name'],
req_params['qos_name'])
builder = pprofiles_view.get_view_builder(request)
result = builder.build(portprofile)
return dict(portprofiles=result)
@ -156,9 +157,9 @@ class PortprofilesController(common.QuantumController, wsgi.Controller):
except exc.HTTPError as exp:
return faults.Fault(exp)
try:
portprofile = self._plugin.\
rename_portprofile(tenant_id,
id, req_params['portprofile_name'])
portprofile = \
self._plugin.rename_portprofile(tenant_id, id,
req_params['portprofile_name'])
builder = pprofiles_view.get_view_builder(request)
result = builder.build(portprofile, True)
@ -190,8 +191,8 @@ class PortprofilesController(common.QuantumController, wsgi.Controller):
port_id = req_params['port-id'].strip()
try:
self._plugin.associate_portprofile(tenant_id,
net_id, port_id,
id)
net_id, port_id,
id)
return exc.HTTPOk()
except exception.PortProfileNotFound as exp:
return faults.Fault(faults.PortprofileNotFound(exp))
@ -212,9 +213,8 @@ class PortprofilesController(common.QuantumController, wsgi.Controller):
net_id = req_params['network-id'].strip()
port_id = req_params['port-id'].strip()
try:
self._plugin. \
disassociate_portprofile(tenant_id,
net_id, port_id, id)
self._plugin.disassociate_portprofile(tenant_id,
net_id, port_id, id)
return exc.HTTPOk()
except exception.PortProfileNotFound as exp:
return faults.Fault(faults.PortprofileNotFound(exp))

@ -69,10 +69,10 @@ class StatsController(wsgi.Controller):
"application/xml": {
"attributes": {
"stats": ["rx_bytes", "rx_packets", "rx_errors",
"tx_bytes", "tx_packets", "tx_errors"],
},
},
"tx_bytes", "tx_packets", "tx_errors"]
}
}
}
def __init__(self, plugin):
self._resource_name = 'stats'

@ -80,7 +80,7 @@ class QosController(common.QuantumController, wsgi.Controller):
_qos_ops_param_list = [
{'param-name': 'qos_name', 'required': True},
{'param-name': 'qos_desc', 'required': True},
]
]
_serialization_metadata = {
"application/xml": {

@ -375,7 +375,7 @@ def _get_config_dirs(project=None):
fix_path('~'),
os.path.join('/etc', project) if project else None,
'/etc'
]
]
return filter(bool, cfg_dirs)
@ -575,11 +575,9 @@ class Opt(object):
dest = self.dest
if group is not None:
dest = group.name + '_' + dest
kwargs.update({
'dest': dest,
'metavar': self.metavar,
'help': self.help,
})
kwargs.update({'dest': dest,
'metavar': self.metavar,
'help': self.help})
return kwargs
def _get_optparse_prefix(self, prefix, group):
@ -892,14 +890,14 @@ class ConfigOpts(collections.Mapping):
self.__cache = {}
opts = [
MultiStrOpt('config-file',
default=self.default_config_files,
metavar='PATH',
help='Path to a config file to use. Multiple config '
'files can be specified, with values in later '
'files taking precedence. The default files '
' used are: %s' %
(self.default_config_files, )),
MultiStrOpt('config-file',
default=self.default_config_files,
metavar='PATH',
help='Path to a config file to use. Multiple config '
'files can be specified, with values in later '
'files taking precedence. The default files '
' used are: %s' %
(self.default_config_files)),
StrOpt('config-dir',
metavar='DIR',
help='Path to a config directory to pull *.conf '
@ -909,7 +907,7 @@ class ConfigOpts(collections.Mapping):
'the file(s), if any, specified via --config-file, '
'hence over-ridden options in the directory take '
'precedence.'),
]
]
self.register_cli_opts(opts)
def __clear_cache(f):
@ -1352,8 +1350,7 @@ class ConfigOpts(collections.Mapping):
default, opt, override = [info[k] for k in sorted(info.keys())]
if opt.required:
if (default is not None or
override is not None):
if (default is not None or override is not None):
continue
if self._get(opt.name, group) is None:
@ -1447,7 +1444,7 @@ class CommonConfigOpts(ConfigOpts):
short='v',
default=False,
help='Print more verbose output'),
]
]
logging_cli_opts = [
StrOpt('log-config',
@ -1481,7 +1478,7 @@ class CommonConfigOpts(ConfigOpts):
StrOpt('syslog-log-facility',
default='LOG_USER',
help='syslog facility to receive log lines')
]
]
def __init__(self, **kwargs):
super(CommonConfigOpts, self).__init__(**kwargs)

@ -30,7 +30,7 @@ def import_class(import_str):
return getattr(sys.modules[mod_str], class_str)
except (ImportError, ValueError, AttributeError), exc:
raise ImportError('Class %s cannot be found (%s)' %
(class_str, str(exc)))
(class_str, str(exc)))
def import_object(import_str, *args, **kwargs):

@ -99,9 +99,9 @@ def schedule_host(tenant_id, instance_id, user_id=None):
'instance_desc': {
'user_id': user_id,
'project_id': project_id,
},
},
}
},
}
request_url = "/novatenants/" + project_id + "/schedule_host"
client = Client(HOST, PORT, USE_SSL, format='json', tenant=TENANT_ID,
@ -138,16 +138,16 @@ COMMANDS = {
"func": create_multiport,
"args": ["tenant-id",
"net-id-list (comma separated list of netword IDs)"],
},
},
"list_extensions": {
"func": list_extensions,
"args": [],
},
},
"schedule_host": {
"func": schedule_host,
"args": ["tenant-id", "instance-id"],
},
}
},
}
def main():

@ -27,7 +27,7 @@ from quantum.common import exceptions
class NoMoreNics(exceptions.QuantumException):
"""No more dynamic nics are available in the system"""
message = _("Unable to complete operation. No more dynamic nics are "
"available in the system.")
"available in the system.")
class PortProfileLimit(exceptions.QuantumException):
@ -83,7 +83,7 @@ class PortProfileAlreadyExists(exceptions.QuantumException):
class PortProfileBindingAlreadyExists(exceptions.QuantumException):
"""Binding cannot be created, since it already exists"""
message = _("PortProfileBinding for port profile %(pp_id)s to "
"port %(port_id) already exists")
"port %(port_id) already exists")
class VlanIDNotFound(exceptions.QuantumException):

@ -25,16 +25,17 @@ class Fault(webob.exc.HTTPException):
"""Error codes for API faults"""
_fault_names = {
400: "malformedRequest",
401: "unauthorized",
421: "PortprofileInUse",
450: "PortprofileNotFound",
451: "CredentialNotFound",
452: "QoSNotFound",
453: "NovatenantNotFound",
454: "MultiportNotFound",
470: "serviceUnavailable",
471: "pluginFault"}
400: "malformedRequest",
401: "unauthorized",
421: "PortprofileInUse",
450: "PortprofileNotFound",
451: "CredentialNotFound",
452: "QoSNotFound",
453: "NovatenantNotFound",
454: "MultiportNotFound",
470: "serviceUnavailable",
471: "pluginFault"
}
def __init__(self, exception):
"""Create a Fault for the given webob.exc.exception."""

@ -49,8 +49,8 @@ def make_port_dict(port_id, port_state, net_id, attachment):
return res
def make_portprofile_dict(tenant_id, profile_id, profile_name,
qos):
def make_portprofile_dict(tenant_id, profile_id,
profile_name, qos):
"""Helper funciton"""
profile_associations = make_portprofile_assc_list(tenant_id,
profile_id)

@ -88,19 +88,19 @@ def network_create(tenant_id, name):
def network_list(tenant_id):
session = get_session()
return session.query(models.Network).\
options(joinedload(models.Network.ports)). \
filter_by(tenant_id=tenant_id).\
all()
return (session.query(models.Network).
options(joinedload(models.Network.ports)).
filter_by(tenant_id=tenant_id).
all())
def network_id(net_name):
session = get_session()
try:
return session.query(models.Network).\
options(joinedload(models.Network.ports)). \
filter_by(name=net_name).\
all()
return (session.query(models.Network).
options(joinedload(models.Network.ports)).
filter_by(name=net_name).
all())
except exc.NoResultFound, e:
raise q_exc.NetworkNotFound(net_name=net_name)
@ -129,9 +129,9 @@ def network_update(net_id, tenant_id, **kwargs):
def network_destroy(net_id):
session = get_session()
try:
net = session.query(models.Network).\