Address nits in server group policy series

Change-Id: I126b51892056e3241640bbf05acf16d7f72b4329
This commit is contained in:
Yikun Jiang 2018-07-11 15:57:08 +08:00
parent 5cdb1ce26b
commit d1ccea4dd7
5 changed files with 8 additions and 8 deletions

View File

@ -447,7 +447,7 @@ class InstanceGroup(API_BASE):
@property @property
def policy(self): def policy(self):
if len(self._policies) not in (0, 1): if len(self._policies) > 1:
msg = ("More than one policy (%(policies)s) is associated with " msg = ("More than one policy (%(policies)s) is associated with "
"group %(group_name)s, only the first one in the list " "group %(group_name)s, only the first one in the list "
"would be returned.") "would be returned.")

View File

@ -120,7 +120,7 @@ class _GroupAntiAffinityFilter(filters.BaseHostFilter):
{'group_uuid': group_uuid, {'group_uuid': group_uuid,
'host': host_state.host, 'host': host_state.host,
'max_server': max_server_per_host}) 'max_server': max_server_per_host})
# Note(yikun): If the number of servers from same group on this host # NOTE(yikun): If the number of servers from same group on this host
# is less than the max_server_per_host, this filter will accept the # is less than the max_server_per_host, this filter will accept the
# given host. In the default case(max_server_per_host=1), this filter # given host. In the default case(max_server_per_host=1), this filter
# will accept the given host if there are 0 servers from the group # will accept the given host if there are 0 servers from the group

View File

@ -149,7 +149,7 @@ class TestGroupAffinityFilter(test.NoDBTestCase):
policy='affinity')) policy='affinity'))
self.assertTrue(filt_cls.host_passes(host, spec_obj)) self.assertTrue(filt_cls.host_passes(host, spec_obj))
spec_obj = objects.RequestSpec(instance_group=objects.InstanceGroup( spec_obj = objects.RequestSpec(instance_group=objects.InstanceGroup(
policy=policy, members=[], rules={}), instance_uuid=uuids.fake) policy=policy, members=[]), instance_uuid=uuids.fake)
spec_obj.instance_group.hosts = [] spec_obj.instance_group.hosts = []
self.assertTrue(filt_cls.host_passes(host, spec_obj)) self.assertTrue(filt_cls.host_passes(host, spec_obj))
spec_obj.instance_group.hosts = ['host2'] spec_obj.instance_group.hosts = ['host2']

View File

@ -1,11 +1,11 @@
--- ---
features: features:
- | - |
Enable users to define the policy rules on server group policy to meet Microversion 2.64 is added and enables users to define rules on server
more advanced policy requirement. This microversion 2.64 brings the group policy to meet more advanced policy requirements. This microversion
following changes in server group APIs: brings the following changes in server group APIs:
* Add ``policy`` and ``rules`` fields in the request of POST * Add ``policy`` and ``rules`` fields in the request of POST
``/os-server-groups``. The ``policy`` represents the name of policy. The ``/os-server-groups``. The ``policy`` represents the name of policy. The
``rules`` field, which is a dict, can be applied to the policy, which ``rules`` field, which is a dict, can be applied to the policy, which
currently only supports ``max_server_per_host`` for ``anti-affinity`` currently only supports ``max_server_per_host`` for ``anti-affinity``

View File

@ -5,6 +5,6 @@ features:
The new style ``policy`` field has been added to ``ServerGroupPayload``. The new style ``policy`` field has been added to ``ServerGroupPayload``.
The ``server_group.create``, ``server_group.delete`` and The ``server_group.create``, ``server_group.delete`` and
``server_group.add_member`` versioned notifications will be updated to ``server_group.add_member`` versioned notifications will be updated to
include the new ``policy`` and ``rules``field. The ``policies`` field is include the new ``policy`` and ``rules`` field. The ``policies`` field is
deprecated for removal but still put into the notification payload for deprecated for removal but still put into the notification payload for
backward compatibility. backward compatibility.