Backslash continuations (nova.tests)

Fixes bug #925285

Backslash continuations removal for package nova.tests

Change-Id: I089dfb9a06a807e58ebb21329800a4eff40ed2bb
This commit is contained in:
Zhongyue Luo 2012-02-06 09:50:06 +08:00
parent 34d77ac8b1
commit fc69f038bb
28 changed files with 316 additions and 331 deletions

View File

@ -209,9 +209,9 @@ class AggregateTestCase(test.TestCase):
self.stubs.Set(self.controller.api, "add_host_to_aggregate",
stub_add_host_to_aggregate)
aggregate = self.\
controller.action(self.req, "1",
body={"add_host": {"host": "host1"}})
aggregate = self.controller.action(self.req, "1",
body={"add_host": {"host":
"host1"}})
self.assertEqual(aggregate["aggregate"], AGGREGATE)

View File

@ -229,69 +229,69 @@ class CreateserverextTest(test.TestCase):
def _create_instance_with_networks_json(self, networks):
body_dict = self._create_networks_request_dict(networks)
request = self._get_create_request_json(body_dict)
compute_api, response = \
self._run_create_instance_with_mock_compute_api(request)
_create_inst = self._run_create_instance_with_mock_compute_api
compute_api, response = _create_inst(request)
return request, response, compute_api.networks
def _create_instance_with_user_data_json(self, networks):
body_dict = self._create_user_data_request_dict(networks)
request = self._get_create_request_json(body_dict)
compute_api, response = \
self._run_create_instance_with_mock_compute_api(request)
_create_inst = self._run_create_instance_with_mock_compute_api
compute_api, response = _create_inst(request)
return request, response, compute_api.user_data
def _create_instance_with_networks_xml(self, networks):
body_dict = self._create_networks_request_dict(networks)
request = self._get_create_request_xml(body_dict)
compute_api, response = \
self._run_create_instance_with_mock_compute_api(request)
_create_inst = self._run_create_instance_with_mock_compute_api
compute_api, response = _create_inst(request)
return request, response, compute_api.networks
def test_create_instance_with_no_networks(self):
request, response, networks = \
self._create_instance_with_networks_json(networks=None)
_create_inst = self._create_instance_with_networks_json
request, response, networks = _create_inst(networks=None)
self.assertEquals(response.status_int, 202)
self.assertEquals(networks, None)
def test_create_instance_with_no_networks_xml(self):
request, response, networks = \
self._create_instance_with_networks_xml(networks=None)
_create_inst = self._create_instance_with_networks_xml
request, response, networks = _create_inst(networks=None)
self.assertEquals(response.status_int, 202)
self.assertEquals(networks, None)
def test_create_instance_with_one_network(self):
request, response, networks = \
self._create_instance_with_networks_json([FAKE_NETWORKS[0]])
_create_inst = self._create_instance_with_networks_json
request, response, networks = _create_inst([FAKE_NETWORKS[0]])
self.assertEquals(response.status_int, 202)
self.assertEquals(networks, [FAKE_NETWORKS[0]])
def test_create_instance_with_one_network_xml(self):
request, response, networks = \
self._create_instance_with_networks_xml([FAKE_NETWORKS[0]])
_create_inst = self._create_instance_with_networks_xml
request, response, networks = _create_inst([FAKE_NETWORKS[0]])
self.assertEquals(response.status_int, 202)
self.assertEquals(networks, [FAKE_NETWORKS[0]])
def test_create_instance_with_two_networks(self):
request, response, networks = \
self._create_instance_with_networks_json(FAKE_NETWORKS)
_create_inst = self._create_instance_with_networks_json
request, response, networks = _create_inst(FAKE_NETWORKS)
self.assertEquals(response.status_int, 202)
self.assertEquals(networks, FAKE_NETWORKS)
def test_create_instance_with_two_networks_xml(self):
request, response, networks = \
self._create_instance_with_networks_xml(FAKE_NETWORKS)
_create_inst = self._create_instance_with_networks_xml
request, response, networks = _create_inst(FAKE_NETWORKS)
self.assertEquals(response.status_int, 202)
self.assertEquals(networks, FAKE_NETWORKS)
def test_create_instance_with_duplicate_networks(self):
request, response, networks = \
self._create_instance_with_networks_json(DUPLICATE_NETWORKS)
_create_inst = self._create_instance_with_networks_json
request, response, networks = _create_inst(DUPLICATE_NETWORKS)
self.assertEquals(response.status_int, 400)
self.assertEquals(networks, None)
def test_create_instance_with_duplicate_networks_xml(self):
request, response, networks = \
self._create_instance_with_networks_xml(DUPLICATE_NETWORKS)
_create_inst = self._create_instance_with_networks_xml
request, response, networks = _create_inst(DUPLICATE_NETWORKS)
self.assertEquals(response.status_int, 400)
self.assertEquals(networks, None)
@ -299,8 +299,8 @@ class CreateserverextTest(test.TestCase):
body_dict = self._create_networks_request_dict([FAKE_NETWORKS[0]])
del body_dict['server']['networks'][0]['uuid']
request = self._get_create_request_json(body_dict)
compute_api, response = \
self._run_create_instance_with_mock_compute_api(request)
_run_create_inst = self._run_create_instance_with_mock_compute_api
compute_api, response = _run_create_inst(request)
self.assertEquals(response.status_int, 400)
self.assertEquals(compute_api.networks, None)
@ -309,41 +309,41 @@ class CreateserverextTest(test.TestCase):
request = self._get_create_request_xml(body_dict)
uuid = ' uuid="aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"'
request.body = request.body.replace(uuid, '')
compute_api, response = \
self._run_create_instance_with_mock_compute_api(request)
_run_create_inst = self._run_create_instance_with_mock_compute_api
compute_api, response = _run_create_inst(request)
self.assertEquals(response.status_int, 400)
self.assertEquals(compute_api.networks, None)
def test_create_instance_with_network_invalid_id(self):
request, response, networks = \
self._create_instance_with_networks_json(INVALID_NETWORKS)
_create_inst = self._create_instance_with_networks_json
request, response, networks = _create_inst(INVALID_NETWORKS)
self.assertEquals(response.status_int, 400)
self.assertEquals(networks, None)
def test_create_instance_with_network_invalid_id_xml(self):
request, response, networks = \
self._create_instance_with_networks_xml(INVALID_NETWORKS)
_create_inst = self._create_instance_with_networks_xml
request, response, networks = _create_inst(INVALID_NETWORKS)
self.assertEquals(response.status_int, 400)
self.assertEquals(networks, None)
def test_create_instance_with_network_empty_fixed_ip(self):
networks = [('1', '')]
request, response, networks = \
self._create_instance_with_networks_json(networks)
_create_inst = self._create_instance_with_networks_json
request, response, networks = _create_inst(networks)
self.assertEquals(response.status_int, 400)
self.assertEquals(networks, None)
def test_create_instance_with_network_non_string_fixed_ip(self):
networks = [('1', 12345)]
request, response, networks = \
self._create_instance_with_networks_json(networks)
_create_inst = self._create_instance_with_networks_json
request, response, networks = _create_inst(networks)
self.assertEquals(response.status_int, 400)
self.assertEquals(networks, None)
def test_create_instance_with_network_empty_fixed_ip_xml(self):
networks = [('1', '')]
request, response, networks = \
self._create_instance_with_networks_xml(networks)
_create_inst = self._create_instance_with_networks_xml
request, response, networks = _create_inst(networks)
self.assertEquals(response.status_int, 400)
self.assertEquals(networks, None)
@ -351,8 +351,8 @@ class CreateserverextTest(test.TestCase):
body_dict = self._create_networks_request_dict([FAKE_NETWORKS[0]])
del body_dict['server']['networks'][0]['fixed_ip']
request = self._get_create_request_json(body_dict)
compute_api, response = \
self._run_create_instance_with_mock_compute_api(request)
_run_create_inst = self._run_create_instance_with_mock_compute_api
compute_api, response = _run_create_inst(request)
self.assertEquals(response.status_int, 202)
self.assertEquals(compute_api.networks,
[('aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', None)])
@ -361,8 +361,8 @@ class CreateserverextTest(test.TestCase):
body_dict = self._create_networks_request_dict([FAKE_NETWORKS[0]])
request = self._get_create_request_xml(body_dict)
request.body = request.body.replace(' fixed_ip="10.0.1.12"', '')
compute_api, response = \
self._run_create_instance_with_mock_compute_api(request)
_run_create_inst = self._run_create_instance_with_mock_compute_api
compute_api, response = _run_create_inst(request)
self.assertEquals(response.status_int, 202)
self.assertEquals(compute_api.networks,
[('aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', None)])
@ -370,22 +370,22 @@ class CreateserverextTest(test.TestCase):
def test_create_instance_with_userdata(self):
user_data_contents = '#!/bin/bash\necho "Oh no!"\n'
user_data_contents = base64.b64encode(user_data_contents)
request, response, user_data = \
self._create_instance_with_user_data_json(user_data_contents)
_create_inst = self._create_instance_with_user_data_json
request, response, user_data = _create_inst(user_data_contents)
self.assertEquals(response.status_int, 202)
self.assertEquals(user_data, user_data_contents)
def test_create_instance_with_userdata_none(self):
user_data_contents = None
request, response, user_data = \
self._create_instance_with_user_data_json(user_data_contents)
_create_inst = self._create_instance_with_user_data_json
request, response, user_data = _create_inst(user_data_contents)
self.assertEquals(response.status_int, 202)
self.assertEquals(user_data, user_data_contents)
def test_create_instance_with_userdata_with_non_b64_content(self):
user_data_contents = '#!/bin/bash\necho "Oh no!"\n'
request, response, user_data = \
self._create_instance_with_user_data_json(user_data_contents)
_create_inst = self._create_instance_with_user_data_json
request, response, user_data = _create_inst(user_data_contents)
self.assertEquals(response.status_int, 400)
self.assertEquals(user_data, None)
@ -398,8 +398,8 @@ class CreateserverextTest(test.TestCase):
self._setup_mock_network_api()
body_dict = self._create_security_group_request_dict(security_groups)
request = self._get_create_request_json(body_dict)
compute_api, response = \
self._run_create_instance_with_mock_compute_api(request)
_run_create_inst = self._run_create_instance_with_mock_compute_api
compute_api, response = _run_create_inst(request)
self.assertEquals(response.status_int, 202)
def test_get_server_by_id_verify_security_groups_json(self):

