Novaclient v2 instead of v1_1

Nova API v1.1 is now deprecated and causes warnings.

Change-Id: Ib4b57a308b7637f4015a07b4e888ccd6347cb947
Closes-Bug: #1437158
changes/57/167557/12
Michal Rostecki 8 years ago committed by Michał Rostecki
parent 216190ce48
commit d9d68cf52b
  1. 1
      MANIFEST.in
  2. 2
      contrib/nova_flavor/nova_flavor/tests/test_nova_flavor.py
  3. 2
      contrib/rackspace/rackspace/tests/test_rackspace_cloud_server.py
  4. 17
      heat/engine/clients/os/nova.py
  5. 6
      heat/tests/autoscaling/test_scaling_group.py
  6. 10
      heat/tests/aws/test_volume.py
  7. 10
      heat/tests/db/test_sqlalchemy_api.py
  8. 6
      heat/tests/neutron/test_neutron_loadbalancer.py
  9. 8
      heat/tests/neutron/test_neutron_security_group.py
  10. 0
      heat/tests/nova/__init__.py
  11. 12
      heat/tests/nova/fakes.py
  12. 12
      heat/tests/openstack/test_volume.py
  13. 10
      heat/tests/test_clients.py
  14. 12
      heat/tests/test_eip.py
  15. 12
      heat/tests/test_engine_service.py
  16. 6
      heat/tests/test_instance.py
  17. 4
      heat/tests/test_instance_group_update_policy.py
  18. 6
      heat/tests/test_instance_network.py
  19. 4
      heat/tests/test_loadbalancer.py
  20. 4
      heat/tests/test_nokey.py
  21. 8
      heat/tests/test_nova_client.py
  22. 6
      heat/tests/test_nova_floatingip.py
  23. 4
      heat/tests/test_nova_keypair.py
  24. 4
      heat/tests/test_nova_servergroup.py
  25. 12
      heat/tests/test_nova_utils.py
  26. 26
      heat/tests/test_security_group.py
  27. 14
      heat/tests/test_server.py
  28. 4
      heat/tests/test_server_tags.py
  29. 4
      heat/tests/test_template.py
  30. 6
      heat/tests/test_validate.py
  31. 4
      heat/tests/test_volume_utils.py
  32. 1
      heat/tests/v1_1/testfile.txt

@ -16,7 +16,6 @@ include heat/db/sqlalchemy/migrate_repo/README
include heat/openstack/common/README
include heat/tests/examples/tags.txt
include heat/tests/testing-overview.txt
include heat/tests/v1_1/testfile.txt
include heat/tests/policy/deny_stack_user.json
include heat/tests/policy/notallowed.json
graft contrib

@ -17,8 +17,8 @@ from heat.engine import parser
from heat.engine import resource
from heat.engine import template
from heat.tests import common
from heat.tests.nova import fakes
from heat.tests import utils
from heat.tests.v1_1 import fakes
from ..resources import nova_flavor # noqa

@ -25,8 +25,8 @@ from heat.engine import resource
from heat.engine import scheduler
from heat.engine import template
from heat.tests import common
from heat.tests.nova import fakes
from heat.tests import utils
from heat.tests.v1_1 import fakes
from ..resources import cloud_server # noqa

