diff --git a/openstack/compute/v2/_proxy.py b/openstack/compute/v2/_proxy.py index f96459d56..35f819d5f 100644 --- a/openstack/compute/v2/_proxy.py +++ b/openstack/compute/v2/_proxy.py @@ -76,8 +76,18 @@ class Proxy(proxy.BaseProxy): flv = flavor.FlavorDetail if details else flavor.Flavor return flv.list(self.session, **params) - def update_flavor(self, **data): - return flavor.Flavor(data).update(self.session) + def update_flavor(self, value, **attrs): + """Update a flavor + + :param value: Either the id of a flavor or a + :class:`~openstack.compute.v2.flavor.Flavor` instance. + :attrs kwargs: The attributes to update on the flavor represented + by ``value``. + + :returns: The updated flavor + :rtype: :class:`~openstack.compute.v2.flavor.Flavor` + """ + return self._update(flavor.Flavor, value, **attrs) def delete_image(self, value, ignore_missing=True): """Delete an image @@ -149,8 +159,18 @@ class Proxy(proxy.BaseProxy): def list_keypairs(self, **params): return keypair.Keypair.list(self.session, **params) - def update_keypair(self, **data): - return keypair.Keypair(data).update(self.session) + def update_keypair(self, value, **attrs): + """Update a keypair + + :param value: Either the id of a keypair or a + :class:`~openstack.compute.v2.keypair.Keypair` instance. + :attrs kwargs: The attributes to update on the keypair represented + by ``value``. + + :returns: The updated keypair + :rtype: :class:`~openstack.compute.v2.keypair.Keypair` + """ + return self._update(keypair.Keypair, value, **attrs) def limits(self): """Retrieve limits that are applied to the project's account @@ -254,8 +274,20 @@ class Proxy(proxy.BaseProxy): def list_server_interfaces(self): return server_interface.ServerInterface.list(self.session) - def update_server_interface(self, **data): - return server_interface.ServerInterface(data).update(self.session) + def update_server_interface(self, value, **attrs): + """Update a server interface + + :param value: Either the id of a server interface or a + :class: + `~openstack.compute.v2.server_interface.ServerInterface` + instance. + :attrs kwargs: The attributes to update on the server interface + represented by ``value``. + + :returns: The updated server interface + :rtype: :class:`~openstack.compute.v2.server_interface.ServerInterface` + """ + return self._update(server_interface.ServerInterface, value, **attrs) def find_server_ip(self, name_or_id): return server_ip.ServerIP.find(self.session, name_or_id) diff --git a/openstack/tests/unit/compute/v2/test_proxy.py b/openstack/tests/unit/compute/v2/test_proxy.py index c1e80d6a3..4c419e650 100644 --- a/openstack/tests/unit/compute/v2/test_proxy.py +++ b/openstack/tests/unit/compute/v2/test_proxy.py @@ -65,8 +65,13 @@ class TestComputeProxy(test_proxy_base.TestProxyBase): method_kwargs={"details": True}) def test_flavor_update(self): - self.verify_update('openstack.compute.v2.flavor.Flavor.update', - self.proxy.update_flavor) + kwargs = {"x": 1, "y": 2, "z": 3} + self.verify_update2('openstack.proxy.BaseProxy._update', + self.proxy.update_flavor, + method_args=["resource_or_id"], + method_kwargs=kwargs, + expected_args=[flavor.Flavor, "resource_or_id"], + expected_kwargs=kwargs) def test_image_delete(self): self.verify_delete2(image.Image, self.proxy.delete_image, False) @@ -121,8 +126,13 @@ class TestComputeProxy(test_proxy_base.TestProxyBase): self.proxy.list_keypairs) def test_keypair_update(self): - self.verify_update('openstack.compute.v2.keypair.Keypair.update', - self.proxy.update_keypair) + kwargs = {"x": 1, "y": 2, "z": 3} + self.verify_update2('openstack.proxy.BaseProxy._update', + self.proxy.update_keypair, + method_args=["resource_or_id"], + method_kwargs=kwargs, + expected_args=[keypair.Keypair, "resource_or_id"], + expected_kwargs=kwargs) def test_limits(self): self.verify_get( @@ -161,9 +171,14 @@ class TestComputeProxy(test_proxy_base.TestProxyBase): self.proxy.list_server_interfaces) def test_server_interface_update(self): - self.verify_update( - 'openstack.compute.v2.server_interface.ServerInterface.update', - self.proxy.update_server_interface) + kwargs = {"x": 1, "y": 2, "z": 3} + self.verify_update2('openstack.proxy.BaseProxy._update', + self.proxy.update_server_interface, + method_args=["resource_or_id"], + method_kwargs=kwargs, + expected_args=[server_interface.ServerInterface, + "resource_or_id"], + expected_kwargs=kwargs) def test_server_ip_find(self): self.verify_find('openstack.compute.v2.server_ip.ServerIP.find',