Basic resource.prop for ID attributes (network)

This patch set updates all network resource objects to use basic
properties for ID attributes. In particular, the following changes
were made:
  - Use basic *_id resource.prop for ID attributes
  - Use list *_ids resource.prop for attributes containing a list of IDs
  - Clarify documentation for ID attributes

Change-Id: I725095bb07da55148e29c511e7e8506bc7dbb7ca
Partial-Bug: #1461200
This commit is contained in:
Richard Theis
2016-01-21 10:13:59 -06:00
parent 5d723e1d26
commit f71f6f0f13
25 changed files with 72 additions and 72 deletions

View File

@@ -23,6 +23,6 @@ def delete_network(conn):
example_network = conn.network.find_network(
'openstacksdk-example-project-network')
for example_subnet in example_network.subnets:
for example_subnet in example_network.subnet_ids:
conn.network.delete_subnet(example_subnet, ignore_missing=False)
conn.network.delete_network(example_network, ignore_missing=False)

View File

@@ -43,7 +43,7 @@ class FloatingIP(resource.Resource):
floating_network_id = resource.prop('floating_network_id')
#: The port ID.
port_id = resource.prop('port_id')
#: The project this floating IP is associated with.
#: The ID of the project this floating IP is associated with.
project_id = resource.prop('tenant_id')
#: The ID of an associated router.
router_id = resource.prop('router_id')

View File

@@ -39,9 +39,10 @@ class HealthMonitor(resource.Resource):
http_method = resource.prop('http_method')
#: Maximum consecutive health probe tries.
max_retries = resource.prop('max_retries')
#: List of IDs of lbaas pools healthmonitor assocaited with
pools = resource.prop('pools')
#: Owner of the VIP
#: List of pools associated with this health monitor
#: *Type: list of dicts which contain the pool IDs*
pool_ids = resource.prop('pools', type=list)
#: The ID of the project this health monitor is associated with.
project_id = resource.prop('tenant_id')
#: The maximum number of seconds for a monitor to wait for a connection
#: to be established before it times out. This value must be less than

View File

@@ -40,12 +40,12 @@ class Listener(resource.Resource):
default_tls_container_ref = resource.prop('default_tls_container_ref')
#: Description for the listener.
description = resource.prop('description')
#: List of IDs of load_balancers associate with this listener.
#: *Type: list*
loadbalancers = resource.prop('loadbalancers')
#: List of load balancers associated with this listener.
#: *Type: list of dicts which contain the load balancer IDs*
load_balancer_ids = resource.prop('loadbalancers')
#: Name of the listener
name = resource.prop('name')
#: The project this listener is associated with.
#: The ID of the project this listener is associated with.
project_id = resource.prop('tenant_id')
#: The protocol of the listener, which is TCP, HTTP, HTTPS
#: or TERMINATED_HTTPS.

View File

@@ -28,23 +28,23 @@ class LoadBalancer(resource.Resource):
allow_list = True
# Properties
#: The administrative state of the load_balancer, which is up
#: The administrative state of the load balancer, which is up
#: ``True`` or down ``False``. *Type: bool*
admin_state_up = resource.prop('admin_state_up', type=bool)
#: Description for the load_balancer.
#: Description for the load balancer.
description = resource.prop('description')
#: List of IDs of listeners associated with this load_balancer.
#: *Type: list*
listeners = resource.prop('listeners')
#: Name of the load_balancer
#: List of listeners associated with this load balancer.
#: *Type: list of dicts which contain the listener IDs*
listener_ids = resource.prop('listeners', type=list)
#: Name of the load balancer
name = resource.prop('name')
#: Status of load_balancer operating, e.g. ONLINE, OFFLINE.
operating_status = resource.prop('operating_status')
#: The project this load_balancer is associated with.
#: The ID of the project this load balancer is associated with.
project_id = resource.prop('tenant_id')
#: The name of the provider.
provider = resource.prop('provider')
#: Status of load_balancer provisioning, e.g. ACTIVE, INACTIVE.
#: Status of load balancer provisioning, e.g. ACTIVE, INACTIVE.
provisioning_status = resource.prop('provisioning_status')
#: The IP address of the VIP.
vip_address = resource.prop('vip_address')

