Merge "Remove logic for nova-network"
This commit is contained in:
commit
0adfd85b1d
@ -2627,15 +2627,6 @@ class Resource(status.ResourceStatus):
|
||||
self.context, self._stored_properties_data).id
|
||||
return self._rsrc_prop_data_id
|
||||
|
||||
def is_using_neutron(self):
|
||||
try:
|
||||
sess_client = self.client('neutron').httpclient
|
||||
if not sess_client.get_endpoint():
|
||||
return False
|
||||
except Exception:
|
||||
return False
|
||||
return True
|
||||
|
||||
@staticmethod
|
||||
def _make_resolver(ref):
|
||||
"""Return an attribute resolution method.
|
||||
|
@ -66,6 +66,11 @@ class ManilaShareNetwork(resource.Resource):
|
||||
properties.Schema.STRING,
|
||||
_('Nova network id.'),
|
||||
update_allowed=True,
|
||||
support_status=support.SupportStatus(
|
||||
status=support.HIDDEN,
|
||||
message=_('nova-network is no longer supported.'),
|
||||
version='21.0.0'
|
||||
)
|
||||
),
|
||||
DESCRIPTION: properties.Schema(
|
||||
properties.Schema.STRING,
|
||||
@ -119,19 +124,9 @@ class ManilaShareNetwork(resource.Resource):
|
||||
|
||||
def validate(self):
|
||||
super(ManilaShareNetwork, self).validate()
|
||||
if (self.properties[self.NEUTRON_NETWORK] and
|
||||
self.properties[self.NOVA_NETWORK]):
|
||||
raise exception.ResourcePropertyConflict(self.NEUTRON_NETWORK,
|
||||
self.NOVA_NETWORK)
|
||||
|
||||
if (self.properties[self.NOVA_NETWORK] and
|
||||
self.properties[self.NEUTRON_SUBNET]):
|
||||
raise exception.ResourcePropertyConflict(self.NEUTRON_SUBNET,
|
||||
self.NOVA_NETWORK)
|
||||
|
||||
if self.is_using_neutron() and self.properties[self.NOVA_NETWORK]:
|
||||
msg = _('With Neutron enabled you need to pass Neutron network '
|
||||
'and Neutron subnet instead of Nova network')
|
||||
if self.properties[self.NOVA_NETWORK]:
|
||||
msg = _('Nova network is no longer supported')
|
||||
raise exception.StackValidationFailed(message=msg)
|
||||
|
||||
if (self.properties[self.NEUTRON_NETWORK] and not
|
||||
@ -186,7 +181,6 @@ class ManilaShareNetwork(resource.Resource):
|
||||
name=self.properties[self.NAME],
|
||||
neutron_net_id=neutron_net_id,
|
||||
neutron_subnet_id=neutron_subnet_id,
|
||||
nova_net_id=self.properties[self.NOVA_NETWORK],
|
||||
description=self.properties[self.DESCRIPTION])
|
||||
self.resource_id_set(network.id)
|
||||
|
||||
@ -222,7 +216,6 @@ class ManilaShareNetwork(resource.Resource):
|
||||
name=prop_diff.get(self.NAME),
|
||||
neutron_net_id=neutron_net_id,
|
||||
neutron_subnet_id=neutron_subnet_id,
|
||||
nova_net_id=prop_diff.get(self.NOVA_NETWORK),
|
||||
description=prop_diff.get(self.DESCRIPTION))
|
||||
|
||||
def parse_live_resource_data(self, resource_properties, resource_data):
|
||||
|
@ -353,18 +353,8 @@ class TroveCluster(resource.Resource):
|
||||
datastore_type, datastore_version,
|
||||
self.DATASTORE_TYPE, self.DATASTORE_VERSION)
|
||||
|
||||
# check validity of instances' NETWORKS
|
||||
is_neutron = self.is_using_neutron()
|
||||
for instance in self.properties[self.INSTANCES]:
|
||||
for nic in instance[self.NETWORKS]:
|
||||
# 'nic.get(self.PORT) is not None' including two cases:
|
||||
# 1. has set port value in template
|
||||
# 2. using 'get_resource' to reference a new resource
|
||||
if not is_neutron and nic.get(self.PORT) is not None:
|
||||
msg = (_("Can not use %s property on Nova-network.")
|
||||
% self.PORT)
|
||||
raise exception.StackValidationFailed(message=msg)
|
||||
|
||||
if (nic.get(self.NET) is None and
|
||||
nic.get(self.PORT) is None):
|
||||
msg = (_("Either %(net)s or %(port)s must be provided.")
|
||||
|
@ -677,14 +677,8 @@ class Instance(resource.Resource):
|
||||
% {'dbs': missing_db, 'name': self.name})
|
||||
raise exception.StackValidationFailed(message=msg)
|
||||
|
||||
# check validity of NICS
|
||||
is_neutron = self.is_using_neutron()
|
||||
nics = self.properties[self.NICS]
|
||||
for nic in nics:
|
||||
if not is_neutron and nic.get(self.PORT):
|
||||
msg = _("Can not use %s property on Nova-network.") % self.PORT
|
||||
raise exception.StackValidationFailed(message=msg)
|
||||
|
||||
if (nic.get(self.NET) is None) == (nic.get(self.PORT) is None):
|
||||
msg = _("Either %(net)s or %(port)s must be provided.") % {
|
||||
'net': self.NET, 'port': self.PORT}
|
||||
|
@ -19,7 +19,6 @@ from neutronclient.common import exceptions as neutron_exc
|
||||
from neutronclient.v2_0 import client as neutronclient
|
||||
|
||||
from heat.common import template_format
|
||||
from heat.engine import resource
|
||||
from heat.engine import rsrc_defn
|
||||
from heat.engine import scheduler
|
||||
from heat.engine import stack as parser
|
||||
@ -79,14 +78,8 @@ Resources:
|
||||
neutronclient.Client, 'delete_security_group')
|
||||
self.m_usg = self.patchobject(
|
||||
neutronclient.Client, 'update_security_group')
|
||||
self.patchobject(resource.Resource, 'is_using_neutron',
|
||||
return_value=True)
|
||||
self.sg_name = utils.PhysName('test_stack', 'the_sg')
|
||||
|
||||
def mock_no_neutron(self):
|
||||
self.patchobject(resource.Resource, 'is_using_neutron',
|
||||
return_value=False)
|
||||
|
||||
def create_stack(self, templ):
|
||||
self.stack = self.parse_stack(template_format.parse(templ))
|
||||
self.assertIsNone(self.stack.create())
|
||||
|
@ -44,11 +44,6 @@ class DummyShareNetwork(object):
|
||||
self.network_type = '6'
|
||||
|
||||
|
||||
class ShareNetworkWithNova(share_network.ManilaShareNetwork):
|
||||
def is_using_neutron(self):
|
||||
return False
|
||||
|
||||
|
||||
class ManilaShareNetworkTest(common.HeatTestCase):
|
||||
|
||||
def setUp(self):
|
||||
@ -83,11 +78,8 @@ class ManilaShareNetworkTest(common.HeatTestCase):
|
||||
self.stub_NetworkConstraint_validate()
|
||||
self.stub_SubnetConstraint_validate()
|
||||
|
||||
def _create_network(self, name, snippet, stack, use_neutron=True):
|
||||
if not use_neutron:
|
||||
net = ShareNetworkWithNova(name, snippet, stack)
|
||||
else:
|
||||
net = share_network.ManilaShareNetwork(name, snippet, stack)
|
||||
def _create_network(self, name, snippet, stack):
|
||||
net = share_network.ManilaShareNetwork(name, snippet, stack)
|
||||
self.client.share_networks.create.return_value = DummyShareNetwork()
|
||||
self.client.share_networks.get.return_value = DummyShareNetwork()
|
||||
|
||||
@ -110,26 +102,7 @@ class ManilaShareNetworkTest(common.HeatTestCase):
|
||||
self.assertEqual('42', net.resource_id)
|
||||
net.client().share_networks.create.assert_called_with(
|
||||
name='1', description='2', neutron_net_id='3',
|
||||
neutron_subnet_id='4', nova_net_id=None)
|
||||
calls = [mock.call('42', '6'), mock.call('42', '7')]
|
||||
net.client().share_networks.add_security_service.assert_has_calls(
|
||||
calls, any_order=True)
|
||||
self.assertEqual('share_networks', net.entity)
|
||||
|
||||
def test_create_with_nova(self):
|
||||
t = template_format.parse(stack_template)
|
||||
t['resources']['share_network']['properties']['nova_network'] = 'n'
|
||||
del t['resources']['share_network']['properties']['neutron_network']
|
||||
del t['resources']['share_network']['properties']['neutron_subnet']
|
||||
stack = utils.parse_stack(t)
|
||||
rsrc_defn = stack.t.resource_definitions(stack)['share_network']
|
||||
net = self._create_network('share_network', rsrc_defn, stack,
|
||||
use_neutron=False)
|
||||
self.assertEqual((net.CREATE, net.COMPLETE), net.state)
|
||||
self.assertEqual('42', net.resource_id)
|
||||
net.client().share_networks.create.assert_called_with(
|
||||
name='1', description='2', neutron_net_id=None,
|
||||
neutron_subnet_id=None, nova_net_id='n')
|
||||
neutron_subnet_id='4')
|
||||
calls = [mock.call('42', '6'), mock.call('42', '7')]
|
||||
net.client().share_networks.add_security_service.assert_has_calls(
|
||||
calls, any_order=True)
|
||||
@ -145,7 +118,7 @@ class ManilaShareNetworkTest(common.HeatTestCase):
|
||||
self.assertEqual('42', net.resource_id)
|
||||
net.client().share_networks.create.assert_called_with(
|
||||
name='1', description='2', neutron_net_id='3',
|
||||
neutron_subnet_id='4', nova_net_id=None)
|
||||
neutron_subnet_id='4')
|
||||
calls = [mock.call('42', '6'), mock.call('42', '7')]
|
||||
net.client().share_networks.add_security_service.assert_has_calls(
|
||||
calls, any_order=True)
|
||||
@ -160,7 +133,7 @@ class ManilaShareNetworkTest(common.HeatTestCase):
|
||||
csn = self.client.share_networks
|
||||
csn.create.assert_called_with(
|
||||
name='1', description='2', neutron_net_id='3',
|
||||
neutron_subnet_id='4', nova_net_id=None)
|
||||
neutron_subnet_id='4')
|
||||
csn.add_security_service.assert_called_once_with('42', '6')
|
||||
|
||||
def test_validate_conflicting_net_subnet(self):
|
||||
@ -169,7 +142,6 @@ class ManilaShareNetworkTest(common.HeatTestCase):
|
||||
stack = utils.parse_stack(t)
|
||||
rsrc_defn = stack.t.resource_definitions(stack)['share_network']
|
||||
net = self._create_network('share_network', rsrc_defn, stack)
|
||||
net.is_using_neutron = mock.Mock(return_value=True)
|
||||
msg = ('Provided neutron_subnet does not belong '
|
||||
'to provided neutron_network.')
|
||||
self.assertRaisesRegex(exception.StackValidationFailed, msg,
|
||||
@ -192,7 +164,6 @@ class ManilaShareNetworkTest(common.HeatTestCase):
|
||||
'description': 'b',
|
||||
'neutron_net_id': 'c',
|
||||
'neutron_subnet_id': 'd',
|
||||
'nova_net_id': None
|
||||
}
|
||||
net.client().share_networks.update.assert_called_with('42', **exp_args)
|
||||
net.client().share_networks.add_security_service.assert_called_with(
|
||||
@ -224,43 +195,6 @@ class ManilaShareNetworkTest(common.HeatTestCase):
|
||||
run = scheduler.TaskRunner(net.update, update_template)
|
||||
self.assertRaises(exception.ResourceFailure, run)
|
||||
|
||||
def test_nova_net_neutron_net_conflict(self):
|
||||
t = template_format.parse(stack_template)
|
||||
t['resources']['share_network']['properties']['nova_network'] = 1
|
||||
stack = utils.parse_stack(t)
|
||||
rsrc_defn = stack.t.resource_definitions(stack)['share_network']
|
||||
net = self._create_network('share_network', rsrc_defn, stack)
|
||||
msg = ('Cannot define the following properties at the same time: '
|
||||
'neutron_network, nova_network.')
|
||||
self.assertRaisesRegex(exception.ResourcePropertyConflict, msg,
|
||||
net.validate)
|
||||
|
||||
def test_nova_net_neutron_subnet_conflict(self):
|
||||
t = template_format.parse(stack_template)
|
||||
t['resources']['share_network']['properties']['nova_network'] = 1
|
||||
del t['resources']['share_network']['properties']['neutron_network']
|
||||
stack = utils.parse_stack(t)
|
||||
rsrc_defn = stack.t.resource_definitions(stack)['share_network']
|
||||
net = self._create_network('share_network', rsrc_defn, stack)
|
||||
msg = ('Cannot define the following properties at the same time: '
|
||||
'neutron_subnet, nova_network.')
|
||||
self.assertRaisesRegex(exception.ResourcePropertyConflict, msg,
|
||||
net.validate)
|
||||
|
||||
def test_nova_net_while_using_neutron(self):
|
||||
t = template_format.parse(stack_template)
|
||||
t['resources']['share_network']['properties']['nova_network'] = 'n'
|
||||
del t['resources']['share_network']['properties']['neutron_network']
|
||||
del t['resources']['share_network']['properties']['neutron_subnet']
|
||||
stack = utils.parse_stack(t)
|
||||
rsrc_defn = stack.t.resource_definitions(stack)['share_network']
|
||||
net = self._create_network('share_network', rsrc_defn, stack)
|
||||
net.is_using_neutron = mock.Mock(return_value=True)
|
||||
msg = ('With Neutron enabled you need to pass Neutron network '
|
||||
'and Neutron subnet instead of Nova network')
|
||||
self.assertRaisesRegex(exception.StackValidationFailed, msg,
|
||||
net.validate)
|
||||
|
||||
def test_neutron_net_without_neutron_subnet(self):
|
||||
t = template_format.parse(stack_template)
|
||||
del t['resources']['share_network']['properties']['neutron_subnet']
|
||||
|
@ -123,8 +123,6 @@ class InstanceTest(common.HeatTestCase):
|
||||
self.patchobject(trove.TroveClientPlugin, '_create',
|
||||
return_value=self.client)
|
||||
self.stub_TroveFlavorConstraint_validate()
|
||||
self.patchobject(resource.Resource, 'is_using_neutron',
|
||||
return_value=True)
|
||||
self.flavor_resolve = self.patchobject(trove.TroveClientPlugin,
|
||||
'find_flavor_by_name_or_id',
|
||||
return_value='1')
|
||||
@ -143,18 +141,14 @@ class InstanceTest(common.HeatTestCase):
|
||||
rsrc.resource_id = '12345'
|
||||
return rsrc
|
||||
|
||||
def _stubout_validate(self, instance, neutron=None,
|
||||
mock_net_constraint=False,
|
||||
def _stubout_validate(self, instance, mock_net_constraint=False,
|
||||
with_port=True):
|
||||
if mock_net_constraint:
|
||||
self.stub_NetworkConstraint_validate()
|
||||
|
||||
self.client.datastore_versions.list.return_value = [FakeVersion()]
|
||||
|
||||
if neutron is not None:
|
||||
instance.is_using_neutron = mock.Mock(return_value=bool(neutron))
|
||||
if with_port:
|
||||
self.stub_PortConstraint_validate()
|
||||
if with_port:
|
||||
self.stub_PortConstraint_validate()
|
||||
|
||||
def test_instance_create(self):
|
||||
t = template_format.parse(db_template)
|
||||
@ -468,8 +462,7 @@ class InstanceTest(common.HeatTestCase):
|
||||
"network": "somenetuuid"
|
||||
}]
|
||||
instance = self._setup_test_instance('dbinstance_test', t)
|
||||
self._stubout_validate(instance, neutron=True,
|
||||
mock_net_constraint=True)
|
||||
self._stubout_validate(instance, mock_net_constraint=True)
|
||||
|
||||
ex = self.assertRaises(
|
||||
exception.StackValidationFailed, instance.validate)
|
||||
@ -483,27 +476,13 @@ class InstanceTest(common.HeatTestCase):
|
||||
"fixed_ip": "1.2.3.4"
|
||||
}]
|
||||
instance = self._setup_test_instance('dbinstance_test', t)
|
||||
self._stubout_validate(instance, neutron=True, with_port=False)
|
||||
self._stubout_validate(instance, with_port=False)
|
||||
|
||||
ex = self.assertRaises(
|
||||
exception.StackValidationFailed, instance.validate)
|
||||
self.assertEqual('Either network or port must be provided.',
|
||||
str(ex))
|
||||
|
||||
def test_instance_validation_nic_port_on_novanet_fails(self):
|
||||
t = template_format.parse(db_template)
|
||||
t['Resources']['MySqlCloudDB']['Properties']['networks'] = [
|
||||
{
|
||||
"port": "someportuuid",
|
||||
}]
|
||||
instance = self._setup_test_instance('dbinstance_test', t)
|
||||
self._stubout_validate(instance, neutron=False)
|
||||
|
||||
ex = self.assertRaises(
|
||||
exception.StackValidationFailed, instance.validate)
|
||||
self.assertEqual('Can not use port property on Nova-network.',
|
||||
str(ex))
|
||||
|
||||
def test_instance_create_with_port(self):
|
||||
t = template_format.parse(db_template_with_nics)
|
||||
instance = self._setup_test_instance('dbinstance_test', t)
|
||||
|
@ -1768,30 +1768,6 @@ class ResourceTest(common.HeatTestCase):
|
||||
'Test::Resource::resource',
|
||||
template_type='hot'))
|
||||
|
||||
def test_is_not_using_neutron_exception(self):
|
||||
snippet = rsrc_defn.ResourceDefinition('aresource',
|
||||
'GenericResourceType')
|
||||
res = resource.Resource('aresource', snippet, self.stack)
|
||||
mock_create = self.patch(
|
||||
'heat.engine.clients.os.neutron.NeutronClientPlugin._create')
|
||||
mock_create.side_effect = Exception()
|
||||
self.assertFalse(res.is_using_neutron())
|
||||
|
||||
def test_is_using_neutron_endpoint_lookup(self):
|
||||
snippet = rsrc_defn.ResourceDefinition('aresource',
|
||||
'GenericResourceType')
|
||||
res = resource.Resource('aresource', snippet, self.stack)
|
||||
client = mock.Mock()
|
||||
self.patchobject(client.httpclient, 'get_endpoint',
|
||||
return_value=None)
|
||||
self.patch(
|
||||
'heat.engine.clients.os.neutron.NeutronClientPlugin._create',
|
||||
return_value=client)
|
||||
self.assertFalse(res.is_using_neutron())
|
||||
self.patchobject(client.httpclient, 'get_endpoint',
|
||||
return_value=mock.Mock())
|
||||
self.assertTrue(res.is_using_neutron())
|
||||
|
||||
def _test_skip_validation_if_custom_constraint(self, tmpl):
|
||||
stack = parser.Stack(utils.dummy_context(), 'test', tmpl)
|
||||
stack.store()
|
||||
|
@ -16,7 +16,6 @@ import uuid
|
||||
|
||||
from heat.common import exception
|
||||
from heat.common import template_format
|
||||
from heat.engine import resource
|
||||
from heat.engine.resources.aws.ec2 import subnet as sn
|
||||
from heat.engine import scheduler
|
||||
from heat.engine import stack as parser
|
||||
@ -521,8 +520,6 @@ Resources:
|
||||
def mock_create_network_interface(
|
||||
self, security_groups=['0389f747-7785-4757-b7bb-2ab07e4b09c3']):
|
||||
|
||||
self.patchobject(resource.Resource, 'is_using_neutron',
|
||||
return_value=True)
|
||||
self.nic_name = utils.PhysName('test_stack', 'the_nic')
|
||||
self._port = {'network_id': 'aaaa',
|
||||
'fixed_ips': [{
|
||||
|
Loading…
x
Reference in New Issue
Block a user