Basic resource.prop for ID attributes (compute)

This patch set updates all compute resource objects to use basic
properties for ID attributes. In particular, the following changes
were made:
  - Use basic *_id resource.prop for ID attributes
  - Clarify documentation for ID attributes

Change-Id: I48662698e9a272a9e42a46f6108ed79f5107d8fe
Partial-Bug: #1461200
This commit is contained in:
Richard Theis 2016-02-12 09:34:10 -06:00
parent 6be8f85712
commit 8268a2eba4
5 changed files with 20 additions and 26 deletions

View File

@ -122,7 +122,7 @@ class Proxy(proxy.BaseProxy):
def update_flavor(self, flavor, **attrs):
"""Update a flavor
:param flavor: Either the id of a flavor or a
:param flavor: 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``.
@ -200,7 +200,7 @@ class Proxy(proxy.BaseProxy):
def get_image_metadata(self, image, key=None):
"""Return a dictionary of metadata for an image
:param server: Either the id of an image or a
:param server: Either the ID of an image or a
:class:`~openstack.compute.v2.image.Image` or
:class:`~openstack.compute.v2.image.ImageDetail`
instance.
@ -217,7 +217,7 @@ class Proxy(proxy.BaseProxy):
def create_image_metadata(self, image, **metadata):
"""Create metadata for an image
:param server: Either the id of an image or a
:param server: Either the ID of an image or a
:class:`~openstack.compute.v2.image.Image` or
:class:`~openstack.compute.v2.image.ImageDetail`
instance.
@ -235,7 +235,7 @@ class Proxy(proxy.BaseProxy):
def replace_image_metadata(self, image, **metadata):
"""Replace metadata for an image
:param server: Either the id of a image or a
:param server: Either the ID of a image or a
:class:`~openstack.compute.v2.image.Image` or
:class:`~openstack.compute.v2.image.ImageDetail`
instance.
@ -254,7 +254,7 @@ class Proxy(proxy.BaseProxy):
def update_image_metadata(self, image, **metadata):
"""Update metadata for an image
:param server: Either the id of an image or a
:param server: Either the ID of an image or a
:class:`~openstack.compute.v2.image.Image` or
:class:`~openstack.compute.v2.image.ImageDetail`
instance.
@ -273,7 +273,7 @@ class Proxy(proxy.BaseProxy):
def delete_image_metadata(self, image, key):
"""Delete metadata for an image
:param server: Either the id of an image or a
:param server: Either the ID of an image or a
:class:`~openstack.compute.v2.image.Image` or
:class:`~openstack.compute.v2.image.ImageDetail`
instance.
@ -353,7 +353,7 @@ class Proxy(proxy.BaseProxy):
def update_keypair(self, keypair, **attrs):
"""Update a keypair
:param keypair: Either the id of a keypair or a
:param keypair: 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
@ -476,7 +476,7 @@ class Proxy(proxy.BaseProxy):
def update_server(self, server, **attrs):
"""Update a server
:param server: Either the id of a server or a
:param server: Either the ID of a server or a
:class:`~openstack.compute.v2.server.Server` instance.
:attrs kwargs: The attributes to update on the server represented
by ``server``.
@ -683,7 +683,7 @@ class Proxy(proxy.BaseProxy):
def get_server_metadata(self, server, key=None):
"""Return a dictionary of metadata for a server
:param server: Either the id of a server or a
:param server: Either the ID of a server or a
:class:`~openstack.compute.v2.server.Server` or
:class:`~openstack.compute.v2.server.ServerDetail`
instance.
@ -700,7 +700,7 @@ class Proxy(proxy.BaseProxy):
def create_server_metadata(self, server, **metadata):
"""Create metadata for a server
:param server: Either the id of a server or a
:param server: Either the ID of a server or a
:class:`~openstack.compute.v2.server.Server` or
:class:`~openstack.compute.v2.server.ServerDetail`
instance.
@ -718,7 +718,7 @@ class Proxy(proxy.BaseProxy):
def replace_server_metadata(self, server, **metadata):
"""Replace metadata for a server
:param server: Either the id of a server or a
:param server: Either the ID of a server or a
:class:`~openstack.compute.v2.server.Server` or
:class:`~openstack.compute.v2.server.ServerDetail`
instance.
@ -737,7 +737,7 @@ class Proxy(proxy.BaseProxy):
def update_server_metadata(self, server, **metadata):
"""Update metadata for a server
:param server: Either the id of a server or a
:param server: Either the ID of a server or a
:class:`~openstack.compute.v2.server.Server` or
:class:`~openstack.compute.v2.server.ServerDetail`
instance.
@ -756,7 +756,7 @@ class Proxy(proxy.BaseProxy):
def delete_server_metadata(self, server, key):
"""Delete metadata for a server
:param server: Either the id of a server or a
:param server: Either the ID of a server or a
:class:`~openstack.compute.v2.server.Server` or
:class:`~openstack.compute.v2.server.ServerDetail`
instance.

View File

@ -11,8 +11,6 @@
# under the License.
from openstack.compute import compute_service
from openstack.compute.v2 import flavor
from openstack.compute.v2 import image
from openstack.compute.v2 import metadata
from openstack import resource
from openstack import utils
@ -47,14 +45,14 @@ class Server(resource.Resource, metadata.MetadataMixin):
#: The dictionary includes a key for the ``id`` of the flavor, as well
#: as a ``links`` key, which includes a list of relevant links for this
#: flavor. *Type: dict*
flavor = resource.prop('flavorRef', alias='flavor', type=flavor.Flavor)
flavor_id = resource.prop('flavorRef', alias='flavor', type=dict)
#: An ID representing the host of this server.
host_id = resource.prop('hostId')
#: A dictionary with details on the image this server is running.
#: The dictionary includes a key for ``id`` of the image, as well
#: as a ``links`` key, which includes a list of relevant links for this
#: image. *Type: dict*
image = resource.prop('imageRef', alias='image', type=image.Image)
image_id = resource.prop('imageRef', alias='image', type=dict)
#: A list of dictionaries holding links relevant to this server.
links = resource.prop('links')
#: Metadata stored for this server. *Type: dict*
@ -64,7 +62,7 @@ class Server(resource.Resource, metadata.MetadataMixin):
#: While the server is building, this value represents the percentage
#: of completion. Once it is completed, it will be 100. *Type: int*
progress = resource.prop('progress', type=int)
#: The project this server is associated with.
#: The ID of the project this server is associated with.
project_id = resource.prop('tenant_id')
#: The state this server is in. Valid values include ``ACTIVE``,
#: ``BUILDING``, ``DELETED``, ``ERROR``, ``HARD_REBOOT``, ``PASSWORD``,

View File

@ -39,5 +39,5 @@ class ServerInterface(resource.Resource):
port_id = resource.prop('port_id')
#: The port state.
port_state = resource.prop('port_state')
#: The UUID for the server.
#: The ID for the server.
server_id = resource.prop('server_id')

View File

@ -31,7 +31,7 @@ class ServerIP(resource.Resource):
addr = resource.prop('addr')
#: The network label, such as public or private.
network_label = resource.prop('network_label')
#: The UUID for the server.
#: The ID for the server.
server_id = resource.prop('server_id')
# Version of the IP protocol. Currently either 4 or 6.
version = resource.prop('version')

View File

@ -15,8 +15,6 @@ import copy
import mock
import testtools
from openstack.compute.v2 import flavor
from openstack.compute.v2 import image
from openstack.compute.v2 import server
IDENTIFIER = 'IDENTIFIER'
@ -68,12 +66,10 @@ class TestServer(testtools.TestCase):
self.assertEqual(EXAMPLE['accessIPv6'], sot.access_ipv6)
self.assertEqual(EXAMPLE['addresses'], sot.addresses)
self.assertEqual(EXAMPLE['created'], sot.created_at)
self.assertEqual(EXAMPLE['flavorRef'], sot.flavor)
self.assertIsInstance(sot.flavor, flavor.Flavor)
self.assertEqual(EXAMPLE['flavorRef'], sot.flavor_id)
self.assertEqual(EXAMPLE['hostId'], sot.host_id)
self.assertEqual(EXAMPLE['id'], sot.id)
self.assertEqual(EXAMPLE['imageRef'], sot.image)
self.assertIsInstance(sot.image, image.Image)
self.assertEqual(EXAMPLE['imageRef'], sot.image_id)
self.assertEqual(EXAMPLE['links'], sot.links)
self.assertEqual(EXAMPLE['metadata'], sot.metadata)
self.assertEqual(EXAMPLE['name'], sot.name)