Store clients in context

Having the Stack create the Clients object means that custom constraints
do not have access to the already created clients. This greatly
complicates test mocking, and results in unnecessarily created
constraint-scoped clients.

This change makes the Clients be created in RequestContext on demand.
Constraints use the Clients associated with the context.

Mocking client create calls is simplified, generally needing to
call _create once instead of MultipleTimes()

Change-Id: If67e2d6761003558b32909c4655fadb4d0630b86
This commit is contained in:
Steve Baker 2014-06-10 13:42:21 +12:00
parent 1ef0aa9e1a
commit 1619c42bea
22 changed files with 159 additions and 127 deletions

View File

@ -15,6 +15,7 @@ from heat.common import exception
from heat.common import policy
from heat.common import wsgi
from heat.db import api as db_api
from heat.engine import clients
from heat.openstack.common import context
from heat.openstack.common import importutils
from heat.openstack.common import local
@ -58,6 +59,7 @@ class RequestContext(context.RequestContext):
if overwrite or not hasattr(local.store, 'context'):
self.update_store()
self._session = None
self._clients = None
self.trust_id = trust_id
self.trustor_user_id = trustor_user_id
self.policy = policy.Enforcer()
@ -76,6 +78,12 @@ class RequestContext(context.RequestContext):
self._session = db_api.get_session()
return self._session
@property
def clients(self):
if self._clients is None:
self._clients = clients.Clients(self)
return self._clients
def to_dict(self):
return {'auth_token': self.auth_token,
'username': self.username,

View File

@ -47,7 +47,7 @@ class OpenStackClients(object):
if name in self._client_plugins:
return self._client_plugins[name]
if _mgr and name in _mgr.names():
client_plugin = _mgr[name].plugin(self)
client_plugin = _mgr[name].plugin(self.context)
self._client_plugins[name] = client_plugin
return client_plugin

View File

@ -19,9 +19,9 @@ import six
@six.add_metaclass(abc.ABCMeta)
class ClientPlugin():
def __init__(self, clients):
self.context = clients.context
self.clients = clients
def __init__(self, context):
self.context = context
self.clients = context.clients
self._client = None
def client(self):

View File

@ -18,7 +18,6 @@ import re
import six
from heat.common import exception
from heat.engine import clients
from heat.engine import resources
from heat.openstack.common import strutils
@ -575,9 +574,8 @@ class BaseCustomConstraint(object):
"value": value, "message": self._error_message}
def validate(self, value, context):
client = clients.Clients(context)
try:
self.validate_with_client(client, value)
self.validate_with_client(context.clients, value)
except self.expected_exceptions as e:
self._error_message = str(e)
return False

View File

@ -25,7 +25,6 @@ from heat.common import exception
from heat.common.exception import StackValidationFailed
from heat.common import identifier
from heat.db import api as db_api
from heat.engine.clients import Clients
from heat.engine import dependencies
from heat.engine import environment
from heat.engine import function
@ -99,7 +98,7 @@ class Stack(collections.Mapping):
if use_stored_context:
self.context = self.stored_context()
self.clients = Clients(self.context)
self.clients = self.context.clients
# This will use the provided tenant ID when loading the stack
# from the DB or get it from the context for new stacks.

View File

@ -267,8 +267,7 @@ class WatchRule(object):
return actions
def _to_ceilometer(self, data):
from heat.engine import clients
clients = clients.Clients(self.context)
clients = self.context.clients
sample = {}
sample['meter_type'] = 'gauge'

View File

@ -212,11 +212,12 @@ class AutoScalingGroupTest(HeatTestCase):
'http://127.0.0.1:8000/v1/waitcondition')
def _mock_get_image_id_success(self, imageId_input, imageId,
update_image=None):
update_image=None, mock_create=True):
g_cli_mock = self.m.CreateMockAnything()
self.m.StubOutWithMock(glance.GlanceClientPlugin, '_create')
glance.GlanceClientPlugin._create().MultipleTimes().AndReturn(
g_cli_mock)
if mock_create:
self.m.StubOutWithMock(glance.GlanceClientPlugin, '_create')
glance.GlanceClientPlugin._create().AndReturn(
g_cli_mock)
self.m.StubOutWithMock(glance_utils, 'get_image_id')
# If update_image is None (create case), validation for initial image
@ -263,7 +264,7 @@ class AutoScalingGroupTest(HeatTestCase):
cookie = object()
self.m.StubOutWithMock(nova.NovaClientPlugin, '_create')
nova.NovaClientPlugin._create().MultipleTimes().AndReturn(self.fc)
nova.NovaClientPlugin._create().AndReturn(self.fc)
# for load balancer setup
if setup_lb:
self._stub_lb_create()
@ -294,10 +295,6 @@ class AutoScalingGroupTest(HeatTestCase):
self.m.StubOutWithMock(instance.Instance, 'check_create_complete')
self.m.StubOutWithMock(instance.Instance, 'destroy')
if num_reloads_expected_on_updt > 1:
self.m.StubOutWithMock(nova.NovaClientPlugin, '_create')
nova.NovaClientPlugin._create().MultipleTimes().AndReturn(self.fc)
cookie = object()
for i in range(num_creates_expected_on_updt):
instance.Instance.handle_create().AndReturn(cookie)
@ -512,7 +509,8 @@ class AutoScalingGroupTest(HeatTestCase):
num_reloads_expected_on_updt)
self.stub_wallclock()
self._mock_get_image_id_success('F20-x86_64-cfntools', 'image_id',
update_image=update_image_id)
update_image=update_image_id,
mock_create=False)
stack.validate()
self.m.ReplayAll()

View File