@ -20,9 +20,9 @@ import os
import pkgutil
import string
from novaclient import client as nc
from novaclient import exceptions
from novaclient import shell as novashell
from novaclient.v2 import client as nc
from oslo_config import cfg
from oslo_serialization import jsonutils
from oslo_utils import uuidutils
@ -39,6 +39,9 @@ from heat.engine import scheduler
LOG = logging.getLogger(__name__)
NOVACLIENT_VERSION = "2"
class NovaClientPlugin(client_plugin.ClientPlugin):
deferred_server_statuses = ['BUILD',
@ -55,10 +58,13 @@ class NovaClientPlugin(client_plugin.ClientPlugin):
exceptions_module = exceptions
def _create(self):
endpoint_type = self._get_client_option('nova', 'endpoint_type')
management_url = self.url_for(service_type='compute',
endpoint_type=endpoint_type)
computeshell = novashell.OpenStackComputeShell()
extensions = computeshell._discover_extensions("1.1")
extensions = computeshell._discover_extensions(NOVACLIENT_VERSION)
endpoint_type = self._get_client_option('nova', 'endpoint_type')
args = {
'project_id': self.context.tenant,
'auth_url': self.context.auth_url,
@ -73,10 +79,7 @@ class NovaClientPlugin(client_plugin.ClientPlugin):
'insecure': self._get_client_option('nova', 'insecure')
}
client = nc.Client(1.1, **args)
management_url = self.url_for(service_type='compute',
endpoint_type=endpoint_type)
client = nc.Client(**args)
client.client.auth_token = self.auth_token
client.client.management_url = management_url

@ -26,8 +26,8 @@ from heat.engine import rsrc_defn
from heat.engine import scheduler
from heat.tests.autoscaling import inline_templates
from heat.tests import common
from heat.tests.nova import fakes as fakes_nova
from heat.tests import utils
from heat.tests.v1_1 import fakes as fakes_v1_1
as_template = inline_templates.as_template
@ -520,7 +520,7 @@ def asg_tmpl_with_updt_policy():
class RollingUpdatePolicyTest(common.HeatTestCase):
def setUp(self):
super(RollingUpdatePolicyTest, self).setUp()
self.fc = fakes_v1_1.FakeClient()
self.fc = fakes_nova.FakeClient()
self.stub_keystoneclient(username='test_stack.CfnLBUser')
self.stub_ImageConstraint_validate()
self.stub_FlavorConstraint_validate()
@ -590,7 +590,7 @@ class RollingUpdatePolicyTest(common.HeatTestCase):
class RollingUpdatePolicyDiffTest(common.HeatTestCase):
def setUp(self):
super(RollingUpdatePolicyDiffTest, self).setUp()
self.fc = fakes_v1_1.FakeClient()
self.fc = fakes_nova.FakeClient()
self.stub_keystoneclient(username='test_stack.CfnLBUser')
cfg.CONF.set_default('heat_waitcondition_server_url',
'http://127.0.0.1:8000/v1/waitcondition')

@ -27,9 +27,9 @@ from heat.engine.resources.aws.ec2 import instance
from heat.engine.resources.aws.ec2 import volume as aws_vol
from heat.engine import rsrc_defn
from heat.engine import scheduler
from heat.tests.nova import fakes as fakes_nova
from heat.tests import test_volume_utils as vt_base
from heat.tests import utils
from heat.tests.v1_1 import fakes as fakes_v1_1
volume_template = '''
@ -251,7 +251,7 @@ class VolumeTest(vt_base.BaseVolumeTest):
self.fc.volumes.get_server_volume(u'WikiDatabase',
'vol-123').AndReturn(fva)
self.fc.volumes.get_server_volume(
u'WikiDatabase', 'vol-123').AndRaise(fakes_v1_1.fake_exception())
u'WikiDatabase', 'vol-123').AndRaise(fakes_nova.fake_exception())
self.m.ReplayAll()
@ -279,13 +279,13 @@ class VolumeTest(vt_base.BaseVolumeTest):
self.cinder_fc.volumes.get(fva.id).AndReturn(fva)
self.fc.volumes.delete_server_volume(
'WikiDatabase', 'vol-123').AndRaise(fakes_v1_1.fake_exception(400))
'WikiDatabase', 'vol-123').AndRaise(fakes_nova.fake_exception(400))
self.cinder_fc.volumes.get(fva.id).AndReturn(
vt_base.FakeVolume('available', id=fva.id))
self.fc.volumes.get_server_volume(u'WikiDatabase',
'vol-123').AndReturn(fva)
self.fc.volumes.get_server_volume(
u'WikiDatabase', 'vol-123').AndRaise(fakes_v1_1.fake_exception())
u'WikiDatabase', 'vol-123').AndRaise(fakes_nova.fake_exception())
self.m.ReplayAll()
stack = utils.parse_stack(self.t, stack_name=stack_name)
@ -370,7 +370,7 @@ class VolumeTest(vt_base.BaseVolumeTest):
self.fc.volumes.get_server_volume(u'WikiDatabase',
'vol-123').AndReturn(fva)
self.fc.volumes.get_server_volume(
u'WikiDatabase', 'vol-123').AndRaise(fakes_v1_1.fake_exception())
u'WikiDatabase', 'vol-123').AndRaise(fakes_nova.fake_exception())
self.m.ReplayAll()

@ -32,8 +32,8 @@ from heat.engine import resource as rsrc
from heat.engine.resources.aws.ec2 import instance as instances
from heat.engine import scheduler
from heat.tests import common
from heat.tests.nova import fakes as fakes_nova
from heat.tests import utils
from heat.tests.v1_1 import fakes as fakes_v1_1
wp_template = '''
@ -86,7 +86,7 @@ class MyResource(rsrc.Resource):
class SqlAlchemyTest(common.HeatTestCase):
def setUp(self):
super(SqlAlchemyTest, self).setUp()
self.fc = fakes_v1_1.FakeClient()
self.fc = fakes_nova.FakeClient()
self.ctx = utils.dummy_context()
def tearDown(self):
@ -111,7 +111,7 @@ class SqlAlchemyTest(common.HeatTestCase):
return (template, stack)
def _mock_create(self, mocks):
fc = fakes_v1_1.FakeClient()
fc = fakes_nova.FakeClient()
mocks.StubOutWithMock(instances.Instance, 'nova')
instances.Instance.nova().MultipleTimes().AndReturn(fc)
self.m.StubOutWithMock(nova.NovaClientPlugin, '_create')
@ -130,12 +130,12 @@ class SqlAlchemyTest(common.HeatTestCase):
return fc
def _mock_delete(self, mocks):
fc = fakes_v1_1.FakeClient()
fc = fakes_nova.FakeClient()
mocks.StubOutWithMock(instances.Instance, 'nova')
instances.Instance.nova().MultipleTimes().AndReturn(fc)
mocks.StubOutWithMock(fc.client, 'get_servers_9999')
get = fc.client.get_servers_9999
get().MultipleTimes().AndRaise(fakes_v1_1.fake_exception())
get().MultipleTimes().AndRaise(fakes_nova.fake_exception())
@mock.patch.object(db_api, '_paginate_query')
def test_filter_and_page_query_paginates_query(self, mock_paginate_query):

@ -27,8 +27,8 @@ from heat.engine.clients.os import nova
from heat.engine.resources.openstack.neutron import loadbalancer
from heat.engine import scheduler
from heat.tests import common
from heat.tests.nova import fakes as fakes_nova
from heat.tests import utils
from heat.tests.v1_1 import fakes as fakes_v1_1
health_monitor_template = '''
@ -847,7 +847,7 @@ class PoolMemberTest(common.HeatTestCase):
def setUp(self):
super(PoolMemberTest, self).setUp()
self.fc = fakes_v1_1.FakeClient()
self.fc = fakes_nova.FakeClient()
self.m.StubOutWithMock(neutronclient.Client, 'create_member')
self.m.StubOutWithMock(neutronclient.Client, 'delete_member')
self.m.StubOutWithMock(neutronclient.Client, 'update_member')
@ -948,7 +948,7 @@ class LoadBalancerTest(common.HeatTestCase):
def setUp(self):
super(LoadBalancerTest, self).setUp()
self.fc = fakes_v1_1.FakeClient()
self.fc = fakes_nova.FakeClient()
self.m.StubOutWithMock(neutronclient.Client, 'create_member')
self.m.StubOutWithMock(neutronclient.Client, 'delete_member')
self.m.StubOutWithMock(nova.NovaClientPlugin, '_create')

@ -13,8 +13,8 @@
from neutronclient.common import exceptions as neutron_exc
from neutronclient.v2_0 import client as neutronclient
from novaclient.v1_1 import security_group_rules as nova_sgr
from novaclient.v1_1 import security_groups as nova_sg
from novaclient.v2 import security_group_rules as nova_sgr
from novaclient.v2 import security_groups as nova_sg
from heat.common import exception
from heat.common import template_format
@ -22,8 +22,8 @@ from heat.engine import parser
from heat.engine import scheduler
from heat.engine import template
from heat.tests import common
from heat.tests.nova import fakes as fakes_nova
from heat.tests import utils
from heat.tests.v1_1 import fakes as fakes_v1_1
class SecurityGroupTest(common.HeatTestCase):
@ -85,7 +85,7 @@ Resources:
def setUp(self):
super(SecurityGroupTest, self).setUp()
self.fc = fakes_v1_1.FakeClient()
self.fc = fakes_nova.FakeClient()
self.m.StubOutWithMock(nova_sgr.SecurityGroupRuleManager, 'create')
self.m.StubOutWithMock(nova_sgr.SecurityGroupRuleManager, 'delete')
self.m.StubOutWithMock(nova_sg.SecurityGroupManager, 'create')

@ -17,13 +17,17 @@
import mock
from novaclient import client as base_client
from novaclient import exceptions as nova_exceptions
from novaclient.v1_1 import client
import requests
from six.moves.urllib import parse as urlparse
from heat.tests import fakes
NOVACLIENT_VERSION = "2"
Client = base_client.get_client_class(NOVACLIENT_VERSION)
def fake_exception(status_code=404, message=None, details=None):
resp = mock.Mock()
resp.status_code = status_code
@ -32,11 +36,11 @@ def fake_exception(status_code=404, message=None, details=None):
return nova_exceptions.from_response(resp, body, None)
class FakeClient(fakes.FakeClient, client.Client):
class FakeClient(fakes.FakeClient, Client):
def __init__(self, *args, **kwargs):
client.Client.__init__(self, 'username', 'password',
'project_id', 'auth_url')
super(FakeClient, self).__init__('username', 'password', 'project_id',
'auth_url')
self.client = FakeHTTPClient(**kwargs)

@ -25,9 +25,9 @@ from heat.engine.clients.os import glance
from heat.engine import rsrc_defn
from heat.engine import scheduler
from heat.objects import resource_data as resource_data_object
from heat.tests.nova import fakes as fakes_nova
from heat.tests import test_volume_utils as vt_base
from heat.tests import utils
from heat.tests.v1_1 import fakes as fakes_v1_1
cinder_volume_template = '''
heat_template_version: 2013-05-23
@ -265,7 +265,7 @@ class CinderVolumeTest(vt_base.BaseVolumeTest):
self.fc.volumes.get_server_volume(u'WikiDatabase',
'vol-123').AndReturn(fva)
self.fc.volumes.get_server_volume(
u'WikiDatabase', 'vol-123').AndRaise(fakes_v1_1.fake_exception())
u'WikiDatabase', 'vol-123').AndRaise(fakes_nova.fake_exception())
self.m.ReplayAll()
@ -431,7 +431,7 @@ class CinderVolumeTest(vt_base.BaseVolumeTest):
self.fc.volumes.get_server_volume(u'WikiDatabase',
'vol-123').AndReturn(fvd)
self.fc.volumes.get_server_volume(
u'WikiDatabase', 'vol-123').AndRaise(fakes_v1_1.fake_exception())
u'WikiDatabase', 'vol-123').AndRaise(fakes_nova.fake_exception())
# resize script
self.cinder_fc.volumes.extend(fvd.id, 2)
@ -671,7 +671,7 @@ class CinderVolumeTest(vt_base.BaseVolumeTest):
self.fc.volumes.get_server_volume(u'WikiDatabase',
'vol-123').AndReturn(fva)
self.fc.volumes.get_server_volume(
u'WikiDatabase', 'vol-123').AndRaise(fakes_v1_1.fake_exception())
u'WikiDatabase', 'vol-123').AndRaise(fakes_nova.fake_exception())
# attach script
self._mock_create_server_volume_script(vt_base.FakeVolume('attaching'),
@ -724,7 +724,7 @@ class CinderVolumeTest(vt_base.BaseVolumeTest):
self.fc.volumes.get_server_volume(u'WikiDatabase',
'vol-123').AndReturn(fva)
self.fc.volumes.get_server_volume(
u'WikiDatabase', 'vol-123').AndRaise(fakes_v1_1.fake_exception())
u'WikiDatabase', 'vol-123').AndRaise(fakes_nova.fake_exception())
# attach script
fv2a = vt_base.FakeVolume('attaching', id='vol-456')
@ -770,7 +770,7 @@ class CinderVolumeTest(vt_base.BaseVolumeTest):
self.fc.volumes.get_server_volume(u'WikiDatabase',
'vol-123').AndReturn(fva)
self.fc.volumes.get_server_volume(
u'WikiDatabase', 'vol-123').AndRaise(fakes_v1_1.fake_exception())
u'WikiDatabase', 'vol-123').AndRaise(fakes_nova.fake_exception())
# attach script
self._mock_create_server_volume_script(vt_base.FakeVolume('attaching'),

@ -34,8 +34,8 @@ from heat.engine import clients
from heat.engine.clients import client_plugin
from heat.tests import common
from heat.tests import fakes
from heat.tests.nova import fakes as fakes_nova
from heat.tests import utils
from heat.tests.v1_1 import fakes as fakes_v1_1
class ClientsTest(common.HeatTestCase):
@ -509,7 +509,7 @@ class TestIsNotFound(common.HeatTestCase):
is_conflict=False,
is_unprocessable_entity=False,
plugin='nova',
exception=lambda: fakes_v1_1.fake_exception(),
exception=lambda: fakes_nova.fake_exception(),
)),
('nova_exception', dict(
is_not_found=False,
@ -527,7 +527,7 @@ class TestIsNotFound(common.HeatTestCase):
is_conflict=False,
is_unprocessable_entity=False,
plugin='nova',
exception=lambda: fakes_v1_1.fake_exception(413),
exception=lambda: fakes_nova.fake_exception(413),
)),
('nova_unprocessable_entity', dict(
is_not_found=False,
@ -536,7 +536,7 @@ class TestIsNotFound(common.HeatTestCase):
is_conflict=False,
is_unprocessable_entity=True,
plugin='nova',
exception=lambda: fakes_v1_1.fake_exception(422),
exception=lambda: fakes_nova.fake_exception(422),
)),
('nova_conflict', dict(
is_not_found=False,
@ -545,7 +545,7 @@ class TestIsNotFound(common.HeatTestCase):
is_conflict=True,
is_unprocessable_entity=False,
plugin='nova',
exception=lambda: fakes_v1_1.fake_exception(409),
exception=lambda: fakes_nova.fake_exception(409),
)),
('swift_not_found', dict(
is_not_found=True,

@ -26,8 +26,8 @@ from heat.engine.resources.aws.ec2 import eip
from heat.engine import rsrc_defn
from heat.engine import scheduler
from heat.tests import common
from heat.tests.nova import fakes as fakes_nova
from heat.tests import utils
from heat.tests.v1_1 import fakes as fakes_v1_1
eip_template = '''
@ -160,7 +160,7 @@ class EIPTest(common.HeatTestCase):
def setUp(self):
# force Nova, will test Neutron below
super(EIPTest, self).setUp()
self.fc = fakes_v1_1.FakeClient()
self.fc = fakes_nova.FakeClient()
self.m.StubOutWithMock(nova.NovaClientPlugin, '_create')
self.m.StubOutWithMock(self.fc.servers, 'get')
@ -286,7 +286,7 @@ class EIPTest(common.HeatTestCase):
def test_eip_with_exception(self):
self.m.StubOutWithMock(self.fc.floating_ips, 'create')
nova.NovaClientPlugin._create().AndReturn(self.fc)
self.fc.floating_ips.create().AndRaise(fakes_v1_1.fake_exception())
self.fc.floating_ips.create().AndRaise(fakes_nova.fake_exception())
self.m.ReplayAll()
t = template_format.parse(eip_template)
@ -305,7 +305,7 @@ class EIPTest(common.HeatTestCase):
self.m.StubOutWithMock(self.fc.floating_ips, 'delete')
nova.NovaClientPlugin._create().AndReturn(self.fc)
self.fc.floating_ips.delete(mox.IsA(object)).AndRaise(
fakes_v1_1.fake_exception())
fakes_nova.fake_exception())
self.fc.servers.get(mox.IsA(object)).AndReturn(False)
self.m.ReplayAll()
@ -371,7 +371,7 @@ class AllocTest(common.HeatTestCase):
def setUp(self):
super(AllocTest, self).setUp()
self.fc = fakes_v1_1.FakeClient()
self.fc = fakes_nova.FakeClient()
self.m.StubOutWithMock(self.fc.servers, 'get')
self.m.StubOutWithMock(nova.NovaClientPlugin, '_create')
self.m.StubOutWithMock(parser.Stack, 'resource_by_refid')
@ -700,7 +700,7 @@ class AllocTest(common.HeatTestCase):
self._mock_server_get(mock_server=server, multiple=True)
self.m.StubOutWithMock(self.fc.servers, 'add_floating_ip')
self.fc.servers.add_floating_ip(server, '11.0.0.1').AndRaise(
fakes_v1_1.fake_exception(400))
fakes_nova.fake_exception(400))
self.m.ReplayAll()
t = template_format.parse(eip_template_ipassoc)

@ -61,8 +61,8 @@ from heat.rpc import worker_api
from heat.tests import common
from heat.tests import fakes as test_fakes
from heat.tests import generic_resource as generic_rsrc
from heat.tests.nova import fakes as fakes_nova
from heat.tests import utils
from heat.tests.v1_1 import fakes as fakes_v1_1
cfg.CONF.import_opt('engine_life_check_timeout', 'heat.common.config')
cfg.CONF.import_opt('enable_stack_abandon', 'heat.common.config')
@ -216,7 +216,7 @@ def setup_mock_for_image_constraint(mocks, imageId_input,
def setup_mocks(mocks, stack, mock_image_constraint=True,
mock_keystone=True):
fc = fakes_v1_1.FakeClient()
fc = fakes_nova.FakeClient()
mocks.StubOutWithMock(instances.Instance, 'nova')
instances.Instance.nova().MultipleTimes().AndReturn(fc)
mocks.StubOutWithMock(nova.NovaClientPlugin, '_create')
@ -270,12 +270,12 @@ def setup_stack(stack_name, ctx, create_res=True):
def clean_up_stack(stack, delete_res=True):
if delete_res:
m = mox.Mox()
fc = fakes_v1_1.FakeClient()
fc = fakes_nova.FakeClient()
m.StubOutWithMock(instances.Instance, 'nova')
instances.Instance.nova().MultipleTimes().AndReturn(fc)
m.StubOutWithMock(fc.client, 'get_servers_9999')
get = fc.client.get_servers_9999
get().AndRaise(fakes_v1_1.fake_exception())
get().AndRaise(fakes_nova.fake_exception())
m.ReplayAll()
stack.delete()
if delete_res:
@ -433,7 +433,7 @@ class StackCreateTest(common.HeatTestCase):
self.m.StubOutWithMock(fc.client, 'get_servers_9999')
get = fc.client.get_servers_9999
get().AndRaise(fakes_v1_1.fake_exception())
get().AndRaise(fakes_nova.fake_exception())
mox.Replay(get)
stack.delete()
@ -1671,7 +1671,7 @@ class StackServiceAuthorizeTest(common.HeatTestCase):
fc = setup_mocks(self.m, stack)
self.m.StubOutWithMock(fc.client, 'get_servers_9999')
get = fc.client.get_servers_9999
get().AndRaise(fakes_v1_1.fake_exception())
get().AndRaise(fakes_nova.fake_exception())
self.m.ReplayAll()
stack.store()

@ -32,8 +32,8 @@ from heat.engine import resource
from heat.engine.resources.aws.ec2 import instance as instances
from heat.engine import scheduler
from heat.tests import common
from heat.tests.nova import fakes as fakes_nova
from heat.tests import utils
from heat.tests.v1_1 import fakes as fakes_v1_1
wp_template = '''
@ -75,7 +75,7 @@ wp_template = '''
class InstancesTest(common.HeatTestCase):
def setUp(self):
super(InstancesTest, self).setUp()
self.fc = fakes_v1_1.FakeClient()
self.fc = fakes_nova.FakeClient()
def _setup_test_stack(self, stack_name):
t = template_format.parse(wp_template)
@ -603,7 +603,7 @@ class InstancesTest(common.HeatTestCase):
d2['server']['status'] = vm_delete_status
get().AndReturn((200, d2))
else:
get().AndRaise(fakes_v1_1.fake_exception())
get().AndRaise(fakes_nova.fake_exception())
self.m.ReplayAll()

@ -21,8 +21,8 @@ from heat.engine import function
from heat.engine.resources.openstack.heat import instance_group as instgrp
from heat.engine import rsrc_defn
from heat.tests import common
from heat.tests.nova import fakes as fakes_nova
from heat.tests import utils
from heat.tests.v1_1 import fakes as fakes_v1_1
ig_tmpl_without_updt_policy = '''
@ -156,7 +156,7 @@ class InstanceGroupTest(common.HeatTestCase):
def setUp(self):
super(InstanceGroupTest, self).setUp()
self.fc = fakes_v1_1.FakeClient()
self.fc = fakes_nova.FakeClient()
def get_launch_conf_name(self, stack, ig_name):
return stack[ig_name].properties['LaunchConfigurationName']

@ -24,8 +24,8 @@ from heat.engine.resources.aws.ec2 import instance as instances
from heat.engine.resources.aws.ec2 import network_interface as net_interfaces
from heat.engine import scheduler
from heat.tests import common
from heat.tests.nova import fakes as fakes_nova
from heat.tests import utils
from heat.tests.v1_1 import fakes as fakes_v1_1
wp_template = '''
@ -152,7 +152,7 @@ class FakeNeutron(object):
class instancesTest(common.HeatTestCase):
def setUp(self):
super(instancesTest, self).setUp()
self.fc = fakes_v1_1.FakeClient()
self.fc = fakes_nova.FakeClient()
def _mock_get_image_id_success(self, imageId_input, imageId):
self.m.StubOutWithMock(glance.GlanceClientPlugin, 'get_image_id')
@ -187,7 +187,7 @@ class instancesTest(common.HeatTestCase):
d2['server']['status'] = vm_delete_status
get().AndReturn((200, d2))
else:
get().AndRaise(fakes_v1_1.fake_exception())
get().AndRaise(fakes_nova.fake_exception())
self.m.ReplayAll()

@ -22,8 +22,8 @@ from heat.engine.clients.os import nova
from heat.engine.resources.aws.lb import loadbalancer as lb
from heat.engine import rsrc_defn
from heat.tests import common
from heat.tests.nova import fakes as fakes_nova
from heat.tests import utils
from heat.tests.v1_1 import fakes as fakes_v1_1
lb_template = '''
@ -72,7 +72,7 @@ lb_template = '''
class LoadBalancerTest(common.HeatTestCase):
def setUp(self):
super(LoadBalancerTest, self).setUp()
self.fc = fakes_v1_1.FakeClient()
self.fc = fakes_nova.FakeClient()
cfg.CONF.set_default('heat_waitcondition_server_url',
'http://server.test:8000/v1/waitcondition')

@ -17,8 +17,8 @@ from heat.engine.clients.os import nova
from heat.engine.resources.aws.ec2 import instance as instances
from heat.engine import scheduler
from heat.tests import common
from heat.tests.nova import fakes as fakes_nova
from heat.tests import utils
from heat.tests.v1_1 import fakes as fakes_v1_1
nokey_template = '''
@ -43,7 +43,7 @@ nokey_template = '''
class nokeyTest(common.HeatTestCase):
def setUp(self):
super(nokeyTest, self).setUp()
self.fc = fakes_v1_1.FakeClient()
self.fc = fakes_nova.FakeClient()
def test_nokey_create(self):

@ -23,8 +23,8 @@ import six
from heat.common import exception
from heat.engine.clients.os import nova
from heat.tests import common
from heat.tests.nova import fakes as fakes_nova
from heat.tests import utils
from heat.tests.v1_1 import fakes as fakes_v1_1
class NovaClientPluginTestCase(common.HeatTestCase):
@ -327,7 +327,7 @@ class ServerConstraintTest(common.HeatTestCase):
class FlavorConstraintTest(common.HeatTestCase):
def test_validate(self):
client = fakes_v1_1.FakeClient()
client = fakes_nova.FakeClient()
self.stub_keystoneclient()
self.patchobject(nova.NovaClientPlugin, '_create', return_value=client)
client.flavors = mock.MagicMock()
@ -351,14 +351,14 @@ class FlavorConstraintTest(common.HeatTestCase):
class KeypairConstraintTest(common.HeatTestCase):
def test_validation(self):
client = fakes_v1_1.FakeClient()
client = fakes_nova.FakeClient()
self.patchobject(nova.NovaClientPlugin, '_create', return_value=client)
client.keypairs = mock.MagicMock()
key = collections.namedtuple("Key", ["name"])
key.name = "foo"
client.keypairs.get.side_effect = [
fakes_v1_1.fake_exception(), key]
fakes_nova.fake_exception(), key]
constraint = nova.KeypairConstraint()
ctx = utils.dummy_context()

@ -23,8 +23,8 @@ from heat.engine.resources.openstack.nova import nova_floatingip
from heat.engine import rsrc_defn
from heat.engine import scheduler
from heat.tests import common
from heat.tests.nova import fakes as fakes_nova
from heat.tests import utils
from heat.tests.v1_1 import fakes as fakes_v1_1
floating_ip_template = '''
@ -148,7 +148,7 @@ class NovaFloatingIPTest(common.HeatTestCase):
def test_delete_floating_ip_assoc_successful_if_create_failed(self):
rsrc = self.prepare_floating_ip_assoc()
self.novaclient.servers.add_floating_ip(None, '11.0.0.1').AndRaise(
fakes_v1_1.fake_exception(400))
fakes_nova.fake_exception(400))
self.m.ReplayAll()
@ -215,7 +215,7 @@ class NovaFloatingIPTest(common.HeatTestCase):
)
self.novaclient.servers.remove_floating_ip("server",
"11.0.0.1").AndRaise(
fakes_v1_1.fake_exception(exc_code))
fakes_nova.fake_exception(exc_code))
self.m.ReplayAll()