View File

@ -19,8 +19,8 @@ import json
from lxml import etree
import webob
from nova.api.openstack.compute.contrib\
import virtual_storage_arrays as vsa_ext
from nova.api.openstack.compute.contrib import (virtual_storage_arrays as
vsa_ext)
from nova import context
import nova.db
from nova import exception
@ -305,29 +305,29 @@ class VSAVolumeApiTest(test.TestCase):
self.assertEqual(resp.status_int, 200)
def test_vsa_volume_detail(self):
req = webob.Request.blank('/v2/fake/zadr-vsa/123/%s/detail' % \
self.test_objs)
req = webob.Request.blank('/v2/fake/zadr-vsa/123/%s/detail' %
self.test_objs)
resp = req.get_response(fakes.wsgi_app())
self.assertEqual(resp.status_int, 200)
def test_vsa_volume_show(self):
obj_num = 234 if self.test_objs == "volumes" else 345
req = webob.Request.blank('/v2/fake/zadr-vsa/123/%s/%s' % \
(self.test_objs, obj_num))
req = webob.Request.blank('/v2/fake/zadr-vsa/123/%s/%s' %
(self.test_objs, obj_num))
resp = req.get_response(fakes.wsgi_app())
self.assertEqual(resp.status_int, 200)
def test_vsa_volume_show_no_vsa_assignment(self):
req = webob.Request.blank('/v2/fake/zadr-vsa/4/%s/333' % \
(self.test_objs))
req = webob.Request.blank('/v2/fake/zadr-vsa/4/%s/333' %
self.test_objs)
resp = req.get_response(fakes.wsgi_app())
self.assertEqual(resp.status_int, 400)
def test_vsa_volume_show_no_volume(self):
self.stubs.Set(volume.api.API, "get", fakes.stub_volume_get_notfound)
req = webob.Request.blank('/v2/fake/zadr-vsa/123/%s/333' % \
(self.test_objs))
req = webob.Request.blank('/v2/fake/zadr-vsa/123/%s/333' %
self.test_objs)
resp = req.get_response(fakes.wsgi_app())
self.assertEqual(resp.status_int, 404)
@ -336,8 +336,8 @@ class VSAVolumeApiTest(test.TestCase):
update = {"status": "available",
"displayName": "Test Display name"}
body = {self.test_obj: update}
req = webob.Request.blank('/v2/fake/zadr-vsa/123/%s/%s' % \
(self.test_objs, obj_num))
req = webob.Request.blank('/v2/fake/zadr-vsa/123/%s/%s' %
(self.test_objs, obj_num))
req.method = 'PUT'
req.body = json.dumps(body)
req.headers['content-type'] = 'application/json'
@ -350,8 +350,8 @@ class VSAVolumeApiTest(test.TestCase):
def test_vsa_volume_delete(self):
obj_num = 234 if self.test_objs == "volumes" else 345
req = webob.Request.blank('/v2/fake/zadr-vsa/123/%s/%s' % \
(self.test_objs, obj_num))
req = webob.Request.blank('/v2/fake/zadr-vsa/123/%s/%s' %
(self.test_objs, obj_num))
req.method = 'DELETE'
resp = req.get_response(fakes.wsgi_app())
if self.test_obj == "volume":
@ -360,8 +360,8 @@ class VSAVolumeApiTest(test.TestCase):
self.assertEqual(resp.status_int, 400)
def test_vsa_volume_delete_no_vsa_assignment(self):
req = webob.Request.blank('/v2/fake/zadr-vsa/4/%s/333' % \
(self.test_objs))
req = webob.Request.blank('/v2/fake/zadr-vsa/4/%s/333' %
self.test_objs)
req.method = 'DELETE'
resp = req.get_response(fakes.wsgi_app())
self.assertEqual(resp.status_int, 400)
@ -369,8 +369,8 @@ class VSAVolumeApiTest(test.TestCase):
def test_vsa_volume_delete_no_volume(self):
self.stubs.Set(volume.api.API, "get", fakes.stub_volume_get_notfound)
req = webob.Request.blank('/v2/fake/zadr-vsa/123/%s/333' % \
(self.test_objs))
req = webob.Request.blank('/v2/fake/zadr-vsa/123/%s/333' %
self.test_objs)
req.method = 'DELETE'
resp = req.get_response(fakes.wsgi_app())
if self.test_obj == "volume":

View File

@ -59,8 +59,8 @@ def fake_instance_type_get_by_flavor_id(flavorid):
def fake_instance_type_get_all(inactive=False, filters=None):
def reject_min(db_attr, filter_attr):
return filter_attr in filters and\
int(flavor[db_attr]) < int(filters[filter_attr])
return (filter_attr in filters and
int(flavor[db_attr]) < int(filters[filter_attr]))
filters = filters or {}
output = {}

View File

@ -776,8 +776,8 @@ class WsgiLimiterProxyTest(BaseLimitTestSuite):
delay, error = self.proxy.check_for_delay("GET", "/delayed")
error = error.strip()
expected = ("60.00", "403 Forbidden\n\nOnly 1 GET request(s) can be "\
"made to /delayed every minute.")
expected = ("60.00", "403 Forbidden\n\nOnly 1 GET request(s) can be "
"made to /delayed every minute.")
self.assertEqual((delay, error), expected)

View File

