Merge "Proxy update network changes"

This commit is contained in:
Jenkins
2015-05-08 00:10:51 +00:00
committed by Gerrit Code Review
2 changed files with 307 additions and 81 deletions

View File

@@ -49,7 +49,7 @@ class Proxy(proxy.BaseProxy):
:class:`~openstack.exceptions.ResourceNotFound` will be
raised when the floating ip does not exist.
When set to ``True``, no exception will be set when
attempting to delete a nonexistent server.
attempting to delete a nonexistent ip.
:returns: ``None``
"""
@@ -67,8 +67,19 @@ class Proxy(proxy.BaseProxy):
def list_ips(self, **params):
return floating_ip.FloatingIP.list(self.session, **params)
def update_ip(self, **data):
return floating_ip.FloatingIP(**data).update(self.session)
def update_ip(self, value, **attrs):
"""Update a ip
:param value: Either the id of a ip or a
:class:`~openstack.compute.v2.floating_ip.FloatingIP`
instance.
:attrs kwargs: The attributes to update on the ip represented
by ``value``.
:returns: The updated ip
:rtype: :class:`~openstack.compute.v2.floating_ip.FloatingIP`
"""
return self._update(floating_ip.FloatingIP, value, **attrs)
def create_health_monitor(self, **data):
return health_monitor.HealthMonitor(data).create(self.session)
@@ -85,7 +96,7 @@ class Proxy(proxy.BaseProxy):
:class:`~openstack.exceptions.ResourceNotFound` will be
raised when the health monitor does not exist.
When set to ``True``, no exception will be set when
attempting to delete a nonexistent server.
attempting to delete a nonexistent health monitor.
:returns: ``None``
"""
@@ -100,8 +111,19 @@ class Proxy(proxy.BaseProxy):
def list_health_monitors(self):
return health_monitor.HealthMonitor.list(self.session)
def update_health_monitor(self, **data):
return health_monitor.HealthMonitor(data).update(self.session)
def update_health_monitor(self, value, **attrs):
"""Update a health monitor
:param value: Either the id of a health monitor or a
:class:`~openstack.compute.v2.health_monitor.
HealthMonitor` instance.
:attrs kwargs: The attributes to update on the health monitor
represented by ``value``.
:returns: The updated health monitor
:rtype: :class:`~openstack.compute.v2.health_monitor.HealthMonitor`
"""
return self._update(health_monitor.HealthMonitor, value, **attrs)
def create_listener(self, **data):
return listener.Listener(data).create(self.session)
@@ -115,7 +137,7 @@ class Proxy(proxy.BaseProxy):
:class:`~openstack.exceptions.ResourceNotFound` will be
raised when the listner does not exist.
When set to ``True``, no exception will be set when
attempting to delete a nonexistent server.
attempting to delete a nonexistent listener.
:returns: ``None``
"""
@@ -130,8 +152,19 @@ class Proxy(proxy.BaseProxy):
def list_listeners(self):
return listener.Listener.list(self.session)
def update_listener(self, **data):
return listener.Listener(data).update(self.session)
def update_listener(self, value, **attrs):
"""Update a listener
:param value: Either the id of a listener or a
:class:`~openstack.compute.v2.listener.Listener`
instance.
:attrs kwargs: The attributes to update on the listener represented
by ``value``.
:returns: The updated listener
:rtype: :class:`~openstack.compute.v2.listener.Listener`
"""
return self._update(listener.Listener, value, **attrs)
def create_load_balancer(self, **data):
return load_balancer.LoadBalancer(data).create(self.session)
@@ -146,7 +179,7 @@ class Proxy(proxy.BaseProxy):
:class:`~openstack.exceptions.ResourceNotFound` will be
raised when the load balancer does not exist.
When set to ``True``, no exception will be set when
attempting to delete a nonexistent server.
attempting to delete a nonexistent load balancer.
:returns: ``None``
"""
@@ -161,8 +194,19 @@ class Proxy(proxy.BaseProxy):
def list_load_balancers(self):
return load_balancer.LoadBalancer.list(self.session)
def update_load_balancer(self, **data):
return load_balancer.LoadBalancer(data).update(self.session)
def update_load_balancer(self, value, **attrs):
"""Update a load balancer
:param value: Either the id of a load balancer or a
:class:`~openstack.compute.v2.load_balancer.LoadBalancer`
instance.
:attrs kwargs: The attributes to update on the load balancer
represented by ``value``.
:returns: The updated load balancer
:rtype: :class:`~openstack.compute.v2.load_balancer.LoadBalancer`
"""
return self._update(load_balancer.LoadBalancer, value, **attrs)
def create_metering_label(self, **data):
return metering_label.MeteringLabel(data).create(self.session)
@@ -177,7 +221,7 @@ class Proxy(proxy.BaseProxy):
:class:`~openstack.exceptions.ResourceNotFound` will be
raised when the metering label does not exist.
When set to ``True``, no exception will be set when
attempting to delete a nonexistent server.
attempting to delete a nonexistent metering label.
:returns: ``None``
"""
@@ -192,8 +236,19 @@ class Proxy(proxy.BaseProxy):
def list_metering_labels(self):
return metering_label.MeteringLabel.list(self.session)
def update_metering_label(self, **data):
return metering_label.MeteringLabel(data).update(self.session)
def update_metering_label(self, value, **attrs):
"""Update a metering label
:param value: Either the id of a metering label or a
:class:`~openstack.compute.v2.metering_label.
MeteringLabel` instance.
:attrs kwargs: The attributes to update on the metering label
represented by ``value``.
:returns: The updated metering label
:rtype: :class:`~openstack.compute.v2.metering_label.MeteringLabel`
"""
return self._update(metering_label.MeteringLabel, value, **attrs)
def create_metering_label_rule(self, **data):
return metering_label_rule.MeteringLabelRule(data).create(self.session)
@@ -209,7 +264,7 @@ class Proxy(proxy.BaseProxy):
:class:`~openstack.exceptions.ResourceNotFound` will be
raised when the metering label rule does not exist.
When set to ``True``, no exception will be set when
attempting to delete a nonexistent server.
attempting to delete a nonexistent metering label rule.
:returns: ``None``
"""
@@ -226,8 +281,21 @@ class Proxy(proxy.BaseProxy):
def list_metering_label_rules(self):
return metering_label_rule.MeteringLabelRule.list(self.session)
def update_metering_label_rule(self, **data):
return metering_label_rule.MeteringLabelRule(data).update(self.session)
def update_metering_label_rule(self, value, **attrs):
"""Update a metering label rule
:param value: Either the id of a metering label rule or a
:class:`~openstack.compute.v2.metering_label_rule.
MeteringLabelRule` instance.
:attrs kwargs: The attributes to update on the metering label rule
represented by ``value``.
:returns: The updated metering label rule
:rtype: :class:`~openstack.compute.v2.metering_label_rule.
MeteringLabelRule`
"""
return self._update(metering_label_rule.MeteringLabelRule, value,
**attrs)
def create_network(self, **data):
return network.Network(data).create(self.session)
@@ -241,7 +309,7 @@ class Proxy(proxy.BaseProxy):
:class:`~openstack.exceptions.ResourceNotFound` will be
raised when the network does not exist.
When set to ``True``, no exception will be set when
attempting to delete a nonexistent server.
attempting to delete a nonexistent network.
:returns: ``None``
"""
@@ -256,8 +324,18 @@ class Proxy(proxy.BaseProxy):
def list_networks(self, **params):
return network.Network.list(self.session, **params)
def update_network(self, **data):
return network.Network(data).update(self.session)
def update_network(self, value, **attrs):
"""Update a network
:param value: Either the id of a network or a
:class:`~openstack.compute.v2.network.Network` instance.
:attrs kwargs: The attributes to update on the network represented
by ``value``.
:returns: The updated network
:rtype: :class:`~openstack.compute.v2.network.Network`
"""
return self._update(network.Network, value, **attrs)
def create_pool(self, **data):
return pool.Pool(data).create(self.session)
@@ -271,7 +349,7 @@ class Proxy(proxy.BaseProxy):
:class:`~openstack.exceptions.ResourceNotFound` will be
raised when the pool does not exist.
When set to ``True``, no exception will be set when
attempting to delete a nonexistent server.
attempting to delete a nonexistent pool.
:returns: ``None``
"""
@@ -286,8 +364,18 @@ class Proxy(proxy.BaseProxy):
def list_pools(self):
return pool.Pool.list(self.session)
def update_pool(self, **data):
return pool.Pool(data).update(self.session)
def update_pool(self, value, **attrs):
"""Update a pool
:param value: Either the id of a pool or a
:class:`~openstack.compute.v2.pool.Pool` instance.
:attrs kwargs: The attributes to update on the pool represented
by ``value``.
:returns: The updated pool
:rtype: :class:`~openstack.compute.v2.pool.Pool`
"""
return self._update(pool.Pool, value, **attrs)
def create_pool_member(self, **data):
return pool_member.PoolMember(data).create(self.session)
@@ -302,7 +390,7 @@ class Proxy(proxy.BaseProxy):
:class:`~openstack.exceptions.ResourceNotFound` will be
raised when the pool member does not exist.
When set to ``True``, no exception will be set when
attempting to delete a nonexistent server.
attempting to delete a nonexistent pool member.
:returns: ``None``
"""
@@ -317,8 +405,19 @@ class Proxy(proxy.BaseProxy):
def list_pool_members(self):
return pool_member.PoolMember.list(self.session)
def update_pool_member(self, **data):
return pool_member.PoolMember(data).update(self.session)
def update_pool_member(self, value, **attrs):
"""Update a pool member
:param value: Either the id of a pool member or a
:class:`~openstack.compute.v2.pool_member.PoolMember`
instance.
:attrs kwargs: The attributes to update on the pool member represented
by ``value``.
:returns: The updated pool member
:rtype: :class:`~openstack.compute.v2.pool_member.PoolMember`
"""
return self._update(pool_member.PoolMember, value, **attrs)
def create_port(self, **data):
return port.Port(data).create(self.session)
@@ -332,7 +431,7 @@ class Proxy(proxy.BaseProxy):
:class:`~openstack.exceptions.ResourceNotFound` will be
raised when the port does not exist.
When set to ``True``, no exception will be set when
attempting to delete a nonexistent server.
attempting to delete a nonexistent port.
:returns: ``None``
"""
@@ -347,8 +446,18 @@ class Proxy(proxy.BaseProxy):
def list_ports(self, **params):
return port.Port.list(self.session, **params)
def update_port(self, **data):
return port.Port(data).update(self.session)
def update_port(self, value, **attrs):
"""Update a port
:param value: Either the id of a port or a
:class:`~openstack.compute.v2.port.Port` instance.
:attrs kwargs: The attributes to update on the port represented
by ``value``.
:returns: The updated port
:rtype: :class:`~openstack.compute.v2.port.Port`
"""
return self._update(port.Port, value, **attrs)
def add_ip_to_port(self, port, ip):
ip['port_id'] = port.id
@@ -382,7 +491,7 @@ class Proxy(proxy.BaseProxy):
:class:`~openstack.exceptions.ResourceNotFound` will be
raised when the router does not exist.
When set to ``True``, no exception will be set when
attempting to delete a nonexistent server.
attempting to delete a nonexistent router.
:returns: ``None``
"""
@@ -397,8 +506,18 @@ class Proxy(proxy.BaseProxy):
def list_routers(self, **params):
return router.Router.list(self.session, **params)
def update_router(self, **data):
return router.Router(**data).update(self.session)
def update_router(self, value, **attrs):
"""Update a router
:param value: Either the id of a router or a
:class:`~openstack.compute.v2.router.Router` instance.
:attrs kwargs: The attributes to update on the router represented
by ``value``.
:returns: The updated router
:rtype: :class:`~openstack.compute.v2.router.Router`
"""
return self._update(router.Router, value, **attrs)
def router_add_interface(self, router, subnet_id):
router.add_interface(self.session, subnet_id)
@@ -419,7 +538,7 @@ class Proxy(proxy.BaseProxy):
:class:`~openstack.exceptions.ResourceNotFound` will be
raised when the security group does not exist.
When set to ``True``, no exception will be set when
attempting to delete a nonexistent server.
attempting to delete a nonexistent security group.
:returns: ``None``
"""
@@ -434,8 +553,20 @@ class Proxy(proxy.BaseProxy):
def list_security_groups(self, **params):
return security_group.SecurityGroup.list(self.session, **params)
def update_security_group(self, **data):
return security_group.SecurityGroup(**data).update(self.session)
def update_security_group(self, value, **attrs):
"""Update a security group
:param value: Either the id of a security group or a
:class:`~openstack.compute.v2.security_group.
SecurityGroup`
instance.
:attrs kwargs: The attributes to update on the security group
represented by ``value``.
:returns: The updated security group
:rtype: :class:`~openstack.compute.v2.security_group.SecurityGroup`
"""
return self._update(security_group.SecurityGroup, value, **attrs)
def security_group_open_port(self, sgid, port, protocol='tcp'):
rule = {
@@ -476,7 +607,7 @@ class Proxy(proxy.BaseProxy):
:class:`~openstack.exceptions.ResourceNotFound` will be
raised when the security group rule does not exist.
When set to ``True``, no exception will be set when
attempting to delete a nonexistent server.
attempting to delete a nonexistent security group rule.
:returns: ``None``
"""
@@ -495,9 +626,21 @@ class Proxy(proxy.BaseProxy):
return security_group_rule.SecurityGroupRule.list(self.session,
**params)
def update_security_group_rule(self, **data):
obj = security_group_rule.SecurityGroupRule(**data)
return obj.update(self.session)
def update_security_group_rule(self, value, **attrs):
"""Update a security group rule
:param value: Either the id of a security group rule or a
:class:`~openstack.compute.v2.security_group_rule.
SecurityGroupRule` instance.
:attrs kwargs: The attributes to update on the security group rule
represented by ``value``.
:returns: The updated security group rule
:rtype: :class:`~openstack.compute.v2.security_group_rule.
SecurityGroupRule`
"""
return self._update(security_group_rule.SecurityGroupRule, value,
**attrs)
def create_subnet(self, **data):
return subnet.Subnet(data).create(self.session)
@@ -511,7 +654,7 @@ class Proxy(proxy.BaseProxy):
:class:`~openstack.exceptions.ResourceNotFound` will be
raised when the subnet does not exist.
When set to ``True``, no exception will be set when
attempting to delete a nonexistent server.
attempting to delete a nonexistent subnet.
:returns: ``None``
"""
@@ -526,5 +669,15 @@ class Proxy(proxy.BaseProxy):
def list_subnets(self, **params):
return subnet.Subnet.list(self.session, **params)
def update_subnet(self, **data):
return subnet.Subnet(**data).update(self.session)
def update_subnet(self, value, **attrs):
"""Update a subnet
:param value: Either the id of a subnet or a
:class:`~openstack.compute.v2.subnet.Subnet` instance.
:attrs kwargs: The attributes to update on the subnet represented
by ``value``.
:returns: The updated subnet
:rtype: :class:`~openstack.compute.v2.subnet.Subnet`
"""
return self._update(subnet.Subnet, value, **attrs)

View File

@@ -69,9 +69,14 @@ class TestNetworkProxy(test_proxy_base.TestProxyBase):
self.proxy.list_ips)
def test_floating_ip_update(self):
self.verify_update(
'openstack.network.v2.floating_ip.FloatingIP.update',
self.proxy.update_ip)
kwargs = {"x": 1, "y": 2, "z": 3}
self.verify_update2('openstack.proxy.BaseProxy._update',
self.proxy.update_ip,
method_args=["resource_or_id"],
method_kwargs=kwargs,
expected_args=[floating_ip.FloatingIP,
"resource_or_id"],
expected_kwargs=kwargs)
def test_health_monitor_create(self):
self.verify_create(
@@ -102,9 +107,14 @@ class TestNetworkProxy(test_proxy_base.TestProxyBase):
self.proxy.list_health_monitors)
def test_health_monitor_update(self):
self.verify_update(
'openstack.network.v2.health_monitor.HealthMonitor.update',
self.proxy.update_health_monitor)
kwargs = {"x": 1, "y": 2, "z": 3}
self.verify_update2('openstack.proxy.BaseProxy._update',
self.proxy.update_health_monitor,
method_args=["resource_or_id"],
method_kwargs=kwargs,
expected_args=[health_monitor.HealthMonitor,
"resource_or_id"],
expected_kwargs=kwargs)
def test_listener_create(self):
self.verify_create('openstack.network.v2.listener.Listener.create',
@@ -131,8 +141,14 @@ class TestNetworkProxy(test_proxy_base.TestProxyBase):
self.proxy.list_listeners)
def test_listener_update(self):
self.verify_update('openstack.network.v2.listener.Listener.update',
self.proxy.update_listener)
kwargs = {"x": 1, "y": 2, "z": 3}
self.verify_update2('openstack.proxy.BaseProxy._update',
self.proxy.update_listener,
method_args=["resource_or_id"],
method_kwargs=kwargs,
expected_args=[listener.Listener,
"resource_or_id"],
expected_kwargs=kwargs)
def test_load_balancer_create(self):
self.verify_create(
@@ -162,9 +178,14 @@ class TestNetworkProxy(test_proxy_base.TestProxyBase):
self.proxy.list_load_balancers)
def test_load_balancer_update(self):
self.verify_update(
'openstack.network.v2.load_balancer.LoadBalancer.update',
self.proxy.update_load_balancer)
kwargs = {"x": 1, "y": 2, "z": 3}
self.verify_update2('openstack.proxy.BaseProxy._update',
self.proxy.update_load_balancer,
method_args=["resource_or_id"],
method_kwargs=kwargs,
expected_args=[load_balancer.LoadBalancer,
"resource_or_id"],
expected_kwargs=kwargs)
def test_metering_label_create(self):
self.verify_create(
@@ -195,9 +216,14 @@ class TestNetworkProxy(test_proxy_base.TestProxyBase):
self.proxy.list_metering_labels)
def test_metering_label_update(self):
self.verify_update(
'openstack.network.v2.metering_label.MeteringLabel.update',
self.proxy.update_metering_label)
kwargs = {"x": 1, "y": 2, "z": 3}
self.verify_update2('openstack.proxy.BaseProxy._update',
self.proxy.update_metering_label,
method_args=["resource_or_id"],
method_kwargs=kwargs,
expected_args=[metering_label.MeteringLabel,
"resource_or_id"],
expected_kwargs=kwargs)
def test_metering_label_rule_create(self):
self.verify_create(
@@ -229,10 +255,16 @@ class TestNetworkProxy(test_proxy_base.TestProxyBase):
self.proxy.list_metering_label_rules)
def test_metering_label_rule_update(self):
self.verify_update(
('openstack.network.v2.metering_label_rule.MeteringLabelRule' +
'.update'),
self.proxy.update_metering_label_rule)
kwargs = {"x": 1, "y": 2, "z": 3}
self.verify_update2('openstack.proxy.BaseProxy._update',
self.proxy.update_metering_label_rule,
method_args=["resource_or_id"],
method_kwargs=kwargs,
expected_args=[
metering_label_rule.MeteringLabelRule,
"resource_or_id"
],
expected_kwargs=kwargs)
def test_network_create(self):
self.verify_create('openstack.network.v2.network.Network.create',
@@ -257,8 +289,13 @@ class TestNetworkProxy(test_proxy_base.TestProxyBase):
self.proxy.list_networks)
def test_network_update(self):
self.verify_update('openstack.network.v2.network.Network.update',
self.proxy.update_network)
kwargs = {"x": 1, "y": 2, "z": 3}
self.verify_update2('openstack.proxy.BaseProxy._update',
self.proxy.update_network,
method_args=["resource_or_id"],
method_kwargs=kwargs,
expected_args=[network.Network, "resource_or_id"],
expected_kwargs=kwargs)
def test_pool_member_create(self):
self.verify_create(
@@ -286,9 +323,14 @@ class TestNetworkProxy(test_proxy_base.TestProxyBase):
self.proxy.list_pool_members)
def test_pool_member_update(self):
self.verify_update(
'openstack.network.v2.pool_member.PoolMember.update',
self.proxy.update_pool_member)
kwargs = {"x": 1, "y": 2, "z": 3}
self.verify_update2('openstack.proxy.BaseProxy._update',
self.proxy.update_pool_member,
method_args=["resource_or_id"],
method_kwargs=kwargs,
expected_args=[pool_member.PoolMember,
"resource_or_id"],
expected_kwargs=kwargs)
def test_pool_create(self):
self.verify_create('openstack.network.v2.pool.Pool.create',
@@ -313,8 +355,13 @@ class TestNetworkProxy(test_proxy_base.TestProxyBase):
self.proxy.list_pools)
def test_pool_update(self):
self.verify_update('openstack.network.v2.pool.Pool.update',
self.proxy.update_pool)
kwargs = {"x": 1, "y": 2, "z": 3}
self.verify_update2('openstack.proxy.BaseProxy._update',
self.proxy.update_pool,
method_args=["resource_or_id"],
method_kwargs=kwargs,
expected_args=[pool.Pool, "resource_or_id"],
expected_kwargs=kwargs)
def test_port_create(self):
self.verify_create('openstack.network.v2.port.Port.create',
@@ -339,8 +386,13 @@ class TestNetworkProxy(test_proxy_base.TestProxyBase):
self.proxy.list_ports)
def test_port_update(self):
self.verify_update('openstack.network.v2.port.Port.update',
self.proxy.update_port)
kwargs = {"x": 1, "y": 2, "z": 3}
self.verify_update2('openstack.proxy.BaseProxy._update',
self.proxy.update_port,
method_args=["resource_or_id"],
method_kwargs=kwargs,
expected_args=[port.Port, "resource_or_id"],
expected_kwargs=kwargs)
def test_quota_list(self):
self.verify_list('openstack.network.v2.quota.Quota.list',
@@ -369,8 +421,13 @@ class TestNetworkProxy(test_proxy_base.TestProxyBase):
self.proxy.list_routers)
def test_router_update(self):
self.verify_update('openstack.network.v2.router.Router.update',
self.proxy.update_router)
kwargs = {"x": 1, "y": 2, "z": 3}
self.verify_update2('openstack.proxy.BaseProxy._update',
self.proxy.update_router,
method_args=["resource_or_id"],
method_kwargs=kwargs,
expected_args=[router.Router, "resource_or_id"],
expected_kwargs=kwargs)
def test_security_group_create(self):
self.verify_create(
@@ -401,9 +458,14 @@ class TestNetworkProxy(test_proxy_base.TestProxyBase):
self.proxy.list_security_groups)
def test_security_group_update(self):
self.verify_update(
'openstack.network.v2.security_group.SecurityGroup.update',
self.proxy.update_security_group)
kwargs = {"x": 1, "y": 2, "z": 3}
self.verify_update2('openstack.proxy.BaseProxy._update',
self.proxy.update_security_group,
method_args=["resource_or_id"],
method_kwargs=kwargs,
expected_args=[security_group.SecurityGroup,
"resource_or_id"],
expected_kwargs=kwargs)
def test_security_group_open_port(self):
mock_class = 'openstack.network.v2._proxy.Proxy'
@@ -476,10 +538,16 @@ class TestNetworkProxy(test_proxy_base.TestProxyBase):
self.proxy.list_security_group_rules)
def test_security_group_rule_update(self):
self.verify_update(
('openstack.network.v2.security_group_rule.SecurityGroupRule' +
'.update'),
self.proxy.update_security_group_rule)
kwargs = {"x": 1, "y": 2, "z": 3}
self.verify_update2('openstack.proxy.BaseProxy._update',
self.proxy.update_security_group_rule,
method_args=["resource_or_id"],
method_kwargs=kwargs,
expected_args=[
security_group_rule.SecurityGroupRule,
"resource_or_id"
],
expected_kwargs=kwargs)
def test_subnet_create(self):
self.verify_create('openstack.network.v2.subnet.Subnet.create',
@@ -504,5 +572,10 @@ class TestNetworkProxy(test_proxy_base.TestProxyBase):
self.proxy.list_subnets)
def test_subnet_update(self):
self.verify_update('openstack.network.v2.subnet.Subnet.update',
self.proxy.update_subnet)
kwargs = {"x": 1, "y": 2, "z": 3}
self.verify_update2('openstack.proxy.BaseProxy._update',
self.proxy.update_subnet,
method_args=["resource_or_id"],
method_kwargs=kwargs,
expected_args=[subnet.Subnet, "resource_or_id"],
expected_kwargs=kwargs)