@ -21,8 +21,8 @@ from heat.engine.clients.os import nova
from heat.engine.resources.openstack.nova import nova_keypair
from heat.engine import scheduler
from heat.tests import common
from heat.tests.nova import fakes as fakes_nova
from heat.tests import utils
from heat.tests.v1_1 import fakes as fakes_v1_1
class NovaKeyPairTest(common.HeatTestCase):
@ -158,7 +158,7 @@ class NovaKeyPairTest(common.HeatTestCase):
test_res.resource_id = "key_name"
test_res.state_set(test_res.CREATE, test_res.COMPLETE)
(self.fake_keypairs.delete("key_name")
.AndRaise(fakes_v1_1.fake_exception()))
.AndRaise(fakes_nova.fake_exception()))
self.m.ReplayAll()
scheduler.TaskRunner(test_res.delete)()
self.assertEqual((test_res.DELETE, test_res.COMPLETE), test_res.state)

@ -18,8 +18,8 @@ import mock
from heat.common import template_format
from heat.engine import scheduler
from heat.tests import common
from heat.tests.nova import fakes as fakes_nova
from heat.tests import utils
from heat.tests.v1_1 import fakes as fakes_v1_1
sg_template = {
"heat_template_version": "2013-05-23",
@ -100,7 +100,7 @@ class NovaServerGroupTest(common.HeatTestCase):
def test_sg_delete_not_found(self):
self._create_sg('test')
self.sg_mgr.delete.side_effect = fakes_v1_1.fake_exception()
self.sg_mgr.delete.side_effect = fakes_nova.fake_exception()
scheduler.TaskRunner(self.sg.delete)()
self.sg_mgr.delete.assert_called_once_with('test')
self.assertEqual((self.sg.DELETE, self.sg.COMPLETE),

@ -23,7 +23,7 @@ from heat.common import exception
from heat.engine import nova_utils
from heat.engine import scheduler
from heat.tests import common
from heat.tests.v1_1 import fakes as fakes_v1_1
from heat.tests.nova import fakes as fakes_nova
class NovaUtilsTests(common.HeatTestCase):
@ -91,7 +91,7 @@ class NovaUtilsTests(common.HeatTestCase):
self.nova_client.keypairs.get(
my_key_name).AndReturn(my_key)
self.nova_client.keypairs.get(
'notakey').AndRaise(fakes_v1_1.fake_exception())
'notakey').AndRaise(fakes_nova.fake_exception())
self.m.ReplayAll()
self.assertEqual(my_key, nova_utils.get_keypair(self.nova_client,
my_key_name))
@ -147,12 +147,12 @@ class NovaUtilsRefreshServerTests(common.HeatTestCase):
def test_overlimit_error(self):
server = mock.Mock()
server.get.side_effect = fakes_v1_1.fake_exception(413)
server.get.side_effect = fakes_nova.fake_exception(413)
self.assertIsNone(nova_utils.refresh_server(server))
def test_500_error(self):
server = self.m.CreateMockAnything()
server.get().AndRaise(fakes_v1_1.fake_exception(500))
server.get().AndRaise(fakes_nova.fake_exception(500))
self.m.ReplayAll()
self.assertIsNone(nova_utils.refresh_server(server))
@ -160,7 +160,7 @@ class NovaUtilsRefreshServerTests(common.HeatTestCase):
def test_503_error(self):
server = self.m.CreateMockAnything()
server.get().AndRaise(fakes_v1_1.fake_exception(503))
server.get().AndRaise(fakes_nova.fake_exception(503))
self.m.ReplayAll()
self.assertIsNone(nova_utils.refresh_server(server))
@ -168,7 +168,7 @@ class NovaUtilsRefreshServerTests(common.HeatTestCase):
def test_unhandled_exception(self):
server = self.m.CreateMockAnything()
server.get().AndRaise(fakes_v1_1.fake_exception(501))
server.get().AndRaise(fakes_nova.fake_exception(501))
self.m.ReplayAll()
self.assertRaises(nova_exceptions.ClientException,

@ -17,8 +17,8 @@ import copy
from keystoneclient import exceptions as keystone_exc
from neutronclient.common import exceptions as neutron_exc
from neutronclient.v2_0 import client as neutronclient
from novaclient.v1_1 import security_group_rules as nova_sgr
from novaclient.v1_1 import security_groups as nova_sg
from novaclient.v2 import security_group_rules as nova_sgr
from novaclient.v2 import security_groups as nova_sg
from heat.common import exception
from heat.common import template_format
@ -28,8 +28,8 @@ from heat.engine import rsrc_defn
from heat.engine import scheduler
from heat.engine import template
from heat.tests import common
from heat.tests.nova import fakes as fakes_nova
from heat.tests import utils
from heat.tests.v1_1 import fakes as fakes_v1_1
NovaSG = collections.namedtuple('NovaSG',
@ -130,7 +130,7 @@ Resources:
def setUp(self):
super(SecurityGroupTest, self).setUp()
self.fc = fakes_v1_1.FakeClient()
self.fc = fakes_nova.FakeClient()
self.m.StubOutWithMock(nova.NovaClientPlugin, '_create')
self.m.StubOutWithMock(nova_sgr.SecurityGroupRuleManager, 'create')
self.m.StubOutWithMock(nova_sgr.SecurityGroupRuleManager, 'delete')
@ -602,16 +602,16 @@ Resources:
nova_sgr.SecurityGroupRuleManager.create(
2, 'tcp', 22, 22, '0.0.0.0/0', None).AndRaise(
fakes_v1_1.fake_exception(400, 'Rule already exists'))
fakes_nova.fake_exception(400, 'Rule already exists'))
nova_sgr.SecurityGroupRuleManager.create(
2, 'tcp', 80, 80, '0.0.0.0/0', None).AndReturn(
fakes_v1_1.fake_exception(400, 'Rule already exists'))
fakes_nova.fake_exception(400, 'Rule already exists'))
nova_sgr.SecurityGroupRuleManager.create(
2, 'tcp', None, None, None, 1).AndReturn(
fakes_v1_1.fake_exception(400, 'Rule already exists'))
fakes_nova.fake_exception(400, 'Rule already exists'))
nova_sgr.SecurityGroupRuleManager.create(
2, 'icmp', None, None, None, '1').AndReturn(
fakes_v1_1.fake_exception(400, 'Rule already exists'))
fakes_nova.fake_exception(400, 'Rule already exists'))
# delete script
nova_sg.SecurityGroupManager.get(2).AndReturn(NovaSG(
@ -663,17 +663,17 @@ Resources:
}]
))
nova_sgr.SecurityGroupRuleManager.delete(130).AndRaise(
fakes_v1_1.fake_exception())
fakes_nova.fake_exception())
nova_sgr.SecurityGroupRuleManager.delete(131).AndRaise(
fakes_v1_1.fake_exception())
fakes_nova.fake_exception())
nova_sgr.SecurityGroupRuleManager.delete(132).AndRaise(
fakes_v1_1.fake_exception())
fakes_nova.fake_exception())
nova_sgr.SecurityGroupRuleManager.delete(133).AndRaise(
fakes_v1_1.fake_exception())
fakes_nova.fake_exception())
nova_sg.SecurityGroupManager.delete(2).AndReturn(None)
nova_sg.SecurityGroupManager.get(2).AndRaise(
fakes_v1_1.fake_exception())
fakes_nova.fake_exception())
self.m.ReplayAll()
stack = self.create_stack(self.test_template_nova)

