Consistent resource.prop for timestamps and booleans (cluster)
This patch set updates all cluster 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: Ie08fcddf47643fabb2bacdc74bc1c582b1598fb9 Partial-Bug: #1544584
This commit is contained in:
@@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
|
|
||||||
from openstack.cluster import cluster_service
|
from openstack.cluster import cluster_service
|
||||||
|
from openstack import format
|
||||||
from openstack import resource
|
from openstack import resource
|
||||||
|
|
||||||
|
|
||||||
@@ -39,9 +40,11 @@ class Action(resource.Resource):
|
|||||||
#: Interval in seconds between two consecutive executions.
|
#: Interval in seconds between two consecutive executions.
|
||||||
interval = resource.prop('interval')
|
interval = resource.prop('interval')
|
||||||
#: The time the action was started.
|
#: The time the action was started.
|
||||||
start_time = resource.prop('start_time')
|
#: *Type: datetime object parsed from a UNIX epoch*
|
||||||
|
start_at = resource.prop('start_time', type=format.UNIXEpoch)
|
||||||
#: The time the action completed execution.
|
#: The time the action completed execution.
|
||||||
end_time = resource.prop('end_time')
|
#: *Type: datetime object parsed from a UNIX epoch*
|
||||||
|
end_at = resource.prop('end_time', type=format.UNIXEpoch)
|
||||||
#: The timeout in seconds.
|
#: The timeout in seconds.
|
||||||
timeout = resource.prop('timeout')
|
timeout = resource.prop('timeout')
|
||||||
#: Current status of the action.
|
#: Current status of the action.
|
||||||
@@ -58,6 +61,8 @@ class Action(resource.Resource):
|
|||||||
#: A list of actions that can start only after this action has finished.
|
#: A list of actions that can start only after this action has finished.
|
||||||
depended_by = resource.prop('depended_by', type=list)
|
depended_by = resource.prop('depended_by', type=list)
|
||||||
#: Timestamp when the action is created.
|
#: Timestamp when the action is created.
|
||||||
created_at = resource.prop('created_at')
|
#: *Type: datetime object parsed from ISO 8601 formatted string*
|
||||||
|
created_at = resource.prop('created_at', type=format.ISO8601)
|
||||||
#: Timestamp when the action was last updated.
|
#: Timestamp when the action was last updated.
|
||||||
updated_at = resource.prop('updated_at')
|
#: *Type: datetime object parsed from ISO 8601 formatted string*
|
||||||
|
updated_at = resource.prop('updated_at', type=format.ISO8601)
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from openstack.cluster import cluster_service
|
from openstack.cluster import cluster_service
|
||||||
|
from openstack import format
|
||||||
from openstack import resource
|
from openstack import resource
|
||||||
from openstack import utils
|
from openstack import utils
|
||||||
|
|
||||||
@@ -43,11 +44,14 @@ class Cluster(resource.Resource):
|
|||||||
#: The ID of the parent cluster (if any).
|
#: The ID of the parent cluster (if any).
|
||||||
parent_id = resource.prop('parent')
|
parent_id = resource.prop('parent')
|
||||||
#: Timestamp of when the cluster was initialized.
|
#: Timestamp of when the cluster was initialized.
|
||||||
init_at = resource.prop('init_at')
|
#: *Type: datetime object parsed from ISO 8601 formatted string*
|
||||||
|
init_at = resource.prop('init_at', type=format.ISO8601)
|
||||||
#: Timestamp of when the cluster was created.
|
#: Timestamp of when the cluster was created.
|
||||||
created_at = resource.prop('created_at')
|
#: *Type: datetime object parsed from ISO 8601 formatted string*
|
||||||
|
created_at = resource.prop('created_at', type=format.ISO8601)
|
||||||
#: Timestamp of when the cluster was last updated.
|
#: Timestamp of when the cluster was last updated.
|
||||||
updated_at = resource.prop('updated_at')
|
#: *Type: datetime object parsed from ISO 8601 formatted string*
|
||||||
|
updated_at = resource.prop('updated_at', type=format.ISO8601)
|
||||||
#: Lower bound (inclusive) for the size of the cluster.
|
#: Lower bound (inclusive) for the size of the cluster.
|
||||||
min_size = resource.prop('min_size', type=int)
|
min_size = resource.prop('min_size', type=int)
|
||||||
#: Upper bound (inclusive) for the size of the cluster. A value of
|
#: Upper bound (inclusive) for the size of the cluster. A value of
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ class ClusterPolicy(resource.Resource):
|
|||||||
cluster_name = resource.prop('cluster_name')
|
cluster_name = resource.prop('cluster_name')
|
||||||
#: Type string of the policy.
|
#: Type string of the policy.
|
||||||
policy_type = resource.prop('policy_type')
|
policy_type = resource.prop('policy_type')
|
||||||
#: Whether the policy is enabled on the cluster.
|
#: Whether the policy is enabled on the cluster. *Type: bool*
|
||||||
enabled = resource.prop('enabled')
|
is_enabled = resource.prop('enabled', type=bool)
|
||||||
#: Data associated with the cluster-policy binding.
|
#: Data associated with the cluster-policy binding.
|
||||||
data = resource.prop('data', type=dict)
|
data = resource.prop('data', type=dict)
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
|
|
||||||
from openstack.cluster import cluster_service
|
from openstack.cluster import cluster_service
|
||||||
|
from openstack import format
|
||||||
from openstack import resource
|
from openstack import resource
|
||||||
|
|
||||||
|
|
||||||
@@ -27,7 +28,7 @@ class Event(resource.Resource):
|
|||||||
|
|
||||||
# Properties
|
# Properties
|
||||||
id = resource.prop('id')
|
id = resource.prop('id')
|
||||||
timestamp = resource.prop('timestamp')
|
timestamp = resource.prop('timestamp', type=format.ISO8601)
|
||||||
obj_id = resource.prop('obj_id')
|
obj_id = resource.prop('obj_id')
|
||||||
obj_name = resource.prop('obj_name')
|
obj_name = resource.prop('obj_name')
|
||||||
obj_type = resource.prop('obj_type')
|
obj_type = resource.prop('obj_type')
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from openstack.cluster import cluster_service
|
from openstack.cluster import cluster_service
|
||||||
|
from openstack import format
|
||||||
from openstack import resource
|
from openstack import resource
|
||||||
from openstack import utils
|
from openstack import utils
|
||||||
|
|
||||||
@@ -50,12 +51,15 @@ class Node(resource.Resource):
|
|||||||
#: A string indicating the role the node plays in a cluster.
|
#: A string indicating the role the node plays in a cluster.
|
||||||
role = resource.prop('role')
|
role = resource.prop('role')
|
||||||
#: The timestamp of the node object's initialization.
|
#: The timestamp of the node object's initialization.
|
||||||
init_at = resource.prop('init_at')
|
#: *Type: datetime object parsed from ISO 8601 formatted string*
|
||||||
|
init_at = resource.prop('init_at', type=format.ISO8601)
|
||||||
#: The timestamp of the node's creation, i.e. the physical object
|
#: The timestamp of the node's creation, i.e. the physical object
|
||||||
#: represented by this node is also created.
|
#: represented by this node is also created.
|
||||||
created_at = resource.prop('created_at')
|
#: *Type: datetime object parsed from ISO 8601 formatted string*
|
||||||
|
created_at = resource.prop('created_at', type=format.ISO8601)
|
||||||
#: The timestamp the node was last updated.
|
#: The timestamp the node was last updated.
|
||||||
updated_at = resource.prop('updated_at')
|
#: *Type: datetime object parsed from ISO 8601 formatted string*
|
||||||
|
updated_at = resource.prop('updated_at', type=format.ISO8601)
|
||||||
#: A string indicating the node's status.
|
#: A string indicating the node's status.
|
||||||
status = resource.prop('status')
|
status = resource.prop('status')
|
||||||
#: A string describing why the node entered its current status.
|
#: A string describing why the node entered its current status.
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from openstack.cluster import cluster_service
|
from openstack.cluster import cluster_service
|
||||||
|
from openstack import format
|
||||||
from openstack import resource
|
from openstack import resource
|
||||||
|
|
||||||
|
|
||||||
@@ -35,9 +36,11 @@ class Policy(resource.Resource):
|
|||||||
#: The type name of the policy.
|
#: The type name of the policy.
|
||||||
type = resource.prop('type')
|
type = resource.prop('type')
|
||||||
#: The timestamp when the policy is created.
|
#: The timestamp when the policy is created.
|
||||||
created_at = resource.prop('created_at')
|
#: *Type: datetime object parsed from ISO 8601 formatted string*
|
||||||
|
created_at = resource.prop('created_at', type=format.ISO8601)
|
||||||
#: The timestamp when the policy was last updated.
|
#: The timestamp when the policy was last updated.
|
||||||
updated_at = resource.prop('updated_at')
|
#: *Type: datetime object parsed from ISO 8601 formatted string*
|
||||||
|
updated_at = resource.prop('updated_at', type=format.ISO8601)
|
||||||
#: The specification of the policy.
|
#: The specification of the policy.
|
||||||
spec = resource.prop('spec', type=dict)
|
spec = resource.prop('spec', type=dict)
|
||||||
#: A dictionary containing runtime data of the policy.
|
#: A dictionary containing runtime data of the policy.
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from openstack.cluster import cluster_service
|
from openstack.cluster import cluster_service
|
||||||
|
from openstack import format
|
||||||
from openstack import resource
|
from openstack import resource
|
||||||
|
|
||||||
|
|
||||||
@@ -39,6 +40,8 @@ class Profile(resource.Resource):
|
|||||||
#: A collection of key-value pairs that are attached to the profile.
|
#: A collection of key-value pairs that are attached to the profile.
|
||||||
metadata = resource.prop('metadata', type=dict)
|
metadata = resource.prop('metadata', type=dict)
|
||||||
#: Timestamp of when the profile was created.
|
#: Timestamp of when the profile was created.
|
||||||
created_at = resource.prop('created_at')
|
#: *Type: datetime object parsed from ISO 8601 formatted string*
|
||||||
|
created_at = resource.prop('created_at', type=format.ISO8601)
|
||||||
#: Timestamp of when the profile was last updated.
|
#: Timestamp of when the profile was last updated.
|
||||||
updated_at = resource.prop('updated_at')
|
#: *Type: datetime object parsed from ISO 8601 formatted string*
|
||||||
|
updated_at = resource.prop('updated_at', type=format.ISO8601)
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
|
|
||||||
from openstack.cluster import cluster_service
|
from openstack.cluster import cluster_service
|
||||||
|
from openstack import format
|
||||||
from openstack import resource
|
from openstack import resource
|
||||||
|
|
||||||
|
|
||||||
@@ -43,9 +44,11 @@ class Receiver(resource.Resource):
|
|||||||
#: The name of the targeted action.
|
#: The name of the targeted action.
|
||||||
action = resource.prop('action')
|
action = resource.prop('action')
|
||||||
#: Timestamp of when the receiver was created.
|
#: Timestamp of when the receiver was created.
|
||||||
created_at = resource.prop('created_at')
|
#: *Type: datetime object parsed from ISO 8601 formatted string*
|
||||||
|
created_at = resource.prop('created_at', type=format.ISO8601)
|
||||||
#: Timestamp of when the receiver was last updated.
|
#: Timestamp of when the receiver was last updated.
|
||||||
updated_at = resource.prop('updated_at')
|
#: *Type: datetime object parsed from ISO 8601 formatted string*
|
||||||
|
updated_at = resource.prop('updated_at', type=format.ISO8601)
|
||||||
#: The credential of the impersonated user.
|
#: The credential of the impersonated user.
|
||||||
actor = resource.prop('actor', type=dict)
|
actor = resource.prop('actor', type=dict)
|
||||||
#: A dictionary containing key-value pairs that are provided to the
|
#: A dictionary containing key-value pairs that are provided to the
|
||||||
|
|||||||
@@ -10,6 +10,9 @@
|
|||||||
# 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 iso8601
|
||||||
|
|
||||||
import testtools
|
import testtools
|
||||||
|
|
||||||
from openstack.cluster.v1 import action
|
from openstack.cluster.v1 import action
|
||||||
@@ -25,8 +28,8 @@ FAKE = {
|
|||||||
'cause': 'RPC Request',
|
'cause': 'RPC Request',
|
||||||
'owner': None,
|
'owner': None,
|
||||||
'interval': -1,
|
'interval': -1,
|
||||||
'start_time': 144450000.0,
|
'start_time': 1453414055.48672,
|
||||||
'end_time': 144450000.0,
|
'end_time': 1453414055.48672,
|
||||||
'timeout': 3600,
|
'timeout': 3600,
|
||||||
'status': 'SUCCEEDED',
|
'status': 'SUCCEEDED',
|
||||||
'status_reason': 'Action completed successfully.',
|
'status_reason': 'Action completed successfully.',
|
||||||
@@ -34,8 +37,8 @@ FAKE = {
|
|||||||
'outputs': {},
|
'outputs': {},
|
||||||
'depends_on': [],
|
'depends_on': [],
|
||||||
'depended_by': [],
|
'depended_by': [],
|
||||||
'created_at': '2015-10-10T04:46:36.000000',
|
'created_at': '2015-10-10T12:46:36.000000',
|
||||||
'updated_at': None,
|
'updated_at': '2016-10-10T12:46:36.000000',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -62,8 +65,12 @@ class TestAction(testtools.TestCase):
|
|||||||
self.assertEqual(FAKE['cause'], sot.cause)
|
self.assertEqual(FAKE['cause'], sot.cause)
|
||||||
self.assertEqual(FAKE['owner'], sot.owner_id)
|
self.assertEqual(FAKE['owner'], sot.owner_id)
|
||||||
self.assertEqual(FAKE['interval'], sot.interval)
|
self.assertEqual(FAKE['interval'], sot.interval)
|
||||||
self.assertEqual(FAKE['start_time'], sot.start_time)
|
self.assertEqual(datetime.datetime(2016, 1, 21, 22, 7, 35, 486720,
|
||||||
self.assertEqual(FAKE['end_time'], sot.end_time)
|
tzinfo=iso8601.UTC),
|
||||||
|
sot.start_at)
|
||||||
|
self.assertEqual(datetime.datetime(2016, 1, 21, 22, 7, 35, 486720,
|
||||||
|
tzinfo=iso8601.UTC),
|
||||||
|
sot.end_at)
|
||||||
self.assertEqual(FAKE['timeout'], sot.timeout)
|
self.assertEqual(FAKE['timeout'], sot.timeout)
|
||||||
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)
|
||||||
@@ -71,5 +78,9 @@ class TestAction(testtools.TestCase):
|
|||||||
self.assertEqual(FAKE['outputs'], sot.outputs)
|
self.assertEqual(FAKE['outputs'], sot.outputs)
|
||||||
self.assertEqual(FAKE['depends_on'], sot.depends_on)
|
self.assertEqual(FAKE['depends_on'], sot.depends_on)
|
||||||
self.assertEqual(FAKE['depended_by'], sot.depended_by)
|
self.assertEqual(FAKE['depended_by'], sot.depended_by)
|
||||||
self.assertEqual(FAKE['created_at'], sot.created_at)
|
dt = datetime.datetime(2015, 10, 10, 12, 46, 36, 000000).replace(
|
||||||
self.assertEqual(FAKE['updated_at'], sot.updated_at)
|
tzinfo=None)
|
||||||
|
self.assertEqual(dt, sot.created_at.replace(tzinfo=None))
|
||||||
|
dt = datetime.datetime(2016, 10, 10, 12, 46, 36, 000000).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 testtools
|
import testtools
|
||||||
|
|
||||||
@@ -28,14 +30,17 @@ FAKE = {
|
|||||||
'profile_id': 'myserver',
|
'profile_id': 'myserver',
|
||||||
'metadata': {},
|
'metadata': {},
|
||||||
'timeout': None,
|
'timeout': None,
|
||||||
|
'init_at': '2015-10-10T12:46:36.000000',
|
||||||
|
'created_at': '2015-10-10T12:46:36.000000',
|
||||||
|
'updated_at': '2016-10-10T12:46:36.000000',
|
||||||
}
|
}
|
||||||
|
|
||||||
FAKE_CREATE_RESP = {
|
FAKE_CREATE_RESP = {
|
||||||
'cluster': {
|
'cluster': {
|
||||||
'action': 'a679c926-908f-49e7-a822-06ca371e64e1',
|
'action': 'a679c926-908f-49e7-a822-06ca371e64e1',
|
||||||
'init_at': None,
|
'init_at': '2015-10-10T12:46:36.000000',
|
||||||
'created_at': None,
|
'created_at': '2015-10-10T12:46:36.000000',
|
||||||
'updated_at': None,
|
'updated_at': '2016-10-10T12:46:36.000000',
|
||||||
'data': {},
|
'data': {},
|
||||||
'desired_capacity': 1,
|
'desired_capacity': 1,
|
||||||
'domain': None,
|
'domain': None,
|
||||||
@@ -90,6 +95,16 @@ class TestCluster(testtools.TestCase):
|
|||||||
self.assertEqual(FAKE['timeout'], sot.timeout)
|
self.assertEqual(FAKE['timeout'], sot.timeout)
|
||||||
self.assertEqual(FAKE['metadata'], sot.metadata)
|
self.assertEqual(FAKE['metadata'], sot.metadata)
|
||||||
|
|
||||||
|
dt = datetime.datetime(2015, 10, 10, 12, 46, 36, 000000).replace(
|
||||||
|
tzinfo=None)
|
||||||
|
self.assertEqual(dt, sot.init_at.replace(tzinfo=None))
|
||||||
|
dt = datetime.datetime(2015, 10, 10, 12, 46, 36, 000000).replace(
|
||||||
|
tzinfo=None)
|
||||||
|
self.assertEqual(dt, sot.created_at.replace(tzinfo=None))
|
||||||
|
dt = datetime.datetime(2016, 10, 10, 12, 46, 36, 000000).replace(
|
||||||
|
tzinfo=None)
|
||||||
|
self.assertEqual(dt, sot.updated_at.replace(tzinfo=None))
|
||||||
|
|
||||||
def test_scale_in(self):
|
def test_scale_in(self):
|
||||||
sot = cluster.Cluster(FAKE)
|
sot = cluster.Cluster(FAKE)
|
||||||
sot['id'] = 'IDENTIFIER'
|
sot['id'] = 'IDENTIFIER'
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ class TestClusterPolicy(testtools.TestCase):
|
|||||||
self.assertEqual(FAKE['cluster_id'], sot.cluster_id)
|
self.assertEqual(FAKE['cluster_id'], sot.cluster_id)
|
||||||
self.assertEqual(FAKE['cluster_name'], sot.cluster_name)
|
self.assertEqual(FAKE['cluster_name'], sot.cluster_name)
|
||||||
self.assertEqual(FAKE['data'], sot.data)
|
self.assertEqual(FAKE['data'], sot.data)
|
||||||
self.assertEqual(FAKE['enabled'], sot.enabled)
|
self.assertTrue(sot.is_enabled)
|
||||||
self.assertEqual(FAKE['policy_id'], sot.policy_id)
|
self.assertEqual(FAKE['policy_id'], sot.policy_id)
|
||||||
self.assertEqual(FAKE['policy_name'], sot.policy_name)
|
self.assertEqual(FAKE['policy_name'], sot.policy_name)
|
||||||
self.assertEqual(FAKE['policy_type'], sot.policy_type)
|
self.assertEqual(FAKE['policy_type'], sot.policy_type)
|
||||||
|
|||||||
@@ -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.cluster.v1 import event
|
from openstack.cluster.v1 import event
|
||||||
@@ -28,7 +30,7 @@ FAKE = {
|
|||||||
'project': '42d9e9663331431f97b75e25136307ff',
|
'project': '42d9e9663331431f97b75e25136307ff',
|
||||||
'status': 'START',
|
'status': 'START',
|
||||||
'status_reason': 'The action was abandoned.',
|
'status_reason': 'The action was abandoned.',
|
||||||
'timestamp': '2015-10-03T03:35:09',
|
'timestamp': '2016-10-10T12:46:36.000000',
|
||||||
'user': '5e5bf8027826429c96af157f68dc9072'
|
'user': '5e5bf8027826429c96af157f68dc9072'
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,5 +63,7 @@ class TestEvent(testtools.TestCase):
|
|||||||
self.assertEqual(FAKE['project'], sot.project_id)
|
self.assertEqual(FAKE['project'], sot.project_id)
|
||||||
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['timestamp'], sot.timestamp)
|
dt = datetime.datetime(2016, 10, 10, 12, 46, 36, 000000).replace(
|
||||||
|
tzinfo=None)
|
||||||
|
self.assertEqual(dt, sot.timestamp.replace(tzinfo=None))
|
||||||
self.assertEqual(FAKE['user'], sot.user_id)
|
self.assertEqual(FAKE['user'], sot.user_id)
|
||||||
|
|||||||
@@ -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 testtools
|
import testtools
|
||||||
|
|
||||||
@@ -27,6 +29,9 @@ FAKE = {
|
|||||||
'profile_id': 'myserver',
|
'profile_id': 'myserver',
|
||||||
'index': 1,
|
'index': 1,
|
||||||
'role': 'master',
|
'role': 'master',
|
||||||
|
'created_at': '2015-10-10T12:46:36.000000',
|
||||||
|
'updated_at': '2016-10-10T12:46:36.000000',
|
||||||
|
'init_at': '2015-10-10T12:46:36.000000',
|
||||||
}
|
}
|
||||||
|
|
||||||
FAKE_CREATE_RESP = {
|
FAKE_CREATE_RESP = {
|
||||||
@@ -35,12 +40,12 @@ FAKE_CREATE_RESP = {
|
|||||||
'name': FAKE_NAME,
|
'name': FAKE_NAME,
|
||||||
'cluster_id': '99001122-aabb-ccdd-ffff-efdcab124567',
|
'cluster_id': '99001122-aabb-ccdd-ffff-efdcab124567',
|
||||||
'action': '1122aabb-eeff-7755-2222-00991234dcba',
|
'action': '1122aabb-eeff-7755-2222-00991234dcba',
|
||||||
'created_at': None,
|
'created_at': '2015-10-10T12:46:36.000000',
|
||||||
'updated_at': None,
|
'updated_at': '2016-10-10T12:46:36.000000',
|
||||||
'data': {},
|
'data': {},
|
||||||
'role': 'master',
|
'role': 'master',
|
||||||
'index': 1,
|
'index': 1,
|
||||||
'init_time': None,
|
'init_at': '2015-10-10T12:46:36.000000',
|
||||||
'metadata': {},
|
'metadata': {},
|
||||||
'profile_id': '560a8f9d-7596-4a32-85e8-03645fa7be13',
|
'profile_id': '560a8f9d-7596-4a32-85e8-03645fa7be13',
|
||||||
'profile_name': 'myserver',
|
'profile_name': 'myserver',
|
||||||
@@ -78,6 +83,15 @@ class TestNode(testtools.TestCase):
|
|||||||
self.assertEqual(FAKE['index'], sot.index)
|
self.assertEqual(FAKE['index'], sot.index)
|
||||||
self.assertEqual(FAKE['role'], sot.role)
|
self.assertEqual(FAKE['role'], sot.role)
|
||||||
self.assertEqual(FAKE['metadata'], sot.metadata)
|
self.assertEqual(FAKE['metadata'], sot.metadata)
|
||||||
|
dt = datetime.datetime(2015, 10, 10, 12, 46, 36, 000000).replace(
|
||||||
|
tzinfo=None)
|
||||||
|
self.assertEqual(dt, sot.init_at.replace(tzinfo=None))
|
||||||
|
dt = datetime.datetime(2015, 10, 10, 12, 46, 36, 000000).replace(
|
||||||
|
tzinfo=None)
|
||||||
|
self.assertEqual(dt, sot.created_at.replace(tzinfo=None))
|
||||||
|
dt = datetime.datetime(2016, 10, 10, 12, 46, 36, 000000).replace(
|
||||||
|
tzinfo=None)
|
||||||
|
self.assertEqual(dt, sot.updated_at.replace(tzinfo=None))
|
||||||
|
|
||||||
def test_check(self):
|
def test_check(self):
|
||||||
sot = node.Node(FAKE)
|
sot = node.Node(FAKE)
|
||||||
|
|||||||
@@ -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.cluster.v1 import policy
|
from openstack.cluster.v1 import policy
|
||||||
@@ -31,8 +33,8 @@ FAKE = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
'type': 'senlin.policy.deletion-1.0',
|
'type': 'senlin.policy.deletion-1.0',
|
||||||
'created_at': '2015-08-10T09:14:53',
|
'created_at': '2015-10-10T12:46:36.000000',
|
||||||
'updated_at': None,
|
'updated_at': '2016-10-10T12:46:36.000000',
|
||||||
'data': {},
|
'data': {},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,5 +62,9 @@ class TestPolicy(testtools.TestCase):
|
|||||||
self.assertEqual(FAKE['name'], sot.name)
|
self.assertEqual(FAKE['name'], sot.name)
|
||||||
self.assertEqual(FAKE['spec'], sot.spec)
|
self.assertEqual(FAKE['spec'], sot.spec)
|
||||||
self.assertEqual(FAKE['data'], sot.data)
|
self.assertEqual(FAKE['data'], sot.data)
|
||||||
self.assertEqual(FAKE['created_at'], sot.created_at)
|
dt = datetime.datetime(2015, 10, 10, 12, 46, 36, 000000).replace(
|
||||||
self.assertEqual(FAKE['updated_at'], sot.updated_at)
|
tzinfo=None)
|
||||||
|
self.assertEqual(dt, sot.created_at.replace(tzinfo=None))
|
||||||
|
dt = datetime.datetime(2016, 10, 10, 12, 46, 36, 000000).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 testtools
|
import testtools
|
||||||
|
|
||||||
from openstack.cluster.v1 import profile
|
from openstack.cluster.v1 import profile
|
||||||
@@ -32,7 +34,9 @@ FAKE = {
|
|||||||
'name': 'cirros_server'
|
'name': 'cirros_server'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'type': 'os.nova.server'
|
'type': 'os.nova.server',
|
||||||
|
'created_at': '2015-10-10T12:46:36.000000',
|
||||||
|
'updated_at': '2016-10-10T12:46:36.000000',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -61,3 +65,9 @@ class TestProfile(testtools.TestCase):
|
|||||||
self.assertEqual(FAKE['metadata'], sot.metadata)
|
self.assertEqual(FAKE['metadata'], sot.metadata)
|
||||||
self.assertEqual(FAKE['spec'], sot.spec)
|
self.assertEqual(FAKE['spec'], sot.spec)
|
||||||
self.assertEqual(FAKE['type'], sot.type_name)
|
self.assertEqual(FAKE['type'], sot.type_name)
|
||||||
|
dt = datetime.datetime(2015, 10, 10, 12, 46, 36, 000000).replace(
|
||||||
|
tzinfo=None)
|
||||||
|
self.assertEqual(dt, sot.created_at.replace(tzinfo=None))
|
||||||
|
dt = datetime.datetime(2016, 10, 10, 12, 46, 36, 000000).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 testtools
|
import testtools
|
||||||
|
|
||||||
from openstack.cluster.v1 import receiver
|
from openstack.cluster.v1 import receiver
|
||||||
@@ -23,8 +25,8 @@ FAKE = {
|
|||||||
'type': 'webhook',
|
'type': 'webhook',
|
||||||
'cluster_id': 'FAKE_CLUSTER',
|
'cluster_id': 'FAKE_CLUSTER',
|
||||||
'action': 'CLUSTER_RESIZE',
|
'action': 'CLUSTER_RESIZE',
|
||||||
'created_at': '2015-08-10T09:14:53',
|
'created_at': '2015-10-10T12:46:36.000000',
|
||||||
'updated_at': None,
|
'updated_at': '2016-10-10T12:46:36.000000',
|
||||||
'actor': {},
|
'actor': {},
|
||||||
'params': {
|
'params': {
|
||||||
'adjustment_type': 'CHANGE_IN_CAPACITY',
|
'adjustment_type': 'CHANGE_IN_CAPACITY',
|
||||||
@@ -64,8 +66,12 @@ class TestReceiver(testtools.TestCase):
|
|||||||
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['action'], sot.action)
|
||||||
self.assertEqual(FAKE['params'], sot.params)
|
self.assertEqual(FAKE['params'], sot.params)
|
||||||
self.assertEqual(FAKE['created_at'], sot.created_at)
|
dt = datetime.datetime(2015, 10, 10, 12, 46, 36, 000000).replace(
|
||||||
self.assertEqual(FAKE['updated_at'], sot.updated_at)
|
tzinfo=None)
|
||||||
|
self.assertEqual(dt, sot.created_at.replace(tzinfo=None))
|
||||||
|
dt = datetime.datetime(2016, 10, 10, 12, 46, 36, 000000).replace(
|
||||||
|
tzinfo=None)
|
||||||
|
self.assertEqual(dt, sot.updated_at.replace(tzinfo=None))
|
||||||
self.assertEqual(FAKE['user'], sot.user_id)
|
self.assertEqual(FAKE['user'], sot.user_id)
|
||||||
self.assertEqual(FAKE['project'], sot.project_id)
|
self.assertEqual(FAKE['project'], sot.project_id)
|
||||||
self.assertEqual(FAKE['domain'], sot.domain_id)
|
self.assertEqual(FAKE['domain'], sot.domain_id)
|
||||||
|
|||||||
Reference in New Issue
Block a user