Revert "Store clients in context"

This commit caused a regression in tripleo when trying to signal
waitconditions.
This reverts commit de8b071acf.
Fixes-bug: #1344079

Change-Id: Ib87eb81b687497a6669da38cb43b4f525cafa754
This commit is contained in:
Derek Higgins 2014-07-19 09:17:05 +01:00
parent 9adf703a8a
commit 45f97e6a84
22 changed files with 127 additions and 159 deletions

View File

@ -15,7 +15,6 @@ 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
@ -59,7 +58,6 @@ 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()
@ -78,12 +76,6 @@ 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.context)
client_plugin = _mgr[name].plugin(self)
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, context):
self.context = context
self.clients = context.clients
def __init__(self, clients):
self.context = clients.context
self.clients = clients
self._client = None
def client(self):

View File

@ -18,6 +18,7 @@ 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
@ -574,8 +575,9 @@ class BaseCustomConstraint(object):
"value": value, "message": self._error_message}
def validate(self, value, context):
client = clients.Clients(context)
try:
self.validate_with_client(context.clients, value)
self.validate_with_client(client, value)
except self.expected_exceptions as e:
self._error_message = str(e)
return False

View File

@ -25,6 +25,7 @@ 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
@ -98,7 +99,7 @@ class Stack(collections.Mapping):
if use_stored_context:
self.context = self.stored_context()
self.clients = context.clients
self.clients = Clients(self.context)
# 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,7 +267,8 @@ class WatchRule(object):
return actions
def _to_ceilometer(self, data):
clients = self.context.clients
from heat.engine import clients
clients = clients.Clients(self.context)
sample = {}
sample['meter_type'] = 'gauge'

View File

@ -212,12 +212,11 @@ class AutoScalingGroupTest(HeatTestCase):
'http://127.0.0.1:8000/v1/waitcondition')
def _mock_get_image_id_success(self, imageId_input, imageId,
update_image=None, mock_create=True):
update_image=None):
g_cli_mock = self.m.CreateMockAnything()
if mock_create:
self.m.StubOutWithMock(glance.GlanceClientPlugin, '_create')
glance.GlanceClientPlugin._create().AndReturn(
g_cli_mock)
self.m.StubOutWithMock(glance.GlanceClientPlugin, '_create')
glance.GlanceClientPlugin._create().MultipleTimes().AndReturn(
g_cli_mock)
self.m.StubOutWithMock(glance_utils, 'get_image_id')
# If update_image is None (create case), validation for initial image
@ -264,7 +263,7 @@ class AutoScalingGroupTest(HeatTestCase):
cookie = object()
self.m.StubOutWithMock(nova.NovaClientPlugin, '_create')
nova.NovaClientPlugin._create().AndReturn(self.fc)
nova.NovaClientPlugin._create().MultipleTimes().AndReturn(self.fc)
# for load balancer setup
if setup_lb:
self._stub_lb_create()
@ -295,6 +294,10 @@ 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)
@ -509,8 +512,7 @@ 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,
mock_create=False)
update_image=update_image_id)
stack.validate()
self.m.ReplayAll()

View File

