From 8034f84459798feda67d04be07082636c456364b Mon Sep 17 00:00:00 2001 From: Christian Rohmann Date: Fri, 16 Sep 2022 17:29:09 +0200 Subject: [PATCH] Add support for updated_at field for volume snapshots Change-Id: Iba4aaa8a0aeec775d2ecfa17ff0ce065c6ffdaea --- openstack/block_storage/v2/snapshot.py | 2 ++ openstack/block_storage/v3/snapshot.py | 2 ++ openstack/tests/fakes.py | 1 + openstack/tests/unit/block_storage/v2/test_snapshot.py | 2 ++ openstack/tests/unit/block_storage/v3/test_snapshot.py | 2 ++ releasenotes/notes/snap-updated_at-a46711b6160e3a26.yaml | 3 +++ 6 files changed, 12 insertions(+) create mode 100644 releasenotes/notes/snap-updated_at-a46711b6160e3a26.yaml diff --git a/openstack/block_storage/v2/snapshot.py b/openstack/block_storage/v2/snapshot.py index c23fed107..49e5a99d0 100644 --- a/openstack/block_storage/v2/snapshot.py +++ b/openstack/block_storage/v2/snapshot.py @@ -45,6 +45,8 @@ class Snapshot(resource.Resource, metadata.MetadataMixin): #: The current status of this snapshot. Potential values are creating, #: available, deleting, error, and error_deleting. status = resource.Body("status") + #: The date and time when the resource was updated. + updated_at = resource.Body("updated_at") #: The ID of the volume this snapshot was taken of. volume_id = resource.Body("volume_id") diff --git a/openstack/block_storage/v3/snapshot.py b/openstack/block_storage/v3/snapshot.py index 3f025473b..4b81d598e 100644 --- a/openstack/block_storage/v3/snapshot.py +++ b/openstack/block_storage/v3/snapshot.py @@ -50,6 +50,8 @@ class Snapshot(resource.Resource, metadata.MetadataMixin): #: The current status of this snapshot. Potential values are creating, #: available, deleting, error, and error_deleting. status = resource.Body("status") + #: The date and time when the resource was updated. + updated_at = resource.Body("updated_at") #: The ID of the volume this snapshot was taken of. volume_id = resource.Body("volume_id") diff --git a/openstack/tests/fakes.py b/openstack/tests/fakes.py index a035895f1..e686cf2e5 100644 --- a/openstack/tests/fakes.py +++ b/openstack/tests/fakes.py @@ -374,6 +374,7 @@ class FakeVolumeSnapshot: self.description = description self.size = size self.created_at = '1900-01-01 12:34:56' + self.updated_at = None self.volume_id = '12345' self.metadata = {} diff --git a/openstack/tests/unit/block_storage/v2/test_snapshot.py b/openstack/tests/unit/block_storage/v2/test_snapshot.py index fc6408d7f..408264ec5 100644 --- a/openstack/tests/unit/block_storage/v2/test_snapshot.py +++ b/openstack/tests/unit/block_storage/v2/test_snapshot.py @@ -23,6 +23,7 @@ SNAPSHOT = { "status": "creating", "description": "Daily backup", "created_at": "2015-03-09T12:14:57.233772", + "updated_at": None, "metadata": {}, "volume_id": "5aa119a8-d25b-45a7-8d1b-88e127885635", "size": 1, @@ -67,6 +68,7 @@ class TestSnapshot(base.TestCase): self.assertEqual(SNAPSHOT["id"], sot.id) self.assertEqual(SNAPSHOT["status"], sot.status) self.assertEqual(SNAPSHOT["created_at"], sot.created_at) + self.assertEqual(SNAPSHOT["updated_at"], sot.updated_at) self.assertEqual(SNAPSHOT["metadata"], sot.metadata) self.assertEqual(SNAPSHOT["volume_id"], sot.volume_id) self.assertEqual(SNAPSHOT["size"], sot.size) diff --git a/openstack/tests/unit/block_storage/v3/test_snapshot.py b/openstack/tests/unit/block_storage/v3/test_snapshot.py index 05f833051..13bef4a85 100644 --- a/openstack/tests/unit/block_storage/v3/test_snapshot.py +++ b/openstack/tests/unit/block_storage/v3/test_snapshot.py @@ -23,6 +23,7 @@ SNAPSHOT = { "status": "creating", "description": "Daily backup", "created_at": "2015-03-09T12:14:57.233772", + "updated_at": None, "metadata": {}, "volume_id": "5aa119a8-d25b-45a7-8d1b-88e127885635", "size": 1, @@ -62,6 +63,7 @@ class TestSnapshot(base.TestCase): self.assertEqual(SNAPSHOT["id"], sot.id) self.assertEqual(SNAPSHOT["status"], sot.status) self.assertEqual(SNAPSHOT["created_at"], sot.created_at) + self.assertEqual(SNAPSHOT["updated_at"], sot.updated_at) self.assertEqual(SNAPSHOT["metadata"], sot.metadata) self.assertEqual(SNAPSHOT["volume_id"], sot.volume_id) self.assertEqual(SNAPSHOT["size"], sot.size) diff --git a/releasenotes/notes/snap-updated_at-a46711b6160e3a26.yaml b/releasenotes/notes/snap-updated_at-a46711b6160e3a26.yaml new file mode 100644 index 000000000..927d6d11a --- /dev/null +++ b/releasenotes/notes/snap-updated_at-a46711b6160e3a26.yaml @@ -0,0 +1,3 @@ +--- +features: + - Added support for the updated_at attribute for volume snapshots.