Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Will Fog supports nested templates for openstack orchestration #3753

Closed
phijojoseph opened this issue Nov 7, 2015 · 11 comments
Closed

Will Fog supports nested templates for openstack orchestration #3753

phijojoseph opened this issue Nov 7, 2015 · 11 comments

Comments

@phijojoseph
Copy link

I tried to use a nested template to deploy a couple of instances . It works fine on heat command.But not with fog. If someone has tried on it, please let me know how to work on resource_resgistry or env.yaml .

Regards
Phijo

@geemus
Copy link
Member

geemus commented Nov 9, 2015

@dhague @Ladas @TerryHowe - could one of you provide insight? Thanks!

@Ladas
Copy link
Contributor

Ladas commented Nov 9, 2015

@phijojoseph https://github.com/ManageIQ/manageiq/blob/387a461df7f11f65cb4bff61c422629ac4872ba9/app/models/manageiq/providers/openstack/infra_manager/orchestration_stack.rb#L26

this is the code I used for stack update, create should be the same

It's a bit different to OpenStack CLI, since Heat CLI is doing some processing of files for you, using your filesystem. E.g. for the 'files' hash, it contains { filename => content } pairs, which you will need to build by scanning the templates recursively, same as heat CLI does.

What is the question about the resource registry and env.yaml? Resource registry contains mapping of resource types to filenames, than the filename has to be present in 'files' hash attribute

@phijojoseph
Copy link
Author

@geemus @Ladas
Thank you for the update. I ll have a try on it.

As i was not able to pass the file, I thought to pass the file via resource registry or env.yaml. But both failed.

Now i ll try with files.
I have a question.
if is pass the file as
:files =>required_file.yaml

how will i access the file in my master.yaml? it will be great if you can share a sample yaml template using nested templates

Thanks in advance.
Phijo

@Ladas
Copy link
Contributor

Ladas commented Nov 11, 2015

@phijojoseph look e.g. on http://docs.openstack.org/developer/heat/template_guide/composition.html, you might want to also check http://hardysteven.blogspot.cz/ where he explains complex TripleO nested Heat templates

the :files needs to contain content of the yamls as a string, so if you have resource registry
resource_registry:
"OS::Nova::Server": my_nova.yaml

then files needs to have {"my_nova.yaml" => "content of my_nova.yaml"}

Similar for any file directly linked from template. The filename in a template or resource registry acts only as an index in the files Hash. Which is different in Heat CLI, which builds the files Hash for you and expects the file to be in your filesystem on a relative path.

@phijojoseph
Copy link
Author

@Ladas
Thank you for the response. I have tried as you mentioned, but am getting some error.

please find my code snippet

response=heat.stacks.new.save({
:stack_name => "stack"+ "_" + SecureRandom.urlsafe_base64(8),
:template => TEMPLATE_CONFIG,
:files => { "server_with_floatingip.yaml" => Slave_Template_CONFIG },
:disable_rollback => "false",
:parameters => {"vmcount" => params[:stack_count]}
})
Output:
TEMPLATE_CONFIG:
{"heat_template_version"=>Thu, 23 May 2013, "parameters"=>{"vmcount"=>{"type"=>"string", "description"=>"count of vm"}}, "resources"=>{"rg"=>{"type"=>"OS::Heat::ResourceGroup", "properties"=>{"count"=>{"get_param"=>"vmcount"}, "resource_def"=>{"type"=>"server_with_floatingip.yaml"}}}}}

Slave_Template_CONFIG
{"heat_template_version"=>Thu, 23 May 2013, "description"=>"Test Template", "resources"=>{"server_conf"=>{"type"=>"OS::Nova::Server", "properties"=>{"name"=>"server_%index%", "image"=>"cirros-0.3.4-x86_64-uec", "flavor"=>"m1.small"}}, "web_floating_IP"=>{"type"=>"OS::Nova::FloatingIP", "properties"=>{"pool"=>"public"}}, "web_floating_IP_att"=>{"type"=>"OS::Nova::FloatingIPAssociation", "properties"=>{"floating_ip"=>{"get_resource"=>"web_floating_IP"}, "server_id"=>{"get_resource"=>"server_conf"}}}}, "outputs"=>{"instance_ip"=>{"description"=>"The IP address of the deployed instance", "value"=>{"get_attr"=>["server_conf", "first_address", "floating_ip"]}}}}

Completed 500 Internal Server Error in 3619ms (ActiveRecord: 0.0ms)
Excon::Errors::BadRequest (Expected(201) <=> Actual(400 Bad Request)
excon.error.response
:body => "{"explanation": "The server could not comply with the request since it is either malformed or otherwise incorrect.", "code": 400, "error": {"message": "Failed to validate: <type 'dict'> can't be decoded", "traceback": "Traceback (most recent call last):\n\n File \"/opt/stack/heat/heat/common/context.py\", line 296, in wrapped\n return func(self, ctx, _args, *_kwargs)\n\n File \"/opt/stack/heat/heat/engine/service.py\", line 715, in create_stack\n parent_resource_name)\n\n File \"/opt/stack/heat/heat/engine/service.py\", line 626, in _parse_template_and_validate_stack\n stack.validate()\n\n File \"/usr/local/lib/python2.7/dist-packages/osprofiler/profiler.py\", line 105, in wrapper\n return f(_args, *_kwargs)\n\n File \"/opt/stack/heat/heat/engine/stack.py\", line 657, in validate\n raise ex\n\nStackValidationFailed: Failed to validate: <type 'dict'> can't be decoded\n", "type": "StackValidationFailed"}, "title": "Bad Request"}"

Is there anything that i need to change?

Sorry for the trouble

Thanks
Phijo

@Ladas
Copy link
Contributor

Ladas commented Nov 11, 2015

@phijojoseph hm some syntax errors maybe, this might need to be a string? "heat_template_version"=>Thu, 23 May 2013

I think you need to also send the template content as a string, so dump your yaml or json to string.

@phijojoseph
Copy link
Author

@Ladas the issue got solved, i have converted the yaml out to json, and parsed with file. seems to be working now.
i have one more question, how about passing multiple slave files to master.yaml?

can i use like this
"files => {"k1" => value1, "k2" => value 2}"

Thanks for all the supports. and i would like to add a suggestion that, it will be great if fog can give some documentation about the supported options or add some comments like this
https://github.com/fog/fog/blob/master/lib/fog/openstack/requests/orchestration/create_stack.rb

Once again thanks

Phijo

@Ladas
Copy link
Contributor

Ladas commented Nov 12, 2015

@phijojoseph yes, exactly like this, files should include all the file names and their contents used, otherwise Heat will throw an exception.

If you could send a patch to documentation, based on you findings, that would be nice :-)

@phijojoseph
Copy link
Author

@Ladas Sure , I ll share my findings. And I would like to know how to pass the parameters to slave.yaml and get the output from slave.yaml.

Regards
Phijo

@Ladas
Copy link
Contributor

Ladas commented Nov 12, 2015

@phijojoseph you can check the tripleo templates for that or e.g. this https://developer.rackspace.com/blog/openstack-orchestration-in-depth-part-3-multi-instance-deployments/ there is always interface to the nested stack.

It should be creating nested stack, where each of them has output, so check e.g. fog call @stack_service.stacks.all(:show_nested => true). There is a link between stack resources and nested stacks.

@plribeiro3000
Copy link
Member

Closed in favor of fog/fog-openstack#53

@fog fog locked and limited conversation to collaborators Mar 10, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants