Support for Cinder volumes was added
This change adds core library classes necessary to work with cinder volumes: Volume is the base class for cinder volume implementations. It defines the interface for volumes. The most important methods of it are "deploy" to deploy the volume and "attachTo" that returns a HOT snippet to attach the volume to Instance CinderVolume represents a new volume. The class wraps OS::Cinder::Volume Heat resource. ExistingCinderVolume is a Volume implementation for volumes created outside of Murano. CinderVolumeBackup and CinderVolumeSnapshot are adapter classes to wrap around Cinder backups and snapshots using their ID. In addition new property "volumes" was added to the Instance class. It is a mapping of a mounting path to Volume implementations that the Instance must be attached to. Because the mapping can be empty (or omitted) new property doesn't break backward compatibility. This commit doesn't has boot from volume functionality that need to be designed separately. Implements blueprint: cinder-volumes-support Change-Id: I8ff7f8e4b48e7fb8112271a642cac703db0963aa
This commit is contained in:
136
meta/io.murano/Classes/resources/CinderVolume.yaml
Normal file
136
meta/io.murano/Classes/resources/CinderVolume.yaml
Normal file
@@ -0,0 +1,136 @@
|
||||
# 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: CinderVolume
|
||||
|
||||
Extends: Volume
|
||||
|
||||
Properties:
|
||||
name:
|
||||
Contract: $.string()
|
||||
|
||||
size:
|
||||
Contract: $.int().notNull().check($ >= 1)
|
||||
|
||||
availabilityZone:
|
||||
Contract: $.string()
|
||||
|
||||
readOnly:
|
||||
Contract: $.bool().notNull()
|
||||
Default: false
|
||||
|
||||
multiattach:
|
||||
Contract: $.bool().notNull()
|
||||
Default: false
|
||||
|
||||
sourceImage:
|
||||
Contract: $.string()
|
||||
|
||||
sourceVolume:
|
||||
Contract: $.class(Volume)
|
||||
|
||||
sourceSnapshot:
|
||||
Contract: $.class(CinderVolumeSnapshot)
|
||||
|
||||
sourceVolumeBackup:
|
||||
Contract: $.class(CinderVolumeBackup)
|
||||
|
||||
Methods:
|
||||
.init:
|
||||
Body:
|
||||
- $._environment: $.find(std:Environment).require()
|
||||
|
||||
buildResourceDefinition:
|
||||
Body:
|
||||
- $properties:
|
||||
size: $.size
|
||||
|
||||
- If: $.availabilityZone != null
|
||||
Then:
|
||||
$properties.availability_zone: $.availabilityZone
|
||||
- If: $.name != null
|
||||
Then:
|
||||
$properties.name: $.name
|
||||
- If: $.sourceVolumeBackup != null
|
||||
Then:
|
||||
$properties.backup_id: $.sourceVolumeBackup.openstackId
|
||||
- If: $.sourceImage != null
|
||||
Then:
|
||||
$properties.image: $.sourceImage
|
||||
- If: $.sourceSnapshot != null
|
||||
Then:
|
||||
$properties.snapshot_id: $.sourceSnapshot.openstackId
|
||||
- If: $.sourceVolume != null
|
||||
Then:
|
||||
$properties.source_volid: $.sourceVolume.openstackId
|
||||
|
||||
# Available only since Heat 6.0.0 (Mitaka)
|
||||
- If: $.multiattach
|
||||
Then:
|
||||
$properties.multiattach: $.multiattach
|
||||
|
||||
# Available only since Heat 5.0.0 (Liberty)
|
||||
- If: $.readOnly
|
||||
Then:
|
||||
$properties.read_only: $.readOnly
|
||||
|
||||
- Return:
|
||||
resources:
|
||||
format('vol-{0}', id($)):
|
||||
type: 'OS::Cinder::Volume'
|
||||
properties: $properties
|
||||
outputs:
|
||||
format('vol-{0}-id', id($)):
|
||||
value: $.getRef()
|
||||
|
||||
deploy:
|
||||
Body:
|
||||
- If: $.sourceSnapshot != null
|
||||
Then:
|
||||
$.sourceSnapshot.validate()
|
||||
- If: $.sourceVolumeBackup != null
|
||||
Then:
|
||||
$.sourceVolumeBackup.validate()
|
||||
- If: $.sourceVolume != null
|
||||
Then:
|
||||
$.sourceVolume.deploy()
|
||||
|
||||
- $snippet: $.buildResourceDefinition()
|
||||
- If: $.getAttr(lastTemplate) != $snippet
|
||||
Then:
|
||||
- $template: $._environment.stack.current()
|
||||
- $template: $template.mergeWith($snippet, maxLevels => 2)
|
||||
- $._environment.stack.setTemplate($template)
|
||||
- $._environment.stack.push()
|
||||
- $outputs: $._environment.stack.output()
|
||||
- $.openstackId: $outputs.get(format('vol-{0}-id', id($)))
|
||||
- $.setAttr(lastTemplate, $snippet)
|
||||
|
||||
releaseResources:
|
||||
Body:
|
||||
- If: $.getAttr(lastTemplate) != null
|
||||
Then:
|
||||
- $template: $._environment.stack.current()
|
||||
- $template.resources: $template.resources.delete(format('vol-{0}', id($)))
|
||||
- $template.outputs: $template.outputs.delete(format('vol-{0}-id', id($)))
|
||||
- $._environment.stack.setTemplate($template)
|
||||
- $._environment.stack.push()
|
||||
- $.setAttr(lastTemplate, null)
|
||||
|
||||
getRef:
|
||||
Body:
|
||||
Return:
|
||||
get_resource: format('vol-{0}', id($))
|
25
meta/io.murano/Classes/resources/CinderVolumeBackup.yaml
Normal file
25
meta/io.murano/Classes/resources/CinderVolumeBackup.yaml
Normal file
@@ -0,0 +1,25 @@
|
||||
# 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:
|
||||
=: io.murano.resources
|
||||
|
||||
Name: CinderVolumeBackup
|
||||
|
||||
Properties:
|
||||
openstackId:
|
||||
Contract: $.string().notNull()
|
||||
|
||||
Methods:
|
||||
validate:
|
||||
Body:
|
||||
# TODO: add validation that backup does exist
|
25
meta/io.murano/Classes/resources/CinderVolumeSnapshot.yaml
Normal file
25
meta/io.murano/Classes/resources/CinderVolumeSnapshot.yaml
Normal file
@@ -0,0 +1,25 @@
|
||||
# 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:
|
||||
=: io.murano.resources
|
||||
|
||||
Name: CinderVolumeSnapshot
|
||||
|
||||
Properties:
|
||||
openstackId:
|
||||
Contract: $.string().notNull()
|
||||
|
||||
Methods:
|
||||
validate:
|
||||
Body:
|
||||
# TODO: add validation that snapshot does exist
|
27
meta/io.murano/Classes/resources/ExistingCinderVolume.yaml
Normal file
27
meta/io.murano/Classes/resources/ExistingCinderVolume.yaml
Normal file
@@ -0,0 +1,27 @@
|
||||
# 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:
|
||||
=: io.murano.resources
|
||||
|
||||
Name: ExistingCinderVolume
|
||||
|
||||
Extends: Volume
|
||||
|
||||
Properties:
|
||||
openstackId:
|
||||
Contract: $.string().notNull()
|
||||
|
||||
Methods:
|
||||
getRef:
|
||||
Body:
|
||||
Return: $.openstackId
|
@@ -65,6 +65,9 @@ Properties:
|
||||
Contract:
|
||||
- $.class(std:SharedIp)
|
||||
Usage: InOut # as it is set in setSharedIps
|
||||
volumes:
|
||||
Contract:
|
||||
$.string().notNull(): $.class(Volume).notNull()
|
||||
|
||||
Methods:
|
||||
initialize:
|
||||
@@ -137,6 +140,14 @@ Methods:
|
||||
get_resource: $.name
|
||||
|
||||
- $.instanceTemplate: $.instanceTemplate.mergeWith($template)
|
||||
- $.volumes.items().select(
|
||||
$.unpack(path, volume) -> $this.attachVolume($path, $volume))
|
||||
|
||||
- For: path
|
||||
In: $.volumes
|
||||
Do:
|
||||
- $volume: $.volumes.get($path)
|
||||
- $this.attachVolume($path, $volume)
|
||||
|
||||
# Any additional template preparation
|
||||
- $.instanceTemplate: $.prepareStackTemplate($.instanceTemplate)
|
||||
@@ -233,6 +244,18 @@ Methods:
|
||||
|
||||
- $._floatingIpOutputName: coalesce($._floatingIpOutputName, $joinResult.instanceFipOutput)
|
||||
|
||||
attachVolume:
|
||||
Arguments:
|
||||
- path:
|
||||
Contract: $.string().notNull()
|
||||
- volume:
|
||||
Contract: $.class(Volume).notNull()
|
||||
Body:
|
||||
- $attachment: $volume.attachTo($this, $path)
|
||||
- $.instanceTemplate: $.instanceTemplate.mergeWith($attachment.template)
|
||||
- $.setAttr(instanceResources, $.getAttr(instanceResources, []).concat($attachment.get(instanceResources, [])))
|
||||
- $.setAttr(instanceOutputs, $.getAttr(instanceOutputs, []).concat($attachment.get(instanceOutputs, [])))
|
||||
|
||||
releaseResources:
|
||||
Body:
|
||||
- $template: $.environment.stack.current()
|
||||
@@ -277,3 +300,8 @@ Methods:
|
||||
Body:
|
||||
- $template: $.environment.stack.current()
|
||||
- Return: $template.resources != null and $.name in $template.resources
|
||||
|
||||
getRef:
|
||||
Body:
|
||||
Return:
|
||||
get_resource: $.name
|
56
meta/io.murano/Classes/resources/Volume.yaml
Normal file
56
meta/io.murano/Classes/resources/Volume.yaml
Normal file
@@ -0,0 +1,56 @@
|
||||
# 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:
|
||||
=: io.murano.resources
|
||||
|
||||
|
||||
Name: Volume
|
||||
|
||||
|
||||
Properties:
|
||||
openstackId:
|
||||
Contract: $.string()
|
||||
Usage: Out
|
||||
|
||||
|
||||
Methods:
|
||||
deploy:
|
||||
|
||||
getRef:
|
||||
|
||||
releaseResources:
|
||||
|
||||
.destroy:
|
||||
Body:
|
||||
- $.releaseResources()
|
||||
|
||||
attachTo:
|
||||
Arguments:
|
||||
- instance:
|
||||
Contract: $.class(Instance).notNull()
|
||||
- path:
|
||||
Contract: $.string().notNull()
|
||||
Body:
|
||||
- $.deploy()
|
||||
- $resourceName: format('vol-attachment-{0}-{1}', id($), $instance.name)
|
||||
- Return:
|
||||
template:
|
||||
resources:
|
||||
$resourceName:
|
||||
type: 'OS::Cinder::VolumeAttachment'
|
||||
properties:
|
||||
instance_uuid: $instance.getRef()
|
||||
mountpoint: $path
|
||||
volume_id: $.getRef()
|
||||
instanceResources: [$resourceName]
|
||||
instanceOutputs: []
|
@@ -49,6 +49,11 @@ Classes:
|
||||
io.murano.resources.NeutronNetwork: resources/NeutronNetwork.yaml
|
||||
io.murano.resources.ExistingNeutronNetwork: resources/ExistingNeutronNetwork.yaml
|
||||
io.murano.resources.NovaNetwork: resources/NovaNetwork.yaml
|
||||
io.murano.resources.Volume: resources/Volume.yaml
|
||||
io.murano.resources.CinderVolume: resources/CinderVolume.yaml
|
||||
io.murano.resources.ExistingCinderVolume: resources/ExistingCinderVolume.yaml
|
||||
io.murano.resources.CinderVolumeBackup: resources/CinderVolumeBackup.yaml
|
||||
io.murano.resources.CinderVolumeSnapshot: resources/CinderVolumeSnapshot.yaml
|
||||
|
||||
io.murano.system.Agent: system/Agent.yaml
|
||||
io.murano.system.AgentListener: system/AgentListener.yaml
|
||||
|
6
releasenotes/notes/cinder-volumes-0412875c1011f8eb.yaml
Normal file
6
releasenotes/notes/cinder-volumes-0412875c1011f8eb.yaml
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
features:
|
||||
- Classes to work with Cinder volumes were added to core library.
|
||||
Now it is possible to create new volume from various sources or use
|
||||
existing volume. Also it is possible to attach volumes to instances.
|
||||
This doesn't include ability to boot instances from volumes.
|
Reference in New Issue
Block a user