Consistent resource.prop for timestamps and booleans (orchestration)
This patch set updates all orchestration objects to use consistent resource.prop for timestamps and booleans. In particular, the following changes were made: - Clarify documentation for timestamp and boolean attributes - Use 'is_' prefix and boolean type for boolean attributes - Use '_at' suffix and timestamp type for timestamp attributes Change-Id: Ic84a481a25e845ad3e05ffeefb55d56371b571bc Partial-Bug: #1544584
This commit is contained in:
@@ -10,6 +10,7 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
from openstack import format
|
||||||
from openstack.orchestration import orchestration_service
|
from openstack.orchestration import orchestration_service
|
||||||
from openstack import resource
|
from openstack import resource
|
||||||
|
|
||||||
@@ -29,12 +30,13 @@ class Resource(resource.Resource):
|
|||||||
allow_update = False
|
allow_update = False
|
||||||
|
|
||||||
# Properties
|
# Properties
|
||||||
name = resource.prop('resource_name')
|
|
||||||
#: A list of dictionaries containing links relevant to the resource.
|
#: A list of dictionaries containing links relevant to the resource.
|
||||||
links = resource.prop('links')
|
links = resource.prop('links')
|
||||||
#: ID of the logical resource, usually the literal name of the resource
|
#: ID of the logical resource, usually the literal name of the resource
|
||||||
#: as it appears in the stack template.
|
#: as it appears in the stack template.
|
||||||
logical_resource_id = resource.prop('logical_resource_id')
|
logical_resource_id = resource.prop('logical_resource_id')
|
||||||
|
#: Name of the resource.
|
||||||
|
name = resource.prop('resource_name')
|
||||||
#: ID of the physical resource (if any) that backs up the resource. For
|
#: ID of the physical resource (if any) that backs up the resource. For
|
||||||
#: example, it contains a nova server ID if the resource is a nova
|
#: example, it contains a nova server ID if the resource is a nova
|
||||||
#: server.
|
#: server.
|
||||||
@@ -50,4 +52,5 @@ class Resource(resource.Resource):
|
|||||||
#: A string that explains why the resource is in its current status.
|
#: A string that explains why the resource is in its current status.
|
||||||
status_reason = resource.prop('resource_status_reason')
|
status_reason = resource.prop('resource_status_reason')
|
||||||
#: Timestamp of the last update made to the resource.
|
#: Timestamp of the last update made to the resource.
|
||||||
updated_at = resource.prop('updated_time')
|
#: *Type: datetime object parsed from ISO 8601 formatted string*
|
||||||
|
updated_at = resource.prop('updated_time', type=format.ISO8601)
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from openstack import exceptions
|
from openstack import exceptions
|
||||||
|
from openstack import format
|
||||||
from openstack.orchestration import orchestration_service
|
from openstack.orchestration import orchestration_service
|
||||||
from openstack import resource
|
from openstack import resource
|
||||||
from openstack import utils
|
from openstack import utils
|
||||||
@@ -32,25 +33,27 @@ class Stack(resource.Resource):
|
|||||||
allow_delete = True
|
allow_delete = True
|
||||||
|
|
||||||
# Properties
|
# Properties
|
||||||
name = resource.prop('stack_name')
|
|
||||||
#: Placeholder for AWS compatible template listing capabilities
|
#: Placeholder for AWS compatible template listing capabilities
|
||||||
#: required by the stack.
|
#: required by the stack.
|
||||||
capabilities = resource.prop('capabilities')
|
capabilities = resource.prop('capabilities')
|
||||||
#: Timestamp of the stack creation.
|
#: Timestamp of the stack creation.
|
||||||
created_at = resource.prop('creation_time')
|
#: *Type: datetime object parsed from ISO 8601 formatted string*
|
||||||
#: A text decription of the stack.
|
created_at = resource.prop('creation_time', type=format.ISO8601)
|
||||||
|
#: A text description of the stack.
|
||||||
description = resource.prop('description')
|
description = resource.prop('description')
|
||||||
#: Whether the stack will support a rollback operation on stack
|
#: Whether the stack will support a rollback operation on stack
|
||||||
#: create/update failures.
|
#: create/update failures. *Type: bool*
|
||||||
disable_rollback = resource.prop('disable_rollback', type=bool)
|
is_rollback_disabled = resource.prop('disable_rollback', type=bool)
|
||||||
#: A list of dictionaris containing links relevant to the stack.
|
#: A list of dictionaries containing links relevant to the stack.
|
||||||
links = resource.prop('links')
|
links = resource.prop('links')
|
||||||
|
#: Name of the stack.
|
||||||
|
name = resource.prop('stack_name')
|
||||||
#: Placeholder for future extensions where stack related events
|
#: Placeholder for future extensions where stack related events
|
||||||
#: can be published.
|
#: can be published.
|
||||||
notification_topics = resource.prop('notification_topics')
|
notification_topics = resource.prop('notification_topics')
|
||||||
#: A dictionary containing output keys and values from the stack, if any.
|
#: A dictionary containing output keys and values from the stack, if any.
|
||||||
outputs = resource.prop('outputs')
|
outputs = resource.prop('outputs')
|
||||||
#: A ditionary containing the parameter names and values for the stack.
|
#: A dictionary containing the parameter names and values for the stack.
|
||||||
parameters = resource.prop('parameters', type=dict)
|
parameters = resource.prop('parameters', type=dict)
|
||||||
#: A string representation of the stack status, e.g. ``CREATE_COMPLETED``.
|
#: A string representation of the stack status, e.g. ``CREATE_COMPLETED``.
|
||||||
status = resource.prop('stack_status')
|
status = resource.prop('stack_status')
|
||||||
@@ -64,7 +67,8 @@ class Stack(resource.Resource):
|
|||||||
#: Stack operation timeout in minutes.
|
#: Stack operation timeout in minutes.
|
||||||
timeout_mins = resource.prop('timeout_mins')
|
timeout_mins = resource.prop('timeout_mins')
|
||||||
#: Timestamp of last update on the stack.
|
#: Timestamp of last update on the stack.
|
||||||
updated_at = resource.prop('updated_time')
|
#: *Type: datetime object parsed from ISO 8601 formatted string*
|
||||||
|
updated_at = resource.prop('updated_time', type=format.ISO8601)
|
||||||
|
|
||||||
def _action(self, session, body):
|
def _action(self, session, body):
|
||||||
"""Perform stack actions"""
|
"""Perform stack actions"""
|
||||||
|
|||||||
@@ -10,6 +10,8 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
import datetime
|
||||||
|
|
||||||
import testtools
|
import testtools
|
||||||
|
|
||||||
from openstack.orchestration.v1 import resource
|
from openstack.orchestration.v1 import resource
|
||||||
@@ -32,7 +34,7 @@ FAKE = {
|
|||||||
'resource_type': 'OS::Heat::FakeResource',
|
'resource_type': 'OS::Heat::FakeResource',
|
||||||
'status': 'CREATE_COMPLETE',
|
'status': 'CREATE_COMPLETE',
|
||||||
'status_reason': 'state changed',
|
'status_reason': 'state changed',
|
||||||
'updated_time': '2015-05-05T07:26:00Z',
|
'updated_time': '2015-03-09T12:15:57.233772',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -62,4 +64,6 @@ class TestResource(testtools.TestCase):
|
|||||||
self.assertEqual(FAKE['resource_type'], sot.resource_type)
|
self.assertEqual(FAKE['resource_type'], sot.resource_type)
|
||||||
self.assertEqual(FAKE['status'], sot.status)
|
self.assertEqual(FAKE['status'], sot.status)
|
||||||
self.assertEqual(FAKE['status_reason'], sot.status_reason)
|
self.assertEqual(FAKE['status_reason'], sot.status_reason)
|
||||||
self.assertEqual(FAKE['updated_time'], sot.updated_at)
|
dt = datetime.datetime(2015, 3, 9, 12, 15, 57, 233772).replace(
|
||||||
|
tzinfo=None)
|
||||||
|
self.assertEqual(dt, sot.updated_at.replace(tzinfo=None))
|
||||||
|
|||||||
@@ -10,6 +10,8 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
import datetime
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
import six
|
import six
|
||||||
import testtools
|
import testtools
|
||||||
@@ -23,7 +25,7 @@ FAKE_ID = 'ce8ae86c-9810-4cb1-8888-7fb53bc523bf'
|
|||||||
FAKE_NAME = 'test_stack'
|
FAKE_NAME = 'test_stack'
|
||||||
FAKE = {
|
FAKE = {
|
||||||
'capabilities': '1',
|
'capabilities': '1',
|
||||||
'creation_time': '2',
|
'creation_time': '2015-03-09T12:15:57.233772',
|
||||||
'description': '3',
|
'description': '3',
|
||||||
'disable_rollback': True,
|
'disable_rollback': True,
|
||||||
'id': FAKE_ID,
|
'id': FAKE_ID,
|
||||||
@@ -39,7 +41,7 @@ FAKE = {
|
|||||||
'template_description': '13',
|
'template_description': '13',
|
||||||
'template_url': 'http://www.example.com/wordpress.yaml',
|
'template_url': 'http://www.example.com/wordpress.yaml',
|
||||||
'timeout_mins': '14',
|
'timeout_mins': '14',
|
||||||
'updated_time': '15',
|
'updated_time': '2015-03-09T12:30:00.000000',
|
||||||
}
|
}
|
||||||
FAKE_CREATE_RESPONSE = {
|
FAKE_CREATE_RESPONSE = {
|
||||||
'stack': {
|
'stack': {
|
||||||
@@ -67,9 +69,11 @@ class TestStack(testtools.TestCase):
|
|||||||
def test_make_it(self):
|
def test_make_it(self):
|
||||||
sot = stack.Stack(FAKE)
|
sot = stack.Stack(FAKE)
|
||||||
self.assertEqual(FAKE['capabilities'], sot.capabilities)
|
self.assertEqual(FAKE['capabilities'], sot.capabilities)
|
||||||
self.assertEqual(FAKE['creation_time'], sot.created_at)
|
dt = datetime.datetime(2015, 3, 9, 12, 15, 57, 233772).replace(
|
||||||
|
tzinfo=None)
|
||||||
|
self.assertEqual(dt, sot.created_at.replace(tzinfo=None))
|
||||||
self.assertEqual(FAKE['description'], sot.description)
|
self.assertEqual(FAKE['description'], sot.description)
|
||||||
self.assertEqual(FAKE['disable_rollback'], sot.disable_rollback)
|
self.assertTrue(sot.is_rollback_disabled)
|
||||||
self.assertEqual(FAKE['id'], sot.id)
|
self.assertEqual(FAKE['id'], sot.id)
|
||||||
self.assertEqual(FAKE['links'], sot.links)
|
self.assertEqual(FAKE['links'], sot.links)
|
||||||
self.assertEqual(FAKE['notification_topics'],
|
self.assertEqual(FAKE['notification_topics'],
|
||||||
@@ -85,7 +89,9 @@ class TestStack(testtools.TestCase):
|
|||||||
self.assertEqual(FAKE['template_url'],
|
self.assertEqual(FAKE['template_url'],
|
||||||
sot.template_url)
|
sot.template_url)
|
||||||
self.assertEqual(FAKE['timeout_mins'], sot.timeout_mins)
|
self.assertEqual(FAKE['timeout_mins'], sot.timeout_mins)
|
||||||
self.assertEqual(FAKE['updated_time'], sot.updated_at)
|
dt = datetime.datetime(2015, 3, 9, 12, 30, 00, 000000).replace(
|
||||||
|
tzinfo=None)
|
||||||
|
self.assertEqual(dt, sot.updated_at.replace(tzinfo=None))
|
||||||
|
|
||||||
def test_create(self):
|
def test_create(self):
|
||||||
resp = mock.Mock()
|
resp = mock.Mock()
|
||||||
|
|||||||
Reference in New Issue
Block a user