Created
March 25, 2017 17:52
-
-
Save tsailiming/6db8e0a368a7018543dbc13a16663e3b to your computer and use it in GitHub Desktop.
Sample code to add AWS provider in a service catalog in CloudForms
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.