-
-
Save coolpalani/39c02fa2e2e818d2a89e3fe9ffac66d2 to your computer and use it in GitHub Desktop.
Sample code to add AWS provider in a service catalog in CloudForms
This file contains hidden or 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