Skip to content

Commit 52cbeec

Browse files
Jenkinsopenstack-gerrit
authored andcommitted
Merge "Rebase network resources onto resource2 (1)"
2 parents 12a3130 + c4101cf commit 52cbeec

18 files changed

+170
-146
lines changed

openstack/network/v2/address_scope.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,30 +11,37 @@
1111
# under the License.
1212

1313
from openstack.network import network_service
14-
from openstack import resource
14+
from openstack import resource2 as resource
1515

1616

1717
class AddressScope(resource.Resource):
18+
"""Address scope extension."""
1819
resource_key = 'address_scope'
1920
resources_key = 'address_scopes'
2021
base_path = '/address-scopes'
2122
service = network_service.NetworkService()
2223

2324
# capabilities
2425
allow_create = True
25-
allow_retrieve = True
26+
allow_get = True
2627
allow_update = True
2728
allow_delete = True
2829
allow_list = True
2930

31+
_query_mapping = resource.QueryParameters(
32+
'name', 'ip_version',
33+
project_id='tenant_id',
34+
is_shared='shared',
35+
)
36+
3037
# Properties
3138
#: The address scope name.
32-
name = resource.prop('name')
39+
name = resource.Body('name')
3340
#: The ID of the project that owns the address scope.
34-
project_id = resource.prop('tenant_id')
41+
project_id = resource.Body('tenant_id')
3542
#: The IP address family of the address scope.
3643
#: *Type: int*
37-
ip_version = resource.prop('ip_version', type=int)
44+
ip_version = resource.Body('ip_version', type=int)
3845
#: Indicates whether this address scope is shared across all projects.
3946
#: *Type: bool*
40-
is_shared = resource.prop('shared', type=bool)
47+
is_shared = resource.Body('shared', type=bool)

openstack/network/v2/agent.py

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,50 +11,58 @@
1111
# under the License.
1212

1313
from openstack.network import network_service
14-
from openstack import resource
14+
from openstack import resource2 as resource
1515
from openstack import utils
1616

1717

1818
class Agent(resource.Resource):
19+
"""Neutron agent extension."""
1920
resource_key = 'agent'
2021
resources_key = 'agents'
2122
base_path = '/agents'
2223
service = network_service.NetworkService()
2324

2425
# capabilities
2526
allow_create = False
26-
allow_retrieve = True
27+
allow_get = True
2728
allow_update = True
2829
allow_delete = True
2930
allow_list = True
3031

32+
# NOTE: We skip query for JSON fields and datetime fields
33+
_query_mapping = resource.QueryParameters(
34+
'agent_type', 'availability_zone', 'binary', 'description', 'host',
35+
'topic',
36+
is_admin_state_up='admin_state_up', is_alive='alive',
37+
)
38+
3139
# Properties
3240
#: The type of network agent.
33-
agent_type = resource.prop('agent_type')
41+
agent_type = resource.Body('agent_type')
3442
#: Availability zone for the network agent.
35-
availability_zone = resource.prop('availability_zone')
43+
availability_zone = resource.Body('availability_zone')
3644
#: The name of the network agent's application binary.
37-
binary = resource.prop('binary')
45+
binary = resource.Body('binary')
3846
#: Network agent configuration data specific to the agent_type.
39-
configuration = resource.prop('configurations')
47+
configuration = resource.Body('configurations')
4048
#: Timestamp when the network agent was created.
41-
created_at = resource.prop('created_at')
49+
created_at = resource.Body('created_at')
4250
#: The network agent description.
43-
description = resource.prop('description')
51+
description = resource.Body('description')
4452
#: Timestamp when the network agent's heartbeat was last seen.
45-
last_heartbeat_at = resource.prop('heartbeat_timestamp')
53+
last_heartbeat_at = resource.Body('heartbeat_timestamp')
4654
#: The host the agent is running on.
47-
host = resource.prop('host')
55+
host = resource.Body('host')
4856
#: The administrative state of the network agent, which is up
4957
#: ``True`` or down ``False``. *Type: bool*
50-
is_admin_state_up = resource.prop('admin_state_up', type=bool)
58+
is_admin_state_up = resource.Body('admin_state_up', type=bool)
5159
#: Whether or not the network agent is alive.
5260
#: *Type: bool*
53-
is_alive = resource.prop('alive', type=bool)
61+
is_alive = resource.Body('alive', type=bool)
5462
#: Timestamp when the network agent was last started.
55-
started_at = resource.prop('started_at')
63+
started_at = resource.Body('started_at')
5664
#: The messaging queue topic the network agent subscribes to.
57-
topic = resource.prop('topic')
65+
topic = resource.Body('topic')
5866

5967
def add_agent_to_network(self, session, **body):
6068
url = utils.urljoin(self.base_path, self.id, 'dhcp-networks')
@@ -77,7 +85,9 @@ class DHCPAgentHostingNetwork(resource.Resource):
7785

