Consistent resource.prop for timestamps and booleans (image)
This patch set updates all image 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: Iba0751c74bd1a05f687fceed2ca3c8b7167a44c8 Partial-Bug: #1544584
This commit is contained in:
parent
4236c93750
commit
17e328141d
@ -10,6 +10,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from openstack import format
|
||||
from openstack.image import image_service
|
||||
from openstack import resource
|
||||
|
||||
@ -38,13 +39,20 @@ class Image(resource.Resource):
|
||||
container_format = resource.prop('container_format')
|
||||
#: A URL to copy an image from
|
||||
copy_from = resource.prop('copy_from')
|
||||
#: The timestamp when this image was created.
|
||||
#: *Type: datetime object parsed from ISO 8601 formatted string*
|
||||
created_at = resource.prop('created_at', type=format.ISO8601)
|
||||
#: Valid values are: aki, ari, ami, raw, iso, vhd, vdi, qcow2, or vmdk.
|
||||
#: The disk format of a VM image is the format of the underlying
|
||||
#: disk image. Virtual appliance vendors have different formats for
|
||||
#: laying out the information contained in a VM disk image.
|
||||
disk_format = resource.prop('disk_format')
|
||||
#: Defines whether the image can be deleted.
|
||||
#: *Type: bool*
|
||||
is_protected = resource.prop('protected', type=bool)
|
||||
#: ``True`` if this is a public image.
|
||||
is_public = resource.prop('is_public')
|
||||
#: *Type: bool*
|
||||
is_public = resource.prop('is_public', type=bool)
|
||||
#: A location for the image identified by a URI
|
||||
location = resource.prop('location')
|
||||
#: The minimum disk size in GB that is required to boot the image.
|
||||
@ -59,13 +67,10 @@ class Image(resource.Resource):
|
||||
owner_id = resource.prop('owner')
|
||||
#: Properties, if any, that are associated with the image.
|
||||
properties = resource.prop('properties')
|
||||
#: Defines whether the image can be deleted.
|
||||
protected = resource.prop('protected')
|
||||
#: The size of the image data, in bytes.
|
||||
size = resource.prop('size')
|
||||
#: The image status.
|
||||
status = resource.prop('status')
|
||||
#: The timestamp when this image was created.
|
||||
created_at = resource.prop('created_at')
|
||||
#: The timestamp when this image 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)
|
||||
|
@ -10,6 +10,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from openstack import format
|
||||
from openstack.image import image_service
|
||||
from openstack import resource
|
||||
from openstack import utils
|
||||
@ -43,12 +44,16 @@ class Image(resource.Resource):
|
||||
#: the image is just a blob of unstructured data.
|
||||
container_format = resource.prop('container_format')
|
||||
#: The date and time when the image 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)
|
||||
#: Valid values are: aki, ari, ami, raw, iso, vhd, vdi, qcow2, or vmdk.
|
||||
#: The disk format of a VM image is the format of the underlying
|
||||
#: disk image. Virtual appliance vendors have different formats
|
||||
#: for laying out the information contained in a VM disk image.
|
||||
disk_format = resource.prop('disk_format')
|
||||
#: Defines whether the image can be deleted.
|
||||
#: *Type: bool*
|
||||
is_protected = resource.prop('protected', type=bool)
|
||||
#: The minimum disk size in GB that is required to boot the image.
|
||||
min_disk = resource.prop('min_disk')
|
||||
#: The name of the image.
|
||||
@ -57,8 +62,6 @@ class Image(resource.Resource):
|
||||
owner_id = resource.prop('owner')
|
||||
#: Properties, if any, that are associated with the image.
|
||||
properties = resource.prop('properties')
|
||||
#: Defines whether the image can be deleted.
|
||||
protected = resource.prop('protected', type=bool)
|
||||
#: The size of the image data, in bytes.
|
||||
size = resource.prop('size', type=int)
|
||||
#: When present, Glance will attempt to store the disk image data in the
|
||||
@ -72,7 +75,8 @@ class Image(resource.Resource):
|
||||
#: Tags, if any, that are associated with the image.
|
||||
tags = resource.prop('tags')
|
||||
#: The date and time when the image was 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 virtual size of the image.
|
||||
virtual_size = resource.prop('virtual_size')
|
||||
#: The image visibility.
|
||||
|
@ -10,6 +10,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from openstack import format
|
||||
from openstack.image import image_service
|
||||
from openstack import resource
|
||||
|
||||
@ -29,10 +30,12 @@ class Member(resource.Resource):
|
||||
|
||||
# Properties
|
||||
#: The date and time when the member 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)
|
||||
#: Image ID stored through the image API. Typically a UUID.
|
||||
image_id = resource.prop('image_id')
|
||||
#: The status of the image.
|
||||
status = resource.prop('status')
|
||||
#: The date and time when the member was 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)
|
||||
|
@ -10,6 +10,8 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import datetime
|
||||
|
||||
import testtools
|
||||
|
||||
from openstack.image.v1 import image
|
||||
@ -21,18 +23,18 @@ EXAMPLE = {
|
||||
'copy_from': '3',
|
||||
'disk_format': '4',
|
||||
'id': IDENTIFIER,
|
||||
'is_public': '5',
|
||||
'is_public': True,
|
||||
'location': '6',
|
||||
'min_disk': '7',
|
||||
'min_ram': '8',
|
||||
'name': '9',
|
||||
'owner': '10',
|
||||
'properties': '11',
|
||||
'protected': '12',
|
||||
'protected': True,
|
||||
'size': '13',
|
||||
'status': '14',
|
||||
'created_at': '2014-06-15 14:18:37.794540',
|
||||
'updated_at': '2014-06-16 14:18:37.794540',
|
||||
'created_at': '2015-03-09T12:14:57.233772',
|
||||
'updated_at': '2015-03-09T12:15:57.233772',
|
||||
}
|
||||
|
||||
|
||||
@ -57,15 +59,19 @@ class TestImage(testtools.TestCase):
|
||||
self.assertEqual(EXAMPLE['copy_from'], sot.copy_from)
|
||||
self.assertEqual(EXAMPLE['disk_format'], sot.disk_format)
|
||||
self.assertEqual(IDENTIFIER, sot.id)
|
||||
self.assertEqual(EXAMPLE['is_public'], sot.is_public)
|
||||
self.assertTrue(sot.is_public)
|
||||
self.assertEqual(EXAMPLE['location'], sot.location)
|
||||
self.assertEqual(EXAMPLE['min_disk'], sot.min_disk)
|
||||
self.assertEqual(EXAMPLE['min_ram'], sot.min_ram)
|
||||
self.assertEqual(EXAMPLE['name'], sot.name)
|
||||
self.assertEqual(EXAMPLE['owner'], sot.owner_id)
|
||||
self.assertEqual(EXAMPLE['properties'], sot.properties)
|
||||
self.assertEqual(EXAMPLE['protected'], sot.protected)
|
||||
self.assertTrue(sot.is_protected)
|
||||
self.assertEqual(EXAMPLE['size'], sot.size)
|
||||
self.assertEqual(EXAMPLE['status'], sot.status)
|
||||
self.assertEqual(EXAMPLE['created_at'], sot.created_at)
|
||||
self.assertEqual(EXAMPLE['updated_at'], sot.updated_at)
|
||||
dt = datetime.datetime(2015, 3, 9, 12, 14, 57, 233772).replace(
|
||||
tzinfo=None)
|
||||
self.assertEqual(dt, sot.created_at.replace(tzinfo=None))
|
||||
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
|
||||
# under the License.
|
||||
|
||||
import datetime
|
||||
|
||||
import mock
|
||||
import testtools
|
||||
|
||||
@ -20,7 +22,7 @@ EXAMPLE = {
|
||||
'id': IDENTIFIER,
|
||||
'checksum': '1',
|
||||
'container_format': '2',
|
||||
'created_at': '2014-11-19T10:44:55.123450Z',
|
||||
'created_at': '2015-03-09T12:14:57.233772',
|
||||
'data': 'This is not an image',
|
||||
'disk_format': '4',
|
||||
'min_disk': 5,
|
||||
@ -30,7 +32,7 @@ EXAMPLE = {
|
||||
'protected': False,
|
||||
'status': '8',
|
||||
'tags': ['g', 'h', 'i'],
|
||||
'updated_at': '2014-11-19T10:44:55.123450Z',
|
||||
'updated_at': '2015-03-09T12:15:57.233772',
|
||||
'virtual_size': '10',
|
||||
'visibility': '11'
|
||||
}
|
||||
@ -54,16 +56,20 @@ class TestImage(testtools.TestCase):
|
||||
self.assertEqual(IDENTIFIER, sot.id)
|
||||
self.assertEqual(EXAMPLE['checksum'], sot.checksum)
|
||||
self.assertEqual(EXAMPLE['container_format'], sot.container_format)
|
||||
self.assertEqual(EXAMPLE['created_at'], sot.created_at)
|
||||
dt = datetime.datetime(2015, 3, 9, 12, 14, 57, 233772).replace(
|
||||
tzinfo=None)
|
||||
self.assertEqual(dt, sot.created_at.replace(tzinfo=None))
|
||||
self.assertEqual(EXAMPLE['disk_format'], sot.disk_format)
|
||||
self.assertEqual(EXAMPLE['min_disk'], sot.min_disk)
|
||||
self.assertEqual(EXAMPLE['name'], sot.name)
|
||||
self.assertEqual(EXAMPLE['owner'], sot.owner_id)
|
||||
self.assertEqual(EXAMPLE['properties'], sot.properties)
|
||||
self.assertEqual(EXAMPLE['protected'], sot.protected)
|
||||
self.assertFalse(sot.is_protected)
|
||||
self.assertEqual(EXAMPLE['status'], sot.status)
|
||||
self.assertEqual(EXAMPLE['tags'], sot.tags)
|
||||
self.assertEqual(EXAMPLE['updated_at'], 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))
|
||||
self.assertEqual(EXAMPLE['virtual_size'], sot.virtual_size)
|
||||
self.assertEqual(EXAMPLE['visibility'], sot.visibility)
|
||||
|
||||
|
@ -10,17 +10,19 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import datetime
|
||||
|
||||
import testtools
|
||||
|
||||
from openstack.image.v2 import member
|
||||
|
||||
IDENTIFIER = 'IDENTIFIER'
|
||||
EXAMPLE = {
|
||||
'created_at': '2014-11-19T16:58:24.123450Z',
|
||||
'created_at': '2015-03-09T12:14:57.233772',
|
||||
'image_id': '2',
|
||||
'member_id': IDENTIFIER,
|
||||
'status': '4',
|
||||
'updated_at': '2014-11-19T16:58:24.123450Z',
|
||||
'updated_at': '2015-03-09T12:15:57.233772',
|
||||
}
|
||||
|
||||
|
||||
@ -41,7 +43,11 @@ class TestMember(testtools.TestCase):
|
||||
def test_make_it(self):
|
||||
sot = member.Member(EXAMPLE)
|
||||
self.assertEqual(IDENTIFIER, sot.id)
|
||||
self.assertEqual(EXAMPLE['created_at'], sot.created_at)
|
||||
dt = datetime.datetime(2015, 3, 9, 12, 14, 57, 233772).replace(
|
||||
tzinfo=None)
|
||||
self.assertEqual(dt, sot.created_at.replace(tzinfo=None))
|
||||
self.assertEqual(EXAMPLE['image_id'], sot.image_id)
|
||||
self.assertEqual(EXAMPLE['status'], sot.status)
|
||||
self.assertEqual(EXAMPLE['updated_at'], 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))
|
||||
|
Loading…
Reference in New Issue
Block a user