Set Flavor and Image resources on Server
This change sets the resource.prop type for flavor and image to their respective types of flavor.Flavor and image.Image. Change-Id: I153ebfa4da9dcde17fa36863ab83917e901f9861
This commit is contained in:
@@ -13,6 +13,8 @@
|
|||||||
import time
|
import time
|
||||||
|
|
||||||
from openstack.compute import compute_service
|
from openstack.compute import compute_service
|
||||||
|
from openstack.compute.v2 import flavor
|
||||||
|
from openstack.compute.v2 import image
|
||||||
from openstack.compute.v2 import server_ip
|
from openstack.compute.v2 import server_ip
|
||||||
from openstack import exceptions
|
from openstack import exceptions
|
||||||
from openstack import resource
|
from openstack import resource
|
||||||
@@ -50,14 +52,14 @@ class Server(resource.Resource):
|
|||||||
#: The dictionary includes a key for the ``id`` of the flavor, as well
|
#: 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
|
#: as a ``links`` key, which includes a list of relevant links for this
|
||||||
#: flavor. *Type: dict*
|
#: flavor. *Type: dict*
|
||||||
flavor = resource.prop('flavorRef', alias='flavor', type=dict)
|
flavor = resource.prop('flavorRef', alias='flavor', type=flavor.Flavor)
|
||||||
#: An ID representing the host of this server.
|
#: An ID representing the host of this server.
|
||||||
host_id = resource.prop('hostId')
|
host_id = resource.prop('hostId')
|
||||||
#: A dictionary with details on the image this server is running.
|
#: A dictionary with details on the image this server is running.
|
||||||
#: The dictionary includes a key for ``id`` of the image, as well
|
#: 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
|
#: as a ``links`` key, which includes a list of relevant links for this
|
||||||
#: image. *Type: dict*
|
#: image. *Type: dict*
|
||||||
image = resource.prop('imageRef', alias='image', type=dict)
|
image = resource.prop('imageRef', alias='image', type=image.Image)
|
||||||
#: A list of dictionaries holding links relevant to this server.
|
#: A list of dictionaries holding links relevant to this server.
|
||||||
links = resource.prop('links')
|
links = resource.prop('links')
|
||||||
#: Metadata stored for this server. *Type: dict*
|
#: Metadata stored for this server. *Type: dict*
|
||||||
|
|||||||
@@ -13,6 +13,8 @@
|
|||||||
import mock
|
import mock
|
||||||
import testtools
|
import testtools
|
||||||
|
|
||||||
|
from openstack.compute.v2 import flavor
|
||||||
|
from openstack.compute.v2 import image
|
||||||
from openstack.compute.v2 import server
|
from openstack.compute.v2 import server
|
||||||
from openstack import exceptions
|
from openstack import exceptions
|
||||||
|
|
||||||
@@ -67,9 +69,11 @@ class TestServer(testtools.TestCase):
|
|||||||
self.assertEqual(EXAMPLE['addresses'], sot.addresses)
|
self.assertEqual(EXAMPLE['addresses'], sot.addresses)
|
||||||
self.assertEqual(EXAMPLE['created'], sot.created)
|
self.assertEqual(EXAMPLE['created'], sot.created)
|
||||||
self.assertEqual(EXAMPLE['flavorRef'], sot.flavor)
|
self.assertEqual(EXAMPLE['flavorRef'], sot.flavor)
|
||||||
|
self.assertEqual(type(sot.flavor), flavor.Flavor)
|
||||||
self.assertEqual(EXAMPLE['hostId'], sot.host_id)
|
self.assertEqual(EXAMPLE['hostId'], sot.host_id)
|
||||||
self.assertEqual(EXAMPLE['id'], sot.id)
|
self.assertEqual(EXAMPLE['id'], sot.id)
|
||||||
self.assertEqual(EXAMPLE['imageRef'], sot.image)
|
self.assertEqual(EXAMPLE['imageRef'], sot.image)
|
||||||
|
self.assertEqual(type(sot.image), image.Image)
|
||||||
self.assertEqual(EXAMPLE['links'], sot.links)
|
self.assertEqual(EXAMPLE['links'], sot.links)
|
||||||
self.assertEqual(EXAMPLE['metadata'], sot.metadata)
|
self.assertEqual(EXAMPLE['metadata'], sot.metadata)
|
||||||
self.assertEqual(EXAMPLE['name'], sot.name)
|
self.assertEqual(EXAMPLE['name'], sot.name)
|
||||||
|
|||||||
Reference in New Issue
Block a user