@ -35,8 +35,8 @@ from heat.engine import scheduler
from heat.engine import template
from heat.objects import resource_data as resource_data_object
from heat.tests import common
from heat.tests.nova import fakes as fakes_nova
from heat.tests import utils
from heat.tests.v1_1 import fakes as fakes_v1_1
wp_template = '''
@ -98,7 +98,7 @@ resources:
class ServersTest(common.HeatTestCase):
def setUp(self):
super(ServersTest, self).setUp()
self.fc = fakes_v1_1.FakeClient()
self.fc = fakes_nova.FakeClient()
self.limits = self.m.CreateMockAnything()
self.limits.absolute = self._limits_absolute()
@ -1126,7 +1126,7 @@ class ServersTest(common.HeatTestCase):
self.m.StubOutWithMock(self.fc.client, 'get_servers_1234')
get = self.fc.client.get_servers_1234
get().AndReturn(server_get)
get().AndRaise(fakes_v1_1.fake_exception())
get().AndRaise(fakes_nova.fake_exception())
mox.Replay(get)
self.m.ReplayAll()
@ -1145,7 +1145,7 @@ class ServersTest(common.HeatTestCase):
self.m.StubOutWithMock(self.fc.client, 'get_servers_1234')
get = self.fc.client.get_servers_1234
get().AndRaise(fakes_v1_1.fake_exception())
get().AndRaise(fakes_nova.fake_exception())
mox.Replay(get)
scheduler.TaskRunner(server.delete)()
@ -1633,7 +1633,7 @@ class ServersTest(common.HeatTestCase):
server.resource_id = '1234'
self.m.StubOutWithMock(self.fc.client, 'get_servers_1234')
get = self.fc.client.get_servers_1234
get().AndRaise(fakes_v1_1.fake_exception())
get().AndRaise(fakes_nova.fake_exception())
mox.Replay(get)
self.m.ReplayAll()
@ -1802,7 +1802,7 @@ class ServersTest(common.HeatTestCase):
# return the SUSPENDED state first (twice, so we sleep)
self.m.StubOutWithMock(self.fc.client, 'get_servers_1234')
get = self.fc.client.get_servers_1234
get().AndRaise(fakes_v1_1.fake_exception())
get().AndRaise(fakes_nova.fake_exception())
self.m.ReplayAll()
server.state_set(server.SUSPEND, server.COMPLETE)
@ -2339,7 +2339,7 @@ class ServersTest(common.HeatTestCase):
server.resource_id = '1234'
self.m.StubOutWithMock(self.fc.client, 'get_servers_1234')
get = self.fc.client.get_servers_1234
get().AndRaise(fakes_v1_1.fake_exception())
get().AndRaise(fakes_nova.fake_exception())
mox.Replay(get)
self.m.ReplayAll()

@ -22,8 +22,8 @@ from heat.engine import parser
from heat.engine.resources.aws.ec2 import instance as instances
from heat.engine import scheduler
from heat.tests import common
from heat.tests.nova import fakes as fakes_nova
from heat.tests import utils
from heat.tests.v1_1 import fakes as fakes_v1_1
instance_template = '''
@ -55,7 +55,7 @@ instance_template = '''
class ServerTagsTest(common.HeatTestCase):
def setUp(self):
super(ServerTagsTest, self).setUp()
self.fc = fakes_v1_1.FakeClient()
self.fc = fakes_nova.FakeClient()
def _mock_get_image_id_success(self, imageId_input, imageId):
self.m.StubOutWithMock(glance.GlanceClientPlugin, 'get_image_id')

@ -35,8 +35,8 @@ from heat.engine import stack
from heat.engine import template
from heat.tests import common
from heat.tests import generic_resource as generic_rsrc
from heat.tests.nova import fakes as fakes_nova
from heat.tests import utils
from heat.tests.v1_1 import fakes as fakes_v1_1
mapping_template = template_format.parse('''{
@ -684,7 +684,7 @@ Mappings:
stk = stack.Stack(self.ctx, 'test_stack',
template.Template(empty_template))
self.m.StubOutWithMock(nova.NovaClientPlugin, '_create')
fc = fakes_v1_1.FakeClient()
fc = fakes_nova.FakeClient()
nova.NovaClientPlugin._create().AndReturn(fc)
self.m.ReplayAll()
self.assertEqual(["nova1"], self.resolve(snippet, tmpl, stk))

@ -25,8 +25,8 @@ from heat.engine import parser
from heat.engine import resources
from heat.engine import service
from heat.tests import common
from heat.tests.nova import fakes as fakes_nova
from heat.tests import utils
from heat.tests.v1_1 import fakes as fakes_v1_1
test_template_volumeattach = '''
{
@ -815,8 +815,8 @@ class validateTest(common.HeatTestCase):
def setUp(self):
super(validateTest, self).setUp()
resources.initialise()
self.fc = fakes_v1_1.FakeClient()
self.gc = fakes_v1_1.FakeClient()
self.fc = fakes_nova.FakeClient()
self.gc = fakes_nova.FakeClient()
resources.initialise()
self.ctx = utils.dummy_context()
self.patch('heat.engine.service.warnings')

@ -21,13 +21,13 @@ from heat.engine.resources.aws.ec2 import volume as aws_vol
from heat.engine.resources.openstack.cinder import volume as os_vol
from heat.engine import scheduler
from heat.tests import common
from heat.tests.v1_1 import fakes as fakes_v1_1
from heat.tests.nova import fakes as fakes_nova
class BaseVolumeTest(common.HeatTestCase):
def setUp(self):
super(BaseVolumeTest, self).setUp()
self.fc = fakes_v1_1.FakeClient()
self.fc = fakes_nova.FakeClient()
self.cinder_fc = cinderclient.Client('username', 'password')
self.cinder_fc.volume_api_version = 2
self.m.StubOutWithMock(cinder.CinderClientPlugin, '_create')

Loading…
Cancel
Save