Add standard attributes to the core network resources
Add the created_at, revision_number, and updated_at standard attributes to the core (floating IP, network, port, router, security group, security group rule, subnet and subnet pool) network resources. Change-Id: I1135eaf0f2bd36242ecbba1f440342cd1516ad7f Partially-Implements: blueprint network-command-sdk-support
This commit is contained in:
@@ -30,6 +30,8 @@ class FloatingIP(resource.Resource):
|
||||
allow_list = True
|
||||
|
||||
# Properties
|
||||
#: Timestamp when the floating IP was created.
|
||||
created_at = resource.prop('created_at')
|
||||
#: The floating IP description.
|
||||
description = resource.prop('description')
|
||||
#: The fixed IP address associated with the floating IP. If you
|
||||
@@ -47,10 +49,14 @@ class FloatingIP(resource.Resource):
|
||||
port_id = resource.prop('port_id')
|
||||
#: The ID of the project this floating IP is associated with.
|
||||
project_id = resource.prop('tenant_id')
|
||||
#: Revision number of the floating IP. *Type: int*
|
||||
revision_number = resource.prop('revision_number', type=int)
|
||||
#: The ID of an associated router.
|
||||
router_id = resource.prop('router_id')
|
||||
#: The floating IP status. Value is ``ACTIVE`` or ``DOWN``.
|
||||
status = resource.prop('status')
|
||||
#: Timestamp when the floating IP was last updated.
|
||||
updated_at = resource.prop('updated_at')
|
||||
|
||||
@classmethod
|
||||
def find_available(cls, session):
|
||||
|
||||
@@ -76,6 +76,8 @@ class Network(resource.Resource):
|
||||
#: An isolated segment ID on the physical network. The provider
|
||||
#: network type defines the segmentation model.
|
||||
provider_segmentation_id = resource.prop('provider:segmentation_id')
|
||||
#: Revision number of the network. *Type: int*
|
||||
revision_number = resource.prop('revision_number', type=int)
|
||||
segments = resource.prop('segments')
|
||||
#: The network status.
|
||||
status = resource.prop('status')
|
||||
|
||||
@@ -91,6 +91,8 @@ class Port(resource.Resource):
|
||||
project_id = resource.prop('tenant_id')
|
||||
#: The ID of the QoS policy attached to the port.
|
||||
qos_policy_id = resource.prop('qos_policy_id')
|
||||
#: Revision number of the port. *Type: int*
|
||||
revision_number = resource.prop('revision_number', type=int)
|
||||
#: The IDs of any attached security groups.
|
||||
#: *Type: list of strs of the security group IDs*
|
||||
security_group_ids = resource.prop('security_groups', type=list)
|
||||
|
||||
@@ -35,6 +35,8 @@ class Router(resource.Resource):
|
||||
#: Availability zones for the router.
|
||||
#: *Type: list of availability zone names*
|
||||
availability_zones = resource.prop('availability_zones')
|
||||
#: Timestamp when the router was created.
|
||||
created_at = resource.prop('created_at')
|
||||
#: The router description.
|
||||
description = resource.prop('description')
|
||||
#: The ``network_id``, for the external gateway. *Type: dict*
|
||||
@@ -52,10 +54,14 @@ class Router(resource.Resource):
|
||||
name = resource.prop('name')
|
||||
#: The ID of the project this router is associated with.
|
||||
project_id = resource.prop('tenant_id')
|
||||
#: Revision number of the router. *Type: int*
|
||||
revision_number = resource.prop('revision_number', type=int)
|
||||
#: The extra routes configuration for the router.
|
||||
routes = resource.prop('routes', type=list)
|
||||
#: The router status.
|
||||
status = resource.prop('status')
|
||||
#: Timestamp when the router was last updated.
|
||||
updated_at = resource.prop('updated_at')
|
||||
|
||||
def add_interface(self, session, **body):
|
||||
"""Add an internal interface to a logical router.
|
||||
|
||||
@@ -29,16 +29,22 @@ class SecurityGroup(resource.Resource):
|
||||
allow_list = True
|
||||
|
||||
# Properties
|
||||
#: Timestamp when the security group was created.
|
||||
created_at = resource.prop('created_at')
|
||||
#: The security group description.
|
||||
description = resource.prop('description')
|
||||
#: The security group name.
|
||||
name = resource.prop('name')
|
||||
#: The ID of the project this security group is associated with.
|
||||
project_id = resource.prop('tenant_id')
|
||||
#: Revision number of the security group. *Type: int*
|
||||
revision_number = resource.prop('revision_number', type=int)
|
||||
#: A list of
|
||||
#: :class:`~openstack.network.v2.security_group_rule.SecurityGroupRule`
|
||||
#: objects. *Type: list*
|
||||
security_group_rules = resource.prop('security_group_rules')
|
||||
#: Timestamp when the security group was last updated.
|
||||
updated_at = resource.prop('updated_at')
|
||||
|
||||
def __init__(self, attrs=None, loaded=False):
|
||||
super(SecurityGroup, self).__init__(attrs=attrs, loaded=loaded)
|
||||
|
||||
@@ -28,6 +28,8 @@ class SecurityGroupRule(resource.Resource):
|
||||
allow_list = True
|
||||
|
||||
# Properties
|
||||
#: Timestamp when the security group rule was created.
|
||||
created_at = resource.prop('created_at')
|
||||
#: ``ingress`` or ``egress``: The direction in which the security group
|
||||
#: rule is applied. For a compute instance, an ingress security group
|
||||
#: rule is applied to incoming ingress traffic for that instance.
|
||||
@@ -62,5 +64,9 @@ class SecurityGroupRule(resource.Resource):
|
||||
#: in the request body. This attribute matches the specified IP prefix
|
||||
#: as the source IP address of the IP packet.
|
||||
remote_ip_prefix = resource.prop('remote_ip_prefix')
|
||||
#: Revision number of the security group rule. *Type: int*
|
||||
revision_number = resource.prop('revision_number', type=int)
|
||||
#: The security group ID to associate with this security group rule.
|
||||
security_group_id = resource.prop('security_group_id')
|
||||
#: Timestamp when the security group rule was last updated.
|
||||
updated_at = resource.prop('updated_at')
|
||||
|
||||
@@ -58,6 +58,8 @@ class Subnet(resource.Resource):
|
||||
network_id = resource.prop('network_id')
|
||||
#: The ID of the project this subnet is associated with.
|
||||
project_id = resource.prop('tenant_id')
|
||||
#: Revision number of the subnet. *Type: int*
|
||||
revision_number = resource.prop('revision_number', type=int)
|
||||
#: The ID of the segment this subnet is associated with.
|
||||
segment_id = resource.prop('segment_id')
|
||||
#: Service types for this subnet
|
||||
|
||||
@@ -66,5 +66,7 @@ class SubnetPool(resource.Resource):
|
||||
#: The adjacent prefixes are merged and treated as a single prefix.
|
||||
#: *Type: list*
|
||||
prefixes = resource.prop('prefixes', type=list)
|
||||
#: Revision number of the subnet pool. *Type: int*
|
||||
revision_number = resource.prop('revision_number', type=int)
|
||||
#: Timestamp when the subnet pool was last updated.
|
||||
updated_at = resource.prop('updated_at')
|
||||
|
||||
@@ -26,6 +26,9 @@ EXAMPLE = {
|
||||
'router_id': '7',
|
||||
'description': '8',
|
||||
'status': 'ACTIVE',
|
||||
'created_at': '2016-10-04T12:14:57.233772',
|
||||
'updated_at': '2016-10-12T12:15:34.233222',
|
||||
'revision_number': 12,
|
||||
}
|
||||
|
||||
|
||||
@@ -56,6 +59,9 @@ class TestFloatingIP(testtools.TestCase):
|
||||
self.assertEqual(EXAMPLE['router_id'], sot.router_id)
|
||||
self.assertEqual(EXAMPLE['description'], sot.description)
|
||||
self.assertEqual(EXAMPLE['status'], sot.status)
|
||||
self.assertEqual(EXAMPLE['created_at'], sot.created_at)
|
||||
self.assertEqual(EXAMPLE['updated_at'], sot.updated_at)
|
||||
self.assertEqual(EXAMPLE['revision_number'], sot.revision_number)
|
||||
|
||||
def test_find_available(self):
|
||||
mock_session = mock.Mock()
|
||||
|
||||
@@ -38,6 +38,7 @@ EXAMPLE = {
|
||||
'created_at': '2016-03-09T12:14:57.233772',
|
||||
'updated_at': '2016-07-09T12:14:57.233772',
|
||||
'is_default': False,
|
||||
'revision_number': 23,
|
||||
}
|
||||
|
||||
|
||||
@@ -86,3 +87,4 @@ class TestNetwork(testtools.TestCase):
|
||||
self.assertEqual(EXAMPLE['created_at'], sot.created_at)
|
||||
self.assertEqual(EXAMPLE['updated_at'], sot.updated_at)
|
||||
self.assertFalse(sot.is_default)
|
||||
self.assertEqual(EXAMPLE['revision_number'], sot.revision_number)
|
||||
|
||||
@@ -41,6 +41,7 @@ EXAMPLE = {
|
||||
'qos_policy_id': '22',
|
||||
'created_at': '2016-03-09T12:14:57.233772',
|
||||
'updated_at': '2016-07-09T12:14:57.233772',
|
||||
'revision_number': 25,
|
||||
}
|
||||
|
||||
|
||||
@@ -87,3 +88,4 @@ class TestPort(testtools.TestCase):
|
||||
self.assertEqual(EXAMPLE['qos_policy_id'], sot.qos_policy_id)
|
||||
self.assertEqual(EXAMPLE['created_at'], sot.created_at)
|
||||
self.assertEqual(EXAMPLE['updated_at'], sot.updated_at)
|
||||
self.assertEqual(EXAMPLE['revision_number'], sot.revision_number)
|
||||
|
||||
@@ -27,6 +27,9 @@ EXAMPLE = {
|
||||
'availability_zone_hints': [],
|
||||
'availability_zones': [],
|
||||
'description': '10',
|
||||
'created_at': '2016-10-04T12:14:57.233772',
|
||||
'updated_at': '2016-10-12T12:15:34.233222',
|
||||
'revision_number': 13,
|
||||
}
|
||||
|
||||
EXAMPLE_WITH_OPTIONAL = {
|
||||
@@ -78,6 +81,9 @@ class TestRouter(testtools.TestCase):
|
||||
self.assertEqual(EXAMPLE['availability_zones'],
|
||||
sot.availability_zones)
|
||||
self.assertEqual(EXAMPLE['description'], sot.description)
|
||||
self.assertEqual(EXAMPLE['created_at'], sot.created_at)
|
||||
self.assertEqual(EXAMPLE['updated_at'], sot.updated_at)
|
||||
self.assertEqual(EXAMPLE['revision_number'], sot.revision_number)
|
||||
|
||||
def test_make_it_with_optional(self):
|
||||
sot = router.Router(EXAMPLE_WITH_OPTIONAL)
|
||||
|
||||
@@ -28,6 +28,9 @@ RULES = [
|
||||
"port_range_min": None,
|
||||
"id": "5",
|
||||
"security_group_id": IDENTIFIER,
|
||||
"created_at": "2016-10-04T12:14:57.233772",
|
||||
"updated_at": "2016-10-12T12:15:34.233222",
|
||||
"revision_number": 6,
|
||||
},
|
||||
{
|
||||
"remote_group_id": "9",
|
||||
@@ -40,6 +43,9 @@ RULES = [
|
||||
"port_range_min": None,
|
||||
"id": "6",
|
||||
"security_group_id": IDENTIFIER,
|
||||
"created_at": "2016-10-04T12:14:57.233772",
|
||||
"updated_at": "2016-10-12T12:15:34.233222",
|
||||
"revision_number": 7,
|
||||
},
|
||||
]
|
||||
EXAMPLE = {
|
||||
|
||||
@@ -27,6 +27,9 @@ EXAMPLE = {
|
||||
'remote_ip_prefix': '9',
|
||||
'security_group_id': '10',
|
||||
'description': '11',
|
||||
'created_at': '2016-10-04T12:14:57.233772',
|
||||
'updated_at': '2016-10-12T12:15:34.233222',
|
||||
'revision_number': 14,
|
||||
}
|
||||
|
||||
|
||||
@@ -57,3 +60,6 @@ class TestSecurityGroupRule(testtools.TestCase):
|
||||
self.assertEqual(EXAMPLE['remote_ip_prefix'], sot.remote_ip_prefix)
|
||||
self.assertEqual(EXAMPLE['security_group_id'], sot.security_group_id)
|
||||
self.assertEqual(EXAMPLE['description'], sot.description)
|
||||
self.assertEqual(EXAMPLE['created_at'], sot.created_at)
|
||||
self.assertEqual(EXAMPLE['updated_at'], sot.updated_at)
|
||||
self.assertEqual(EXAMPLE['revision_number'], sot.revision_number)
|
||||
|
||||
@@ -35,6 +35,7 @@ EXAMPLE = {
|
||||
'created_at': '2016-03-09T12:14:57.233772',
|
||||
'updated_at': '2016-07-09T12:14:57.233772',
|
||||
'segment_id': '16',
|
||||
'revision_number': 17,
|
||||
}
|
||||
|
||||
|
||||
@@ -73,3 +74,4 @@ class TestSubnet(testtools.TestCase):
|
||||
self.assertEqual(EXAMPLE['updated_at'], sot.updated_at)
|
||||
self.assertEqual(EXAMPLE['segment_id'], sot.segment_id)
|
||||
self.assertEqual(EXAMPLE['service_types'], sot.service_types)
|
||||
self.assertEqual(EXAMPLE['revision_number'], sot.revision_number)
|
||||
|
||||
@@ -31,6 +31,7 @@ EXAMPLE = {
|
||||
'created_at': '2016-03-09T12:14:57.233772',
|
||||
'updated_at': '2016-07-09T12:14:57.233772',
|
||||
'is_default': True,
|
||||
'revision_number': 16,
|
||||
}
|
||||
|
||||
|
||||
@@ -68,3 +69,4 @@ class TestSubnetpool(testtools.TestCase):
|
||||
self.assertEqual(EXAMPLE['created_at'], sot.created_at)
|
||||
self.assertEqual(EXAMPLE['updated_at'], sot.updated_at)
|
||||
self.assertTrue(sot.is_default)
|
||||
self.assertEqual(EXAMPLE['revision_number'], sot.revision_number)
|
||||
|
||||
Reference in New Issue
Block a user