Add segments attribute to OS::Neutron::Net
Adds a attribute to the neutron Net resource to get the segments of a network. Story: 2001988 Task: 19610 Change-Id: I7acb3d29a01fa92bebdb2c85094655e27cb16a29
This commit is contained in:
parent
066f95815a
commit
6e4831cc49
@ -42,10 +42,12 @@ class Net(neutron.NeutronResource):
|
||||
|
||||
ATTRIBUTES = (
|
||||
STATUS, NAME_ATTR, SUBNETS, ADMIN_STATE_UP_ATTR, TENANT_ID_ATTR,
|
||||
PORT_SECURITY_ENABLED_ATTR, MTU_ATTR, QOS_POLICY_ATTR, L2_ADJACENCY
|
||||
PORT_SECURITY_ENABLED_ATTR, MTU_ATTR, QOS_POLICY_ATTR, L2_ADJACENCY,
|
||||
SEGMENTS,
|
||||
) = (
|
||||
"status", "name", "subnets", "admin_state_up", "tenant_id",
|
||||
"port_security_enabled", "mtu", 'qos_policy_id', 'l2_adjacency'
|
||||
"port_security_enabled", "mtu", 'qos_policy_id', 'l2_adjacency',
|
||||
'segments',
|
||||
)
|
||||
|
||||
properties_schema = {
|
||||
@ -167,6 +169,11 @@ class Net(neutron.NeutronResource):
|
||||
type=attributes.Schema.BOOLEAN,
|
||||
support_status=support.SupportStatus(version='9.0.0'),
|
||||
),
|
||||
SEGMENTS: attributes.Schema(
|
||||
_("The segments of this network."),
|
||||
type=attributes.Schema.LIST,
|
||||
support_status=support.SupportStatus(version='11.0.0'),
|
||||
),
|
||||
}
|
||||
|
||||
def translation_rules(self, properties):
|
||||
@ -273,6 +280,15 @@ class Net(neutron.NeutronResource):
|
||||
pass
|
||||
return result
|
||||
|
||||
def _resolve_attribute(self, name):
|
||||
if self.resource_id is None:
|
||||
return
|
||||
if name == self.SEGMENTS:
|
||||
return [segment.to_dict() for segment in list(self.client(
|
||||
'openstack').network.segments(network_id=self.resource_id))]
|
||||
attributes = self._show_resource()
|
||||
return attributes[name]
|
||||
|
||||
|
||||
def resource_mapping():
|
||||
return {
|
||||
|
@ -27,7 +27,7 @@ from heat.tests import utils
|
||||
|
||||
|
||||
neutron_template = '''
|
||||
heat_template_version: 2015-04-30
|
||||
heat_template_version: rocky
|
||||
description: Template to test network Neutron resource
|
||||
resources:
|
||||
network:
|
||||
@ -288,7 +288,7 @@ class NeutronNetTest(common.HeatTestCase):
|
||||
|
||||
def test_net_get_live_state(self):
|
||||
tmpl = """
|
||||
heat_template_version: 2015-10-15
|
||||
heat_template_version: rocky
|
||||
resources:
|
||||
net:
|
||||
type: OS::Neutron::Net
|
||||
|
@ -0,0 +1,14 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
Adds a new attribute ``segments`` to the ``OS::Neutron::Net`` resource.
|
||||
The attribute resolves the network segments on the network. The attribute
|
||||
is useful when migrating from a non routed provider network to a routed
|
||||
provider network. The example below show how to migrate an existing subnet
|
||||
to one that is associated with the segment::
|
||||
|
||||
TestSubnet:
|
||||
type: OS::Neutron::Subnet
|
||||
name: the_subnet
|
||||
properties:
|
||||
segment: {get_attr: [the_network, segments, 0, id]}
|
Loading…
Reference in New Issue
Block a user