7886
# capabilities
7987
allow_create = False
80-
allow_retrieve = True
88+
allow_get = True
8189
allow_update = False
8290
allow_delete = False
8391
allow_list = True
92+
93+
# NOTE: No query parameter is supported

openstack/network/v2/availability_zone.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# under the License.
1212

1313
from openstack.network import network_service
14-
from openstack import resource as _resource
14+
from openstack import resource2 as _resource
1515

1616

1717
class AvailabilityZone(_resource.Resource):
@@ -22,16 +22,21 @@ class AvailabilityZone(_resource.Resource):
2222

2323
# capabilities
2424
allow_create = False
25-
allow_retrieve = False
25+
allow_get = False
2626
allow_update = False
2727
allow_delete = False
2828
allow_list = True
2929

30+
# NOTE: We don't support query by state yet because there is a mapping
31+
# at neutron side difficult to map.
32+
_query_mapping = _resource.QueryParameters(
33+
name='availability_zone', resource='agent_type')
34+
3035
# Properties
3136
#: Name of the availability zone.
32-
name = _resource.prop('name')
37+
name = _resource.Body('name')
3338
#: Type of resource for the availability zone, such as ``network``.
34-
resource = _resource.prop('resource')
39+
resource = _resource.Body('resource')
3540
#: State of the availability zone, either ``available`` or
3641
#: ``unavailable``.
37-
state = _resource.prop('state')
42+
state = _resource.Body('state')

openstack/network/v2/extension.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,30 +11,29 @@
1111
# under the License.
1212

1313
from openstack.network import network_service
14-
from openstack import resource
14+
from openstack import resource2 as resource
1515

1616

1717
class Extension(resource.Resource):
1818
resource_key = 'extension'
1919
resources_key = 'extensions'
2020
base_path = '/extensions'
2121
service = network_service.NetworkService()
22-
id_attribute = "alias"
2322

2423
# capabilities
25-
allow_retrieve = True
24+
allow_get = True
2625
allow_list = True
2726

27+
# NOTE: No query parameters supported
28+
2829
# Properties
2930
#: An alias the extension is known under.
30-
alias = resource.prop('alias')
31+
alias = resource.Body('alias', alternate_id=True)
3132
#: Text describing what the extension does.
32-
description = resource.prop('description')
33+
description = resource.Body('description')
3334
#: Links pertaining to this extension.
34-
links = resource.prop('links')
35+
links = resource.Body('links')
3536
#: The name of this extension.
36-
name = resource.prop('name')
37-
#: A URL pointing to the namespace for this extension.
38-
namespace = resource.prop('namespace')
37+
name = resource.Body('name')
3938
#: Timestamp when the extension was last updated.
40-
updated_at = resource.prop('updated')
39+
updated_at = resource.Body('updated')

openstack/network/v2/flavor.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# under the License.
1212

1313
from openstack.network import network_service
14-
from openstack import resource
14+
from openstack import resource2 as resource
1515

1616

1717
class Flavor(resource.Resource):
@@ -22,19 +22,22 @@ class Flavor(resource.Resource):
2222

2323
# capabilities
2424
allow_create = True
25-
allow_retrieve = True
25+
allow_get = True
2626
allow_update = True
2727
allow_delete = True
2828
allow_list = True
2929

30+
_query_mapping = resource.QueryParameters(
31+
'description', 'name', 'service_type', is_enabled='enabled')
32+
3033
# properties
3134
#: description for the flavor
32-
description = resource.prop('description')
35+
description = resource.Body('description')
3336
#: Sets enabled flag
34-
is_enabled = resource.prop('enabled', type=bool)
37+
is_enabled = resource.Body('enabled', type=bool)
3538
#: The name of the flavor
36-
name = resource.prop('name')
37-
#: The owner project ID
38-
project_id = resource.prop('tenant_id')
39+
name = resource.Body('name')
3940
#: Service type to which the flavor applies
40-
service_type = resource.prop('service_type')
41+
service_type = resource.Body('service_type')
42+
#: IDs of service profiles associated with this flavor
43+
service_profile_ids = resource.Body('service_profiles')

openstack/network/v2/floating_ip.py

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# under the License.
1212

1313
from openstack.network import network_service
14-
from openstack import resource
14+
from openstack import resource2 as resource
1515

1616

1717
class FloatingIP(resource.Resource):
@@ -24,47 +24,45 @@ class FloatingIP(resource.Resource):
2424

2525
# capabilities
2626
allow_create = True
27-
allow_retrieve = True
27+
allow_get = True
2828
allow_update = True
2929
allow_delete = True
3030
allow_list = True
3131

