Skip to content

Instantly share code, notes, and snippets.

@tsailiming
Created March 25, 2017 17:52
Show Gist options
  • Save tsailiming/6db8e0a368a7018543dbc13a16663e3b to your computer and use it in GitHub Desktop.
Save tsailiming/6db8e0a368a7018543dbc13a16663e3b to your computer and use it in GitHub Desktop.
Sample code to add AWS provider in a service catalog in CloudForms
require 'rest-client'
require 'json'
servername = 'cf'
username = 'admin'
password = 'smartvm'
url = "https://#{servername}/api/providers"
post_params = {
:name => $evm.root['dialog_name'],
:type => "ManageIQ::Providers::Amazon::CloudManager",
#:zone => { :id => "1000000000001" },
:provider_region => "ap-southeast-1",
:credentials => {
:userid => $evm.root['dialog_aws_access_key_id'],
:password => $evm.root['dialog_aws_secret_access_key']
}
}.to_json
begin
rest_return = RestClient::Request.execute(
method: :post,
url: url,
:user => username,
:password => password,
:headers => {:accept => :json},
:payload => post_params,
verify_ssl: false)
result = JSON.parse(rest_return)
$evn.log(:info, result)
rescue => e
$evm.log(:error, "Error: #{e}")
end
@coolpalani
Copy link

Hello,

Could you describe what are all prerequisite you had done in AWS for integrate Amazon with CloudForms.
If you post with screen shots or share steps it would be great.
Thanks in advance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment