Add Nova anti-affinity rules
Change-Id: I62a94daf47983443b557f038217b6a0d35761c81 Closes-Bug: #1625017
This commit is contained in:
parent
f1bc936a6e
commit
5e36ae8fc6
@ -83,9 +83,12 @@ Properties:
|
||||
- network: $.class(Network).notNull()
|
||||
ipList: [$.string().notNull()]
|
||||
Usage: Out
|
||||
#policies: anti-affinity, affinity
|
||||
instanceAffinityGroup:
|
||||
Contract: $.class(InstanceAffinityGroup)
|
||||
|
||||
Methods:
|
||||
initialize:
|
||||
.init:
|
||||
Body:
|
||||
- $._environment: $.find(std:Environment).require()
|
||||
- $.agent: new(sys:Agent, host => $)
|
||||
@ -93,6 +96,14 @@ Methods:
|
||||
- $.instanceTemplate: {}
|
||||
- $._floatingIpOutputName: null
|
||||
|
||||
- $.volumes.values().concat($this.blockDevices.volume).select(
|
||||
sys:GC.subscribeDestruction($, $this, _onReferencedResourceDelete))
|
||||
|
||||
- If: $.instanceAffinityGroup != null
|
||||
Then: sys:GC.subscribeDestruction(
|
||||
$this.instanceAffinityGroup, $this, _onReferencedResourceDelete)
|
||||
|
||||
|
||||
# Called after the Instance template pieces are in place. It
|
||||
# is at this stage alterations to the template should be made
|
||||
prepareStackTemplate:
|
||||
@ -148,7 +159,11 @@ Methods:
|
||||
- $properties.block_device_mapping_v2: $bdmDefinition
|
||||
Else:
|
||||
$properties.image: $.image
|
||||
|
||||
- If: $.instanceAffinityGroup != null
|
||||
Then:
|
||||
- $.instanceAffinityGroup.deploy()
|
||||
- $properties.scheduler_hints:
|
||||
group: $.instanceAffinityGroup.getRef()
|
||||
- $template:
|
||||
resources:
|
||||
$.name:
|
||||
@ -160,7 +175,6 @@ Methods:
|
||||
description: format('ID of {0} instance', $.name)
|
||||
value:
|
||||
get_resource: $.name
|
||||
|
||||
- $.instanceTemplate: $.instanceTemplate.mergeWith($template)
|
||||
- $.volumes.items().select(
|
||||
$.unpack(path, volume) -> $this.attachVolume($path, $volume))
|
||||
@ -326,6 +340,15 @@ Methods:
|
||||
|
||||
- $region.stack.setTemplate($template)
|
||||
|
||||
_onReferencedResourceDelete:
|
||||
Arguments:
|
||||
- resource:
|
||||
Contract: $.class(std:CloudResource).notNull()
|
||||
Body:
|
||||
- If: sys:GC.isDoomed($this)
|
||||
Then:
|
||||
- $.beginReleaseResources()
|
||||
|
||||
endReleaseResources:
|
||||
Body:
|
||||
- $region: $.getRegion()
|
||||
|
64
meta/io.murano/Classes/resources/InstanceAffinityGroup.yaml
Normal file
64
meta/io.murano/Classes/resources/InstanceAffinityGroup.yaml
Normal file
@ -0,0 +1,64 @@
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
Namespaces:
|
||||
std: io.murano
|
||||
=: io.murano.resources
|
||||
|
||||
Name: InstanceAffinityGroup
|
||||
Extends: std:CloudResource
|
||||
|
||||
Properties:
|
||||
|
||||
affinity:
|
||||
Contract: $.bool().notNull()
|
||||
Default: false #affinity: true, anti-affinity: false
|
||||
|
||||
|
||||
Methods:
|
||||
deploy:
|
||||
Body:
|
||||
- If: $.affinity
|
||||
Then:
|
||||
- $policies: ['affinity']
|
||||
Else:
|
||||
- $policies: ['anti-affinity']
|
||||
- $name: $._getHeatName()
|
||||
- $affinityTemplate:
|
||||
resources:
|
||||
$name:
|
||||
type: 'OS::Nova::ServerGroup'
|
||||
properties:
|
||||
name: $name
|
||||
policies: $policies
|
||||
- $region: $.getRegion()
|
||||
- $region.stack.updateTemplate($affinityTemplate)
|
||||
- $region.stack.push(async => true)
|
||||
|
||||
.destroy:
|
||||
Body:
|
||||
- $name: $._getHeatName()
|
||||
- $region: $.getRegion()
|
||||
- $template: $region.stack.current()
|
||||
- $template.resources: $template.resources.delete($name)
|
||||
- $region.stack.setTemplate($template)
|
||||
- $region.stack.push(async => true)
|
||||
|
||||
|
||||
getRef:
|
||||
Body:
|
||||
- Return:
|
||||
get_resource: $._getHeatName()
|
||||
|
||||
_getHeatName:
|
||||
Body:
|
||||
- Return: format('NovaServerGroup-{0}', id($this))
|
@ -58,6 +58,7 @@ Classes:
|
||||
io.murano.resources.CinderVolumeBackup: resources/CinderVolumeBackup.yaml
|
||||
io.murano.resources.CinderVolumeSnapshot: resources/CinderVolumeSnapshot.yaml
|
||||
io.murano.resources.MetadataAware: resources/MetadataAware.yaml
|
||||
io.murano.resources.InstanceAffinityGroup: resources/InstanceAffinityGroup.yaml
|
||||
|
||||
io.murano.system.Agent: system/Agent.yaml
|
||||
io.murano.system.AgentListener: system/AgentListener.yaml
|
||||
|
Loading…
Reference in New Issue
Block a user