From 38442dd3c06d9e11977b6509ca0e6b9d186d00d2 Mon Sep 17 00:00:00 2001 From: Brian Curtin Date: Tue, 16 Feb 2016 10:02:28 -0500 Subject: [PATCH] Basic resource.prop for ID attributes (cluster) This patch set updates all cluster objects to use basic properties for ID attributes. In particular, the following changes were made: - Use basic *_id resource.prop for ID attributes Change-Id: I9b4a99fee5a32856f6a5023424e6f12c70618b29 Partial-Bug: #1461200 --- openstack/cluster/v1/action.py | 4 ++-- openstack/cluster/v1/cluster.py | 13 ++++++------- openstack/cluster/v1/event.py | 4 ++-- openstack/cluster/v1/node.py | 8 +++----- openstack/cluster/v1/receiver.py | 9 ++++----- openstack/tests/unit/cluster/v1/test_action.py | 4 ++-- openstack/tests/unit/cluster/v1/test_event.py | 4 ++-- openstack/tests/unit/cluster/v1/test_node.py | 1 - openstack/tests/unit/cluster/v1/test_receiver.py | 8 ++++---- 9 files changed, 25 insertions(+), 30 deletions(-) diff --git a/openstack/cluster/v1/action.py b/openstack/cluster/v1/action.py index 7779fa08d..06c85e023 100644 --- a/openstack/cluster/v1/action.py +++ b/openstack/cluster/v1/action.py @@ -29,13 +29,13 @@ class Action(resource.Resource): #: Name of the action. name = resource.prop('name') #: ID of the target object, which can be a cluster or a node. - target = resource.prop('target') + target_id = resource.prop('target') #: Built-in type name of action. action = resource.prop('action') #: A string representation of the reason why the action was created. cause = resource.prop('cause') #: The owning engine that is currently running the action. - owner = resource.prop('owner') + owner_id = resource.prop('owner') #: Interval in seconds between two consecutive executions. interval = resource.prop('interval') #: The time the action was started. diff --git a/openstack/cluster/v1/cluster.py b/openstack/cluster/v1/cluster.py index 48fa16875..85545eb5e 100644 --- a/openstack/cluster/v1/cluster.py +++ b/openstack/cluster/v1/cluster.py @@ -11,7 +11,6 @@ # under the License. from openstack.cluster import cluster_service -from openstack.cluster.v1 import profile as _profile from openstack import resource from openstack import utils @@ -34,15 +33,15 @@ class Cluster(resource.Resource): #: The name of the cluster. name = resource.prop('name') #: The ID of the profile used by this cluster. - profile = resource.prop('profile_id', type=_profile.Profile) + profile_id = resource.prop('profile_id') #: The ID of the user who created this cluster, thus the owner of it. - user = resource.prop('user') + user_id = resource.prop('user') #: The ID of the project this cluster belongs to. - project = resource.prop('project') + project_id = resource.prop('project') #: The domain ID of the cluster owner. - domain = resource.prop('domain') + domain_id = resource.prop('domain') #: The ID of the parent cluster (if any). - parent = resource.prop('parent') + parent_id = resource.prop('parent') #: Timestamp of when the cluster was initialized. init_at = resource.prop('init_at') #: Timestamp of when the cluster was created. @@ -68,7 +67,7 @@ class Cluster(resource.Resource): #: A dictionary with some runtime data associated with the cluster. data = resource.prop('data', type=dict) #: A list IDs of nodes that are members of the cluster. - nodes = resource.prop('nodes') + node_ids = resource.prop('nodes') #: Name of the profile used by the cluster. profile_name = resource.prop('profile_name') diff --git a/openstack/cluster/v1/event.py b/openstack/cluster/v1/event.py index 963becc2f..d16bc9db5 100644 --- a/openstack/cluster/v1/event.py +++ b/openstack/cluster/v1/event.py @@ -33,8 +33,8 @@ class Event(resource.Resource): obj_type = resource.prop('obj_type') cluster_id = resource.prop('cluster_id') level = resource.prop('level') - user = resource.prop('user') - project = resource.prop('project') + user_id = resource.prop('user') + project_id = resource.prop('project') action = resource.prop('action') status = resource.prop('status') status_reason = resource.prop('status_reason') diff --git a/openstack/cluster/v1/node.py b/openstack/cluster/v1/node.py index f30d0ee3e..4106f54ab 100644 --- a/openstack/cluster/v1/node.py +++ b/openstack/cluster/v1/node.py @@ -11,8 +11,6 @@ # under the License. from openstack.cluster import cluster_service -from openstack.cluster.v1 import cluster as _cluster -from openstack.cluster.v1 import profile as _profile from openstack import resource from openstack import utils @@ -39,11 +37,11 @@ class Node(resource.Resource): physical_id = resource.prop('physical_id') #: The ID of the cluster in which this node is a member. #: A node is an orphan node if this field is empty. - cluster = resource.prop('cluster_id', type=_cluster.Cluster) + cluster_id = resource.prop('cluster_id') #: The ID of the profile used by this node. - profile = resource.prop('profile_id', type=_profile.Profile) + profile_id = resource.prop('profile_id') #: The ID of the project this node belongs to. - project = resource.prop('project') + project_id = resource.prop('project') #: The name of the profile used by this node. profile_name = resource.prop('profile_name') #: An integer that is unique inside the owning cluster. diff --git a/openstack/cluster/v1/receiver.py b/openstack/cluster/v1/receiver.py index 7dc1311f3..e7326e7d7 100644 --- a/openstack/cluster/v1/receiver.py +++ b/openstack/cluster/v1/receiver.py @@ -12,7 +12,6 @@ from openstack.cluster import cluster_service -from openstack.cluster.v1 import cluster as _cluster from openstack import resource @@ -34,13 +33,13 @@ class Receiver(resource.Resource): #: The type of the receiver. type = resource.prop('type') #: The ID of the user who created the receiver, thus the owner of it. - user = resource.prop('user') + user_id = resource.prop('user') #: The ID of the project this receiver belongs to. - project = resource.prop('project') + project_id = resource.prop('project') #: The domain ID of the receiver. - domain = resource.prop('domain') + domain_id = resource.prop('domain') #: The ID of the targeted cluster. - cluster = resource.prop('cluster_id', type=_cluster.Cluster) + cluster_id = resource.prop('cluster_id') #: The name of the targeted action. action = resource.prop('action') #: Timestamp of when the receiver was created. diff --git a/openstack/tests/unit/cluster/v1/test_action.py b/openstack/tests/unit/cluster/v1/test_action.py index 1910b77e5..32acabe61 100644 --- a/openstack/tests/unit/cluster/v1/test_action.py +++ b/openstack/tests/unit/cluster/v1/test_action.py @@ -57,10 +57,10 @@ class TestAction(testtools.TestCase): sot = action.Action(FAKE) self.assertIsNone(sot.id) self.assertEqual(FAKE['name'], sot.name) - self.assertEqual(FAKE['target'], sot.target) + self.assertEqual(FAKE['target'], sot.target_id) self.assertEqual(FAKE['action'], sot.action) self.assertEqual(FAKE['cause'], sot.cause) - self.assertEqual(FAKE['owner'], sot.owner) + self.assertEqual(FAKE['owner'], sot.owner_id) self.assertEqual(FAKE['interval'], sot.interval) self.assertEqual(FAKE['start_time'], sot.start_time) self.assertEqual(FAKE['end_time'], sot.end_time) diff --git a/openstack/tests/unit/cluster/v1/test_event.py b/openstack/tests/unit/cluster/v1/test_event.py index fe62b8f88..c7b692cb9 100644 --- a/openstack/tests/unit/cluster/v1/test_event.py +++ b/openstack/tests/unit/cluster/v1/test_event.py @@ -58,8 +58,8 @@ class TestEvent(testtools.TestCase): self.assertEqual(FAKE['obj_id'], sot.obj_id) self.assertEqual(FAKE['obj_name'], sot.obj_name) self.assertEqual(FAKE['obj_type'], sot.obj_type) - self.assertEqual(FAKE['project'], sot.project) + self.assertEqual(FAKE['project'], sot.project_id) self.assertEqual(FAKE['status'], sot.status) self.assertEqual(FAKE['status_reason'], sot.status_reason) self.assertEqual(FAKE['timestamp'], sot.timestamp) - self.assertEqual(FAKE['user'], sot.user) + self.assertEqual(FAKE['user'], sot.user_id) diff --git a/openstack/tests/unit/cluster/v1/test_node.py b/openstack/tests/unit/cluster/v1/test_node.py index 1985c692a..32a269f2d 100644 --- a/openstack/tests/unit/cluster/v1/test_node.py +++ b/openstack/tests/unit/cluster/v1/test_node.py @@ -72,7 +72,6 @@ class TestNode(testtools.TestCase): sot = node.Node(FAKE) self.assertEqual(FAKE['id'], sot.id) self.assertEqual(FAKE['name'], sot.name) - self.assertEqual(FAKE['profile_id'], sot.profile_id) self.assertEqual(FAKE['cluster_id'], sot.cluster_id) self.assertEqual(FAKE['name'], sot.name) diff --git a/openstack/tests/unit/cluster/v1/test_receiver.py b/openstack/tests/unit/cluster/v1/test_receiver.py index 8fd8f23b5..f5bdee691 100644 --- a/openstack/tests/unit/cluster/v1/test_receiver.py +++ b/openstack/tests/unit/cluster/v1/test_receiver.py @@ -61,12 +61,12 @@ class TestReceiver(testtools.TestCase): self.assertIsNone(sot.id) self.assertEqual(FAKE['name'], sot.name) self.assertEqual(FAKE['type'], sot.type) - self.assertEqual(FAKE['cluster_id'], sot.cluster.id) + self.assertEqual(FAKE['cluster_id'], sot.cluster_id) self.assertEqual(FAKE['action'], sot.action) self.assertEqual(FAKE['params'], sot.params) self.assertEqual(FAKE['created_at'], sot.created_at) self.assertEqual(FAKE['updated_at'], sot.updated_at) - self.assertEqual(FAKE['user'], sot.user) - self.assertEqual(FAKE['project'], sot.project) - self.assertEqual(FAKE['domain'], sot.domain) + self.assertEqual(FAKE['user'], sot.user_id) + self.assertEqual(FAKE['project'], sot.project_id) + self.assertEqual(FAKE['domain'], sot.domain_id) self.assertEqual(FAKE['channel'], sot.channel)