Merge "Support for Cinder volumes was added"

This commit is contained in:
Jenkins
2016-01-14 15:29:23 +00:00
committed by Gerrit Code Review
8 changed files with 308 additions and 0 deletions

View 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($))

View 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

View 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

View 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

View File

@@ -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

View 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: []

View File

@@ -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

View 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.