@ -27,8 +27,6 @@ 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
@ -49,8 +47,6 @@ 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
@ -71,8 +67,6 @@ 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
@ -88,8 +82,6 @@ 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
@ -109,8 +101,6 @@ 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'
@ -131,9 +121,7 @@ class ClientPluginTest(HeatTestCase):
con.tenant_id = "b363706f891f48019483f8bd6503c54b"
con.auth_token = "3bcc3d3a03f44e3d8377f9247b0ad155"
c = clients.Clients(con)
con.clients = c
plugin = FooClientsPlugin(con)
plugin = FooClientsPlugin(c)
cfg.CONF.set_override('ca_file', '/tmp/bar',
group='clients_heat')
@ -153,13 +141,11 @@ 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(con)
plugin = FooClientsPlugin(c)
# assert token is from keystone rather than context
# even though both are set
@ -171,13 +157,11 @@ 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(con)
plugin = FooClientsPlugin(c)
self.assertEqual('http://192.0.2.1/foo',
plugin.url_for(service_type='foo'))
@ -186,8 +170,6 @@ 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)
@ -200,7 +182,6 @@ 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))
@ -212,7 +193,6 @@ 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().AndReturn(fkc)
keystone.KeystoneClientPlugin._create().MultipleTimes().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().AndReturn(
glance.GlanceClientPlugin._create().MultipleTimes().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().AndReturn(fc)
nova.NovaClientPlugin._create().MultipleTimes().AndReturn(fc)
instance = stack['WebServer']
if mock_image_constraint:
setup_mock_for_image_constraint(mocks,
@ -644,7 +644,6 @@ 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(
@ -653,8 +652,8 @@ class StackServiceCreateUpdateDeleteTest(HeatTestCase):
'ImageId': 'CentOS 5.2',
'KeyName': 'test',
'InstanceType': 'm1.large'
},
context=self.ctx)
})
setup_mock_for_image_constraint(self.m, 'CentOS 5.2')
stack.validate()
resource.properties = Properties(
@ -662,8 +661,7 @@ 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,24 +17,21 @@ 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", ctx))
self.assertTrue(constraint.validate("foo", None))
@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", ctx))
self.assertFalse(constraint.validate("bar", None))

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

View File

@ -131,13 +131,11 @@ class ServerTagsTest(HeatTestCase):
super(ServerTagsTest, self).setUp()
self.fc = fakes.FakeClient()
def _mock_get_image_id_success(self, imageId_input, imageId,
mock_create=True):
def _mock_get_image_id_success(self, imageId_input, imageId):
g_cli_mock = self.m.CreateMockAnything()
if mock_create:
self.m.StubOutWithMock(glance.GlanceClientPlugin, '_create')
glance.GlanceClientPlugin._create().AndReturn(
g_cli_mock)
self.m.StubOutWithMock(glance.GlanceClientPlugin, '_create')
glance.GlanceClientPlugin._create().MultipleTimes().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)
@ -156,7 +154,7 @@ class ServerTagsTest(HeatTestCase):
resource_defns['WebServer'], stack)
self.m.StubOutWithMock(nova.NovaClientPlugin, '_create')
nova.NovaClientPlugin._create().AndReturn(self.fc)
nova.NovaClientPlugin._create().MultipleTimes().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(
@ -206,11 +204,13 @@ 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, False)
self._mock_get_image_id_success('CentOS 5.2', 1)
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().AndReturn(self.fc)
nova.NovaClientPlugin._create().MultipleTimes().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().AndReturn(self.fc)
nova.NovaClientPlugin._create().MultipleTimes().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().AndReturn(
glance.GlanceClientPlugin._create().MultipleTimes().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().AndReturn(self.fc)
nova.NovaClientPlugin._create().MultipleTimes().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().AndReturn(
glance.GlanceClientPlugin._create().MultipleTimes().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().AndReturn(
glance.GlanceClientPlugin._create().MultipleTimes().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().AndReturn(self.fc)
nova.NovaClientPlugin._create().MultipleTimes().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().AndReturn(self.fc)
nova.NovaClientPlugin._create().MultipleTimes().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().AndReturn(self.gc)
glance.GlanceClientPlugin._create().MultipleTimes().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().AndReturn(
cinder.CinderClientPlugin._create().MultipleTimes().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().AndReturn(self.fc)
nova.NovaClientPlugin._create().MultipleTimes().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().AndReturn(self.fc)
nova.NovaClientPlugin._create().MultipleTimes().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().AndReturn(
cinder.CinderClientPlugin._create().MultipleTimes().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().AndReturn(
cinder.CinderClientPlugin._create().MultipleTimes().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().AndReturn(
cinder.CinderClientPlugin._create().MultipleTimes().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().AndReturn(
cinder.CinderClientPlugin._create().MultipleTimes().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().AndReturn(
cinder.CinderClientPlugin._create().MultipleTimes().AndReturn(
self.cinder_fc)
g_cli_mock = self.m.CreateMockAnything()
self.m.StubOutWithMock(glance.GlanceClientPlugin, '_create')
glance.GlanceClientPlugin._create().AndReturn(
glance.GlanceClientPlugin._create().MultipleTimes().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().AndReturn(
cinder.CinderClientPlugin._create().MultipleTimes().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().AndReturn(
cinder.CinderClientPlugin._create().MultipleTimes().AndReturn(
self.cinder_fc)
vol_name = utils.PhysName(stack_name, 'DataVolume')
self.cinder_fc.volumes.create(