View File

@@ -28,9 +28,9 @@ class MeteringLabel(resource.Resource):
allow_list = True
# Properties
#: Description of the label.
#: Description of the metering label.
description = resource.prop('description')
#: Name of the label.
#: Name of the metering label.
name = resource.prop('name')
#: Project this label is associated with.
#: The ID of the project this metering label is associated with.
project_id = resource.prop('tenant_id')

View File

@@ -28,7 +28,7 @@ class MeteringLabelRule(resource.Resource):
allow_list = True
# Properties
#: ingress or egress: The direction in which metering rule is
#: ingress or egress: The direction in which metering label rule is
#: applied. Default: ``"ingress"``
direction = resource.prop('direction')
#: Specify whether the ``remote_ip_prefix`` will be excluded or not
@@ -36,7 +36,7 @@ class MeteringLabelRule(resource.Resource):
#: traffic of a specific IP address of a range. Default: ``False``,
#: *Type: bool*
excluded = resource.prop('excluded', type=bool)
#: The meteting label ID to associate with this metering rule.
#: The metering label ID to associate with this metering label rule.
metering_label_id = resource.prop('metering_label_id')
#: The remote IP prefix to be associated with this metering rule.
#: The remote IP prefix to be associated with this metering label rule.
remote_ip_prefix = resource.prop('remote_ip_prefix')

View File

@@ -39,15 +39,15 @@ class Network(resource.Resource):
availability_zones = resource.prop('availability_zones')
#: The network name.
name = resource.prop('name')
#: The project this network is associated with.
#: The ID of the project this network is associated with.
project_id = resource.prop('tenant_id')
# TODO(briancurtin): These provider_ explanations are made up because
# they're undocumented.
#: Type of network, such as vlan.
#: The type of physical network that maps to this network resource.
#: For example, ``flat``, ``vlan``, ``vxlan``, or ``gre``.
provider_network_type = resource.prop('provider:network_type')
#: ID of the physical network.
#: The physical network where this network object is implemented.
provider_physical_network = resource.prop('provider:physical_network')
#: Segmentation ID.
#: An isolated segment ID on the physical network. The provider
#: network type defines the segmentation model.
provider_segmentation_id = resource.prop('provider:segmentation_id')
#: Whether or not the router is external. *Type: bool*
router_external = resource.prop('router:external')
@@ -60,8 +60,9 @@ class Network(resource.Resource):
shared = resource.prop('shared', type=bool)
#: The network status.
status = resource.prop('status')
#: The associated subnets.
subnets = resource.prop('subnets')
#: The associated subnet IDs.
#: *Type: list of strs of the subnet IDs*
subnet_ids = resource.prop('subnets', type=list)
#: Read-only. The maximum transmission unit (MTU) of the network resource.
mtu = resource.prop('mtu', type=int)
#: The port security status, which is enabled ``True`` or disabled

View File

@@ -34,18 +34,20 @@ class Pool(resource.Resource):
#: Description for the pool.
description = resource.prop('description')
#: The ID of the associated health monitor.
healthmonitor_id = resource.prop('healthmonitor_id')
health_monitor_id = resource.prop('healthmonitor_id')
#: The load-balancer algorithm, which is round-robin, least-connections,
#: and so on. This value, which must be supported, is dependent on the
#: load-balancer provider. Round-robin must be supported.
lb_algorithm = resource.prop('lb_algorithm')
#: List of IDs of associated listeners. *Type: list*
listeners = resource.prop('listeners')
#: List of members that belong to the pool. *Type: list*
members = resource.prop('members')
#: List of associated listeners.
#: *Type: list of dicts which contain the listener IDs*
listener_ids = resource.prop('listeners', type=list)
#: List of members that belong to the pool.
#: *Type: list of dicts which contain the member IDs*
member_ids = resource.prop('members', type=list)
#: Pool name. Does not have to be unique.
name = resource.prop('name')
#: The project this pool is associated with.
#: The ID of the project this pool is associated with.
project_id = resource.prop('tenant_id')
#: The protocol of the pool, which is TCP, HTTP, or HTTPS.
protocol = resource.prop('protocol')

