OSDir


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Openstack] parameterizing server creation


You can use ResourceGroups. Here is a snippet from a resource file I 
have created:

   my_server_instance:
     type: OS::Nova::Server
     properties:
       image: { get_param: image }
       flavor: { get_param: flavor }
#      key_name: { get_param: key }
       availability_zone: { get_param: [avl_zones, get_param: index ]}
       networks:
         - port: { get_resource: myport}

and the 'deployment' file from where I instantiate the resource (not 
complete, removed stuff for simplicity). Note usage of index, lets you 
address individual servers.

   my_cluster:
     type: OS::Heat::ResourceGroup
     properties:
       count: { get_param: my_cluster_size }
       resource_def:
         type: myresource
         properties:
           image: "someimage"
           index: "%index%"

(Assumed that there is a registry as below:

resource_registry:
   myresource: myresourcefile.yaml

I know this is patchy, but I think provides all required clues.
rk

On 3/27/2018 9:01 AM, Sashan Govender wrote:
> Hi
>
> I have a HOT file that has 4 Nova::Server resources. They differences 
> between them are minimal and, when I look at the file, I see a lot of 
> duplication. How can I reduce this. I've tried fiddling with the 
> 'repeat' intrinsic and StructuredConfig but with no luck. I basically 
> want to create a loop like the following in the pseudo code:
>
> list_of_servers = ["s1", "s2", "s3", "s4"]
> for server_name in list_of_servers:
>     create_server(server_name)
>
>
>
>
> _______________________________________________
> Mailing list: http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack
> Post to     : openstack at lists.openstack.org
> Unsubscribe : http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack

-- 
Rathnakumar Kayyar
LCN
http://www.lcnpl.com



---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstack.org/pipermail/openstack/attachments/20180327/8da1ac21/attachment.html>