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:
Brian Curtin
2015-03-02 21:11:35 -06:00
committed by Terry Howe
parent 0f0a22d1d1
commit 3f75c4f25e
2 changed files with 8 additions and 2 deletions

View File

@@ -13,6 +13,8 @@
import time
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 import exceptions
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
#: as a ``links`` key, which includes a list of relevant links for this
#: 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.
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=dict)
image = resource.prop('imageRef', alias='image', type=image.Image)
#: A list of dictionaries holding links relevant to this server.
links = resource.prop('links')
#: Metadata stored for this server. *Type: dict*

View File

@@ -13,6 +13,8 @@
import mock
import testtools
from openstack.compute.v2 import flavor
from openstack.compute.v2 import image
from openstack.compute.v2 import server
from openstack import exceptions
@@ -67,9 +69,11 @@ class TestServer(testtools.TestCase):
self.assertEqual(EXAMPLE['addresses'], sot.addresses)
self.assertEqual(EXAMPLE['created'], sot.created)
self.assertEqual(EXAMPLE['flavorRef'], sot.flavor)
self.assertEqual(type(sot.flavor), flavor.Flavor)
self.assertEqual(EXAMPLE['hostId'], sot.host_id)
self.assertEqual(EXAMPLE['id'], sot.id)
self.assertEqual(EXAMPLE['imageRef'], sot.image)
self.assertEqual(type(sot.image), image.Image)
self.assertEqual(EXAMPLE['links'], sot.links)
self.assertEqual(EXAMPLE['metadata'], sot.metadata)
self.assertEqual(EXAMPLE['name'], sot.name)