View File

@@ -33,11 +33,11 @@ class PoolMember(resource.Resource):
#: The administrative state of the pool member, which is up ``True`` or
#: down ``False``. *Type: bool*
admin_state_up = resource.prop('admin_state_up', type=bool)
#: The project this pool member is associated with.
#: The ID of the project this pool member is associated with.
project_id = resource.prop('tenant_id')
#: The port on which the application is hosted.
protocol_port = resource.prop('protocol_port', type=int)
#: Subnet in which to access this pool member.
#: Subnet ID in which to access this pool member.
subnet_id = resource.prop('subnet_id')
#: A positive integer value that indicates the relative portion of traffic
#: that this member should receive from the pool. For example, a member

View File

@@ -59,9 +59,9 @@ class Port(resource.Resource):
#: In GET operations, the binding:vnic_type extended attribute is
#: visible to only port owners and administrative users.
binding_vnic_type = resource.prop('binding:vnic_type')
#: The ID of the device that uses this port. For example, a virtual server.
#: Device ID of this port.
device_id = resource.prop('device_id')
#: The ID of the entity that uses this port. For example, a dhcp agent.
#: Device owner of this port (e.g. ``network:dhcp``).
device_owner = resource.prop('device_owner')
#: DNS assignment for the port.
dns_assignment = resource.prop('dns_assignment')
@@ -80,8 +80,9 @@ class Port(resource.Resource):
#: The ID of the project who owns the network. Only administrative
#: users can specify a project ID other than their own.
project_id = resource.prop('tenant_id')
#: The IDs of any attached security groups. *Type: list*
security_groups = resource.prop('security_groups', type=list)
#: 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)
#: The port status. Value is ``ACTIVE`` or ``DOWN``.
status = resource.prop('status')
#: The port security status, which is enabled ``True`` or disabled

View File

@@ -33,7 +33,7 @@ class Quota(resource.Resource):
networks = resource.prop('network', type=int)
#: The maximum amount of ports you can create. *Type: int*
ports = resource.prop('port', type=int)
#: The project these quota values are for.
#: The ID of the project these quota values are for.
project_id = resource.prop('tenant_id')
#: The maximum amount of routers you can create. *Type: int*
routers = resource.prop('router', type=int)

View File

@@ -42,7 +42,7 @@ class Router(resource.Resource):
external_gateway_info = resource.prop('external_gateway_info', type=dict)
#: The router name.
name = resource.prop('name')
#: The project this router is associated with.
#: The ID of the project this router is associated with.
project_id = resource.prop('tenant_id')
#: The router status.
status = resource.prop('status')

View File

@@ -33,7 +33,7 @@ class SecurityGroup(resource.Resource):
description = resource.prop('description')
#: The security group name.
name = resource.prop('name')
#: The project this security group is associated with.
#: The ID of the project this security group is associated with.
project_id = resource.prop('tenant_id')
#: A list of
#: :class:`~openstack.network.v2.security_group_rule.SecurityGroupRule`

View File

@@ -46,14 +46,14 @@ class SecurityGroupRule(resource.Resource):
#: must be less than or equal to the value of the port_range_max
#: attribute. If the protocol is ICMP, this value must be an ICMP type.
port_range_min = resource.prop('port_range_min')
#: The project this rule is associated with.
#: The ID of the project this security group rule is associated with.
project_id = resource.prop('tenant_id')
#: The protocol that is matched by the security group rule.
#: Valid values are ``null``, ``tcp``, ``udp``, and ``icmp``.
protocol = resource.prop('protocol')
#: The remote group ID to be associated with this security group rule.
#: You can specify either ``remote_group_id`` or ``remote_ip_prefix``
#: in the request body.
#: The remote security group ID to be associated with this security
#: group rule. You can specify either ``remote_group_id`` or
#: ``remote_ip_prefix`` in the request body.
remote_group_id = resource.prop('remote_group_id')
#: The remote IP prefix to be associated with this security group rule.
#: You can specify either ``remote_group_id`` or ``remote_ip_prefix``

