Created
January 28, 2009 21:25
-
-
Save jeremyd/54201 to your computer and use it in GitHub Desktop.
rightscript example get and put, to and from a local file
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
--- | |
:pass: yourSecurePassword | |
:user: youremail@test.com | |
:rs_api_url: https://my.rightscale.com/api/acct/999999999999 |
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
#!/usr/bin/ruby | |
require 'rubygems' | |
require 'rest_client' | |
require 'xmlsimple' | |
require 'yaml' | |
id = ARGV[0] | |
config = YAML::load(IO.read('rs_api_config.yaml')) | |
res = RestClient::Resource.new(config[:rs_api_url], config[:user], config[:pass]) | |
script = res["right_scripts/#{id}"].get('X-API-VERSION' => '1.0') | |
sc_hash = XmlSimple.xml_in(script) | |
File.open(id, "w") do |f| | |
f.write(sc_hash['script']) | |
end |
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
#!/usr/bin/ruby | |
require 'rubygems' | |
require 'rest_client' | |
require 'yaml' | |
id = ARGV[0] | |
pkgfile = "#{id}.packages" | |
inputfile = "#{id}.inputs" | |
unless id && File.exists?(id) && File.exists?(pkgfile) && File.exists?(inputfile) | |
raise "file not found found\nsyntax: rs_put.rb <script id>" | |
end | |
config = YAML::load(IO.read('rs_api_config.yaml')) | |
res = RestClient::Resource.new(config[:rs_api_url], config[:user], config[:pass]) | |
# expecting simple string format here, space separated | |
packages = IO.read(pkgfile) | |
inputs = IO.read(inputfile) | |
# inputs are in hacky hash format, need better api support | |
input_hash = {} | |
i = inputs.split(/\s/) | |
i.each do |convert| | |
input_hash[convert] = "TRASHVAL" | |
end | |
res["right_scripts/#{id}"].put(:right_script => { :packages => packages, | |
:inputs => input_hash, | |
:script => IO.read(id) }, | |
:api_version => '1.0') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment