Add soft policy for nova server group

Add soft-anti-affinity and soft-affinity policy for nova server
group resource.

DocImpact

Change-Id: Ib9a80d1418ea89bd81dfb01145a1691ca1b9b10c
Closes-Bug: #1665164
This commit is contained in:
ShunliZhou 2017-02-21 17:00:52 +08:00
parent 2e4902532a
commit 219bb0c8e9
2 changed files with 13 additions and 6 deletions

View File

@ -59,9 +59,9 @@ class NovaClientPlugin(client_plugin.ClientPlugin):
exceptions_module = exceptions
supported_versions = [
NOVA_API_VERSION, V2_2, V2_26
NOVA_API_VERSION, V2_2, V2_15, V2_26
] = [
'2.1', '2.2', '2.26'
'2.1', '2.2', '2.15', '2.26'
]
service_types = [COMPUTE] = ['compute']
@ -89,7 +89,7 @@ class NovaClientPlugin(client_plugin.ClientPlugin):
client = nc.Client(version, **args)
# NOTE: check for microversion availability
if version in [self.V2_2, self.V2_26]:
if version in [self.V2_2, self.V2_15, self.V2_26]:
try:
client.versions.get_current()
except exceptions.NotAcceptable:

View File

@ -49,7 +49,9 @@ class ServerGroup(resource.Resource):
'Defaults to anti-affinity.'),
default=['anti-affinity'],
constraints=[
constraints.AllowedValues(["anti-affinity", "affinity"])
constraints.AllowedValues(["anti-affinity", "affinity",
"soft-anti-affinity",
"soft-affinity"])
],
schema=properties.Schema(
properties.Schema.STRING,
@ -60,8 +62,13 @@ class ServerGroup(resource.Resource):
def handle_create(self):
name = self.physical_resource_name()
policies = self.properties[self.POLICIES]
server_group = self.client().server_groups.create(name=name,
policies=policies)
if 'soft-affinity' in policies or 'soft-anti-affinity' in policies:
client = self.client(
version=self.client_plugin().V2_15)
else:
client = self.client()
server_group = client.server_groups.create(name=name,
policies=policies)
self.resource_id_set(server_group.id)
def physical_resource_name(self):