@ -1423,8 +1423,8 @@ class ServersControllerCreateTest(test.TestCase):
def rpc_call_wrapper(context, topic, msg):
"""Stub out the scheduler creating the instance entry"""
if topic == FLAGS.scheduler_topic and \
msg['method'] == 'run_instance':
if (topic == FLAGS.scheduler_topic and
msg['method'] == 'run_instance'):
request_spec = msg['args']['request_spec']
num_instances = request_spec.get('num_instances', 1)
instances = []
@ -2399,8 +2399,8 @@ class TestServerCreateRequestXMLDeserializer(test.TestCase):
self.assertDictMatch(request['body'], expected)
def test_spec_request(self):
image_bookmark_link = "http://servers.api.openstack.org/1234/" + \
"images/52415800-8b69-11e0-9b19-734f6f006e54"
image_bookmark_link = ("http://servers.api.openstack.org/1234/"
"images/52415800-8b69-11e0-9b19-734f6f006e54")
serial_request = """
<server xmlns="http://docs.openstack.org/compute/api/v2"
imageRef="%s"
@ -2417,8 +2417,8 @@ class TestServerCreateRequestXMLDeserializer(test.TestCase):
expected = {
"server": {
"name": "new-server-test",
"imageRef": "http://servers.api.openstack.org/1234/" + \
"images/52415800-8b69-11e0-9b19-734f6f006e54",
"imageRef": ("http://servers.api.openstack.org/1234/"
"images/52415800-8b69-11e0-9b19-734f6f006e54"),
"flavorRef": "52415800-8b69-11e0-9b19-734f1195ff37",
"metadata": {"My Server Name": "Apache1"},
"personality": [

View File

@ -406,8 +406,8 @@ class FakeAuthManager(object):
def create_project(self, name, manager_user, description=None,
member_users=None):
member_ids = [User.safe_id(m) for m in member_users] \
if member_users else []
member_ids = ([User.safe_id(m) for m in member_users]
if member_users else [])
p = Project(name, name, User.safe_id(manager_user),
description, member_ids)
FakeAuthManager.projects[name] = p

View File

@ -48,8 +48,8 @@ class RequestTest(test.TestCase):
self.assertEqual(result, "application/json")
request = wsgi.Request.blank('/tests/123')
request.headers["Accept"] = \
"application/json; q=0.3, application/xml; q=0.9"
request.headers["Accept"] = ("application/json; q=0.3, "
"application/xml; q=0.9")
result = request.best_match_content_type()
self.assertEqual(result, "application/xml")

View File

@ -95,9 +95,9 @@ class DomainReadWriteTestCase(test.TestCase):
self.mox.StubOutWithMock(__builtin__, 'open')
try:
open('/tftpboot/test_fake_dom_file', 'r').AndRaise(\
IOError(2, 'No such file or directory',
'/tftpboot/test_fake_dom_file'))
open('/tftpboot/test_fake_dom_file',
'r').AndRaise(IOError(2, 'No such file or directory',
'/tftpboot/test_fake_dom_file'))
self.mox.ReplayAll()
@ -128,8 +128,8 @@ class DomainReadWriteTestCase(test.TestCase):
# Python object as expected_json
# We can't do an exact string comparison
# because of ordering and whitespace
mock_file.write(mox.Func(functools.partial(self.assertJSONEquals,\
expected_json)))
mock_file.write(mox.Func(functools.partial(self.assertJSONEquals,
expected_json)))
mock_file.close()
self.mox.ReplayAll()
@ -236,8 +236,8 @@ class BareMetalDomTestCase(test.TestCase):
self.mox.StubOutWithMock(dom, 'write_domains')
# Expected calls
dom.read_domains('/tftpboot/test_fake_dom_file')\
.AndReturn(fake_domains)
dom.read_domains('/tftpboot/'
'test_fake_dom_file').AndReturn(fake_domains)
dom.write_domains('/tftpboot/test_fake_dom_file', fake_domains)
self.mox.ReplayAll()
@ -274,8 +274,8 @@ class ProxyBareMetalTestCase(test.TestCase):
self.mox.StubOutWithMock(dom, 'write_domains')
# Expected calls
dom.read_domains('/tftpboot/test_fake_dom_file')\
.AndReturn(fake_domains)
dom.read_domains('/tftpboot/'
'test_fake_dom_file').AndReturn(fake_domains)
dom.write_domains('/tftpboot/test_fake_dom_file', fake_domains)
self.mox.ReplayAll()

View File

@ -26,26 +26,29 @@ class TileraBareMetalNodesTestCase(test.TestCase):
def setUp(self):
super(TileraBareMetalNodesTestCase, self).setUp()
self.board_info = """\
# board_id ip_address mac_address 00:1A:CA:00:57:90 \
00:1A:CA:00:58:98 00:1A:CA:00:58:50
6 10.0.2.7 00:1A:CA:00:58:5C 10 16218 917 476 1 tilera_hv 1 \
{"vendor":"tilera","model":"TILEmpower","arch":"TILEPro64","features":\
["8x8Grid","32bVLIW","5.6MBCache","443BOPS","37TbMesh","700MHz-866MHz",\
"4DDR2","2XAUIMAC/PHY","2GbEMAC"],"topology":{"cores":"64"}}
7 10.0.2.8 00:1A:CA:00:58:A4 10 16218 917 476 1 tilera_hv 1 \
{"vendor":"tilera","model":"TILEmpower","arch":"TILEPro64","features":\
["8x8Grid","32bVLIW","5.6MBCache","443BOPS","37TbMesh","700MHz-866MHz",\
"4DDR2","2XAUIMAC/PHY","2GbEMAC"],"topology":{"cores":"64"}}
8 10.0.2.9 00:1A:CA:00:58:1A 10 16218 917 476 1 tilera_hv 1 \
{"vendor":"tilera","model":"TILEmpower","arch":"TILEPro64","features":\
["8x8Grid","32bVLIW","5.6MBCache","443BOPS","37TbMesh","700MHz-866MHz",\
"4DDR2","2XAUIMAC/PHY","2GbEMAC"],"topology":{"cores":"64"}}
9 10.0.2.10 00:1A:CA:00:58:38 10 16385 1000 0 0 tilera_hv 1 \
{"vendor":"tilera","model":"TILEmpower","arch":"TILEPro64","features":\
["8x8Grid","32bVLIW","5.6MBCache","443BOPS","37TbMesh","700MHz-866MHz",\
"4DDR2","2XAUIMAC/PHY","2GbEMAC"],"topology":{"cores":"64"}}
"""
self.board_info = "\n".join([
'# board_id ip_address mac_address 00:1A:CA:00:57:90 '
'00:1A:CA:00:58:98 00:1A:CA:00:58:50',
'6 10.0.2.7 00:1A:CA:00:58:5C 10 16218 917 476 1 tilera_hv 1 '
'{"vendor":"tilera","model":"TILEmpower","arch":"TILEPro64",'
'"features":["8x8Grid","32bVLIW","5.6MBCache","443BOPS","37TbMesh",'
'"700MHz-866MHz","4DDR2","2XAUIMAC/PHY","2GbEMAC"],'
'"topology":{"cores":"64"}}',
'7 10.0.2.8 00:1A:CA:00:58:A4 10 16218 917 476 1 tilera_hv 1 '
'{"vendor":"tilera","model":"TILEmpower","arch":"TILEPro64",'
'"features":["8x8Grid","32bVLIW","5.6MBCache","443BOPS","37TbMesh",'
'"700MHz-866MHz","4DDR2","2XAUIMAC/PHY","2GbEMAC"],'
'"topology":{"cores":"64"}}',
'8 10.0.2.9 00:1A:CA:00:58:1A 10 16218 917 476 1 tilera_hv 1 '
'{"vendor":"tilera","model":"TILEmpower","arch":"TILEPro64",'
'"features":["8x8Grid","32bVLIW","5.6MBCache","443BOPS","37TbMesh",'
'"700MHz-866MHz","4DDR2","2XAUIMAC/PHY","2GbEMAC"],'
'"topology":{"cores":"64"}}',
'9 10.0.2.10 00:1A:CA:00:58:38 10 16385 1000 0 0 tilera_hv 1 '
'{"vendor":"tilera","model":"TILEmpower","arch":"TILEPro64",'
'"features":["8x8Grid","32bVLIW","5.6MBCache","443BOPS","37TbMesh",'
'"700MHz-866MHz","4DDR2","2XAUIMAC/PHY","2GbEMAC"],'
'"topology":{"cores":"64"}}'])
def tearDown(self):
super(TileraBareMetalNodesTestCase, self).tearDown()
@ -63,8 +66,8 @@ class TileraBareMetalNodesTestCase(test.TestCase):
try:
self.mox.StubOutWithMock(__builtin__, 'open')
open("/tftpboot/tilera_boards", "r").AndReturn(\
StringIO.StringIO(self.board_info))
open("/tftpboot/tilera_boards",
"r").AndReturn(StringIO.StringIO(self.board_info))
self.mox.ReplayAll()
@ -78,8 +81,8 @@ class TileraBareMetalNodesTestCase(test.TestCase):
self.mox.StubOutWithMock(__builtin__, 'open')
open("/tftpboot/tilera_boards", "r").AndReturn(\
StringIO.StringIO(self.board_info))
open("/tftpboot/tilera_boards",
"r").AndReturn(StringIO.StringIO(self.board_info))
self.mox.ReplayAll()
nodes = tilera.BareMetalNodes()

View File

@ -100,9 +100,9 @@ def stub_out_db_network_api(stubs):
networks = [network_fields]
def fake_floating_ip_allocate_address(context, project_id, pool):
ips = filter(lambda i: i['fixed_ip_id'] is None \
and i['project_id'] is None \
and i['pool'] == pool,
ips = filter(lambda i: i['fixed_ip_id'] is None and
i['project_id'] is None and
i['pool'] == pool,
floating_ips)
if not ips:
raise exception.NoMoreFloatingIps()
@ -169,9 +169,8 @@ def stub_out_db_network_api(stubs):
ips[0]['instance_id'] = instance_id
def fake_fixed_ip_associate_pool(context, network_id, instance_id):
ips = filter(lambda i: (i['network_id'] == network_id \
or i['network_id'] is None) \
and not i['instance'],
ips = filter(lambda i: (i['network_id'] == network_id or
i['network_id'] is None) and not i['instance'],
fixed_ips)
if not ips:
raise exception.NoMoreFixedIps()
@ -243,7 +242,7 @@ def stub_out_db_network_api(stubs):
return FakeModel(vif)
def fake_virtual_interface_delete_by_instance(context, instance_id):
addresses = [m for m in virtual_interfacees \
addresses = [m for m in virtual_interfacees
if m['instance_id'] == instance_id]
try:
for address in addresses:
@ -252,13 +251,13 @@ def stub_out_db_network_api(stubs):
pass
def fake_virtual_interface_get_by_instance(context, instance_id):
return [FakeModel(m) for m in virtual_interfacees \
return [FakeModel(m) for m in virtual_interfacees
if m['instance_id'] == instance_id]
def fake_virtual_interface_get_by_instance_and_network(context,
instance_id,
network_id):
vif = filter(lambda m: m['instance_id'] == instance_id and \
vif = filter(lambda m: m['instance_id'] == instance_id and
m['network_id'] == network_id,
virtual_interfacees)
if not vif:
@ -302,7 +301,7 @@ def stub_out_db_network_api(stubs):
net[key] = values[key]
def fake_project_get_networks(context, project_id):
return [FakeModel(n) for n in networks \
return [FakeModel(n) for n in networks
if n['project_id'] == project_id]
def fake_queue_get_for(context, topic, node):

View File

@ -122,10 +122,10 @@ class VsaSchedulerTestCase(test_scheduler.SchedulerTestCase):
dtype['DriveType'] = 'type_' + str(j)
dtype['TotalDrives'] = 2 * (self.init_num_drives + i)
dtype['DriveCapacity'] = vsa_sched.GB_TO_BYTES(1 + 100 * j)
dtype['TotalCapacity'] = dtype['TotalDrives'] * \
dtype['DriveCapacity']
dtype['AvailableCapacity'] = (dtype['TotalDrives'] - i) * \
dtype['DriveCapacity']
dtype['TotalCapacity'] = (dtype['TotalDrives'] *
dtype['DriveCapacity'])
dtype['AvailableCapacity'] = ((dtype['TotalDrives'] - i) *
dtype['DriveCapacity'])
dtype['DriveRpm'] = 7200
dtype['DifCapable'] = 0
dtype['SedCapable'] = 0
@ -150,18 +150,20 @@ class VsaSchedulerTestCase(test_scheduler.SchedulerTestCase):
qos = host_val['volume']['drive_qos_info']
for k, d in qos.iteritems():
LOG.info("\t%s: type %s: drives (used %2d, total %2d) "\
"size %3d, total %4d, used %4d, avail %d",
k, d['DriveType'],
d['FullDrive']['NumOccupiedDrives'], d['TotalDrives'],
vsa_sched.BYTES_TO_GB(d['DriveCapacity']),
vsa_sched.BYTES_TO_GB(d['TotalCapacity']),
vsa_sched.BYTES_TO_GB(d['TotalCapacity'] - \
d['AvailableCapacity']),
vsa_sched.BYTES_TO_GB(d['AvailableCapacity']))
LOG.info("\t%s: type %s: drives (used %2d, total %2d) "
"size %3d, total %4d, used %4d, avail %d",
k,
d['DriveType'],
d['FullDrive']['NumOccupiedDrives'],
d['TotalDrives'],
vsa_sched.BYTES_TO_GB(d['DriveCapacity']),
vsa_sched.BYTES_TO_GB(d['TotalCapacity']),
vsa_sched.BYTES_TO_GB(d['TotalCapacity'] -
d['AvailableCapacity']),
vsa_sched.BYTES_TO_GB(d['AvailableCapacity']))
total_used += vsa_sched.BYTES_TO_GB(d['TotalCapacity'] - \
d['AvailableCapacity'])
total_used += vsa_sched.BYTES_TO_GB(d['TotalCapacity'] -
d['AvailableCapacity'])
total_available += vsa_sched.BYTES_TO_GB(
d['AvailableCapacity'])
LOG.info("Host %s: used %d, avail %d",
@ -196,7 +198,7 @@ class VsaSchedulerTestCase(test_scheduler.SchedulerTestCase):
LOG.debug(_("\t vol=%(vol)s"), locals())
def _fake_vsa_update(self, context, vsa_id, values):
LOG.debug(_("Test: VSA update request: vsa_id=%(vsa_id)s "\
LOG.debug(_("Test: VSA update request: vsa_id=%(vsa_id)s "
"values=%(values)s"), locals())
def _fake_volume_create(self, context, options):
@ -214,7 +216,7 @@ class VsaSchedulerTestCase(test_scheduler.SchedulerTestCase):
return global_volume
def _fake_volume_update(self, context, volume_id, values):
LOG.debug(_("Test: Volume update request: id=%(volume_id)s "\
LOG.debug(_("Test: Volume update request: id=%(volume_id)s "
"values=%(values)s"), locals())
global scheduled_volume
scheduled_volume = {'id': volume_id, 'host': values['host']}

View File

@ -279,7 +279,7 @@ class ApiEc2TestCase(test.TestCase):
a key pair, that the API call to list key pairs works properly"""
self.expect_http()
self.mox.ReplayAll()
keyname = "".join(random.choice("sdiuisudfsdcnpaqwertasd") \
keyname = "".join(random.choice("sdiuisudfsdcnpaqwertasd")
for x in range(random.randint(4, 8)))
# NOTE(vish): create depends on pool, so call helper directly
cloud._gen_key(context.get_admin_context(), 'fake', keyname)
@ -293,7 +293,7 @@ class ApiEc2TestCase(test.TestCase):
requesting a second keypair with the same name fails sanely"""
self.expect_http()
self.mox.ReplayAll()
keyname = "".join(random.choice("sdiuisudfsdcnpaqwertasd") \
keyname = "".join(random.choice("sdiuisudfsdcnpaqwertasd")
for x in range(random.randint(4, 8)))
# NOTE(vish): create depends on pool, so call helper directly
self.ec2.create_key_pair('test')

View File

@ -74,8 +74,8 @@ orig_rpc_cast = rpc.cast
def rpc_call_wrapper(context, topic, msg, do_cast=True):
"""Stub out the scheduler creating the instance entry"""
if topic == FLAGS.scheduler_topic and \
msg['method'] == 'run_instance':
if (topic == FLAGS.scheduler_topic and
msg['method'] == 'run_instance'):
request_spec = msg['args']['request_spec']
scheduler = scheduler_driver.Scheduler
num_instances = request_spec.get('num_instances', 1)
@ -892,11 +892,11 @@ class ComputeTestCase(BaseTestCase):
fake_get_nw_info)
self.mox.StubOutWithMock(self.compute.network_api,
"allocate_for_instance")
self.compute.network_api.allocate_for_instance(mox.IgnoreArg(),
mox.IgnoreArg(),
requested_networks=None,
vpn=False).\
AndRaise(quantum_client.QuantumServerException())
self.compute.network_api.allocate_for_instance(
mox.IgnoreArg(),
mox.IgnoreArg(),
requested_networks=None,
vpn=False).AndRaise(quantum_client.QuantumServerException())
self.flags(stub_network=False)
@ -918,9 +918,9 @@ class ComputeTestCase(BaseTestCase):
instance = self._create_fake_instance()
self.mox.StubOutWithMock(self.compute, "_setup_block_device_mapping")
self.compute._setup_block_device_mapping(mox.IgnoreArg(),
mox.IgnoreArg()).\
AndRaise(rpc.common.RemoteError('', '', ''))
self.compute._setup_block_device_mapping(
mox.IgnoreArg(),
mox.IgnoreArg()).AndRaise(rpc.common.RemoteError('', '', ''))
self.mox.ReplayAll()
@ -1339,11 +1339,12 @@ class ComputeTestCase(BaseTestCase):
self.mox.StubOutWithMock(self.compute.driver, 'get_instance_disk_info')
self.compute.driver.get_instance_disk_info(inst_ref.name)
rpc.call(c, topic, {"method": "pre_live_migration",
"args": {'instance_id': instance_id,
'block_migration': True,
'disk': None}}).\
AndRaise(rpc.common.RemoteError('', '', ''))
rpc.call(c, topic,
{"method": "pre_live_migration",
"args": {'instance_id': instance_id,
'block_migration': True,
'disk': None}
}).AndRaise(rpc.common.RemoteError('', '', ''))
# mocks for rollback
rpc.call(c, topic, {"method": "remove_volume_connection",
"args": {'instance_id': instance_id,

View File

@ -125,8 +125,8 @@ class DirectTestCase(test.TestCase):
req = webob.Request.blank('/fake/echo')
req.environ['openstack.context'] = self.context
req.method = 'POST'
req.body = 'data=foo&_underscored=ignoreMe&self=ignoreMe&context='\
'ignoreMe'
req.body = ('data=foo&_underscored=ignoreMe&self=ignoreMe&context='
'ignoreMe')
resp = req.get_response(self.router)
self.assertEqual(resp.status_int, 200)
resp_parsed = json.loads(resp.body)

View File

@ -49,8 +49,8 @@ class InstanceTypeTestCase(test.TestCase):
def _generate_flavorid(self):
"""return a flavorid not in the DB"""
nonexistent_flavor = 2700
flavor_ids = [value["id"] for key, value in\
instance_types.get_all_types().iteritems()]
flavor_ids = [value["id"] for key, value in
instance_types.get_all_types().iteritems()]
while nonexistent_flavor in flavor_ids:
nonexistent_flavor += 1
else:

View File

@ -121,8 +121,8 @@ class IptablesManagerTestCase(test.TestCase):
"nova-postouting-bottom: %s" % last_postrouting_line)
for chain in ['POSTROUTING', 'PREROUTING', 'OUTPUT']:
self.assertTrue('-A %s -j runner.py-%s' \
% (chain, chain) in new_lines,
self.assertTrue('-A %s -j runner.py-%s' %
(chain, chain) in new_lines,
"Built-in chain %s not wrapped" % (chain,))
def test_filter_rules(self):
@ -157,6 +157,6 @@ class IptablesManagerTestCase(test.TestCase):
"nova-filter-top does not jump to wrapped local chain")
for chain in ['INPUT', 'OUTPUT', 'FORWARD']:
self.assertTrue('-A %s -j runner.py-%s' \
% (chain, chain) in new_lines,
self.assertTrue('-A %s -j runner.py-%s' %
(chain, chain) in new_lines,
"Built-in chain %s not wrapped" % (chain,))

View File

@ -83,17 +83,17 @@ class TgtAdmTestCase(test.TestCase, TargetAdminTestCase):
super(TgtAdmTestCase, self).setUp()
TargetAdminTestCase.setUp(self)
self.flags(iscsi_helper='tgtadm')
self.script_template = """
tgtadm --op new --lld=iscsi --mode=target --tid=%(tid)s \
--targetname=%(target_name)s
tgtadm --op bind --lld=iscsi --mode=target --initiator-address=ALL \
--tid=%(tid)s
tgtadm --op show --lld=iscsi --mode=target --tid=%(tid)s
tgtadm --op new --lld=iscsi --mode=logicalunit --tid=%(tid)s --lun=%(lun)d \
--backing-store=%(path)s
tgtadm --op delete --lld=iscsi --mode=logicalunit --tid=%(tid)s --lun=%(lun)d
tgtadm --op delete --lld=iscsi --mode=target --tid=%(tid)s
"""
self.script_template = "\n".join([
"tgtadm --op new --lld=iscsi --mode=target --tid=%(tid)s "
"--targetname=%(target_name)s",
"tgtadm --op bind --lld=iscsi --mode=target --initiator-address=ALL "
"--tid=%(tid)s",
"tgtadm --op show --lld=iscsi --mode=target --tid=%(tid)s",
"tgtadm --op new --lld=iscsi --mode=logicalunit --tid=%(tid)s "
"--lun=%(lun)d --backing-store=%(path)s",
"tgtadm --op delete --lld=iscsi --mode=logicalunit --tid=%(tid)s "
"--lun=%(lun)d",
"tgtadm --op delete --lld=iscsi --mode=target --tid=%(tid)s"])
def get_script_params(self):
params = super(TgtAdmTestCase, self).get_script_params()
@ -107,10 +107,10 @@ class IetAdmTestCase(test.TestCase, TargetAdminTestCase):
super(IetAdmTestCase, self).setUp()
TargetAdminTestCase.setUp(self)
self.flags(iscsi_helper='ietadm')
self.script_template = """
ietadm --op new --tid=%(tid)s --params Name=%(target_name)s
ietadm --op show --tid=%(tid)s
ietadm --op new --tid=%(tid)s --lun=%(lun)d --params Path=%(path)s,Type=fileio
ietadm --op delete --tid=%(tid)s --lun=%(lun)d
ietadm --op delete --tid=%(tid)s
"""
self.script_template = "\n".join([
"ietadm --op new --tid=%(tid)s --params Name=%(target_name)s",
"ietadm --op show --tid=%(tid)s",
"ietadm --op new --tid=%(tid)s --lun=%(lun)d "
"--params Path=%(path)s,Type=fileio",
"ietadm --op delete --tid=%(tid)s --lun=%(lun)d",
"ietadm --op delete --tid=%(tid)s"])

View File

@ -906,10 +906,11 @@ class LibvirtConnTestCase(test.TestCase):
# Preparing mocks
vdmock = self.mox.CreateMock(libvirt.virDomain)
self.mox.StubOutWithMock(vdmock, "migrateToURI")
_bandwidth = FLAGS.live_migration_bandwidth
vdmock.migrateToURI(FLAGS.live_migration_uri % 'dest',
mox.IgnoreArg(),
None, FLAGS.live_migration_bandwidth).\
AndRaise(libvirt.libvirtError('ERR'))
None,
_bandwidth).AndRaise(libvirt.libvirtError('ERR'))
def fake_lookup(instance_name):
if instance_name == instance_ref.name:
@ -1025,8 +1026,8 @@ class LibvirtConnTestCase(test.TestCase):
os.path.getsize('/test/disk').AndReturn((10737418240))
self.mox.StubOutWithMock(utils, "execute")
utils.execute('qemu-img', 'info', '/test/disk.local').\
AndReturn((ret, ''))
utils.execute('qemu-img', 'info',
'/test/disk.local').AndReturn((ret, ''))
os.path.getsize('/test/disk.local').AndReturn((21474836480))
@ -1185,10 +1186,11 @@ class LibvirtConnTestCase(test.TestCase):
class HostStateTestCase(test.TestCase):
cpu_info = '{"vendor": "Intel", "model": "pentium", "arch": "i686", '\
'"features": ["ssse3", "monitor", "pni", "sse2", "sse", "fxsr", '\
'"clflush", "pse36", "pat", "cmov", "mca", "pge", "mtrr", "sep", '\
'"apic"], "topology": {"cores": "1", "threads": "1", "sockets": "1"}}'
cpu_info = ('{"vendor": "Intel", "model": "pentium", "arch": "i686", '
'"features": ["ssse3", "monitor", "pni", "sse2", "sse", '
'"fxsr", "clflush", "pse36", "pat", "cmov", "mca", "pge", '
'"mtrr", "sep", "apic"], '
'"topology": {"cores": "1", "threads": "1", "sockets": "1"}}')
class FakeConnection(object):
"""Fake connection object"""
@ -1232,13 +1234,13 @@ class HostStateTestCase(test.TestCase):
stats = hs._stats
self.assertEquals(stats["vcpus"], 1)
self.assertEquals(stats["vcpus_used"], 0)
self.assertEquals(stats["cpu_info"], \
{"vendor": "Intel", "model": "pentium", "arch": "i686",
"features": ["ssse3", "monitor", "pni", "sse2", "sse", "fxsr",
"clflush", "pse36", "pat", "cmov", "mca", "pge",
"mtrr", "sep", "apic"],
"topology": {"cores": "1", "threads": "1", "sockets": "1"}
})
self.assertEquals(stats["cpu_info"],
{"vendor": "Intel", "model": "pentium", "arch": "i686",
"features": ["ssse3", "monitor", "pni", "sse2", "sse",
"fxsr", "clflush", "pse36", "pat", "cmov",
"mca", "pge", "mtrr", "sep", "apic"],
"topology": {"cores": "1", "threads": "1", "sockets": "1"}
})
self.assertEquals(stats["disk_total"], 100)
self.assertEquals(stats["disk_used"], 20)
self.assertEquals(stats["disk_available"], 80)
@ -1523,10 +1525,10 @@ class IptablesFirewallTestCase(test.TestCase):
admin_ctxt = context.get_admin_context()
fakefilter = NWFilterFakes()
self.fw.nwfilter._conn.nwfilterDefineXML =\
fakefilter.filterDefineXMLMock
self.fw.nwfilter._conn.nwfilterLookupByName =\
fakefilter.nwfilterLookupByName
_xml_mock = fakefilter.filterDefineXMLMock
self.fw.nwfilter._conn.nwfilterDefineXML = _xml_mock
_lookup_name = fakefilter.nwfilterLookupByName
self.fw.nwfilter._conn.nwfilterLookupByName = _lookup_name
instance_ref = self._create_instance_ref()
network_info = _fake_network_info(self.stubs, 1)

View File

@ -206,21 +206,19 @@ class LinuxNetworkTestCase(test.TestCase):
self.mox.StubOutWithMock(self.driver, 'ensure_path')
self.mox.StubOutWithMock(os, 'chmod')
db.network_get_associated_fixed_ips(mox.IgnoreArg(),
mox.IgnoreArg())\
.AndReturn([fixed_ips[0],
fixed_ips[3]])
db.network_get_associated_fixed_ips(
mox.IgnoreArg(),
mox.IgnoreArg()).AndReturn([fixed_ips[0], fixed_ips[3]])
db.network_get_associated_fixed_ips(mox.IgnoreArg(),
mox.IgnoreArg())\
.AndReturn([fixed_ips[0],
fixed_ips[3]])
db.virtual_interface_get_by_instance(mox.IgnoreArg(),
mox.IgnoreArg())\
.AndReturn([vifs[0], vifs[1]])
db.virtual_interface_get_by_instance(mox.IgnoreArg(),
mox.IgnoreArg())\
.AndReturn([vifs[2], vifs[3]])
db.network_get_associated_fixed_ips(
mox.IgnoreArg(),
mox.IgnoreArg()).AndReturn([fixed_ips[0], fixed_ips[3]])
db.virtual_interface_get_by_instance(
mox.IgnoreArg(),
mox.IgnoreArg()).AndReturn([vifs[0], vifs[1]])
db.virtual_interface_get_by_instance(
mox.IgnoreArg(),
mox.IgnoreArg()).AndReturn([vifs[2], vifs[3]])
self.driver.write_to_file(mox.IgnoreArg(), mox.IgnoreArg())
self.driver.write_to_file(mox.IgnoreArg(), mox.IgnoreArg())
self.driver.ensure_path(mox.IgnoreArg())
@ -254,21 +252,19 @@ class LinuxNetworkTestCase(test.TestCase):
self.mox.StubOutWithMock(self.driver, 'ensure_path')
self.mox.StubOutWithMock(os, 'chmod')
db.network_get_associated_fixed_ips(mox.IgnoreArg(),
mox.IgnoreArg())\
.AndReturn([fixed_ips[1],
fixed_ips[2]])
db.network_get_associated_fixed_ips(
mox.IgnoreArg(),
mox.IgnoreArg()).AndReturn([fixed_ips[1], fixed_ips[2]])
db.network_get_associated_fixed_ips(mox.IgnoreArg(),
mox.IgnoreArg())\
.AndReturn([fixed_ips[1],
fixed_ips[2]])
db.virtual_interface_get_by_instance(mox.IgnoreArg(),
mox.IgnoreArg())\
.AndReturn([vifs[0], vifs[1]])
db.virtual_interface_get_by_instance(mox.IgnoreArg(),
mox.IgnoreArg())\
.AndReturn([vifs[2], vifs[3]])
db.network_get_associated_fixed_ips(
mox.IgnoreArg(),
mox.IgnoreArg()).AndReturn([fixed_ips[1], fixed_ips[2]])
db.virtual_interface_get_by_instance(
mox.IgnoreArg(),
mox.IgnoreArg()).AndReturn([vifs[0], vifs[1]])
db.virtual_interface_get_by_instance(
mox.IgnoreArg(),
mox.IgnoreArg()).AndReturn([vifs[2], vifs[3]])
self.driver.write_to_file(mox.IgnoreArg(), mox.IgnoreArg())
self.driver.write_to_file(mox.IgnoreArg(), mox.IgnoreArg())
self.driver.ensure_path(mox.IgnoreArg())
@ -298,17 +294,15 @@ class LinuxNetworkTestCase(test.TestCase):
self.stubs.Set(db, 'instance_get', get_instance)
self.mox.StubOutWithMock(db, 'network_get_associated_fixed_ips')
db.network_get_associated_fixed_ips(mox.IgnoreArg(),
mox.IgnoreArg())\
.AndReturn([fixed_ips[0],
fixed_ips[3]])
db.network_get_associated_fixed_ips(
mox.IgnoreArg(),
mox.IgnoreArg()).AndReturn([fixed_ips[0], fixed_ips[3]])
self.mox.ReplayAll()
expected = \
"DE:AD:BE:EF:00:00,fake_instance00.novalocal,"\
"192.168.0.100,net:NW-i00000000-0\n"\
"DE:AD:BE:EF:00:03,fake_instance01.novalocal,"\
"192.168.1.101,net:NW-i00000001-0"
expected = ("DE:AD:BE:EF:00:00,fake_instance00.novalocal,"
"192.168.0.100,net:NW-i00000000-0\n"
"DE:AD:BE:EF:00:03,fake_instance01.novalocal,"
"192.168.1.101,net:NW-i00000001-0")
actual_hosts = self.driver.get_dhcp_hosts(self.context, networks[1])
self.assertEquals(actual_hosts, expected)
@ -326,17 +320,15 @@ class LinuxNetworkTestCase(test.TestCase):
self.stubs.Set(db, 'instance_get', get_instance)
self.mox.StubOutWithMock(db, 'network_get_associated_fixed_ips')
db.network_get_associated_fixed_ips(mox.IgnoreArg(),
mox.IgnoreArg())\
.AndReturn([fixed_ips[1],
fixed_ips[2]])
db.network_get_associated_fixed_ips(
mox.IgnoreArg(),
mox.IgnoreArg()).AndReturn([fixed_ips[1], fixed_ips[2]])
self.mox.ReplayAll()
expected = \
"DE:AD:BE:EF:00:01,fake_instance00.novalocal,"\
"192.168.1.100,net:NW-i00000000-1\n"\
"DE:AD:BE:EF:00:02,fake_instance01.novalocal,"\
"192.168.0.101,net:NW-i00000001-1"
expected = ("DE:AD:BE:EF:00:01,fake_instance00.novalocal,"
"192.168.1.100,net:NW-i00000000-1\n"
"DE:AD:BE:EF:00:02,fake_instance01.novalocal,"
"192.168.0.101,net:NW-i00000001-1")
actual_hosts = self.driver.get_dhcp_hosts(self.context, networks[0])
self.assertEquals(actual_hosts, expected)
@ -349,21 +341,16 @@ class LinuxNetworkTestCase(test.TestCase):
self.mox.StubOutWithMock(db, 'network_get_associated_fixed_ips')
self.mox.StubOutWithMock(db, 'virtual_interface_get_by_instance')
db.network_get_associated_fixed_ips(mox.IgnoreArg(),
mox.IgnoreArg())\
.AndReturn([fixed_ips[0],
fixed_ips[3],
fixed_ips[4]])
db.virtual_interface_get_by_instance(mox.IgnoreArg(),
mox.IgnoreArg())\
.AndReturn([vifs[0],
vifs[1],
vifs[4]])
db.virtual_interface_get_by_instance(mox.IgnoreArg(),
mox.IgnoreArg())\
.AndReturn([vifs[2],
vifs[3],
vifs[5]])
db.network_get_associated_fixed_ips(
mox.IgnoreArg(),
mox.IgnoreArg()).AndReturn([fixed_ips[0], fixed_ips[3],
fixed_ips[4]])
db.virtual_interface_get_by_instance(
mox.IgnoreArg(),
mox.IgnoreArg()).AndReturn([vifs[0], vifs[1], vifs[4]])
db.virtual_interface_get_by_instance(
mox.IgnoreArg(),
mox.IgnoreArg()).AndReturn([vifs[2], vifs[3], vifs[5]])
self.mox.ReplayAll()
expected_opts = 'NW-i00000001-0,3'
@ -380,21 +367,16 @@ class LinuxNetworkTestCase(test.TestCase):
self.mox.StubOutWithMock(db, 'network_get_associated_fixed_ips')
self.mox.StubOutWithMock(db, 'virtual_interface_get_by_instance')
db.network_get_associated_fixed_ips(mox.IgnoreArg(),
mox.IgnoreArg())\
.AndReturn([fixed_ips[1],
fixed_ips[2],
fixed_ips[5]])
db.virtual_interface_get_by_instance(mox.IgnoreArg(),
mox.IgnoreArg())\
.AndReturn([vifs[0],
vifs[1],
vifs[4]])
db.virtual_interface_get_by_instance(mox.IgnoreArg(),
mox.IgnoreArg())\
.AndReturn([vifs[2],
vifs[3],
vifs[5]])
db.network_get_associated_fixed_ips(
mox.IgnoreArg(),
mox.IgnoreArg()).AndReturn([fixed_ips[1], fixed_ips[2],
fixed_ips[5]])
db.virtual_interface_get_by_instance(
mox.IgnoreArg(),
mox.IgnoreArg()).AndReturn([vifs[0], vifs[1], vifs[4]])
db.virtual_interface_get_by_instance(
mox.IgnoreArg(),
mox.IgnoreArg()).AndReturn([vifs[2], vifs[3], vifs[5]])
self.mox.ReplayAll()
expected_opts = "NW-i00000000-1,3"
@ -498,8 +480,8 @@ class LinuxNetworkTestCase(test.TestCase):
self._test_initialize_gateway(existing, expected)
def test_initialize_gateway_resets_route(self):
routes = "0.0.0.0 192.68.0.1 0.0.0.0 " \
"UG 100 0 0 eth0"
routes = ("0.0.0.0 192.68.0.1 0.0.0.0 "
"UG 100 0 0 eth0")
existing = ("2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> "
" mtu 1500 qdisc pfifo_fast state UNKNOWN qlen 1000\n"
" link/ether de:ad:be:ef:be:ef brd ff:ff:ff:ff:ff:ff\n"

View File

@ -80,8 +80,9 @@ class LogHandlerTestCase(test.TestCase):
class NovaFormatterTestCase(test.TestCase):
def setUp(self):
super(NovaFormatterTestCase, self).setUp()
self.flags(logging_context_format_string="HAS CONTEXT "\
"[%(request_id)s]: %(message)s",
self.flags(logging_context_format_string="HAS CONTEXT "
"[%(request_id)s]: "
"%(message)s",
logging_default_format_string="NOCTXT: %(message)s",
logging_debug_format_suffix="--DBG")
self.log = log.logging.root

View File

@ -1171,9 +1171,9 @@ class CommonNetworkTestCase(test.TestCase):
manager = fake_network.FakeNetworkManager()
fake_context = context.RequestContext('user', 'project')
self.mox.StubOutWithMock(manager.db, 'network_get_all_by_uuids')
manager.db.network_get_all_by_uuids(mox.IgnoreArg(),
mox.IgnoreArg()).\
AndReturn(networks)
manager.db.network_get_all_by_uuids(
mox.IgnoreArg(),
mox.IgnoreArg()).AndReturn(networks)
self.mox.ReplayAll()
uuid = 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa'
network = manager.get_network(fake_context, uuid)
@ -1184,8 +1184,7 @@ class CommonNetworkTestCase(test.TestCase):
fake_context = context.RequestContext('user', 'project')
self.mox.StubOutWithMock(manager.db, 'network_get_all_by_uuids')
manager.db.network_get_all_by_uuids(mox.IgnoreArg(),
mox.IgnoreArg()).\
AndReturn([])
mox.IgnoreArg()).AndReturn([])
self.mox.ReplayAll()
uuid = 'eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee'
self.assertRaises(exception.NetworkNotFound,
@ -1195,8 +1194,7 @@ class CommonNetworkTestCase(test.TestCase):
manager = fake_network.FakeNetworkManager()
fake_context = context.RequestContext('user', 'project')
self.mox.StubOutWithMock(manager.db, 'network_get_all')
manager.db.network_get_all(mox.IgnoreArg()).\
AndReturn(networks)
manager.db.network_get_all(mox.IgnoreArg()).AndReturn(networks)
self.mox.ReplayAll()
output = manager.get_all_networks(fake_context)
self.assertEqual(len(networks), 2)
@ -1209,9 +1207,9 @@ class CommonNetworkTestCase(test.TestCase):
manager = fake_network.FakeNetworkManager()
fake_context = context.RequestContext('user', 'project')
self.mox.StubOutWithMock(manager.db, 'network_get_all_by_uuids')
manager.db.network_get_all_by_uuids(mox.IgnoreArg(),
mox.IgnoreArg()).\
AndReturn(networks)
manager.db.network_get_all_by_uuids(
mox.IgnoreArg(),
mox.IgnoreArg()).AndReturn(networks)
self.mox.ReplayAll()
uuid = 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa'
manager.disassociate_network(fake_context, uuid)
@ -1221,8 +1219,7 @@ class CommonNetworkTestCase(test.TestCase):
fake_context = context.RequestContext('user', 'project')
self.mox.StubOutWithMock(manager.db, 'network_get_all_by_uuids')
manager.db.network_get_all_by_uuids(mox.IgnoreArg(),
mox.IgnoreArg()).\
AndReturn([])
mox.IgnoreArg()).AndReturn([])
self.mox.ReplayAll()
uuid = 'eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee'
self.assertRaises(exception.NetworkNotFound,

View File

@ -172,9 +172,9 @@ class NetworkCommandsTestCase(test.TestCase):
self.commands.list()
sys.stdout = sys.__stdout__
result = output.getvalue()
_fmt = "%(id)-5s\t%(cidr)-18s\t%(cidr_v6)-15s\t%(dhcp_start)-15s\t" +\
"%(dns1)-15s\t%(dns2)-15s\t%(vlan)-15s\t%(project_id)-15s\t" +\
"%(uuid)-15s"
_fmt = "\t".join(["%(id)-5s", "%(cidr)-18s", "%(cidr_v6)-15s",
"%(dhcp_start)-15s", "%(dns1)-15s", "%(dns2)-15s",
"%(vlan)-15s", "%(project_id)-15s", "%(uuid)-15s"])
head = _fmt % {'id': _('id'),
'cidr': _('IPv4'),
'cidr_v6': _('IPv6'),

View File

@ -465,8 +465,8 @@ class QuantumNovaPortSecurityTestCase(QuantumNovaTestCase):
self.assertTrue(pairs[0]['mac_address'] == fake_mac)
self.net_man.q_conn.create_and_attach_port = oldfunc
return oldfunc(tenant_id, net_id, interface_id, **kwargs)
self.net_man.q_conn.create_and_attach_port = \
_instrumented_create_and_attach_port
_port_attach = _instrumented_create_and_attach_port
self.net_man.q_conn.create_and_attach_port = _port_attach
nw_info = self.net_man.allocate_for_instance(ctx,
instance_id=instance_ref['id'], host="",
rxtx_factor=3,
@ -500,8 +500,8 @@ class QuantumNovaPortSecurityTestCase(QuantumNovaTestCase):
self.assertTrue(len(pairs) == 0)
self.net_man.q_conn.create_and_attach_port = oldfunc
return oldfunc(tenant_id, net_id, interface_id, **kwargs)
self.net_man.q_conn.create_and_attach_port = \
_instrumented_create_and_attach_port
_port_attach = _instrumented_create_and_attach_port
self.net_man.q_conn.create_and_attach_port = _port_attach
nw_info = self.net_man.allocate_for_instance(ctx,
instance_id=instance_ref['id'], host="",
rxtx_factor=3,

View File

@ -59,8 +59,8 @@ class QuotaTestCase(test.TestCase):
def rpc_call_wrapper(context, topic, msg):
"""Stub out the scheduler creating the instance entry"""
if topic == FLAGS.scheduler_topic and \
msg['method'] == 'run_instance':
if (topic == FLAGS.scheduler_topic and
msg['method'] == 'run_instance'):
scheduler = scheduler_driver.Scheduler
instance = scheduler().create_instance_db_entry(
context,

View File

@ -78,8 +78,7 @@ class VolumeTypeTestCase(test.TestCase):
def test_get_all_volume_types(self):
"""Ensures that all volume types can be retrieved"""
session = get_session()
total_volume_types = session.query(models.VolumeTypes).\
count()
total_volume_types = session.query(models.VolumeTypes).count()
vol_types = volume_types.get_all_types(self.ctxt)
self.assertEqual(total_volume_types, len(vol_types))

View File

@ -513,8 +513,8 @@ class XenAPIVMTestCase(test.TestCase):
# Change the default host_call_plugin to one that'll return
# a swap disk
orig_func = stubs.FakeSessionForVMTests.host_call_plugin
stubs.FakeSessionForVMTests.host_call_plugin = \
stubs.FakeSessionForVMTests.host_call_plugin_swap
_host_call_plugin = stubs.FakeSessionForVMTests.host_call_plugin_swap
stubs.FakeSessionForVMTests.host_call_plugin = _host_call_plugin
# Stubbing out firewall driver as previous stub sets a particular
# stub for async plugin calls
stubs.stubout_firewall_driver(self.stubs, self.conn)
@ -954,8 +954,8 @@ class XenAPIMigrateInstance(test.TestCase):
self.assertEqual(self.fake_vm_start_called, True)
def test_finish_migrate_no_local_storage(self):
tiny_type_id = \
instance_types.get_instance_type_by_name('m1.tiny')['id']
tiny_type = instance_types.get_instance_type_by_name('m1.tiny')
tiny_type_id = tiny_type['id']
self.instance_values.update({'instance_type_id': tiny_type_id,
'root_gb': 0})
instance = db.instance_create(self.context, self.instance_values)
@ -1550,10 +1550,10 @@ class XenAPIDom0IptablesFirewallTestCase(test.TestCase):
ipv6_addr_per_network = 1
networks_count = 5
instance_ref = self._create_instance_ref()
network_info = fake_network.\
fake_get_instance_nw_info(self.stubs,
networks_count,
ipv4_addr_per_network)
_get_instance_nw_info = fake_network.fake_get_instance_nw_info
network_info = _get_instance_nw_info(self.stubs,
networks_count,
ipv4_addr_per_network)
ipv4_len = len(self.fw.iptables.ipv4['filter'].rules)
ipv6_len = len(self.fw.iptables.ipv6['filter'].rules)
inst_ipv4, inst_ipv6 = self.fw.instance_rules(instance_ref,
@ -1681,8 +1681,8 @@ class XenAPISRSelectionTestCase(test.TestCase):
helper = vm_utils.VMHelper
helper.XenAPI = session.get_imported_xenapi()
host_ref = xenapi_fake.get_all('host')[0]
local_sr = xenapi_fake.\
create_sr(name_label='Fake Storage',
local_sr = xenapi_fake.create_sr(
name_label='Fake Storage',
type='lvm',
other_config={'i18n-original-value-name_label':
'Local storage',
@ -1699,11 +1699,10 @@ class XenAPISRSelectionTestCase(test.TestCase):
helper = vm_utils.VMHelper
helper.XenAPI = session.get_imported_xenapi()
host_ref = xenapi_fake.get_all('host')[0]
local_sr = xenapi_fake.\
create_sr(name_label='Fake Storage',
type='lvm',
other_config={'my_fake_sr': 'true'},
host_ref=host_ref)
local_sr = xenapi_fake.create_sr(name_label='Fake Storage',
type='lvm',
other_config={'my_fake_sr': 'true'},
host_ref=host_ref)
expected = helper.safe_find_sr(session)
self.assertEqual(local_sr, expected)

View File

@ -160,14 +160,14 @@ def _make_fake_vdi():
class FakeSessionForVMTests(fake.SessionBase):
""" Stubs out a XenAPISession for VM tests """
_fake_iptables_save_output = \
"# Generated by iptables-save v1.4.10 on Sun Nov 6 22:49:02 2011\n"\
"*filter\n"\
":INPUT ACCEPT [0:0]\n"\
":FORWARD ACCEPT [0:0]\n"\
":OUTPUT ACCEPT [0:0]\n"\
"COMMIT\n"\
"# Completed on Sun Nov 6 22:49:02 2011\n"
_fake_iptables_save_output = ("# Generated by iptables-save v1.4.10 on "
"Sun Nov 6 22:49:02 2011\n"
"*filter\n"
":INPUT ACCEPT [0:0]\n"
":FORWARD ACCEPT [0:0]\n"
":OUTPUT ACCEPT [0:0]\n"
"COMMIT\n"
"# Completed on Sun Nov 6 22:49:02 2011\n")
def __init__(self, uri):
super(FakeSessionForVMTests, self).__init__(uri)