@ -27,6 +27,8 @@ class ClientsTest(HeatTestCase):
con = mock.Mock()
con.tenant_id = "b363706f891f48019483f8bd6503c54b"
c = clients.Clients(con)
con.clients = c
obj = c.client_plugin('heat')
obj._get_client_option = mock.Mock()
obj._get_client_option.return_value = None
@ -47,6 +49,8 @@ class ClientsTest(HeatTestCase):
con.tenant_id = "b363706f891f48019483f8bd6503c54b"
con.auth_token = "3bcc3d3a03f44e3d8377f9247b0ad155"
c = clients.Clients(con)
con.clients = c
obj = c.client_plugin('heat')
obj._get_heat_url = mock.Mock(name="_get_heat_url")
obj._get_heat_url.return_value = None
@ -67,6 +71,8 @@ class ClientsTest(HeatTestCase):
con.tenant_id = "b363706f891f48019483f8bd6503c54b"
con.auth_token = None
c = clients.Clients(con)
con.clients = c
obj = c.client_plugin('heat')
obj._get_heat_url = mock.Mock(name="_get_heat_url")
obj._get_heat_url.return_value = None
@ -82,6 +88,8 @@ class ClientsTest(HeatTestCase):
con.tenant_id = "b363706f891f48019483f8bd6503c54b"
con.auth_token = "3bcc3d3a03f44e3d8377f9247b0ad155"
c = clients.Clients(con)
con.clients = c
obj = c.client_plugin('heat')
obj._get_heat_url = mock.Mock(name="_get_heat_url")
obj._get_heat_url.return_value = None
@ -101,6 +109,8 @@ class ClientsTest(HeatTestCase):
con.password = 'verysecret'
con.auth_token = None
obj = clients.Clients(con)
con.clients = obj
self.assertIsNotNone(obj.client('heat'))
self.assertEqual('token1', obj.auth_token)
fkc.auth_token = 'token2'
@ -121,7 +131,9 @@ class ClientPluginTest(HeatTestCase):
con.tenant_id = "b363706f891f48019483f8bd6503c54b"
con.auth_token = "3bcc3d3a03f44e3d8377f9247b0ad155"
c = clients.Clients(con)
plugin = FooClientsPlugin(c)
con.clients = c
plugin = FooClientsPlugin(con)
cfg.CONF.set_override('ca_file', '/tmp/bar',
group='clients_heat')
@ -141,11 +153,13 @@ class ClientPluginTest(HeatTestCase):
con.auth_token = "1234"
c = clients.Clients(con)
con.clients = c
c.client = mock.Mock(name="client")
mock_keystone = mock.Mock()
c.client.return_value = mock_keystone
mock_keystone.auth_token = '5678'
plugin = FooClientsPlugin(c)
plugin = FooClientsPlugin(con)
# assert token is from keystone rather than context
# even though both are set
@ -157,11 +171,13 @@ class ClientPluginTest(HeatTestCase):
con.auth_token = "1234"
c = clients.Clients(con)
con.clients = c
c.client = mock.Mock(name="client")
mock_keystone = mock.Mock()
c.client.return_value = mock_keystone
mock_keystone.url_for.return_value = 'http://192.0.2.1/foo'
plugin = FooClientsPlugin(c)
plugin = FooClientsPlugin(con)
self.assertEqual('http://192.0.2.1/foo',
plugin.url_for(service_type='foo'))
@ -170,6 +186,8 @@ class ClientPluginTest(HeatTestCase):
def test_abstract_create(self):
con = mock.Mock()
c = clients.Clients(con)
con.clients = c
self.assertRaises(TypeError, client_plugin.ClientPlugin, c)
@ -182,6 +200,7 @@ class TestClientPluginsInitialise(HeatTestCase):
con.tenant_id = "b363706f891f48019483f8bd6503c54b"
con.auth_token = "3bcc3d3a03f44e3d8377f9247b0ad155"
c = clients.Clients(con)
con.clients = c
for plugin_name in clients._mgr.names():
self.assertTrue(clients.has_client(plugin_name))
@ -193,6 +212,7 @@ class TestClientPluginsInitialise(HeatTestCase):
con = mock.Mock()
c = clients.Clients(con)
con.clients = c
for plugin_name in plugin_types:
plugin = c.client_plugin(plugin_name)

View File

@ -199,14 +199,14 @@ def get_stack(stack_name, ctx, template):
def setup_keystone_mocks(mocks, stack):
fkc = test_fakes.FakeKeystoneClient()
mocks.StubOutWithMock(keystone.KeystoneClientPlugin, '_create')
keystone.KeystoneClientPlugin._create().MultipleTimes().AndReturn(fkc)
keystone.KeystoneClientPlugin._create().AndReturn(fkc)
def setup_mock_for_image_constraint(mocks, imageId_input,
imageId_output=744):
g_cli_mock = mocks.CreateMockAnything()
mocks.StubOutWithMock(glance.GlanceClientPlugin, '_create')
glance.GlanceClientPlugin._create().MultipleTimes().AndReturn(
glance.GlanceClientPlugin._create().AndReturn(
g_cli_mock)
mocks.StubOutWithMock(glance_utils, 'get_image_id')
glance_utils.get_image_id(g_cli_mock, imageId_input).\
@ -218,7 +218,7 @@ def setup_mocks(mocks, stack, mock_image_constraint=True):
mocks.StubOutWithMock(instances.Instance, 'nova')
instances.Instance.nova().MultipleTimes().AndReturn(fc)
mocks.StubOutWithMock(nova.NovaClientPlugin, '_create')
nova.NovaClientPlugin._create().MultipleTimes().AndReturn(fc)
nova.NovaClientPlugin._create().AndReturn(fc)
instance = stack['WebServer']
if mock_image_constraint:
setup_mock_for_image_constraint(mocks,
@ -644,6 +644,7 @@ class StackServiceCreateUpdateDeleteTest(HeatTestCase):
setup_mocks(self.m, stack, mock_image_constraint=False)
resource = stack['WebServer']
setup_mock_for_image_constraint(self.m, 'CentOS 5.2')
self.m.ReplayAll()
resource.properties = Properties(
@ -652,8 +653,8 @@ class StackServiceCreateUpdateDeleteTest(HeatTestCase):
'ImageId': 'CentOS 5.2',
'KeyName': 'test',
'InstanceType': 'm1.large'
})
setup_mock_for_image_constraint(self.m, 'CentOS 5.2')
},
context=self.ctx)
stack.validate()
resource.properties = Properties(
@ -661,7 +662,8 @@ class StackServiceCreateUpdateDeleteTest(HeatTestCase):
{
'KeyName': 'test',
'InstanceType': 'm1.large'
})
},
context=self.ctx)
self.assertRaises(exception.StackValidationFailed, stack.validate)
def test_stack_delete(self):

View File

@ -17,21 +17,24 @@ from heat.engine import clients
from heat.engine.resources import glance_utils
from heat.engine.resources import image
from heat.tests.common import HeatTestCase
from heat.tests import utils
class ImageConstraintTest(HeatTestCase):
@mock.patch.object(glance_utils, 'get_image_id')
def test_validation(self, mock_get_image):
ctx = utils.dummy_context()
with mock.patch.object(clients, "OpenStackClients"):
constraint = image.ImageConstraint()
mock_get_image.return_value = "id1"
self.assertTrue(constraint.validate("foo", None))
self.assertTrue(constraint.validate("foo", ctx))
@mock.patch.object(glance_utils, 'get_image_id')
def test_validation_error(self, mock_get_image):
ctx = utils.dummy_context()
with mock.patch.object(clients, "OpenStackClients"):
constraint = image.ImageConstraint()
mock_get_image.side_effect = exception.ImageNotFound(
image_name='bar')
self.assertFalse(constraint.validate("bar", None))
self.assertFalse(constraint.validate("bar", ctx))