View File

@@ -11,7 +11,6 @@
# under the License.
from openstack.network import network_service
from openstack.network.v2 import subnet_pool as _subnet_pool
from openstack import resource
@@ -55,8 +54,7 @@ class Subnet(resource.Resource):
name = resource.prop('name')
#: The ID of the attached network.
network_id = resource.prop('network_id')
#: The project this subnet is associated with.
#: The ID of the project this subnet is associated with.
project_id = resource.prop('tenant_id')
#: The subnet pool from which to obtain a CIDR. *Type: SubnetPool*
subnet_pool = resource.prop('subnetpool_id',
type=_subnet_pool.SubnetPool)
#: The subnet pool ID from which to obtain a CIDR.
subnet_pool_id = resource.prop('subnetpool_id')

View File

@@ -45,7 +45,7 @@ class SubnetPool(resource.Resource):
#: default_quota is measured units of /64. All projects that use the
#: subnet pool have the same prefix quota applied. *Type: int*
default_quota = resource.prop('default_quota', type=int)
#: The project that owns the subnet pool.
#: The ID of the project that owns the subnet pool.
project_id = resource.prop('tenant_id')
#: A list of subnet prefixes that are assigned to the subnet pool.
#: The adjacent prefixes are merged and treated as a single prefix.

View File

@@ -39,9 +39,9 @@ class VPNService(resource.Resource):
name = resource.prop('name')
#: ID of the router into which the VPN service is inserted.
router_id = resource.prop('router_id')
#: The project this vpnservice is associated with.
#: The ID of the project this vpnservice is associated with.
project_id = resource.prop('tenant_id')
#: The vpnservice status.
status = resource.prop('status')
#: The subnet on which the tenant wants the vpnservice.
#: The ID of the subnet on which the tenant wants the vpnservice.
subnet_id = resource.prop('subnet_id')

View File

@@ -52,7 +52,7 @@ class TestHealthMonitor(testtools.TestCase):
self.assertEqual(EXAMPLE['http_method'], sot.http_method)
self.assertEqual(EXAMPLE['id'], sot.id)
self.assertEqual(EXAMPLE['max_retries'], sot.max_retries)
self.assertEqual(EXAMPLE['pools'], sot.pools)
self.assertEqual(EXAMPLE['pools'], sot.pool_ids)
self.assertEqual(EXAMPLE['tenant_id'], sot.project_id)
self.assertEqual(EXAMPLE['timeout'], sot.timeout)
self.assertEqual(EXAMPLE['type'], sot.type)

View File

@@ -52,7 +52,7 @@ class TestListener(testtools.TestCase):
self.assertEqual(EXAMPLE['default_pool_id'], sot.default_pool_id)
self.assertEqual(EXAMPLE['description'], sot.description)
self.assertEqual(EXAMPLE['id'], sot.id)
self.assertEqual(EXAMPLE['loadbalancers'], sot.loadbalancers)
self.assertEqual(EXAMPLE['loadbalancers'], sot.load_balancer_ids)
self.assertEqual(EXAMPLE['name'], sot.name)
self.assertEqual(EXAMPLE['tenant_id'], sot.project_id)
self.assertEqual(EXAMPLE['protocol'], sot.protocol)

View File

