add masakari enabled to segment

Add 'enabled' to Masakari segment in microversion 1.2.
It returns "enabled" flag in segments API.

Change-Id: I445774a8af60a75c6b936d25fbab858233c632e9
This commit is contained in:
sue 2021-02-24 14:10:18 +08:00
parent eecefcf6e9
commit 736f3aa16c
3 changed files with 14 additions and 2 deletions

View File

@ -32,6 +32,9 @@ class Segment(resource.Resource):
allow_commit = True
allow_delete = True
# add enabled flag to segment in 1.2
_max_microversion = '1.2'
#: A ID of representing this segment.
id = resource.Body("id")
#: A Uuid of representing this segment.
@ -48,7 +51,9 @@ class Segment(resource.Resource):
recovery_method = resource.Body("recovery_method")
#: The service type of this segment.
service_type = resource.Body("service_type")
#: The enabled flag of this segment.
is_enabled = resource.Body("enabled", type=bool)
_query_mapping = resource.QueryParameters(
"sort_key", "sort_dir", recovery_method="recovery_method",
service_type="service_type")
service_type="service_type", is_enabled="enabled")

View File

@ -25,7 +25,8 @@ SEGMENT = {
"name": "my_segment",
"description": "something",
"recovery_method": "auto",
"service_type": "COMPUTE_HOST"
"service_type": "COMPUTE_HOST",
"enabled": True,
}
@ -46,6 +47,7 @@ class TestSegment(base.TestCase):
"marker": "marker",
"recovery_method": "recovery_method",
"service_type": "service_type",
"is_enabled": "enabled",
"sort_dir": "sort_dir",
"sort_key": "sort_key"},
sot._query_mapping._mapping)
@ -60,3 +62,4 @@ class TestSegment(base.TestCase):
self.assertEqual(SEGMENT["description"], sot.description)
self.assertEqual(SEGMENT["recovery_method"], sot.recovery_method)
self.assertEqual(SEGMENT["service_type"], sot.service_type)
self.assertEqual(SEGMENT["enabled"], sot.is_enabled)

View File

@ -0,0 +1,4 @@
---
features:
- Add support for the ``enabled`` field of the ``Segment`` resource for
the instance HA service (Masakari).