Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to add Volume in the secondary development of Openstack Murano

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly shows you "Openstack Murano secondary development of how to add Volume", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "Openstack Murano secondary development of how to add Volume" this article.

# # requirements currently, murano does not support adding volume to the instance, but murano creates resources through heat, while heat can create and attach volume. Murano can do what heat can do (of course, more can be done). Let's implement this feature step by step.

# # modify io.murano # create Cinder.yaml

The core library of murano is placed in murano/meta/io.murano. First, register the Cinder class in murano/meta/io.murano/manifest.yaml, copy the following to manifest.yaml and save it:

Io.murano.resources.Cinder: resources/Cinder.yaml

Create a murano/meta/io.murano/Class/resources/Cinder.yaml file:

Namespaces: =: io.murano.resources # current namespace std: io.murano Name: Cinder Properties: # the size of the Volume to be created Unit GB size: Contract: $.int (). NotNull () Methods: initialize: Body:-$. _ environment: $. Find (std:Environment). Require () genTemplate: Arguments: # volume to attach to the instance-instance: Contract: $.class (Instance). NotNull () Body: # $volumeName indicates the volume name to be created, and $instance.name is the name of the instance It is also the name of instance in the heat template. -$volumeName: format ('volume- {0}-{1}', $.id (), $instance.name)-$volumeAttachment: format ('volumeAttachment- {0}-{1}', $.id (), $instance.name) # the standard heta template is saved in $template # template first created a Volume Then use VolumeAttachment to attach to the specified instance-$template: resources: $volumeName: type: OS::Cinder::Volume properties: size: $.size $volumeAttachment: type: OS::Cinder::VolumeAttachment properties: volume_id: {get_resource: $volumeName} instance_uuid: {get_resource: $instance.name} # returns the template created The template modification will be merged into a complete heat template in the following steps. -Return: $template

# modify Instance.yaml

Modify murano/meta/io.murano/Class/resources/Instance.yaml

(1) add the following to the Properties: block:

VolumeSize: Contract: $.int () Default: null

This is used to pass parameters to app.

(2) add the following after line 99 (that is,-$.networks.customNetworks.select ($this.joinNet ($, $securityGroupName)):

-If: $.volumeSize! = null Then:-$cinder: new (Cinder, size = > $.volumeSize)-$volumeTemplate: $cinder.genTemplate ($this)-$.instanceTemplate: $.instanceTemplate.mergeWith ($volumeTemplate)

These lines of code are easy to understand: if $.volumeSize is not empty, instantiate a Cinder object and merge the generated volume template into the $.instanceTemplate template.

# updating io.murano

````murano-manage-- config-file. / etc/murano/murano.conf import-package meta/io.murano/-- update```

# # modifying murano-app murano can now add volume, and now you need to modify an app to allow it to use this feature. It should be noted that the volumeSize parameter in Instance.yaml is optional, so there will be no problem if the existing app is not modified.

Here we use Tomcatapp to test, Tomcat can be downloaded from https://github.com/openstack/murano-apps.git, and remember the correct branch that git checkout-t origin/stable/kilo switched to after the download.

Edit murano-apps/Tomcat/package/UI/ui.yaml:

Version: 2Application:?: type: io.murano.apps.apache.Tomcat name: $. AppConfiguration.name instance:: type: io.murano.resources.LinuxMuranoInstance name: generateHostname ($.instanceConfiguration.unitNamingPattern 1) flavor: $.instanceConfiguration.flavor image: $.instanceConfiguration.osImage keyname: $.instanceConfiguration.keyPair availabilityZone: $.instanceConfiguration.availabilityZone assignFloatingIp: $.appConfiguration.assignFloatingIP volumeSize: $.instanceConfiguration.volumeSize # add this line [...]-name: unitNamingPattern type: string label: Instance NamingPattern required: false maxLength: 64 regexpValidator:'^ [a-zA-z] [- _ [W] * $'errorMessages: invalid: Just letters Numbers, underscores and hyphens are allowed. HelpText: Just letters, numbers, underscores and hyphens are allowed. Description: >-Specify a string, that will be used in instance hostname. Just Amurz, aMuz, 0-9, dash and underline are allowed. # add the following lines-name: volumeSize type: integer label: Volume Size (GB) required: false description: Instance Volume Size.

[...] above. Indicates the omitted content, and there are comments where it needs to be modified. After modification, the Tomcat will be created with an optional parameter VolumeSize, and a volume will be created if the parameter is not empty.

Update the Tomcat code:

Murano-manage-- config-file. / etc/murano/murano.conf import-package.. / murano-apps/Tomcat/package-- update is all the contents of the article "how to add Volume for the second Development of Openstack Murano". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report