32+
_query_mapping = resource.QueryParameters(
33+
'description', 'fixed_ip_address', 'floating_ip_address',
34+
'floating_network_id', 'port_id', 'router_id', 'status',
35+
project_id='tenant_id',
36+
revision_number='revision')
37+
3238
# Properties
33-
#: Timestamp when the floating IP was created.
34-
created_at = resource.prop('created_at')
3539
#: The floating IP description.
36-
description = resource.prop('description')
40+
description = resource.Body('description')
3741
#: The fixed IP address associated with the floating IP. If you
3842
#: intend to associate the floating IP with a fixed IP at creation
3943
#: time, then you must indicate the identifier of the internal port.
4044
#: If an internal port has multiple associated IP addresses, the
4145
#: service chooses the first IP unless you explicitly specify the
4246
#: parameter fixed_ip_address to select a specific IP.
43-
fixed_ip_address = resource.prop('fixed_ip_address')
47+
fixed_ip_address = resource.Body('fixed_ip_address')
4448
#: The floating IP address.
45-
floating_ip_address = resource.prop('floating_ip_address')
49+
floating_ip_address = resource.Body('floating_ip_address')
4650
#: The ID of the network associated with the floating IP.
47-
floating_network_id = resource.prop('floating_network_id')
51+
floating_network_id = resource.Body('floating_network_id')
4852
#: The port ID.
49-
port_id = resource.prop('port_id')
53+
port_id = resource.Body('port_id')
5054
#: The ID of the project this floating IP is associated with.
51-
project_id = resource.prop('tenant_id')
55+
project_id = resource.Body('tenant_id')
5256
#: Revision number of the floating IP. *Type: int*
53-
revision_number = resource.prop('revision_number', type=int)
57+
revision_number = resource.Body('revision', type=int)
5458
#: The ID of an associated router.
55-
router_id = resource.prop('router_id')
59+
router_id = resource.Body('router_id')
5660
#: The floating IP status. Value is ``ACTIVE`` or ``DOWN``.
57-
status = resource.prop('status')
58-
#: Timestamp when the floating IP was last updated.
59-
updated_at = resource.prop('updated_at')
61+
status = resource.Body('status')
6062

6163
@classmethod
6264
def find_available(cls, session):
63-
params = {
64-
'port_id': '',
65-
'fields': cls.id_attribute,
66-
}
67-
info = cls.list(session, params=params)
65+
info = cls.list(session, fields='id', port_id='')
6866
try:
6967
return next(info)
7068
except StopIteration:

openstack/network/v2/health_monitor.py

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# under the License.
1212

1313
from openstack.network import network_service
14-
from openstack import resource
14+
from openstack import resource2 as resource
1515

1616

1717
class HealthMonitor(resource.Resource):
@@ -22,36 +22,43 @@ class HealthMonitor(resource.Resource):
2222

2323
# capabilities
2424
allow_create = True
25-
allow_retrieve = True
25+
allow_get = True
2626
allow_update = True
2727
allow_delete = True
2828
allow_list = True
2929

30+
_query_mapping = resource.QueryParameters(
31+
'delay', 'expected_codes', 'http_method', 'max_retries',
32+
'timeout', 'type', 'url_path',
33+
is_admin_state_up='adminstate_up',
34+
project_id='tenant_id',
35+
)
36+
3037
# Properties
3138
#: The time, in milliseconds, between sending probes to members.
32-
delay = resource.prop('delay')
39+
delay = resource.Body('delay')
3340
#: Expected HTTP codes for a passing HTTP(S) monitor.
34-
expected_codes = resource.prop('expected_codes')
41+
expected_codes = resource.Body('expected_codes')
3542
#: The HTTP method that the monitor uses for requests.
36-
http_method = resource.prop('http_method')
43+
http_method = resource.Body('http_method')
3744
#: The administrative state of the health monitor, which is up
3845
#: ``True`` or down ``False``. *Type: bool*
39-
is_admin_state_up = resource.prop('admin_state_up', type=bool)
46+
is_admin_state_up = resource.Body('admin_state_up', type=bool)
4047
#: Maximum consecutive health probe tries.
41-
max_retries = resource.prop('max_retries')
48+
max_retries = resource.Body('max_retries')
4249
#: Name of the health monitor.
43-
name = resource.prop('name')
50+
name = resource.Body('name')
4451
#: List of pools associated with this health monitor
4552
#: *Type: list of dicts which contain the pool IDs*
46-
pool_ids = resource.prop('pools', type=list)
53+
pool_ids = resource.Body('pools', type=list)
4754
#: The ID of the project this health monitor is associated with.
48-
project_id = resource.prop('tenant_id')
55+
project_id = resource.Body('tenant_id')
4956
#: The maximum number of milliseconds for a monitor to wait for a
5057
#: connection to be established before it times out. This value must
5158
#: be less than the delay value.
52-
timeout = resource.prop('timeout')
59+
timeout = resource.Body('timeout')
5360
#: The type of probe sent by the load balancer to verify the member
5461
#: state, which is PING, TCP, HTTP, or HTTPS.
55-
type = resource.prop('type')
62+
type = resource.Body('type')
5663
#: Path portion of URI that will be probed if type is HTTP(S).
57-
url_path = resource.prop('url_path')
64+
url_path = resource.Body('url_path')

0 commit comments

Comments
 (0)