@@ -19,7 +19,7 @@ EXAMPLE = {
'admin_state_up': True,
'description': '2',
'id': IDENTIFIER,
'listeners': '4',
'listeners': [{'id', '4'}],
'name': '5',
'operating_status': '6',
'provisioning_status': '7',
@@ -50,7 +50,7 @@ class TestLoadBalancer(testtools.TestCase):
self.assertEqual(EXAMPLE['admin_state_up'], sot.admin_state_up)
self.assertEqual(EXAMPLE['description'], sot.description)
self.assertEqual(EXAMPLE['id'], sot.id)
self.assertEqual(EXAMPLE['listeners'], sot.listeners)
self.assertEqual(EXAMPLE['listeners'], sot.listener_ids)
self.assertEqual(EXAMPLE['name'], sot.name)
self.assertEqual(EXAMPLE['operating_status'], sot.operating_status)
self.assertEqual(EXAMPLE['provisioning_status'],

View File

@@ -27,7 +27,7 @@ EXAMPLE = {
'segments': '9',
'shared': True,
'status': '11',
'subnets': '12',
'subnets': ['12a', '12b'],
'mtu': 1400,
'port_security_enabled': True,
'availability_zone_hints': ['15', '16'],
@@ -65,7 +65,7 @@ class TestNetwork(testtools.TestCase):
self.assertEqual(EXAMPLE['segments'], sot.segments)
self.assertEqual(EXAMPLE['shared'], sot.shared)
self.assertEqual(EXAMPLE['status'], sot.status)
self.assertEqual(EXAMPLE['subnets'], sot.subnets)
self.assertEqual(EXAMPLE['subnets'], sot.subnet_ids)
self.assertEqual(EXAMPLE['mtu'], sot.mtu)
self.assertEqual(EXAMPLE['port_security_enabled'],
sot.is_port_security_enabled)

View File

@@ -48,11 +48,11 @@ class TestPool(testtools.TestCase):
sot = pool.Pool(EXAMPLE)
self.assertEqual(EXAMPLE['admin_state_up'], sot.admin_state_up)
self.assertEqual(EXAMPLE['description'], sot.description)
self.assertEqual(EXAMPLE['healthmonitor_id'], sot.healthmonitor_id)
self.assertEqual(EXAMPLE['healthmonitor_id'], sot.health_monitor_id)
self.assertEqual(EXAMPLE['id'], sot.id)
self.assertEqual(EXAMPLE['lb_algorithm'], sot.lb_algorithm)
self.assertEqual(EXAMPLE['listeners'], sot.listeners)
self.assertEqual(EXAMPLE['members'], sot.members)
self.assertEqual(EXAMPLE['listeners'], sot.listener_ids)
self.assertEqual(EXAMPLE['members'], sot.member_ids)
self.assertEqual(EXAMPLE['name'], sot.name)
self.assertEqual(EXAMPLE['tenant_id'], sot.project_id)
self.assertEqual(EXAMPLE['protocol'], sot.protocol)

View File

@@ -74,7 +74,7 @@ class TestPort(testtools.TestCase):
self.assertEqual(EXAMPLE['name'], sot.name)
self.assertEqual(EXAMPLE['network_id'], sot.network_id)
self.assertEqual(EXAMPLE['tenant_id'], sot.project_id)
self.assertEqual(EXAMPLE['security_groups'], sot.security_groups)
self.assertEqual(EXAMPLE['security_groups'], sot.security_group_ids)
self.assertEqual(EXAMPLE['status'], sot.status)
self.assertEqual(EXAMPLE['port_security_enabled'],
sot.is_port_security_enabled)

View File

@@ -13,7 +13,6 @@
import testtools
from openstack.network.v2 import subnet
from openstack.network.v2 import subnet_pool
IDENTIFIER = 'IDENTIFIER'
EXAMPLE = {
@@ -63,6 +62,4 @@ class TestSubnet(testtools.TestCase):
self.assertEqual(EXAMPLE['name'], sot.name)
self.assertEqual(EXAMPLE['network_id'], sot.network_id)
self.assertEqual(EXAMPLE['tenant_id'], sot.project_id)
subnet_pool_data = {'id': EXAMPLE['subnetpool_id']}
self.assertEqual(subnet_pool.SubnetPool(subnet_pool_data),
sot.subnet_pool)
self.assertEqual(EXAMPLE['subnetpool_id'], sot.subnet_pool_id)