From 3f75c4f25e80c1162e44ea00bc0e2040bee42845 Mon Sep 17 00:00:00 2001 From: Brian Curtin Date: Mon, 2 Mar 2015 21:11:35 -0600 Subject: [PATCH] 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 --- openstack/compute/v2/server.py | 6 ++++-- openstack/tests/compute/v2/test_server.py | 4 ++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/openstack/compute/v2/server.py b/openstack/compute/v2/server.py index 4fce5382..5ca7e31f 100644 --- a/openstack/compute/v2/server.py +++ b/openstack/compute/v2/server.py @@ -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* diff --git a/openstack/tests/compute/v2/test_server.py b/openstack/tests/compute/v2/test_server.py index 92ed1557..f5c93a18 100644 --- a/openstack/tests/compute/v2/test_server.py +++ b/openstack/tests/compute/v2/test_server.py @@ -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)