View File

@ -82,7 +82,7 @@ class InstancesTest(HeatTestCase):
def _mock_get_image_id_success(self, imageId_input, imageId):
g_cli_mock = self.m.CreateMockAnything()
self.m.StubOutWithMock(glance.GlanceClientPlugin, '_create')
glance.GlanceClientPlugin._create().MultipleTimes().AndReturn(
glance.GlanceClientPlugin._create().AndReturn(
g_cli_mock)
self.m.StubOutWithMock(glance_utils, 'get_image_id')
glance_utils.get_image_id(g_cli_mock, imageId_input).MultipleTimes().\
@ -91,7 +91,7 @@ class InstancesTest(HeatTestCase):
def _mock_get_image_id_fail(self, image_id, exp):
g_cli_mock = self.m.CreateMockAnything()
self.m.StubOutWithMock(glance.GlanceClientPlugin, '_create')
glance.GlanceClientPlugin._create().MultipleTimes().AndReturn(
glance.GlanceClientPlugin._create().AndReturn(
g_cli_mock)
self.m.StubOutWithMock(glance_utils, 'get_image_id')
glance_utils.get_image_id(g_cli_mock, image_id).AndRaise(exp)
@ -116,7 +116,7 @@ class InstancesTest(HeatTestCase):
self._mock_get_image_id_success(image_id or 'CentOS 5.2', 1)
self.m.StubOutWithMock(nova.NovaClientPlugin, '_create')
nova.NovaClientPlugin._create().MultipleTimes().AndReturn(self.fc)
nova.NovaClientPlugin._create().AndReturn(self.fc)
if stub_create:
self.m.StubOutWithMock(self.fc.servers, 'create')
@ -314,7 +314,7 @@ class InstancesTest(HeatTestCase):
resource_defns['WebServer'], stack)
self.m.StubOutWithMock(nova.NovaClientPlugin, '_create')
nova.NovaClientPlugin._create().MultipleTimes().AndReturn(self.fc)
nova.NovaClientPlugin._create().AndReturn(self.fc)
self._mock_get_image_id_success('1', 1)
self.m.ReplayAll()

View File

@ -154,7 +154,7 @@ class instancesTest(HeatTestCase):
def _mock_get_image_id_success(self, imageId_input, imageId):
g_cli_mock = self.m.CreateMockAnything()
self.m.StubOutWithMock(glance.GlanceClientPlugin, '_create')
glance.GlanceClientPlugin._create().MultipleTimes().AndReturn(
glance.GlanceClientPlugin._create().AndReturn(
g_cli_mock)
self.m.StubOutWithMock(glance_utils, 'get_image_id')
glance_utils.get_image_id(g_cli_mock, imageId_input).MultipleTimes().\
@ -177,7 +177,7 @@ class instancesTest(HeatTestCase):
resource_defns['WebServer'], stack)
self.m.StubOutWithMock(nova.NovaClientPlugin, '_create')
nova.NovaClientPlugin._create().MultipleTimes().AndReturn(self.fc)
nova.NovaClientPlugin._create().AndReturn(self.fc)
self._mock_get_image_id_success(image_id, 1)
@ -235,7 +235,7 @@ class instancesTest(HeatTestCase):
nic.neutron().MultipleTimes().AndReturn(FakeNeutron())
self.m.StubOutWithMock(nova.NovaClientPlugin, '_create')
nova.NovaClientPlugin._create().MultipleTimes().AndReturn(self.fc)
nova.NovaClientPlugin._create().AndReturn(self.fc)
# need to resolve the template functions
server_userdata = nova_utils.build_userdata(

View File

@ -126,7 +126,7 @@ class LoadBalancerTest(HeatTestCase):
def _mock_get_image_id_success(self, imageId_input, imageId):
g_cli_mock = self.m.CreateMockAnything()
self.m.StubOutWithMock(glance.GlanceClientPlugin, '_create')
glance.GlanceClientPlugin._create().MultipleTimes().AndReturn(
glance.GlanceClientPlugin._create().AndReturn(
g_cli_mock)
self.m.StubOutWithMock(glance_utils, 'get_image_id')
glance_utils.get_image_id(g_cli_mock, imageId_input).\
@ -137,7 +137,7 @@ class LoadBalancerTest(HeatTestCase):
utils.PhysName('test_stack', 'LoadBalancer'),
'LB_instance',
limit=instance.Instance.physical_resource_name_limit)
nova.NovaClientPlugin._create().MultipleTimes().AndReturn(self.fc)
nova.NovaClientPlugin._create().AndReturn(self.fc)
self.fc.servers.create(
flavor=2, image=746, key_name=key_name,
meta=None, nics=None, name=server_name,

View File

@ -2394,19 +2394,21 @@ class NeutronPortTest(HeatTestCase):
class NetworkConstraintTest(HeatTestCase):
def test_validate(self):
nc = self.m.CreateMockAnything()
self.m.StubOutWithMock(neutron.NeutronClientPlugin, '_create')
neutron.NeutronClientPlugin._create().MultipleTimes().AndReturn(None)
neutron.NeutronClientPlugin._create().AndReturn(nc)
self.m.StubOutWithMock(net.neutronV20, 'find_resourceid_by_name_or_id')
net.neutronV20.find_resourceid_by_name_or_id(
None, 'network', 'foo'
nc, 'network', 'foo'
).AndReturn('foo')
net.neutronV20.find_resourceid_by_name_or_id(
None, 'network', 'bar'
nc, 'network', 'bar'
).AndRaise(qe.NeutronClientException(status_code=404))
self.m.ReplayAll()
constraint = net.NetworkConstraint()
self.assertTrue(constraint.validate("foo", None))
self.assertFalse(constraint.validate("bar", None))
ctx = utils.dummy_context()
self.assertTrue(constraint.validate("foo", ctx))
self.assertFalse(constraint.validate("bar", ctx))
self.m.VerifyAll()

View File

@ -64,7 +64,7 @@ class nokeyTest(HeatTestCase):
nova.NovaClientPlugin._create().AndReturn(self.fc)
g_cli_mock = self.m.CreateMockAnything()
self.m.StubOutWithMock(glance.GlanceClientPlugin, '_create')
glance.GlanceClientPlugin._create().MultipleTimes().AndReturn(
glance.GlanceClientPlugin._create().AndReturn(
g_cli_mock)
self.m.StubOutWithMock(glance_utils, 'get_image_id')
glance_utils.get_image_id(g_cli_mock, 'CentOS 5.2').MultipleTimes().\

View File

@ -151,7 +151,7 @@ class KeypairConstraintTest(HeatTestCase):
def test_validation(self):
client = fakes.FakeClient()
self.m.StubOutWithMock(nova.NovaClientPlugin, '_create')
nova.NovaClientPlugin._create().MultipleTimes().AndReturn(client)
nova.NovaClientPlugin._create().AndReturn(client)
client.keypairs = self.m.CreateMockAnything()
key = collections.namedtuple("Key", ["name"])
@ -161,8 +161,9 @@ class KeypairConstraintTest(HeatTestCase):
self.m.ReplayAll()
constraint = nova_keypair.KeypairConstraint()
self.assertFalse(constraint.validate("bar", None))
self.assertTrue(constraint.validate("foo", None))
self.assertTrue(constraint.validate("", None))
ctx = utils.dummy_context()
self.assertFalse(constraint.validate("bar", ctx))
self.assertTrue(constraint.validate("foo", ctx))
self.assertTrue(constraint.validate("", ctx))
self.m.VerifyAll()

View File

@ -469,7 +469,7 @@ Mappings:
parser.Template(empty_template))
self.m.StubOutWithMock(nova.NovaClientPlugin, '_create')
fc = fakes.FakeClient()
nova.NovaClientPlugin._create().MultipleTimes().AndReturn(fc)
nova.NovaClientPlugin._create().AndReturn(fc)
self.m.ReplayAll()
self.assertEqual(["nova1"], self.resolve(snippet, tmpl, stack))
@ -1347,7 +1347,7 @@ class StackTest(HeatTestCase):
raise Exception("Shouldn't delete")
self.m.StubOutWithMock(keystone.KeystoneClientPlugin, '_create')
keystone.KeystoneClientPlugin._create().MultipleTimes().AndReturn(
keystone.KeystoneClientPlugin._create().AndReturn(
FakeKeystoneClientFail())
self.m.ReplayAll()
@ -1373,7 +1373,7 @@ class StackTest(HeatTestCase):
raise kc_exceptions.Forbidden("Denied!")
self.m.StubOutWithMock(keystone.KeystoneClientPlugin, '_create')
keystone.KeystoneClientPlugin._create().MultipleTimes().AndReturn(
keystone.KeystoneClientPlugin._create().AndReturn(
FakeKeystoneClientFail())
self.m.ReplayAll()
@ -3032,7 +3032,7 @@ class StackTest(HeatTestCase):
cfg.CONF.set_override('deferred_auth_method', 'trusts')
self.m.StubOutWithMock(keystone.KeystoneClientPlugin, '_create')
keystone.KeystoneClientPlugin._create().MultipleTimes().AndReturn(
keystone.KeystoneClientPlugin._create().AndReturn(
FakeKeystoneClient())
self.m.ReplayAll()
@ -3331,7 +3331,7 @@ class StackTest(HeatTestCase):
# works for stack creation
fc = fakes.FakeClient()
self.m.StubOutWithMock(nova.NovaClientPlugin, '_create')
nova.NovaClientPlugin._create().MultipleTimes().AndReturn(fc)
nova.NovaClientPlugin._create().AndReturn(fc)
fc.flavors = self.m.CreateMockAnything()
flavor = collections.namedtuple("Flavor", ["id", "name"])

View File

@ -126,7 +126,7 @@ class ServersTest(HeatTestCase):
server_rebuild=server_rebuild)
self.m.StubOutWithMock(nova.NovaClientPlugin, '_create')
nova.NovaClientPlugin._create().MultipleTimes().AndReturn(self.fc)
nova.NovaClientPlugin._create().AndReturn(self.fc)
if stub_create:
self.m.StubOutWithMock(self.fc.servers, 'create')
@ -162,11 +162,13 @@ class ServersTest(HeatTestCase):
return fake_interface(port, mac, ip)
def _mock_get_image_id_success(self, imageId_input, imageId,
server_rebuild=False):
server_rebuild=False,
mock_create=True):
g_cli_mock = self.m.CreateMockAnything()
self.m.StubOutWithMock(glance.GlanceClientPlugin, '_create')
glance.GlanceClientPlugin._create().MultipleTimes().AndReturn(
g_cli_mock)
if mock_create:
self.m.StubOutWithMock(glance.GlanceClientPlugin, '_create')
glance.GlanceClientPlugin._create().AndReturn(
g_cli_mock)
self.m.StubOutWithMock(glance_utils, 'get_image_id')
glance_utils.get_image_id(g_cli_mock, imageId_input).MultipleTimes().\
AndReturn(imageId)
@ -178,7 +180,7 @@ class ServersTest(HeatTestCase):
def _mock_get_image_id_fail(self, image_id, exp):
g_cli_mock = self.m.CreateMockAnything()
self.m.StubOutWithMock(glance.GlanceClientPlugin, '_create')
glance.GlanceClientPlugin._create().MultipleTimes().AndReturn(
glance.GlanceClientPlugin._create().AndReturn(
g_cli_mock)
self.m.StubOutWithMock(glance_utils, 'get_image_id')
glance_utils.get_image_id(g_cli_mock, image_id).AndRaise(exp)
@ -186,7 +188,7 @@ class ServersTest(HeatTestCase):
def _mock_get_keypair_success(self, keypair_input, keypair):
n_cli_mock = self.m.CreateMockAnything()
self.m.StubOutWithMock(nova.NovaClientPlugin, '_create')
nova.NovaClientPlugin._create().MultipleTimes().AndReturn(
nova.NovaClientPlugin._create().AndReturn(
n_cli_mock)
self.m.StubOutWithMock(nova_utils, 'get_keypair')
nova_utils.get_keypair(n_cli_mock, keypair_input).MultipleTimes().\
@ -194,7 +196,7 @@ class ServersTest(HeatTestCase):
def _server_validate_mock(self, server):
self.m.StubOutWithMock(nova.NovaClientPlugin, '_create')
nova.NovaClientPlugin._create().MultipleTimes().AndReturn(self.fc)
nova.NovaClientPlugin._create().AndReturn(self.fc)
self._mock_get_image_id_success('F17-x86_64-gold', 'image_id')
def test_server_create(self):
@ -274,7 +276,7 @@ class ServersTest(HeatTestCase):
admin_pass=None).AndReturn(return_server)
self.m.StubOutWithMock(nova.NovaClientPlugin, '_create')
nova.NovaClientPlugin._create().MultipleTimes().AndReturn(self.fc)
nova.NovaClientPlugin._create().AndReturn(self.fc)
self._mock_get_image_id_success('F17-x86_64-gold', image_id)
self.m.ReplayAll()
@ -451,7 +453,7 @@ class ServersTest(HeatTestCase):
resource_defns['WebServer'], stack)
self.m.StubOutWithMock(nova.NovaClientPlugin, '_create')
nova.NovaClientPlugin._create().MultipleTimes().AndReturn(self.fc)
nova.NovaClientPlugin._create().AndReturn(self.fc)
self._mock_get_image_id_success('F17-x86_64-gold', 744)
self.m.StubOutWithMock(self.fc.servers, 'create')
@ -492,7 +494,7 @@ class ServersTest(HeatTestCase):
None, '8c813873-f6ee-4809-8eec-959ef39acb55').AndReturn(
'wordpress from config')
nova.NovaClientPlugin._create().MultipleTimes().AndReturn(self.fc)
nova.NovaClientPlugin._create().AndReturn(self.fc)
self._mock_get_image_id_success('F17-x86_64-gold', 744)
self.m.StubOutWithMock(self.fc.servers, 'create')
@ -533,7 +535,7 @@ class ServersTest(HeatTestCase):
None, sc_id).AndRaise(exception.SoftwareConfigMissing(
software_config_id=sc_id))
nova.NovaClientPlugin._create().MultipleTimes().AndReturn(self.fc)
nova.NovaClientPlugin._create().AndReturn(self.fc)
self._mock_get_image_id_success('F17-x86_64-gold', 744)
self.m.StubOutWithMock(self.fc.servers, 'create')
@ -568,7 +570,7 @@ class ServersTest(HeatTestCase):
self.m.StubOutWithMock(nova.NovaClientPlugin, '_create')
self.m.StubOutWithMock(server, 'heat')
nova.NovaClientPlugin._create().MultipleTimes().AndReturn(self.fc)
nova.NovaClientPlugin._create().AndReturn(self.fc)
self._mock_get_image_id_success('F17-x86_64-gold', 744)
self.m.StubOutWithMock(self.fc.servers, 'create')
@ -630,7 +632,7 @@ class ServersTest(HeatTestCase):
self.m.StubOutWithMock(nova.NovaClientPlugin, '_create')
nova.NovaClientPlugin._create().MultipleTimes().AndReturn(self.fc)
nova.NovaClientPlugin._create().AndReturn(self.fc)
self._mock_get_image_id_success('F17-x86_64-gold', 744)
self.m.StubOutWithMock(self.fc.servers, 'create')
@ -750,7 +752,7 @@ class ServersTest(HeatTestCase):
resource_defns['WebServer'], stack)
self.m.StubOutWithMock(nova.NovaClientPlugin, '_create')
nova.NovaClientPlugin._create().MultipleTimes().AndReturn(self.fc)
nova.NovaClientPlugin._create().AndReturn(self.fc)
self._mock_get_image_id_success('1', 1)
self.m.ReplayAll()
@ -767,7 +769,7 @@ class ServersTest(HeatTestCase):
web_server = tmpl.t['Resources']['WebServer']
del web_server['Properties']['image']
def create_server(device_name, mock_nova=True):
def create_server(device_name, mock_nova=True, mock_create=True):
self.m.UnsetStubs()
web_server['Properties']['block_device_mapping'] = [{
"device_name": device_name,
@ -780,16 +782,17 @@ class ServersTest(HeatTestCase):
if mock_nova:
self.m.StubOutWithMock(server, 'nova')
server.nova().MultipleTimes().AndReturn(self.fc)
self.m.StubOutWithMock(nova.NovaClientPlugin, '_create')
nova.NovaClientPlugin._create().MultipleTimes().AndReturn(self.fc)
if mock_create:
self.m.StubOutWithMock(nova.NovaClientPlugin, '_create')
nova.NovaClientPlugin._create().AndReturn(self.fc)
self.m.ReplayAll()
return server
server = create_server(u'vda')
self.assertIsNone(server.validate())
server = create_server('vda')
server = create_server('vda', mock_create=False)
self.assertIsNone(server.validate())
server = create_server('vdb', mock_nova=False)
server = create_server('vdb', mock_nova=False, mock_create=False)
ex = self.assertRaises(exception.StackValidationFailed,
server.validate)
self.assertEqual('Neither image nor bootable volume is specified for '
@ -855,7 +858,7 @@ class ServersTest(HeatTestCase):
resource_defns['WebServer'], stack)
self.m.StubOutWithMock(nova.NovaClientPlugin, '_create')
nova.NovaClientPlugin._create().MultipleTimes().AndReturn(self.fc)
nova.NovaClientPlugin._create().AndReturn(self.fc)
self.m.ReplayAll()
error = self.assertRaises(exception.StackValidationFailed,
@ -881,7 +884,7 @@ class ServersTest(HeatTestCase):
resource_defns['WebServer'], stack)
self.m.StubOutWithMock(nova.NovaClientPlugin, '_create')
nova.NovaClientPlugin._create().MultipleTimes().AndReturn(self.fc)
nova.NovaClientPlugin._create().AndReturn(self.fc)
self._mock_get_image_id_success('F17-x86_64-gold', 'image_id')
self.m.ReplayAll()
@ -912,7 +915,7 @@ class ServersTest(HeatTestCase):
resource_defns['WebServer'], stack)
self.m.StubOutWithMock(nova.NovaClientPlugin, '_create')
nova.NovaClientPlugin._create().MultipleTimes().AndReturn(self.fc)
nova.NovaClientPlugin._create().AndReturn(self.fc)
self._mock_get_image_id_success('F17-x86_64-gold', 'image_id')
self.m.ReplayAll()
@ -1049,8 +1052,6 @@ class ServersTest(HeatTestCase):
self.m.UnsetStubs()
# part two change the metadata (test removing the old key)
self.m.StubOutWithMock(nova.NovaClientPlugin, '_create')
nova.NovaClientPlugin._create().MultipleTimes().AndReturn(self.fc)
self.m.ReplayAll()
new_meta = {'new_key': 'yeah'}
@ -1062,7 +1063,7 @@ class ServersTest(HeatTestCase):
self.m.StubOutWithMock(self.fc.servers, 'set_meta')
self.fc.servers.set_meta(new_return_server,
new_meta).AndReturn(None)
self._mock_get_image_id_success('CentOS 5.2', 1)
self._mock_get_image_id_success('CentOS 5.2', 1, mock_create=False)
self.m.ReplayAll()
update_template = copy.deepcopy(server.t)
update_template['Properties']['metadata'] = new_meta
@ -1164,7 +1165,7 @@ class ServersTest(HeatTestCase):
stack_name = 'update_flvrep'
(tmpl, stack) = self._setup_test_stack(stack_name)
self.m.StubOutWithMock(nova.NovaClientPlugin, '_create')
nova.NovaClientPlugin._create().MultipleTimes().AndReturn(self.fc)
nova.NovaClientPlugin._create().AndReturn(self.fc)
self._mock_get_image_id_success('F17-x86_64-gold', 'image_id')
self.m.ReplayAll()
@ -1183,7 +1184,7 @@ class ServersTest(HeatTestCase):
stack_name = 'update_flvpol'
(tmpl, stack) = self._setup_test_stack(stack_name)
self.m.StubOutWithMock(nova.NovaClientPlugin, '_create')
nova.NovaClientPlugin._create().MultipleTimes().AndReturn(self.fc)
nova.NovaClientPlugin._create().AndReturn(self.fc)
self._mock_get_image_id_success('F17-x86_64-gold', 'image_id')
self.m.ReplayAll()
@ -1211,7 +1212,7 @@ class ServersTest(HeatTestCase):
resource_defns['WebServer'], stack)
image_id = self.getUniqueString()
self.m.StubOutWithMock(nova.NovaClientPlugin, '_create')
nova.NovaClientPlugin._create().MultipleTimes().AndReturn(self.fc)
nova.NovaClientPlugin._create().AndReturn(self.fc)
self.m.StubOutWithMock(image.ImageConstraint, "validate")
image.ImageConstraint.validate(
mox.IgnoreArg(), mox.IgnoreArg()).MultipleTimes().AndReturn(True)
@ -1746,7 +1747,7 @@ class ServersTest(HeatTestCase):
server = servers.Server('server_create_image_err',
resource_defns['WebServer'], stack)
self.m.StubOutWithMock(nova.NovaClientPlugin, '_create')
nova.NovaClientPlugin._create().MultipleTimes().AndReturn(self.fc)
nova.NovaClientPlugin._create().AndReturn(self.fc)
self._mock_get_image_id_success('F17-x86_64-gold', 'image_id')
self.m.ReplayAll()
@ -1765,7 +1766,7 @@ class ServersTest(HeatTestCase):
server = servers.Server('server_create_image_err',
resource_defns['WebServer'], stack)
self.m.StubOutWithMock(nova.NovaClientPlugin, '_create')
nova.NovaClientPlugin._create().MultipleTimes().AndReturn(self.fc)
nova.NovaClientPlugin._create().AndReturn(self.fc)
self._mock_get_image_id_success('F17-x86_64-gold', 'image_id')
self.m.ReplayAll()
@ -1789,7 +1790,7 @@ class ServersTest(HeatTestCase):
server = servers.Server('server_create_image_err',
resource_defns['WebServer'], stack)
self.m.StubOutWithMock(nova.NovaClientPlugin, '_create')
nova.NovaClientPlugin._create().MultipleTimes().AndReturn(self.fc)
nova.NovaClientPlugin._create().AndReturn(self.fc)
self.m.ReplayAll()
ex = self.assertRaises(exception.StackValidationFailed,
@ -1816,7 +1817,7 @@ class ServersTest(HeatTestCase):
self.fc.limits.get().MultipleTimes().AndReturn(self.limits)
self.m.StubOutWithMock(nova.NovaClientPlugin, '_create')
nova.NovaClientPlugin._create().MultipleTimes().AndReturn(self.fc)
nova.NovaClientPlugin._create().AndReturn(self.fc)
self._mock_get_image_id_success('F17-x86_64-gold', 'image_id')
self.m.ReplayAll()
@ -1843,7 +1844,7 @@ class ServersTest(HeatTestCase):
self.m.StubOutWithMock(server, 'nova')
server.nova().MultipleTimes().AndReturn(self.fc)
self.m.StubOutWithMock(nova.NovaClientPlugin, '_create')
nova.NovaClientPlugin._create().MultipleTimes().AndReturn(self.fc)
nova.NovaClientPlugin._create().AndReturn(self.fc)
self._mock_get_image_id_success('F17-x86_64-gold', 'image_id')
self.m.ReplayAll()
self.assertIsNone(server.validate())
@ -1868,7 +1869,7 @@ class ServersTest(HeatTestCase):
self.fc.limits.get().MultipleTimes().AndReturn(self.limits)
self.m.StubOutWithMock(nova.NovaClientPlugin, '_create')
nova.NovaClientPlugin._create().MultipleTimes().AndReturn(self.fc)
nova.NovaClientPlugin._create().AndReturn(self.fc)
self._mock_get_image_id_success('F17-x86_64-gold', 'image_id')
self.m.ReplayAll()
@ -1896,7 +1897,7 @@ class ServersTest(HeatTestCase):
self.fc.limits.get().MultipleTimes().AndReturn(self.limits)
self.m.StubOutWithMock(nova.NovaClientPlugin, '_create')
nova.NovaClientPlugin._create().MultipleTimes().AndReturn(self.fc)
nova.NovaClientPlugin._create().AndReturn(self.fc)
self._mock_get_image_id_success('F17-x86_64-gold', 'image_id')
self.m.ReplayAll()
@ -1917,7 +1918,7 @@ class ServersTest(HeatTestCase):
self.fc.limits.get().MultipleTimes().AndReturn(self.limits)
self.m.StubOutWithMock(nova.NovaClientPlugin, '_create')
nova.NovaClientPlugin._create().MultipleTimes().AndReturn(self.fc)
nova.NovaClientPlugin._create().AndReturn(self.fc)
self._mock_get_image_id_success('F17-x86_64-gold', 'image_id')
self.m.ReplayAll()
@ -1938,7 +1939,7 @@ class ServersTest(HeatTestCase):
self.fc.limits.get().MultipleTimes().AndReturn(self.limits)
self.m.StubOutWithMock(nova.NovaClientPlugin, '_create')
nova.NovaClientPlugin._create().MultipleTimes().AndReturn(self.fc)
nova.NovaClientPlugin._create().AndReturn(self.fc)
self._mock_get_image_id_success('F17-x86_64-gold', 'image_id')
self.m.ReplayAll()
@ -2004,7 +2005,7 @@ class ServersTest(HeatTestCase):
disk_config=None, reservation_id=None, files={},
admin_pass=None).AndReturn(return_server)
self.m.StubOutWithMock(nova.NovaClientPlugin, '_create')
nova.NovaClientPlugin._create().MultipleTimes().AndReturn(self.fc)
nova.NovaClientPlugin._create().AndReturn(self.fc)
self._mock_get_image_id_success('F17-x86_64-gold', image_id)
self.m.StubOutWithMock(nova_utils, 'build_userdata')
nova_utils.build_userdata(server,
@ -2508,7 +2509,7 @@ class FlavorConstraintTest(HeatTestCase):
client = fakes.FakeClient()
self.stub_keystoneclient()
self.m.StubOutWithMock(nova.NovaClientPlugin, '_create')
nova.NovaClientPlugin._create().MultipleTimes().AndReturn(client)
nova.NovaClientPlugin._create().AndReturn(client)
client.flavors = self.m.CreateMockAnything()
flavor = collections.namedtuple("Flavor", ["id", "name"])
@ -2518,8 +2519,9 @@ class FlavorConstraintTest(HeatTestCase):
self.m.ReplayAll()
constraint = servers.FlavorConstraint()
self.assertFalse(constraint.validate("bar", None))
self.assertTrue(constraint.validate("foo", None))
self.assertTrue(constraint.validate("1234", None))
ctx = utils.dummy_context()
self.assertFalse(constraint.validate("bar", ctx))
self.assertTrue(constraint.validate("foo", ctx))
self.assertTrue(constraint.validate("1234", ctx))
self.m.VerifyAll()

View File

@ -131,11 +131,13 @@ class ServerTagsTest(HeatTestCase):
super(ServerTagsTest, self).setUp()
self.fc = fakes.FakeClient()
def _mock_get_image_id_success(self, imageId_input, imageId):
def _mock_get_image_id_success(self, imageId_input, imageId,
mock_create=True):
g_cli_mock = self.m.CreateMockAnything()
self.m.StubOutWithMock(glance.GlanceClientPlugin, '_create')
glance.GlanceClientPlugin._create().MultipleTimes().AndReturn(
g_cli_mock)
if mock_create:
self.m.StubOutWithMock(glance.GlanceClientPlugin, '_create')
glance.GlanceClientPlugin._create().AndReturn(
g_cli_mock)
self.m.StubOutWithMock(glance_utils, 'get_image_id')
glance_utils.get_image_id(g_cli_mock, imageId_input).MultipleTimes().\
AndReturn(imageId)
@ -154,7 +156,7 @@ class ServerTagsTest(HeatTestCase):
resource_defns['WebServer'], stack)
self.m.StubOutWithMock(nova.NovaClientPlugin, '_create')
nova.NovaClientPlugin._create().MultipleTimes().AndReturn(self.fc)
nova.NovaClientPlugin._create().AndReturn(self.fc)
self._mock_get_image_id_success('CentOS 5.2', 1)
# need to resolve the template functions
server_userdata = nova_utils.build_userdata(
@ -204,13 +206,11 @@ class ServerTagsTest(HeatTestCase):
new_tags = [{'Key': 'Food', 'Value': 'yuk'}]
new_metadata = dict((tm['Key'], tm['Value']) for tm in new_tags)
self.m.StubOutWithMock(nova.NovaClientPlugin, '_create')
nova.NovaClientPlugin._create().MultipleTimes().AndReturn(self.fc)
self.m.StubOutWithMock(self.fc.servers, 'set_meta')
self.fc.servers.set_meta(self.fc.servers.list()[1],
new_metadata).AndReturn(None)
self._mock_get_image_id_success('CentOS 5.2', 1)
self._mock_get_image_id_success('CentOS 5.2', 1, False)
self.m.ReplayAll()
update_template = copy.deepcopy(instance.t)
update_template['Properties']['Tags'] = new_tags
@ -240,7 +240,7 @@ class ServerTagsTest(HeatTestCase):
group.name)
self.m.StubOutWithMock(nova.NovaClientPlugin, '_create')
nova.NovaClientPlugin._create().MultipleTimes().AndReturn(self.fc)
nova.NovaClientPlugin._create().AndReturn(self.fc)
self._mock_get_image_id_success('CentOS 5.2', 1)
# need to resolve the template functions
self.m.StubOutWithMock(self.fc.servers, 'create')
@ -289,7 +289,7 @@ class ServerTagsTest(HeatTestCase):
group._cooldown_timestamp(mox.IgnoreArg()).AndReturn(None)
self.m.StubOutWithMock(nova.NovaClientPlugin, '_create')
nova.NovaClientPlugin._create().MultipleTimes().AndReturn(self.fc)
nova.NovaClientPlugin._create().AndReturn(self.fc)
self._mock_get_image_id_success('CentOS 5.2', 1)
# need to resolve the template functions
self.m.StubOutWithMock(self.fc.servers, 'create')

View File

@ -98,7 +98,7 @@ class SqlAlchemyTest(HeatTestCase):
def _mock_get_image_id_success(self, imageId_input, imageId):
g_cli_mock = self.m.CreateMockAnything()
self.m.StubOutWithMock(glance.GlanceClientPlugin, '_create')
glance.GlanceClientPlugin._create().MultipleTimes().AndReturn(
glance.GlanceClientPlugin._create().AndReturn(
g_cli_mock)
self.m.StubOutWithMock(glance_utils, 'get_image_id')
glance_utils.get_image_id(g_cli_mock, imageId_input).MultipleTimes().\
@ -122,7 +122,7 @@ class SqlAlchemyTest(HeatTestCase):
mocks.StubOutWithMock(instances.Instance, 'nova')
instances.Instance.nova().MultipleTimes().AndReturn(fc)
self.m.StubOutWithMock(nova.NovaClientPlugin, '_create')
nova.NovaClientPlugin._create().MultipleTimes().AndReturn(self.fc)
nova.NovaClientPlugin._create().AndReturn(self.fc)
self._mock_get_image_id_success('F17-x86_64-gold', 744)
mocks.StubOutWithMock(fc.servers, 'create')

View File

@ -819,7 +819,7 @@ class validateTest(HeatTestCase):
def _mock_get_image_id_success(self, imageId_input, imageId):
g_cli_mock = self.m.CreateMockAnything()
self.m.StubOutWithMock(glance.GlanceClientPlugin, '_create')
glance.GlanceClientPlugin._create().MultipleTimes().AndReturn(
glance.GlanceClientPlugin._create().AndReturn(
g_cli_mock)
self.m.StubOutWithMock(glance_utils, 'get_image_id')
glance_utils.get_image_id(g_cli_mock, imageId_input).MultipleTimes().\
@ -828,7 +828,7 @@ class validateTest(HeatTestCase):
def _mock_get_image_id_fail(self, image_id, exp):
g_cli_mock = self.m.CreateMockAnything()
self.m.StubOutWithMock(glance.GlanceClientPlugin, '_create')
glance.GlanceClientPlugin._create().MultipleTimes().AndReturn(
glance.GlanceClientPlugin._create().AndReturn(
g_cli_mock)
self.m.StubOutWithMock(glance_utils, 'get_image_id')
glance_utils.get_image_id(g_cli_mock, image_id).AndRaise(exp)
@ -1265,7 +1265,7 @@ class validateTest(HeatTestCase):
self._mock_get_image_id_success('image_name', 'image_id')
self.m.StubOutWithMock(nova.NovaClientPlugin, '_create')
nova.NovaClientPlugin._create().MultipleTimes().AndReturn(self.fc)
nova.NovaClientPlugin._create().AndReturn(self.fc)
self.m.ReplayAll()
resource = stack['Instance']
@ -1282,7 +1282,7 @@ class validateTest(HeatTestCase):
self._mock_get_image_id_success('image_name', 'image_id')
self.m.StubOutWithMock(nova.NovaClientPlugin, '_create')
nova.NovaClientPlugin._create().MultipleTimes().AndReturn(self.fc)
nova.NovaClientPlugin._create().AndReturn(self.fc)
self.m.ReplayAll()
resource = stack['Instance']
@ -1299,7 +1299,7 @@ class validateTest(HeatTestCase):
self.gc.images.list().AndRaise(
glance_exceptions.ClientException(500))
self.m.StubOutWithMock(glance.GlanceClientPlugin, '_create')
glance.GlanceClientPlugin._create().MultipleTimes().AndReturn(self.gc)
glance.GlanceClientPlugin._create().AndReturn(self.gc)
self.m.ReplayAll()
self.assertRaises(exception.StackValidationFailed, stack.validate)

View File

@ -143,7 +143,7 @@ class VolumeTest(HeatTestCase):
return rsrc
def _mock_create_volume(self, fv, stack_name, size=1):
cinder.CinderClientPlugin._create().MultipleTimes().AndReturn(
cinder.CinderClientPlugin._create().AndReturn(
self.cinder_fc)
vol_name = utils.PhysName(stack_name, 'DataVolume')
self.cinder_fc.volumes.create(
@ -167,7 +167,7 @@ class VolumeTest(HeatTestCase):
device=u'/dev/vdc',
update=False):
if not update:
nova.NovaClientPlugin._create().MultipleTimes().AndReturn(self.fc)
nova.NovaClientPlugin._create().AndReturn(self.fc)
self.fc.volumes.create_server_volume(
device=device, server_id=server, volume_id=volume).AndReturn(fva)
self.cinder_fc.volumes.get(volume).AndReturn(fva)
@ -210,7 +210,7 @@ class VolumeTest(HeatTestCase):
stack_name = 'test_volume_stack'
# create script
nova.NovaClientPlugin._create().MultipleTimes().AndReturn(self.fc)
nova.NovaClientPlugin._create().AndReturn(self.fc)
self.m.StubOutWithMock(instance.Instance, 'handle_create')
self.m.StubOutWithMock(instance.Instance, 'check_create_complete')
self.m.StubOutWithMock(vol.VolumeAttachment, 'handle_create')
@ -218,7 +218,7 @@ class VolumeTest(HeatTestCase):
self.m.StubOutWithMock(image.ImageConstraint, "validate")
instance.Instance.handle_create().AndReturn(None)
instance.Instance.check_create_complete(None).AndReturn(True)
cinder.CinderClientPlugin._create().MultipleTimes().AndReturn(
cinder.CinderClientPlugin._create().AndReturn(
self.cinder_fc)
image.ImageConstraint.validate(
mox.IgnoreArg(), mox.IgnoreArg()).MultipleTimes().AndReturn(True)
@ -752,7 +752,7 @@ class VolumeTest(HeatTestCase):
fvbr = FakeBackupRestore('vol-123')
# create script
cinder.CinderClientPlugin._create().MultipleTimes().AndReturn(
cinder.CinderClientPlugin._create().AndReturn(
self.cinder_fc)
self.m.StubOutWithMock(self.cinder_fc.restores, 'restore')
self.cinder_fc.restores.restore('backup-123').AndReturn(fvbr)
@ -780,7 +780,7 @@ class VolumeTest(HeatTestCase):
fvbr = FakeBackupRestore('vol-123')
# create script
cinder.CinderClientPlugin._create().MultipleTimes().AndReturn(
cinder.CinderClientPlugin._create().AndReturn(
self.cinder_fc)
self.m.StubOutWithMock(self.cinder_fc.restores, 'restore')
self.cinder_fc.restores.restore('backup-123').AndReturn(fvbr)
@ -811,7 +811,7 @@ class VolumeTest(HeatTestCase):
fv = FakeVolume('creating', 'available')
stack_name = 'test_volume_stack'
cinder.CinderClientPlugin._create().MultipleTimes().AndReturn(
cinder.CinderClientPlugin._create().AndReturn(
self.cinder_fc)
self.cinder_fc.volumes.create(
size=1, availability_zone='nova',
@ -883,11 +883,11 @@ class VolumeTest(HeatTestCase):
fv = FakeVolumeWithStateTransition('downloading', 'available')
stack_name = 'test_volume_stack'
image_id = '46988116-6703-4623-9dbc-2bc6d284021b'
cinder.CinderClientPlugin._create().MultipleTimes().AndReturn(
cinder.CinderClientPlugin._create().AndReturn(
self.cinder_fc)
g_cli_mock = self.m.CreateMockAnything()
self.m.StubOutWithMock(glance.GlanceClientPlugin, '_create')
glance.GlanceClientPlugin._create().MultipleTimes().AndReturn(
glance.GlanceClientPlugin._create().AndReturn(
g_cli_mock)
self.m.StubOutWithMock(glance_utils, 'get_image_id')
glance_utils.get_image_id(g_cli_mock, image_id).MultipleTimes().\
@ -926,7 +926,7 @@ class VolumeTest(HeatTestCase):
fv = FakeVolume('creating', 'available')
stack_name = 'test_volume_stack'
cinder.CinderClientPlugin._create().MultipleTimes().AndReturn(
cinder.CinderClientPlugin._create().AndReturn(
self.cinder_fc)
vol_name = utils.PhysName(stack_name, 'DataVolume')
self.cinder_fc.volumes.create(
@ -963,7 +963,7 @@ class VolumeTest(HeatTestCase):
created_at='2013-02-25T02:40:21.000000')
stack_name = 'test_volume_stack'
cinder.CinderClientPlugin._create().MultipleTimes().AndReturn(
cinder.CinderClientPlugin._create().AndReturn(
self.cinder_fc)
vol_name = utils.PhysName(stack_name, 'DataVolume')
self.cinder_fc.volumes.create(