Merge "Rebase network resources onto resource2 (1)"
This commit is contained in:
@@ -11,10 +11,11 @@
|
||||
# under the License.
|
||||
|
||||
from openstack.network import network_service
|
||||
from openstack import resource
|
||||
from openstack import resource2 as resource
|
||||
|
||||
|
||||
class AddressScope(resource.Resource):
|
||||
"""Address scope extension."""
|
||||
resource_key = 'address_scope'
|
||||
resources_key = 'address_scopes'
|
||||
base_path = '/address-scopes'
|
||||
@@ -22,19 +23,25 @@ class AddressScope(resource.Resource):
|
||||
|
||||
# capabilities
|
||||
allow_create = True
|
||||
allow_retrieve = True
|
||||
allow_get = True
|
||||
allow_update = True
|
||||
allow_delete = True
|
||||
allow_list = True
|
||||
|
||||
_query_mapping = resource.QueryParameters(
|
||||
'name', 'ip_version',
|
||||
project_id='tenant_id',
|
||||
is_shared='shared',
|
||||
)
|
||||
|
||||
# Properties
|
||||
#: The address scope name.
|
||||
name = resource.prop('name')
|
||||
name = resource.Body('name')
|
||||
#: The ID of the project that owns the address scope.
|
||||
project_id = resource.prop('tenant_id')
|
||||
project_id = resource.Body('tenant_id')
|
||||
#: The IP address family of the address scope.
|
||||
#: *Type: int*
|
||||
ip_version = resource.prop('ip_version', type=int)
|
||||
ip_version = resource.Body('ip_version', type=int)
|
||||
#: Indicates whether this address scope is shared across all projects.
|
||||
#: *Type: bool*
|
||||
is_shared = resource.prop('shared', type=bool)
|
||||
is_shared = resource.Body('shared', type=bool)
|
||||
|
||||
@@ -11,11 +11,12 @@
|
||||
# under the License.
|
||||
|
||||
from openstack.network import network_service
|
||||
from openstack import resource
|
||||
from openstack import resource2 as resource
|
||||
from openstack import utils
|
||||
|
||||
|
||||
class Agent(resource.Resource):
|
||||
"""Neutron agent extension."""
|
||||
resource_key = 'agent'
|
||||
resources_key = 'agents'
|
||||
base_path = '/agents'
|
||||
@@ -23,38 +24,45 @@ class Agent(resource.Resource):
|
||||
|
||||
# capabilities
|
||||
allow_create = False
|
||||
allow_retrieve = True
|
||||
allow_get = True
|
||||
allow_update = True
|
||||
allow_delete = True
|
||||
allow_list = True
|
||||
|
||||
# NOTE: We skip query for JSON fields and datetime fields
|
||||
_query_mapping = resource.QueryParameters(
|
||||
'agent_type', 'availability_zone', 'binary', 'description', 'host',
|
||||
'topic',
|
||||
is_admin_state_up='admin_state_up', is_alive='alive',
|
||||
)
|
||||
|
||||
# Properties
|
||||
#: The type of network agent.
|
||||
agent_type = resource.prop('agent_type')
|
||||
agent_type = resource.Body('agent_type')
|
||||
#: Availability zone for the network agent.
|
||||
availability_zone = resource.prop('availability_zone')
|
||||
availability_zone = resource.Body('availability_zone')
|
||||
#: The name of the network agent's application binary.
|
||||
binary = resource.prop('binary')
|
||||
binary = resource.Body('binary')
|
||||
#: Network agent configuration data specific to the agent_type.
|
||||
configuration = resource.prop('configurations')
|
||||
configuration = resource.Body('configurations')
|
||||
#: Timestamp when the network agent was created.
|
||||
created_at = resource.prop('created_at')
|
||||
created_at = resource.Body('created_at')
|
||||
#: The network agent description.
|
||||
description = resource.prop('description')
|
||||
description = resource.Body('description')
|
||||
#: Timestamp when the network agent's heartbeat was last seen.
|
||||
last_heartbeat_at = resource.prop('heartbeat_timestamp')
|
||||
last_heartbeat_at = resource.Body('heartbeat_timestamp')
|
||||
#: The host the agent is running on.
|
||||
host = resource.prop('host')
|
||||
host = resource.Body('host')
|
||||
#: The administrative state of the network agent, which is up
|
||||
#: ``True`` or down ``False``. *Type: bool*
|
||||
is_admin_state_up = resource.prop('admin_state_up', type=bool)
|
||||
is_admin_state_up = resource.Body('admin_state_up', type=bool)
|
||||
#: Whether or not the network agent is alive.
|
||||
#: *Type: bool*
|
||||
is_alive = resource.prop('alive', type=bool)
|
||||
is_alive = resource.Body('alive', type=bool)
|
||||
#: Timestamp when the network agent was last started.
|
||||
started_at = resource.prop('started_at')
|
||||
started_at = resource.Body('started_at')
|
||||
#: The messaging queue topic the network agent subscribes to.
|
||||
topic = resource.prop('topic')
|
||||
topic = resource.Body('topic')
|
||||
|
||||
def add_agent_to_network(self, session, **body):
|
||||
url = utils.urljoin(self.base_path, self.id, 'dhcp-networks')
|
||||
@@ -77,7 +85,9 @@ class DHCPAgentHostingNetwork(resource.Resource):
|
||||
|
||||
# capabilities
|
||||
allow_create = False
|
||||
allow_retrieve = True
|
||||
allow_get = True
|
||||
allow_update = False
|
||||
allow_delete = False
|
||||
allow_list = True
|
||||
|
||||
# NOTE: No query parameter is supported
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
# under the License.
|
||||
|
||||
from openstack.network import network_service
|
||||
from openstack import resource as _resource
|
||||
from openstack import resource2 as _resource
|
||||
|
||||
|
||||
class AvailabilityZone(_resource.Resource):
|
||||
@@ -22,16 +22,21 @@ class AvailabilityZone(_resource.Resource):
|
||||
|
||||
# capabilities
|
||||
allow_create = False
|
||||
allow_retrieve = False
|
||||
allow_get = False
|
||||
allow_update = False
|
||||
allow_delete = False
|
||||
allow_list = True
|
||||
|
||||
# NOTE: We don't support query by state yet because there is a mapping
|
||||
# at neutron side difficult to map.
|
||||
_query_mapping = _resource.QueryParameters(
|
||||
name='availability_zone', resource='agent_type')
|
||||
|
||||
# Properties
|
||||
#: Name of the availability zone.
|
||||
name = _resource.prop('name')
|
||||
name = _resource.Body('name')
|
||||
#: Type of resource for the availability zone, such as ``network``.
|
||||
resource = _resource.prop('resource')
|
||||
resource = _resource.Body('resource')
|
||||
#: State of the availability zone, either ``available`` or
|
||||
#: ``unavailable``.
|
||||
state = _resource.prop('state')
|
||||
state = _resource.Body('state')
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
# under the License.
|
||||
|
||||
from openstack.network import network_service
|
||||
from openstack import resource
|
||||
from openstack import resource2 as resource
|
||||
|
||||
|
||||
class Extension(resource.Resource):
|
||||
@@ -19,22 +19,21 @@ class Extension(resource.Resource):
|
||||
resources_key = 'extensions'
|
||||
base_path = '/extensions'
|
||||
service = network_service.NetworkService()
|
||||
id_attribute = "alias"
|
||||
|
||||
# capabilities
|
||||
allow_retrieve = True
|
||||
allow_get = True
|
||||
allow_list = True
|
||||
|
||||
# NOTE: No query parameters supported
|
||||
|
||||
# Properties
|
||||
#: An alias the extension is known under.
|
||||
alias = resource.prop('alias')
|
||||
alias = resource.Body('alias', alternate_id=True)
|
||||
#: Text describing what the extension does.
|
||||
description = resource.prop('description')
|
||||
description = resource.Body('description')
|
||||
#: Links pertaining to this extension.
|
||||
links = resource.prop('links')
|
||||
links = resource.Body('links')
|
||||
#: The name of this extension.
|
||||
name = resource.prop('name')
|
||||
#: A URL pointing to the namespace for this extension.
|
||||
namespace = resource.prop('namespace')
|
||||
name = resource.Body('name')
|
||||
#: Timestamp when the extension was last updated.
|
||||
updated_at = resource.prop('updated')
|
||||
updated_at = resource.Body('updated')
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
# under the License.
|
||||
|
||||
from openstack.network import network_service
|
||||
from openstack import resource
|
||||
from openstack import resource2 as resource
|
||||
|
||||
|
||||
class Flavor(resource.Resource):
|
||||
@@ -22,19 +22,22 @@ class Flavor(resource.Resource):
|
||||
|
||||
# capabilities
|
||||
allow_create = True
|
||||
allow_retrieve = True
|
||||
allow_get = True
|
||||
allow_update = True
|
||||
allow_delete = True
|
||||
allow_list = True
|
||||
|
||||
_query_mapping = resource.QueryParameters(
|
||||
'description', 'name', 'service_type', is_enabled='enabled')
|
||||
|
||||
# properties
|
||||
#: description for the flavor
|
||||
description = resource.prop('description')
|
||||
description = resource.Body('description')
|
||||
#: Sets enabled flag
|
||||
is_enabled = resource.prop('enabled', type=bool)
|
||||
is_enabled = resource.Body('enabled', type=bool)
|
||||
#: The name of the flavor
|
||||
name = resource.prop('name')
|
||||
#: The owner project ID
|
||||
project_id = resource.prop('tenant_id')
|
||||
name = resource.Body('name')
|
||||
#: Service type to which the flavor applies
|
||||
service_type = resource.prop('service_type')
|
||||
service_type = resource.Body('service_type')
|
||||
#: IDs of service profiles associated with this flavor
|
||||
service_profile_ids = resource.Body('service_profiles')
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
# under the License.
|
||||
|
||||
from openstack.network import network_service
|
||||
from openstack import resource
|
||||
from openstack import resource2 as resource
|
||||
|
||||
|
||||
class FloatingIP(resource.Resource):
|
||||
@@ -24,47 +24,45 @@ class FloatingIP(resource.Resource):
|
||||
|
||||
# capabilities
|
||||
allow_create = True
|
||||
allow_retrieve = True
|
||||
allow_get = True
|
||||
allow_update = True
|
||||
allow_delete = True
|
||||
allow_list = True
|
||||
|
||||
_query_mapping = resource.QueryParameters(
|
||||
'description', 'fixed_ip_address', 'floating_ip_address',
|
||||
'floating_network_id', 'port_id', 'router_id', 'status',
|
||||
project_id='tenant_id',
|
||||
revision_number='revision')
|
||||
|
||||
# Properties
|
||||
#: Timestamp when the floating IP was created.
|
||||
created_at = resource.prop('created_at')
|
||||
#: The floating IP description.
|
||||
description = resource.prop('description')
|
||||
description = resource.Body('description')
|
||||
#: The fixed IP address associated with the floating IP. If you
|
||||
#: intend to associate the floating IP with a fixed IP at creation
|
||||
#: time, then you must indicate the identifier of the internal port.
|
||||
#: If an internal port has multiple associated IP addresses, the
|
||||
#: service chooses the first IP unless you explicitly specify the
|
||||
#: parameter fixed_ip_address to select a specific IP.
|
||||
fixed_ip_address = resource.prop('fixed_ip_address')
|
||||
fixed_ip_address = resource.Body('fixed_ip_address')
|
||||
#: The floating IP address.
|
||||
floating_ip_address = resource.prop('floating_ip_address')
|
||||
floating_ip_address = resource.Body('floating_ip_address')
|
||||
#: The ID of the network associated with the floating IP.
|
||||
floating_network_id = resource.prop('floating_network_id')
|
||||
floating_network_id = resource.Body('floating_network_id')
|
||||
#: The port ID.
|
||||
port_id = resource.prop('port_id')
|
||||
port_id = resource.Body('port_id')
|
||||
#: The ID of the project this floating IP is associated with.
|
||||
project_id = resource.prop('tenant_id')
|
||||
project_id = resource.Body('tenant_id')
|
||||
#: Revision number of the floating IP. *Type: int*
|
||||
revision_number = resource.prop('revision_number', type=int)
|
||||
revision_number = resource.Body('revision', type=int)
|
||||
#: The ID of an associated router.
|
||||
router_id = resource.prop('router_id')
|
||||
router_id = resource.Body('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')
|
||||
status = resource.Body('status')
|
||||
|
||||
@classmethod
|
||||
def find_available(cls, session):
|
||||
params = {
|
||||
'port_id': '',
|
||||
'fields': cls.id_attribute,
|
||||
}
|
||||
info = cls.list(session, params=params)
|
||||
info = cls.list(session, fields='id', port_id='')
|
||||
try:
|
||||
return next(info)
|
||||
except StopIteration:
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
# under the License.
|
||||
|
||||
from openstack.network import network_service
|
||||
from openstack import resource
|
||||
from openstack import resource2 as resource
|
||||
|
||||
|
||||
class HealthMonitor(resource.Resource):
|
||||
@@ -22,36 +22,43 @@ class HealthMonitor(resource.Resource):
|
||||
|
||||
# capabilities
|
||||
allow_create = True
|
||||
allow_retrieve = True
|
||||
allow_get = True
|
||||
allow_update = True
|
||||
allow_delete = True
|
||||
allow_list = True
|
||||
|
||||
_query_mapping = resource.QueryParameters(
|
||||
'delay', 'expected_codes', 'http_method', 'max_retries',
|
||||
'timeout', 'type', 'url_path',
|
||||
is_admin_state_up='adminstate_up',
|
||||
project_id='tenant_id',
|
||||
)
|
||||
|
||||
# Properties
|
||||
#: The time, in milliseconds, between sending probes to members.
|
||||
delay = resource.prop('delay')
|
||||
delay = resource.Body('delay')
|
||||
#: Expected HTTP codes for a passing HTTP(S) monitor.
|
||||
expected_codes = resource.prop('expected_codes')
|
||||
expected_codes = resource.Body('expected_codes')
|
||||
#: The HTTP method that the monitor uses for requests.
|
||||
http_method = resource.prop('http_method')
|
||||
http_method = resource.Body('http_method')
|
||||
#: The administrative state of the health monitor, which is up
|
||||
#: ``True`` or down ``False``. *Type: bool*
|
||||
is_admin_state_up = resource.prop('admin_state_up', type=bool)
|
||||
is_admin_state_up = resource.Body('admin_state_up', type=bool)
|
||||
#: Maximum consecutive health probe tries.
|
||||
max_retries = resource.prop('max_retries')
|
||||
max_retries = resource.Body('max_retries')
|
||||
#: Name of the health monitor.
|
||||
name = resource.prop('name')
|
||||
name = resource.Body('name')
|
||||
#: List of pools associated with this health monitor
|
||||
#: *Type: list of dicts which contain the pool IDs*
|
||||
pool_ids = resource.prop('pools', type=list)
|
||||
pool_ids = resource.Body('pools', type=list)
|
||||
#: The ID of the project this health monitor is associated with.
|
||||
project_id = resource.prop('tenant_id')
|
||||
project_id = resource.Body('tenant_id')
|
||||
#: The maximum number of milliseconds for a monitor to wait for a
|
||||
#: connection to be established before it times out. This value must
|
||||
#: be less than the delay value.
|
||||
timeout = resource.prop('timeout')
|
||||
timeout = resource.Body('timeout')
|
||||
#: The type of probe sent by the load balancer to verify the member
|
||||
#: state, which is PING, TCP, HTTP, or HTTPS.
|
||||
type = resource.prop('type')
|
||||
type = resource.Body('type')
|
||||
#: Path portion of URI that will be probed if type is HTTP(S).
|
||||
url_path = resource.prop('url_path')
|
||||
url_path = resource.Body('url_path')
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
# under the License.
|
||||
|
||||
from openstack.network import network_service
|
||||
from openstack import resource
|
||||
from openstack import resource2 as resource
|
||||
|
||||
|
||||
class Listener(resource.Resource):
|
||||
@@ -22,36 +22,42 @@ class Listener(resource.Resource):
|
||||
|
||||
# capabilities
|
||||
allow_create = True
|
||||
allow_retrieve = True
|
||||
allow_get = True
|
||||
allow_update = True
|
||||
allow_delete = True
|
||||
allow_list = True
|
||||
|
||||
_query_mapping = resource.QueryParameters(
|
||||
'connection_limit', 'default_pool_id', 'default_tls_container_ref',
|
||||
'description', 'name', 'project_id', 'protocol', 'protocol_port',
|
||||
is_admin_state_up='admin_state_up'
|
||||
)
|
||||
|
||||
# Properties
|
||||
#: The maximum number of connections permitted for this load balancer.
|
||||
#: Default is infinite.
|
||||
connection_limit = resource.prop('connection_limit')
|
||||
connection_limit = resource.Body('connection_limit')
|
||||
#: ID of default pool. Must have compatible protocol with listener.
|
||||
default_pool_id = resource.prop('default_pool_id')
|
||||
default_pool_id = resource.Body('default_pool_id')
|
||||
#: A reference to a container of TLS secrets.
|
||||
default_tls_container_ref = resource.prop('default_tls_container_ref')
|
||||
default_tls_container_ref = resource.Body('default_tls_container_ref')
|
||||
#: Description for the listener.
|
||||
description = resource.prop('description')
|
||||
description = resource.Body('description')
|
||||
#: The administrative state of the listener, which is up
|
||||
#: ``True`` or down ``False``. *Type: bool*
|
||||
is_admin_state_up = resource.prop('admin_state_up', type=bool)
|
||||
is_admin_state_up = resource.Body('admin_state_up', type=bool)
|
||||
#: List of load balancers associated with this listener.
|
||||
#: *Type: list of dicts which contain the load balancer IDs*
|
||||
load_balancer_ids = resource.prop('loadbalancers')
|
||||
load_balancer_ids = resource.Body('loadbalancers')
|
||||
#: Name of the listener
|
||||
name = resource.prop('name')
|
||||
name = resource.Body('name')
|
||||
#: The ID of the project this listener is associated with.
|
||||
project_id = resource.prop('tenant_id')
|
||||
project_id = resource.Body('project_id')
|
||||
#: The protocol of the listener, which is TCP, HTTP, HTTPS
|
||||
#: or TERMINATED_HTTPS.
|
||||
protocol = resource.prop('protocol')
|
||||
protocol = resource.Body('protocol')
|
||||
#: Port the listener will listen to, e.g. 80.
|
||||
protocol_port = resource.prop('protocol_port')
|
||||
protocol_port = resource.Body('protocol_port')
|
||||
#: A list of references to TLS secrets.
|
||||
#: *Type: list*
|
||||
sni_container_refs = resource.prop('sni_container_refs')
|
||||
sni_container_refs = resource.Body('sni_container_refs')
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
# under the License.
|
||||
|
||||
from openstack.network import network_service
|
||||
from openstack import resource
|
||||
from openstack import resource2 as resource
|
||||
|
||||
|
||||
class LoadBalancer(resource.Resource):
|
||||
@@ -22,36 +22,36 @@ class LoadBalancer(resource.Resource):
|
||||
|
||||
# capabilities
|
||||
allow_create = True
|
||||
allow_retrieve = True
|
||||
allow_get = True
|
||||
allow_update = True
|
||||
allow_delete = True
|
||||
allow_list = True
|
||||
|
||||
# Properties
|
||||
#: Description for the load balancer.
|
||||
description = resource.prop('description')
|
||||
description = resource.Body('description')
|
||||
#: The administrative state of the load balancer, which is up
|
||||
#: ``True`` or down ``False``. *Type: bool*
|
||||
is_admin_state_up = resource.prop('admin_state_up', type=bool)
|
||||
is_admin_state_up = resource.Body('admin_state_up', type=bool)
|
||||
#: List of listeners associated with this load balancer.
|
||||
#: *Type: list of dicts which contain the listener IDs*
|
||||
listener_ids = resource.prop('listeners', type=list)
|
||||
listener_ids = resource.Body('listeners', type=list)
|
||||
#: Name of the load balancer
|
||||
name = resource.prop('name')
|
||||
name = resource.Body('name')
|
||||
#: Status of load_balancer operating, e.g. ONLINE, OFFLINE.
|
||||
operating_status = resource.prop('operating_status')
|
||||
operating_status = resource.Body('operating_status')
|
||||
#: List of pools associated with this load balancer.
|
||||
#: *Type: list of dicts which contain the pool IDs*
|
||||
pool_ids = resource.prop('pools', type=list)
|
||||
pool_ids = resource.Body('pools', type=list)
|
||||
#: The ID of the project this load balancer is associated with.
|
||||
project_id = resource.prop('tenant_id')
|
||||
project_id = resource.Body('tenant_id')
|
||||
#: The name of the provider.
|
||||
provider = resource.prop('provider')
|
||||
provider = resource.Body('provider')
|
||||
#: Status of load balancer provisioning, e.g. ACTIVE, INACTIVE.
|
||||
provisioning_status = resource.prop('provisioning_status')
|
||||
provisioning_status = resource.Body('provisioning_status')
|
||||
#: The IP address of the VIP.
|
||||
vip_address = resource.prop('vip_address')
|
||||
vip_address = resource.Body('vip_address')
|
||||
#: The ID of the port for the VIP.
|
||||
vip_port_id = resource.prop('vip_port_id')
|
||||
vip_port_id = resource.Body('vip_port_id')
|
||||
#: The ID of the subnet on which to allocate the VIP address.
|
||||
vip_subnet_id = resource.prop('vip_subnet_id')
|
||||
vip_subnet_id = resource.Body('vip_subnet_id')
|
||||
|
||||
@@ -33,13 +33,13 @@ class TestAddressScope(testtools.TestCase):
|
||||
self.assertEqual('/address-scopes', sot.base_path)
|
||||
self.assertEqual('network', sot.service.service_type)
|
||||
self.assertTrue(sot.allow_create)
|
||||
self.assertTrue(sot.allow_retrieve)
|
||||
self.assertTrue(sot.allow_get)
|
||||
self.assertTrue(sot.allow_update)
|
||||
self.assertTrue(sot.allow_delete)
|
||||
self.assertTrue(sot.allow_list)
|
||||
|
||||
def test_make_it(self):
|
||||
sot = address_scope.AddressScope(EXAMPLE)
|
||||
sot = address_scope.AddressScope(**EXAMPLE)
|
||||
self.assertEqual(EXAMPLE['id'], sot.id)
|
||||
self.assertEqual(EXAMPLE['ip_version'], sot.ip_version)
|
||||
self.assertEqual(EXAMPLE['name'], sot.name)
|
||||
|
||||
@@ -42,13 +42,13 @@ class TestAgent(testtools.TestCase):
|
||||
self.assertEqual('/agents', sot.base_path)
|
||||
self.assertEqual('network', sot.service.service_type)
|
||||
self.assertFalse(sot.allow_create)
|
||||
self.assertTrue(sot.allow_retrieve)
|
||||
self.assertTrue(sot.allow_get)
|
||||
self.assertTrue(sot.allow_update)
|
||||
self.assertTrue(sot.allow_delete)
|
||||
self.assertTrue(sot.allow_list)
|
||||
|
||||
def test_make_it(self):
|
||||
sot = agent.Agent(EXAMPLE)
|
||||
sot = agent.Agent(**EXAMPLE)
|
||||
self.assertTrue(sot.is_admin_state_up)
|
||||
self.assertEqual(EXAMPLE['agent_type'], sot.agent_type)
|
||||
self.assertTrue(sot.is_alive)
|
||||
@@ -66,7 +66,7 @@ class TestAgent(testtools.TestCase):
|
||||
|
||||
def test_add_agent_to_network(self):
|
||||
# Add agent to network
|
||||
net = agent.Agent(EXAMPLE)
|
||||
net = agent.Agent(**EXAMPLE)
|
||||
response = mock.Mock()
|
||||
response.body = {'network_id': '1'}
|
||||
response.json = mock.Mock(return_value=response.body)
|
||||
@@ -81,7 +81,7 @@ class TestAgent(testtools.TestCase):
|
||||
|
||||
def test_remove_agent_from_network(self):
|
||||
# Remove agent from agent
|
||||
net = agent.Agent(EXAMPLE)
|
||||
net = agent.Agent(**EXAMPLE)
|
||||
sess = mock.Mock()
|
||||
self.assertIsNone(net.remove_agent_from_network(sess))
|
||||
body = {}
|
||||
@@ -100,7 +100,7 @@ class TestDHCPAgentHostingNetwork(testtools.TestCase):
|
||||
self.assertEqual('dhcp-network', net.resource_name)
|
||||
self.assertEqual('network', net.service.service_type)
|
||||
self.assertFalse(net.allow_create)
|
||||
self.assertTrue(net.allow_retrieve)
|
||||
self.assertTrue(net.allow_get)
|
||||
self.assertFalse(net.allow_update)
|
||||
self.assertFalse(net.allow_delete)
|
||||
self.assertTrue(net.allow_list)
|
||||
|
||||
@@ -32,13 +32,13 @@ class TestAvailabilityZone(testtools.TestCase):
|
||||
self.assertEqual('/availability_zones', sot.base_path)
|
||||
self.assertEqual('network', sot.service.service_type)
|
||||
self.assertFalse(sot.allow_create)
|
||||
self.assertFalse(sot.allow_retrieve)
|
||||
self.assertFalse(sot.allow_get)
|
||||
self.assertFalse(sot.allow_update)
|
||||
self.assertFalse(sot.allow_delete)
|
||||
self.assertTrue(sot.allow_list)
|
||||
|
||||
def test_make_it(self):
|
||||
sot = availability_zone.AvailabilityZone(EXAMPLE)
|
||||
sot = availability_zone.AvailabilityZone(**EXAMPLE)
|
||||
self.assertEqual(EXAMPLE['id'], sot.id)
|
||||
self.assertEqual(EXAMPLE['name'], sot.name)
|
||||
self.assertEqual(EXAMPLE['resource'], sot.resource)
|
||||
|
||||
@@ -20,7 +20,6 @@ EXAMPLE = {
|
||||
'description': '2',
|
||||
'links': '3',
|
||||
'name': '4',
|
||||
'namespace': '5',
|
||||
'updated': '2016-03-09T12:14:57.233772',
|
||||
}
|
||||
|
||||
@@ -34,17 +33,16 @@ class TestExtension(testtools.TestCase):
|
||||
self.assertEqual('/extensions', sot.base_path)
|
||||
self.assertEqual('network', sot.service.service_type)
|
||||
self.assertFalse(sot.allow_create)
|
||||
self.assertTrue(sot.allow_retrieve)
|
||||
self.assertTrue(sot.allow_get)
|
||||
self.assertFalse(sot.allow_update)
|
||||
self.assertFalse(sot.allow_delete)
|
||||
self.assertTrue(sot.allow_list)
|
||||
|
||||
def test_make_it(self):
|
||||
sot = extension.Extension(EXAMPLE)
|
||||
sot = extension.Extension(**EXAMPLE)
|
||||
self.assertEqual(EXAMPLE['alias'], sot.id)
|
||||
self.assertEqual(EXAMPLE['alias'], sot.alias)
|
||||
self.assertEqual(EXAMPLE['description'], sot.description)
|
||||
self.assertEqual(EXAMPLE['links'], sot.links)
|
||||
self.assertEqual(EXAMPLE['name'], sot.name)
|
||||
self.assertEqual(EXAMPLE['namespace'], sot.namespace)
|
||||
self.assertEqual(EXAMPLE['updated'], sot.updated_at)
|
||||
|
||||
@@ -18,9 +18,9 @@ IDENTIFIER = 'IDENTIFIER'
|
||||
EXAMPLE_WITH_OPTIONAL = {
|
||||
'name': 'test-flavor',
|
||||
'service_type': 'VPN',
|
||||
'tenant_id': '5',
|
||||
'description': 'VPN flavor',
|
||||
'enabled': True,
|
||||
'service_profiles': ['1', '2'],
|
||||
}
|
||||
|
||||
EXAMPLE = {
|
||||
@@ -37,23 +37,23 @@ class TestFlavor(testtools.TestCase):
|
||||
self.assertEqual('/flavors', flavors.base_path)
|
||||
self.assertEqual('network', flavors.service.service_type)
|
||||
self.assertTrue(flavors.allow_create)
|
||||
self.assertTrue(flavors.allow_retrieve)
|
||||
self.assertTrue(flavors.allow_get)
|
||||
self.assertTrue(flavors.allow_update)
|
||||
self.assertTrue(flavors.allow_delete)
|
||||
self.assertTrue(flavors.allow_list)
|
||||
|
||||
def test_make_it(self):
|
||||
flavors = flavor.Flavor(EXAMPLE)
|
||||
flavors = flavor.Flavor(**EXAMPLE)
|
||||
self.assertEqual(EXAMPLE['name'], flavors.name)
|
||||
self.assertEqual(EXAMPLE['service_type'], flavors.service_type)
|
||||
|
||||
def test_make_it_with_optional(self):
|
||||
flavors = flavor.Flavor(EXAMPLE_WITH_OPTIONAL)
|
||||
flavors = flavor.Flavor(**EXAMPLE_WITH_OPTIONAL)
|
||||
self.assertEqual(EXAMPLE_WITH_OPTIONAL['name'], flavors.name)
|
||||
self.assertEqual(EXAMPLE_WITH_OPTIONAL['service_type'],
|
||||
flavors.service_type)
|
||||
self.assertEqual(EXAMPLE_WITH_OPTIONAL['tenant_id'],
|
||||
flavors.tenant_id)
|
||||
self.assertEqual(EXAMPLE_WITH_OPTIONAL['description'],
|
||||
flavors.description)
|
||||
self.assertEqual(EXAMPLE_WITH_OPTIONAL['enabled'], flavors.is_enabled)
|
||||
self.assertEqual(EXAMPLE_WITH_OPTIONAL['service_profiles'],
|
||||
flavors.service_profile_ids)
|
||||
|
||||
@@ -26,8 +26,6 @@ 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,
|
||||
}
|
||||
|
||||
@@ -41,13 +39,13 @@ class TestFloatingIP(testtools.TestCase):
|
||||
self.assertEqual('/floatingips', sot.base_path)
|
||||
self.assertEqual('network', sot.service.service_type)
|
||||
self.assertTrue(sot.allow_create)
|
||||
self.assertTrue(sot.allow_retrieve)
|
||||
self.assertTrue(sot.allow_get)
|
||||
self.assertTrue(sot.allow_update)
|
||||
self.assertTrue(sot.allow_delete)
|
||||
self.assertTrue(sot.allow_list)
|
||||
|
||||
def test_make_it(self):
|
||||
sot = floating_ip.FloatingIP(EXAMPLE)
|
||||
sot = floating_ip.FloatingIP(**EXAMPLE)
|
||||
self.assertEqual(EXAMPLE['fixed_ip_address'], sot.fixed_ip_address)
|
||||
self.assertEqual(EXAMPLE['floating_ip_address'],
|
||||
sot.floating_ip_address)
|
||||
@@ -59,38 +57,31 @@ 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()
|
||||
mock_get = mock.Mock()
|
||||
mock_session.get = mock_get
|
||||
mock_session.get_filter = mock.Mock(return_value={})
|
||||
data = {'id': 'one', 'floating_ip_address': '10.0.0.1'}
|
||||
fake_response = mock.Mock()
|
||||
body = {floating_ip.FloatingIP.resources_key: [data]}
|
||||
fake_response.json = mock.Mock(return_value=body)
|
||||
mock_get.return_value = fake_response
|
||||
mock_session.get = mock.Mock(return_value=fake_response)
|
||||
|
||||
result = floating_ip.FloatingIP.find_available(mock_session)
|
||||
|
||||
self.assertEqual('one', result.id)
|
||||
p = {'fields': 'id', 'port_id': ''}
|
||||
mock_get.assert_called_with(
|
||||
mock_session.get.assert_called_with(
|
||||
floating_ip.FloatingIP.base_path,
|
||||
endpoint_filter=floating_ip.FloatingIP.service,
|
||||
headers={'Accept': 'application/json'},
|
||||
params=p)
|
||||
params={'port_id': ''})
|
||||
|
||||
def test_find_available_nada(self):
|
||||
mock_session = mock.Mock()
|
||||
mock_get = mock.Mock()
|
||||
mock_session.get = mock_get
|
||||
fake_response = mock.Mock()
|
||||
body = {floating_ip.FloatingIP.resources_key: []}
|
||||
fake_response.json = mock.Mock(return_value=body)
|
||||
mock_get.return_value = fake_response
|
||||
mock_session.get = mock.Mock(return_value=fake_response)
|
||||
|
||||
self.assertIsNone(floating_ip.FloatingIP.find_available(mock_session))
|
||||
|
||||
@@ -40,13 +40,13 @@ class TestHealthMonitor(testtools.TestCase):
|
||||
self.assertEqual('/lbaas/healthmonitors', sot.base_path)
|
||||
self.assertEqual('network', sot.service.service_type)
|
||||
self.assertTrue(sot.allow_create)
|
||||
self.assertTrue(sot.allow_retrieve)
|
||||
self.assertTrue(sot.allow_get)
|
||||
self.assertTrue(sot.allow_update)
|
||||
self.assertTrue(sot.allow_delete)
|
||||
self.assertTrue(sot.allow_list)
|
||||
|
||||
def test_make_it(self):
|
||||
sot = health_monitor.HealthMonitor(EXAMPLE)
|
||||
sot = health_monitor.HealthMonitor(**EXAMPLE)
|
||||
self.assertTrue(sot.is_admin_state_up)
|
||||
self.assertEqual(EXAMPLE['delay'], sot.delay)
|
||||
self.assertEqual(EXAMPLE['expected_codes'], sot.expected_codes)
|
||||
|
||||
@@ -23,7 +23,7 @@ EXAMPLE = {
|
||||
'id': IDENTIFIER,
|
||||
'loadbalancers': [{'id': '6'}],
|
||||
'name': '7',
|
||||
'tenant_id': '8',
|
||||
'project_id': '8',
|
||||
'protocol': '9',
|
||||
'protocol_port': '10',
|
||||
'default_tls_container_ref': '11',
|
||||
@@ -40,13 +40,13 @@ class TestListener(testtools.TestCase):
|
||||
self.assertEqual('/lbaas/listeners', sot.base_path)
|
||||
self.assertEqual('network', sot.service.service_type)
|
||||
self.assertTrue(sot.allow_create)
|
||||
self.assertTrue(sot.allow_retrieve)
|
||||
self.assertTrue(sot.allow_get)
|
||||
self.assertTrue(sot.allow_update)
|
||||
self.assertTrue(sot.allow_delete)
|
||||
self.assertTrue(sot.allow_list)
|
||||
|
||||
def test_make_it(self):
|
||||
sot = listener.Listener(EXAMPLE)
|
||||
sot = listener.Listener(**EXAMPLE)
|
||||
self.assertTrue(sot.is_admin_state_up)
|
||||
self.assertEqual(EXAMPLE['connection_limit'], sot.connection_limit)
|
||||
self.assertEqual(EXAMPLE['default_pool_id'], sot.default_pool_id)
|
||||
@@ -54,7 +54,7 @@ class TestListener(testtools.TestCase):
|
||||
self.assertEqual(EXAMPLE['id'], sot.id)
|
||||
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['project_id'], sot.project_id)
|
||||
self.assertEqual(EXAMPLE['protocol'], sot.protocol)
|
||||
self.assertEqual(EXAMPLE['protocol_port'], sot.protocol_port)
|
||||
self.assertEqual(EXAMPLE['default_tls_container_ref'],
|
||||
|
||||
@@ -41,13 +41,13 @@ class TestLoadBalancer(testtools.TestCase):
|
||||
self.assertEqual('/lbaas/loadbalancers', sot.base_path)
|
||||
self.assertEqual('network', sot.service.service_type)
|
||||
self.assertTrue(sot.allow_create)
|
||||
self.assertTrue(sot.allow_retrieve)
|
||||
self.assertTrue(sot.allow_get)
|
||||
self.assertTrue(sot.allow_update)
|
||||
self.assertTrue(sot.allow_delete)
|
||||
self.assertTrue(sot.allow_list)
|
||||
|
||||
def test_make_it(self):
|
||||
sot = load_balancer.LoadBalancer(EXAMPLE)
|
||||
sot = load_balancer.LoadBalancer(**EXAMPLE)
|
||||
self.assertTrue(sot.is_admin_state_up)
|
||||
self.assertEqual(EXAMPLE['description'], sot.description)
|
||||
self.assertEqual(EXAMPLE['id'], sot.id)
|
||||
|
||||
Reference in New Issue
Block a user