From 05a697679b096a3bf14b125ad0d4cc21a2ce8385 Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Mon, 6 Dec 2010 10:34:58 -0800 Subject: [PATCH 001/239] Added clone deployment function --- lib/rest_connection/rightscale/deployment.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/rest_connection/rightscale/deployment.rb b/lib/rest_connection/rightscale/deployment.rb index 67718df..fa8679a 100644 --- a/lib/rest_connection/rightscale/deployment.rb +++ b/lib/rest_connection/rightscale/deployment.rb @@ -36,4 +36,13 @@ def servers s.reload end end + + def duplicate + clone + end + + def clone + deploy_href = URI.parse(self.href) + Deployment.new(:href => connection.post(deploy_href.path + "/duplicate")) + end end From 73805d8402da24d77e34a5aaf2309ca9f8a87e7d Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Fri, 10 Dec 2010 13:56:57 -0800 Subject: [PATCH 002/239] added set_inputs(hash) to server.rb --- lib/rest_connection/rightscale/server.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/rest_connection/rightscale/server.rb b/lib/rest_connection/rightscale/server.rb index 269fa77..9a3ca95 100644 --- a/lib/rest_connection/rightscale/server.rb +++ b/lib/rest_connection/rightscale/server.rb @@ -167,6 +167,11 @@ def set_input(name, value) connection.put(serv_href.path, :server => {:parameters => {name.to_sym => value} }) end + def set_inputs(hash) + serv_href = URI.parse(self.href) + connection.put(serv_href.path, :server => {:parameters => hash}) + end + def set_template(href) serv_href = URI.parse(self.href) connection.put(serv_href.path, :server => {:server_template_href => href}) From e1159e1123be6a9f4a4a204815b7df18eb125955 Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Fri, 10 Dec 2010 14:15:15 -0800 Subject: [PATCH 003/239] merged jeremyd's --- lib/rest_connection/rightscale/server.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rest_connection/rightscale/server.rb b/lib/rest_connection/rightscale/server.rb index 06ed4be..6b31134 100644 --- a/lib/rest_connection/rightscale/server.rb +++ b/lib/rest_connection/rightscale/server.rb @@ -167,7 +167,7 @@ def set_input(name, value) connection.put(serv_href.path, :server => {:parameters => {name.to_sym => value} }) end - def set_inputs(hash) + def set_inputs(hash = {}) serv_href = URI.parse(self.href) connection.put(serv_href.path, :server => {:parameters => hash}) end From 2d6fcf7c21ffd2cf28088c191633f8250274c917 Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Fri, 14 Jan 2011 11:24:59 -0800 Subject: [PATCH 004/239] multicloud support --- lib/rest_connection/rightscale/deployment.rb | 6 +++++- lib/rest_connection/rightscale/mc_server.rb | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/rest_connection/rightscale/deployment.rb b/lib/rest_connection/rightscale/deployment.rb index fa8679a..7517b61 100644 --- a/lib/rest_connection/rightscale/deployment.rb +++ b/lib/rest_connection/rightscale/deployment.rb @@ -25,7 +25,11 @@ def set_input(name, value) def servers_no_reload server_list = [] @params['servers'].each do |s| - server_list << Server.new(s) + if s["server_type"] == "ec2" + server_list << Server.new(s) + else + server_list << McServer.new(s) + end end return server_list end diff --git a/lib/rest_connection/rightscale/mc_server.rb b/lib/rest_connection/rightscale/mc_server.rb index 9f87f9a..62b94cf 100644 --- a/lib/rest_connection/rightscale/mc_server.rb +++ b/lib/rest_connection/rightscale/mc_server.rb @@ -16,7 +16,7 @@ # # You must have Beta v1.5 API access to use these internal API calls. # -class McServer +class McServer < Server include RightScale::Api::Gateway extend RightScale::Api::GatewayExtend From b740aa38fa58f40a15e872c209f432932f2dfe18 Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Tue, 18 Jan 2011 14:43:29 -0800 Subject: [PATCH 005/239] some more upgrades for multicloud --- lib/rest_connection/rightscale/mc_server.rb | 13 +++++++++++++ lib/rest_connection/rightscale/server.rb | 2 ++ 2 files changed, 15 insertions(+) diff --git a/lib/rest_connection/rightscale/mc_server.rb b/lib/rest_connection/rightscale/mc_server.rb index 62b94cf..e8d591c 100644 --- a/lib/rest_connection/rightscale/mc_server.rb +++ b/lib/rest_connection/rightscale/mc_server.rb @@ -36,4 +36,17 @@ def self.resource_singular_name "server" end + def self.create(opts) + server = {} + server[:name] = opts[:nickname] if opts[:nickname] + server[:deployment_href] = opts[:deployment_href] if opts[:deployment_href] + server[:instance] = {:server_template_href => opts[:server_template_href]} + server[:instance][:cloud_href] = "https://my.rightscale.com/api/clouds/#{opts[:cloud_id]}" + server[:instance][:multi_cloud_image_href] = opts[:mci_href] + server[:instance][:instance_type_href] = nil #TODO..... + server[:instance][:inputs] = opts[:inputs] + location = connection.post(self.resource_plural_name, {self.resource_singular_name.to_sym => server}) + newrecord = self.new('href' => location) + newrecord.reload + newrecord end diff --git a/lib/rest_connection/rightscale/server.rb b/lib/rest_connection/rightscale/server.rb index 6b31134..7bc0a1f 100644 --- a/lib/rest_connection/rightscale/server.rb +++ b/lib/rest_connection/rightscale/server.rb @@ -24,6 +24,8 @@ def self.create(opts) create_options = Hash.new create_options[self.resource_singular_name.to_sym] = opts create_options["cloud_id"] = opts[:cloud_id] if opts[:cloud_id] + create_options[self.resource_singular_name.to_sum][:mci_href] = nil + create_options[self.resource_singular_name.to_sum][:inputs] = nil location = connection.post(self.resource_plural_name,create_options) newrecord = self.new('href' => location) newrecord.reload From c91760544e916555cc6e55eb56e7be1ab61a0be8 Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Tue, 18 Jan 2011 17:30:17 -0800 Subject: [PATCH 006/239] more multicloud support + bugfixes --- lib/rest_connection/rightscale/deployment.rb | 68 ++++++++++++++++++-- lib/rest_connection/rightscale/mc_server.rb | 1 + 2 files changed, 64 insertions(+), 5 deletions(-) diff --git a/lib/rest_connection/rightscale/deployment.rb b/lib/rest_connection/rightscale/deployment.rb index 7517b61..a4e47bf 100644 --- a/lib/rest_connection/rightscale/deployment.rb +++ b/lib/rest_connection/rightscale/deployment.rb @@ -13,12 +13,70 @@ # You should have received a copy of the GNU General Public License # along with RestConnection. If not, see . -class Deployment - include RightScale::Api::Base - extend RightScale::Api::BaseExtend +class Deployment + class McDeployment + include RightScale::Api::Gateway + extend RightScale::Api::GatewayExtend + + def resource_plural_name + "deployments" + end + + def resource_singular_name + "deployment" + end + + def self.resource_plural_name + "deployments" + end + + def self.resource_singular_name + "deployment" + end + end + + class EC2Deployment + include RightScale::Api::Base + extend RightScale::Api::BaseExtend + + def resource_plural_name + "deployments" + end + + def resource_singular_name + "deployment" + end + + def self.resource_plural_name + "deployments" + end + + def self.resource_singular_name + "deployment" + end + end + + def initialize(params = {}) + if params[:cloud_id].to_i < 10 + @deploy = Deployment::EC2Deployment.new(params) + else + @deploy = Deployment::McDeployment.new(params) + end + end + + def method_missing(method_name, *args) + @deploy.method_missing(method_name, *args) + end + + def create(opts) + location = connection.post(@deploy.resource_plural_name, @deploy.resource_singular_name.to_sym => opts) + newrecord = self.new('href' => location) + newrecord.reload + newrecord + end def set_input(name, value) - deploy_href = URI.parse(self.href) + deploy_href = URI.parse(@deploy.href) connection.put(deploy_href.path, :deployment => {:parameters => {name => value} }) end @@ -46,7 +104,7 @@ def duplicate end def clone - deploy_href = URI.parse(self.href) + deploy_href = URI.parse(@deploy.href) Deployment.new(:href => connection.post(deploy_href.path + "/duplicate")) end end diff --git a/lib/rest_connection/rightscale/mc_server.rb b/lib/rest_connection/rightscale/mc_server.rb index e8d591c..3034352 100644 --- a/lib/rest_connection/rightscale/mc_server.rb +++ b/lib/rest_connection/rightscale/mc_server.rb @@ -49,4 +49,5 @@ def self.create(opts) newrecord = self.new('href' => location) newrecord.reload newrecord + end end From 0942ae7395a0d346f4da63a23552ec63f4a88716 Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Wed, 26 Jan 2011 11:34:13 -0800 Subject: [PATCH 007/239] inital multicloud commit --- lib/rest_connection.rb | 2 +- lib/rest_connection/rightscale/deployment.rb | 82 ++---- lib/rest_connection/rightscale/inputs.rb | 50 ++++ lib/rest_connection/rightscale/mc_instance.rb | 65 +++++ lib/rest_connection/rightscale/mc_server.rb | 100 ++++++- .../rightscale/monitoring_metric.rb | 36 +++ .../rightscale/rightscale_api_gateway.rb | 6 +- .../rightscale/rightscale_api_resources.rb | 4 + lib/rest_connection/rightscale/server.rb | 4 +- .../rightscale/server_interface.rb | 255 ++++++++++++++++++ 10 files changed, 528 insertions(+), 76 deletions(-) create mode 100644 lib/rest_connection/rightscale/inputs.rb create mode 100644 lib/rest_connection/rightscale/mc_instance.rb create mode 100644 lib/rest_connection/rightscale/monitoring_metric.rb create mode 100644 lib/rest_connection/rightscale/server_interface.rb diff --git a/lib/rest_connection.rb b/lib/rest_connection.rb index 3c3f888..072c8a1 100644 --- a/lib/rest_connection.rb +++ b/lib/rest_connection.rb @@ -183,7 +183,7 @@ def logger(message) STDOUT.puts init_message end - @@logger.info(message) + @@logger.info("[API V#{@settings[:common_headers]["X_API_VERSION"]} ]" + message) end # used by requestify to build parameters strings diff --git a/lib/rest_connection/rightscale/deployment.rb b/lib/rest_connection/rightscale/deployment.rb index a4e47bf..b6043c9 100644 --- a/lib/rest_connection/rightscale/deployment.rb +++ b/lib/rest_connection/rightscale/deployment.rb @@ -14,82 +14,40 @@ # along with RestConnection. If not, see . class Deployment - class McDeployment - include RightScale::Api::Gateway - extend RightScale::Api::GatewayExtend - - def resource_plural_name - "deployments" - end - - def resource_singular_name - "deployment" - end - - def self.resource_plural_name - "deployments" - end - - def self.resource_singular_name - "deployment" - end + include RightScale::Api::Base + extend RightScale::Api::BaseExtend + + def reload + uri = URI.parse(self.href) + @params ? @params.merge!(connection.get(uri.path)) : @params = connection.get(uri.path) + @params['cloud_id'] = cloud_id + @params end - class EC2Deployment - include RightScale::Api::Base - extend RightScale::Api::BaseExtend - - def resource_plural_name - "deployments" - end - - def resource_singular_name - "deployment" - end - - def self.resource_plural_name - "deployments" - end - - def self.resource_singular_name - "deployment" - end + def cloud_id + @cloud_id = self.nickname.match(/cloud_[0-9]+/)[0].match(/[0-9]+/)[0].to_i unless @cloud_id + @cloud_id end - def initialize(params = {}) - if params[:cloud_id].to_i < 10 - @deploy = Deployment::EC2Deployment.new(params) - else - @deploy = Deployment::McDeployment.new(params) - end - end - - def method_missing(method_name, *args) - @deploy.method_missing(method_name, *args) - end - - def create(opts) - location = connection.post(@deploy.resource_plural_name, @deploy.resource_singular_name.to_sym => opts) + def self.create(opts) + location = connection.post(self.resource_plural_name, self.resource_singular_name.to_sym => opts) newrecord = self.new('href' => location) newrecord.reload newrecord end + def set_inputs(hash = {}) + deploy_href = URI.parse(self.href) + connection.put(deploy_href.path, :deployment => {:parameters => hash }) + end + def set_input(name, value) - deploy_href = URI.parse(@deploy.href) + deploy_href = URI.parse(self.href) connection.put(deploy_href.path, :deployment => {:parameters => {name => value} }) end def servers_no_reload - server_list = [] - @params['servers'].each do |s| - if s["server_type"] == "ec2" - server_list << Server.new(s) - else - server_list << McServer.new(s) - end - end - return server_list + @params['servers'].map { |s| ServerInterface.new(s) } end def servers diff --git a/lib/rest_connection/rightscale/inputs.rb b/lib/rest_connection/rightscale/inputs.rb new file mode 100644 index 0000000..08f9666 --- /dev/null +++ b/lib/rest_connection/rightscale/inputs.rb @@ -0,0 +1,50 @@ +# This file is part of RestConnection +# +# RestConnection is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# RestConnection is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with RestConnection. If not, see . + +# +# You must have Beta v1.5 API access to use these internal API calls. +# +class Inputs + include RightScale::Api::Gateway + extend RightScale::Api::GatewayExtend + + def resource_plural_name + "inputs" + end + + def resource_singular_name + "inputs" + end + + def self.resource_plural_name + "inputs" + end + + def self.resource_singular_name + "inputs" + end + + def self.create + + end + + def show + #TODO + end + + def multi_update + #TODO + end +end diff --git a/lib/rest_connection/rightscale/mc_instance.rb b/lib/rest_connection/rightscale/mc_instance.rb new file mode 100644 index 0000000..3f43c83 --- /dev/null +++ b/lib/rest_connection/rightscale/mc_instance.rb @@ -0,0 +1,65 @@ +# This file is part of RestConnection +# +# RestConnection is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# RestConnection is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with RestConnection. If not, see . + +# +# You must have Beta v1.5 API access to use these internal API calls. +# +class McInstance + include RightScale::Api::Gateway + extend RightScale::Api::GatewayExtend + + def resource_plural_name + "instances" + end + + def resource_singular_name + "instance" + end + + def self.resource_plural_name + "instances" + end + + def self.resource_singular_name + "instance" + end + + def show + inst_href = URI.parse(self.href) + @params.merge! connection.get(inst_href.path, 'view' => "full") + end + + def save + inst_href = URI.parse(self.href) + connection.put(inst_href.path, @params) + end + + def launch + inst_href = URI.parse(self.href) + connection.post(inst_href.path + '/launch') + end + + def terminate + inst_href = URI.parse(self.href) + connection.post(inst_href.path + '/terminate') + end + + def run_executable(executable, opts=nil) +# script_options = { :server => {} } +# if executable.is_a?(Executable) or executable.is_a?(RightScript) +# executable = Task.convert_from(executable) +# inst_href = URI.parse(self.href) + end +end diff --git a/lib/rest_connection/rightscale/mc_server.rb b/lib/rest_connection/rightscale/mc_server.rb index 3034352..64d23d9 100644 --- a/lib/rest_connection/rightscale/mc_server.rb +++ b/lib/rest_connection/rightscale/mc_server.rb @@ -37,17 +37,99 @@ def self.resource_singular_name end def self.create(opts) - server = {} - server[:name] = opts[:nickname] if opts[:nickname] - server[:deployment_href] = opts[:deployment_href] if opts[:deployment_href] - server[:instance] = {:server_template_href => opts[:server_template_href]} - server[:instance][:cloud_href] = "https://my.rightscale.com/api/clouds/#{opts[:cloud_id]}" - server[:instance][:multi_cloud_image_href] = opts[:mci_href] - server[:instance][:instance_type_href] = nil #TODO..... - server[:instance][:inputs] = opts[:inputs] - location = connection.post(self.resource_plural_name, {self.resource_singular_name.to_sym => server}) + location = connection.post(self.resource_plural_name, {self.resource_singular_name.to_sym => opts}) newrecord = self.new('href' => location) newrecord.reload newrecord end + + def initialize(params) + @params = params + if @params[:server] + @instance = McInstance.create(@params[:server][:instance]) + if @params[:server][:instance] + @inputs = Inputs.create(@params[:server][:instance][:inputs]) + end + end +# @monitor = MonitoringMetrics.create(@params[: + end + + def launch + if @instance.state == "stopped" + t = URI.parse(self.href) + connection.post(t.path + '/launch') + else + connection.logger("WARNING: was in #{self.state} so skipping launch call") + end + end + + def terminate + if @instance.href + t = URI.parse(self.href) + connection.post(t.path + '/terminate') + else + connection.logger("WARNING: was in #{self.state} so skipping launch call") + end + end + + def start #start_ebs + raise "You shouldn't be here." + end + + def stop #stop_ebs + raise "You shouldn't be here." + end + + def run_executable(executable, opts=nil) + connection.logger("Congratulations on making it this far into the Multicloud Monkey.") + raise "Congratulations on making it this far into the Multicloud Monkey." + end + + def transform_parameters(sym, parameters) + ret = nil + if parameters.is_a?(Array) and sym == :to_h + ret = {} + parameters.each { |hash| ret[hash['name']] = hash['value'] } + elsif parameters.is_a?(Hash) and sym == :to_a + ret = [] + parameters.each { |key,val| ret << {'name' => key, 'value' => val} } + end + ret + end + + def set_input(name, value) + @inputs.multi_update([{'name' => name, 'value' => value}]) + end + + def set_inputs(hash = {}) + @inputs.multi_update(transform_parameters(:to_a, hash)) + end + + def settings + serv_href = URI.parse(self.href) + @params.merge! connection.get(serv_href.path, 'view' => 'full') + @params[:server][:instance].merge! @instance.show + @params[:server][:instance][:inputs].merge! @inputs.show +# @monitoring update + @params + end + + def get_sketchy_data(params = {}) + connection.logger("Congratulations on making it this far into the Multicloud Monkey.") + raise "Congratulations on making it this far into the Multicloud Monkey." +# TODO: Inprogress +# base_href = self.href.split(/\/server/).first +# base_href = base_href.split(/\/deployment/).first if base_href.include?(/\/deployment/) +# @monitors ? @monitors = MonitoringMetric.new('href' => MonitoringMetric.href(find_all(@cloud_id + end + + def monitoring + get_sketchy_data ? true : false + end + + def relaunch + self.terminate + self.wait_for_state("stopped") + self.launch + end end diff --git a/lib/rest_connection/rightscale/monitoring_metric.rb b/lib/rest_connection/rightscale/monitoring_metric.rb new file mode 100644 index 0000000..36b8655 --- /dev/null +++ b/lib/rest_connection/rightscale/monitoring_metric.rb @@ -0,0 +1,36 @@ +# This file is part of RestConnection +# +# RestConnection is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# RestConnection is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with RestConnection. If not, see . + +# +# You must have Beta v1.5 API access to use these internal API calls. +# +class MonitoringMetric + include RightScale::Api::Gateway + extend RightScale::Api::GatewayExtend + + def self.href(cloud_id, instance_id) + "/clouds/#{cloud_id}/instances/#{instance_id}/#{self.resource_plural_name}" + end + +# def self.find_all(cloud_id, instance_id) +# a = Array.new +# connection.get(self.href).each +# end + + def show + mm_href = URI.parse(self.href) + @params.merge! connection.get(mm.path) + end +end diff --git a/lib/rest_connection/rightscale/rightscale_api_gateway.rb b/lib/rest_connection/rightscale/rightscale_api_gateway.rb index 5a4c529..9ee8ec5 100644 --- a/lib/rest_connection/rightscale/rightscale_api_gateway.rb +++ b/lib/rest_connection/rightscale/rightscale_api_gateway.rb @@ -1,12 +1,13 @@ module RightScale module Api module Gateway + include RightScale::Api::Base def connection @@gateway_connection ||= RestConnection::Connection.new settings = @@gateway_connection.settings settings[:common_headers]["X_API_VERSION"] = "1.5" settings[:api_href], account = settings[:api_url].split(/\/acct\//) if settings[:api_url].include?("acct") - settings[:extension] = "" + settings[:extension] = ".json" unless @@gateway_connection.cookie # login params = { "email" => settings[:user], "password" => settings[:pass], "account_href" => "/api/accounts/#{account}" } @@ -23,12 +24,13 @@ def connection end module GatewayExtend + include RightScale::Api::BaseExtend def connection @@gateway_connection ||= RestConnection::Connection.new settings = @@gateway_connection.settings settings[:common_headers]["X_API_VERSION"] = "1.5" settings[:api_href], account = settings[:api_url].split(/\/acct\//) if settings[:api_url].include?("acct") - settings[:extension] = "" + settings[:extension] = ".json" unless @@gateway_connection.cookie # login params = { "email" => settings[:user], "password" => settings[:pass], "account_href" => "/api/accounts/#{account}" } diff --git a/lib/rest_connection/rightscale/rightscale_api_resources.rb b/lib/rest_connection/rightscale/rightscale_api_resources.rb index e0e9ccc..baba634 100644 --- a/lib/rest_connection/rightscale/rightscale_api_resources.rb +++ b/lib/rest_connection/rightscale/rightscale_api_resources.rb @@ -35,6 +35,10 @@ require 'rest_connection/rightscale/ec2_ebs_snapshot' require 'rest_connection/rightscale/server_internal' require 'rest_connection/rightscale/mc_server' +require 'rest_connection/rightscale/server_interface' +require 'rest_connection/rightscale/mc_instance' +require 'rest_connection/rightscale/inputs' +require 'rest_connection/rightscale/monitoring_metric' require 'rest_connection/rightscale/ec2_ssh_key_internal' require 'rest_connection/rightscale/server_template_internal' require 'rest_connection/rightscale/right_script_internal' diff --git a/lib/rest_connection/rightscale/server.rb b/lib/rest_connection/rightscale/server.rb index 7bc0a1f..77838dc 100644 --- a/lib/rest_connection/rightscale/server.rb +++ b/lib/rest_connection/rightscale/server.rb @@ -24,8 +24,8 @@ def self.create(opts) create_options = Hash.new create_options[self.resource_singular_name.to_sym] = opts create_options["cloud_id"] = opts[:cloud_id] if opts[:cloud_id] - create_options[self.resource_singular_name.to_sum][:mci_href] = nil - create_options[self.resource_singular_name.to_sum][:inputs] = nil + create_options[self.resource_singular_name.to_sym][:mci_href] = nil + create_options[self.resource_singular_name.to_sym][:inputs] = nil location = connection.post(self.resource_plural_name,create_options) newrecord = self.new('href' => location) newrecord.reload diff --git a/lib/rest_connection/rightscale/server_interface.rb b/lib/rest_connection/rightscale/server_interface.rb new file mode 100644 index 0000000..fda2525 --- /dev/null +++ b/lib/rest_connection/rightscale/server_interface.rb @@ -0,0 +1,255 @@ +# This file is part of RestConnection +# +# RestConnection is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# RestConnection is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with RestConnection. If not, see . + +require 'rest_connection/ssh_hax' + +class ServerInterface + def initialize(cloud_id = 1, params = {}) + @multicloud = (cloud_id.to_i > 10 ? true : false) + @impl = (@multicloud ? McServer.new(params) : Server.new(params)) + end + + def create(opts) + location = connection.post(resource_plural_name, translate_create_opts(opts)) + @impl = (@multicloud ? McServer.new('href' => location) : Server.new('href' => location)) + reload + self + end + + def href + if @multicloud + return @impl.href + else + return + end + end + + def name + nickname + end + + def nickname + param = :nickname + param = :name if @multicloud + @impl.__send__(param) + end + + def method_missing(method_name, *args, &block) + @impl.__send__(method_name, *args, &block) + end + + def ruby_1_8_7_keep_if(hsh, &block) + temp_a = hsh.select &block + temp_h = {} + temp_a.each { |array| temp_h[array.first] = array.last } + hsh.replace(temp_h) + end + + def deep_duplicate(obj) + copy = {"Array" => lambda { |array| elem = deep_duplicate(elem) }, + "Hash" => lambda { |key,val| + key = deep_duplicate(key) + val = deep_duplicate(val) + }} + new_obj = obj.dup.each + return new_obj + end + + def translate_create_opts(old_opts) + opts = old_opts.dup + server = {} + server[:deployment_href] = opts[:deployment_href] + if @multicloud + server[:name] = (opts[:nickname] or opts[:name]) + server[:instance] = {} + server[:instance][:server_template_href] = opts[:server_template_href] + server[:instance][:cloud_href] = opts[:cloud_href] if opts[:cloud_href] + server[:instance][:cloud_href] = "https://my.rightscale.com/api/clouds/#{opts[:cloud_id]}" if opts[:cloud_id] + server[:instance][:multi_cloud_image_href] = (opts[:mci_href] or opts[:multi_cloud_image_href]) + server[:instance][:instance_type_href] = (map_ec2instance_type(opts[:instance_type]) or + opts[:instance_type_href]) + server[:instance][:inputs] = opts[:inputs] + server[:instance][:user_data] = (opts[:ec2_user_data] or opts[:user_data]) + server[:instance][:image_href] = (opts[:aki_image_href] or opts[:ari_image_href] or opts[:ec2_image_href]) + server[:instance][:security_groups_href] = (opts[:ec2_security_groups_href] or opts[:security_groups_href]) + server[:instance][:ssh_key_href] = (opts[:ec2_ssh_key_href] or opts[:ssh_key_href]) + server[:instance][:datacenter_href] = opts[:datacenter_href] + server[:instance][:kernel_image_href] = opts[:kernel_image_href] + server[:instance][:ramdisk_image_href] = opts[:ramdisk_image_href] + server[:description] = opts[:description] + ruby_1_8_7_keep_if(server) { |key,val| + if val.is_a?(Hash) + val.delete_if { |k,v| v.nil? or v == "" } + val.each { |k,v| v = translate_href(v) if k.to_s =~ /href/ } + ret = true + elsif val.nil? or val == "" + ret = false + else + val = translate_href(val) if key.to_s =~ /href/ + ret = true + end + ret + } + return {:server => server} + else #API 1.0 + server[:nickname] = (opts[:nickname] or opts[:name]) + server[:deployment_href] = opts[:deployment_href] + server[:server_template_href] = opts[:server_template_href] + server[:aki_image_href] = opts[:aki_image_href] + server[:ari_image_href] = opts[:ari_image_href] + server[:ec2_image_href] = opts[:ec2_image_href] + server[:ec2_user_data] = (opts[:ec2_user_data] or opts[:user_data]) + server[:instance_type] = (opts[:instance_type] or unmap_ec2_instance_href(opts[:instance_type_href])) + server[:ec2_security_groups_href] = (opts[:ec2_security_groups_href] or opts[:security_groups_href]) + server[:vpc_subnet_href] = opts[:vpc_subnet_href] + server[:ec2_availability_zone] = opts[:ec2_availability_zone] + server[:pricing] = opts[:pricing] + server[:max_spot_price] = opts[:max_spot_price] + begin + cloud_id = opts[:cloud_href].split(/\/clouds\//).last + rescue Exception => e + cloud_id = opts[:cloud_id] + end + ruby_1_8_7_keep_if(server) { |key,val| + if val.is_a?(Hash) + val.delete_if { |k,v| v.nil? or v == "" } + val.each { |k,v| v = translate_href(v) if k.to_s =~ /href/ } + ret = true + elsif val.nil? or val == "" + ret = false + else + val = translate_href(val) if key.to_s =~ /href/ + ret = true + end + ret + } + return {:server => server, :cloud_id => cloud_id} + end + end + + def translate_href(href) + if href.include?("acct") #API 1.0 + return href.gsub!(/\/acct\/[0-9]*/,'').gsub!(/ec2_/,'') if @multicloud +# my_base_href, @account = href.split(/\/acct\//) +# @account, *remaining = @account.split(/\//) +# if @multicloud +# return my_base_href + "/" + remaining.join("/").gsub(/ec2_/,'') +# else +# return href +# end +# else #API 1.5 + end + href + end + + # The RightScale api returns the server parameters as a hash with "name" and "value". + # This must be transformed into a hash in case we want to PUT this back to the API. + def transform_parameters(parameters) + new_params_hash = {} + parameters.each do |parameter_hash| + new_params_hash[parameter_hash["name"]] = parameter_hash["value"] + end + new_params_hash + end + + # Since RightScale hands back the parameters with a "name" and "value" tags we should + # transform them into the proper hash. This it the same for setting and getting. + def parameters + # if the parameters are an array of hashes, that means we need to transform. + if @params['parameters'].is_a?(Array) + @params['parameters'] = transform_parameters(@params['parameters']) + end + @params['parameters'] + end + + def start + launch + end + + def stop + terminate + end + + def launch + @impl.launch if @multicloud + @impl.start unless @multicloud + end + + def terminate + @impl.terminate if @multicloud + @impl.stop unless @multicloud + end + + def start_ebs + connection.logger("WARNING: Gateway Servers do not support start_ebs. Ignoring.") if @multicloud + @impl.start_ebs unless @multicloud + end + + def stop_ebs + connection.logger("WARNING: Gateway Servers do not support stop_ebs. Ignoring.") if @multicloud + @impl.stop_ebs unless @multicloud + end + + # This should be used with v4 images only. + def run_script(script,opts=nil) + connection.logger("WARNING: Gateway Servers do not support run_script. Ignoring.") if @multicloud + @impl.run_script(script,opts) unless @multicloud + end + + def attach_volume(params) + connection.logger("WARNING: Gateway Servers do not support attach_volume. Ignoring.") if @multicloud + @impl.attach_volume(params) unless @multicloud + end + + def get_sketchy_data(params = {}) + @impl.get_sketchy_data(translate_sketchy_params(params)) + end + + def translate_sketchy_params(params) + return params + #TODO +# ret = {} +# if @multicloud #API 1.5 +# ret['period'] = (ret['period'] or (ret['start'] +# else #API 1.0 +# ret['start'] = +# end +# monitor=server.get_sketchy_data({'start'=>-60,'end'=>-20,'plugin_name'=>"cpu-0",'plugin_type'=>"cpu-idle"}) + end + + # takes Bool argument to wait for state change (insurance that we can detect a reboot happened) + def reboot(wait_for_state = false) + connection.logger("WARNING: Gateway Servers do not support reboot. Ignoring.") if @multicloud + @impl.reboot(wait_for_state) unless @multicloud + end + + # Save the servers parameters to the current server (instead of the next server) + def save_current + connection.logger("WARNING: Gateway Servers do not currently support save_current. Ignoring.") if @multicloud + @impl.save_current unless @multicloud + end + + # Load server's settings from the current server (instead of the next server) + def settings_current + connection.logger("WARNING: Gateway Servers do not support settings_current. Ignoring.") if @multicloud + @impl.settings_current unless @multicloud + end + + # Reload the server's basic information from the current server. + def reload_current + connection.logger("WARNING: Gateway Servers do not support reload_current. Ignoring.") if @multicloud + @impl.reload_current unless @multicloud + end +end From 7f9a1cf4b2077cfb9c0553fd65d6bae7ccc754ad Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Mon, 7 Feb 2011 15:11:24 -0800 Subject: [PATCH 008/239] merged jd & my changes --- lib/rest_connection/rightscale/deployment.rb | 2 +- .../rightscale/mc_datacenter.rb | 49 +++++ lib/rest_connection/rightscale/mc_instance.rb | 3 +- .../rightscale/mc_security_group.rb | 49 +++++ lib/rest_connection/rightscale/mc_server.rb | 66 +++--- .../rightscale/rightscale_api_base.rb | 4 +- .../rightscale/rightscale_api_gateway.rb | 124 ++++++++++++ .../rightscale/rightscale_api_resources.rb | 2 + .../rightscale/server_interface.rb | 190 +++++++++--------- 9 files changed, 363 insertions(+), 126 deletions(-) create mode 100644 lib/rest_connection/rightscale/mc_datacenter.rb create mode 100644 lib/rest_connection/rightscale/mc_security_group.rb diff --git a/lib/rest_connection/rightscale/deployment.rb b/lib/rest_connection/rightscale/deployment.rb index b6043c9..4453084 100644 --- a/lib/rest_connection/rightscale/deployment.rb +++ b/lib/rest_connection/rightscale/deployment.rb @@ -47,7 +47,7 @@ def set_input(name, value) end def servers_no_reload - @params['servers'].map { |s| ServerInterface.new(s) } + @params['servers'].map { |s| ServerInterface.new(cloud_id, s) } end def servers diff --git a/lib/rest_connection/rightscale/mc_datacenter.rb b/lib/rest_connection/rightscale/mc_datacenter.rb new file mode 100644 index 0000000..da8dff8 --- /dev/null +++ b/lib/rest_connection/rightscale/mc_datacenter.rb @@ -0,0 +1,49 @@ +# This file is part of RestConnection +# +# RestConnection is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# RestConnection is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with RestConnection. If not, see . + +# +# You must have Beta v1.5 API access to use these internal API calls. +# +class McDatacenter + include RightScale::Api::Gateway + extend RightScale::Api::GatewayExtend + + def resource_plural_name + "datacenters" + end + + def resource_singular_name + "datacenter" + end + + def self.resource_plural_name + "datacenters" + end + + def self.resource_singular_name + "datacenter" + end + + def show + inst_href = URI.parse(self.href) + @params.merge! connection.get(inst_href.path, 'view' => "full") + end + + def save + inst_href = URI.parse(self.href) + connection.put(inst_href.path, @params) + end + +end diff --git a/lib/rest_connection/rightscale/mc_instance.rb b/lib/rest_connection/rightscale/mc_instance.rb index 3f43c83..9c55cd8 100644 --- a/lib/rest_connection/rightscale/mc_instance.rb +++ b/lib/rest_connection/rightscale/mc_instance.rb @@ -41,7 +41,7 @@ def show @params.merge! connection.get(inst_href.path, 'view' => "full") end - def save + def update inst_href = URI.parse(self.href) connection.put(inst_href.path, @params) end @@ -57,6 +57,7 @@ def terminate end def run_executable(executable, opts=nil) + raise "Congratulations on making it this far into the Multicloud Monkey." # script_options = { :server => {} } # if executable.is_a?(Executable) or executable.is_a?(RightScript) # executable = Task.convert_from(executable) diff --git a/lib/rest_connection/rightscale/mc_security_group.rb b/lib/rest_connection/rightscale/mc_security_group.rb new file mode 100644 index 0000000..cd5c7d3 --- /dev/null +++ b/lib/rest_connection/rightscale/mc_security_group.rb @@ -0,0 +1,49 @@ +# This file is part of RestConnection +# +# RestConnection is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# RestConnection is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with RestConnection. If not, see . + +# +# You must have Beta v1.5 API access to use these internal API calls. +# +class McSecurityGroup + include RightScale::Api::Gateway + extend RightScale::Api::GatewayExtend + + def resource_plural_name + "security_groups" + end + + def resource_singular_name + "security_group" + end + + def self.resource_plural_name + "security_groups" + end + + def self.resource_singular_name + "security_group" + end + + def show + inst_href = URI.parse(self.href) + @params.merge! connection.get(inst_href.path, 'view' => "full") + end + + def save + inst_href = URI.parse(self.href) + connection.put(inst_href.path, @params) + end + +end diff --git a/lib/rest_connection/rightscale/mc_server.rb b/lib/rest_connection/rightscale/mc_server.rb index 64d23d9..e8960c5 100644 --- a/lib/rest_connection/rightscale/mc_server.rb +++ b/lib/rest_connection/rightscale/mc_server.rb @@ -36,26 +36,8 @@ def self.resource_singular_name "server" end - def self.create(opts) - location = connection.post(self.resource_plural_name, {self.resource_singular_name.to_sym => opts}) - newrecord = self.new('href' => location) - newrecord.reload - newrecord - end - - def initialize(params) - @params = params - if @params[:server] - @instance = McInstance.create(@params[:server][:instance]) - if @params[:server][:instance] - @inputs = Inputs.create(@params[:server][:instance][:inputs]) - end - end -# @monitor = MonitoringMetrics.create(@params[: - end - def launch - if @instance.state == "stopped" + if actions.include?("launch") t = URI.parse(self.href) connection.post(t.path + '/launch') else @@ -64,11 +46,11 @@ def launch end def terminate - if @instance.href + if actions.include?("terminate") t = URI.parse(self.href) connection.post(t.path + '/terminate') else - connection.logger("WARNING: was in #{self.state} so skipping launch call") + connection.logger("WARNING: was in #{self.state} so skipping terminate call") end end @@ -81,11 +63,10 @@ def stop #stop_ebs end def run_executable(executable, opts=nil) - connection.logger("Congratulations on making it this far into the Multicloud Monkey.") - raise "Congratulations on making it this far into the Multicloud Monkey." + @instance.run_executable(executable, opts) end - def transform_parameters(sym, parameters) + def transform_inputs(sym, parameters) ret = nil if parameters.is_a?(Array) and sym == :to_h ret = {} @@ -102,20 +83,19 @@ def set_input(name, value) end def set_inputs(hash = {}) - @inputs.multi_update(transform_parameters(:to_a, hash)) + @inputs.multi_update(transform_inputs(:to_a, hash)) end - def settings + def settings #show serv_href = URI.parse(self.href) - @params.merge! connection.get(serv_href.path, 'view' => 'full') - @params[:server][:instance].merge! @instance.show - @params[:server][:instance][:inputs].merge! @inputs.show + @params.merge! connection.get(serv_href.path, 'view' => 'instance_detail') + @current_instance = McInstance.new(self.current_instance) if self.current_instance + @next_instance = McInstance.new(self.next_instance) # @monitoring update @params end def get_sketchy_data(params = {}) - connection.logger("Congratulations on making it this far into the Multicloud Monkey.") raise "Congratulations on making it this far into the Multicloud Monkey." # TODO: Inprogress # base_href = self.href.split(/\/server/).first @@ -129,7 +109,31 @@ def monitoring def relaunch self.terminate - self.wait_for_state("stopped") + self.wait_for_state("inactive") self.launch end + + # Attributes taken for granted in API 1.0 + def server_type + "gateway" + end + + def server_template_href + if @current_instance + return @current_instance.server_template + end + return @next_instance.server_template + end + + def tags + [] + end + + def deployment_href + hash_of_links["deployment"] + end + + def current_instance_href + hash_of_links["current_instance"] + end end diff --git a/lib/rest_connection/rightscale/rightscale_api_base.rb b/lib/rest_connection/rightscale/rightscale_api_base.rb index cfbe6da..f930013 100644 --- a/lib/rest_connection/rightscale/rightscale_api_base.rb +++ b/lib/rest_connection/rightscale/rightscale_api_base.rb @@ -189,9 +189,9 @@ def [](name) try_these = [name, name.to_s.gsub(/_/,'-'), name.to_sym] try_these.each do |t| if @params[t] - return @params[name] + return @params[t] else - return nil + @params[t] end end end diff --git a/lib/rest_connection/rightscale/rightscale_api_gateway.rb b/lib/rest_connection/rightscale/rightscale_api_gateway.rb index 9ee8ec5..8a65eee 100644 --- a/lib/rest_connection/rightscale/rightscale_api_gateway.rb +++ b/lib/rest_connection/rightscale/rightscale_api_gateway.rb @@ -21,6 +21,106 @@ def connection end @@gateway_connection end + + def hash_of_links + ret = {} + unless @params['links']# and not (@params['nickname'] or @params['name']) + @params = Kernel.const_get(self.class.to_s).find_by(:name) { |n| n == self.nickname }.first.params + connection.logger("#{@params.inspect}") + end + @params['links'].each { |link| ret[link['rel']] = link['href'] } if @params['links'] + ret + end + + def href + return @params['href'] if @params['href'] + ret = nil + unless @params['links'] + raise "Cannot find attribute 'nickname' or 'name' in #{self.inspect}. Aborting." unless self.nickname + @params = Kernel.const_get(self.class.to_s).find_by(:name) { |n| n == self.nickname }.first.params + connection.logger("#{@params.inspect}") + end + @params['links'].each { |link| ret = link['href'] if link['rel'] == 'self' } + ret + end + + def actions + ret = [] + unless @params['actions'] + raise "Cannot find attribute 'nickname' or 'name' in #{self.inspect}. Aborting." unless self.nickname + @params = Kernel.const_get(self.class.to_s).find_by(:name) { |n| n == self.nickname }.first.params + connection.logger("#{@params.inspect}") + end + @params['actions'].each { |action| ret << action['rel'] } + ret + end + + def save + update + end + + def reload + settings + end + + def method_missing(method_name, *args) + puts "#{method_name}" + mn = method_name.to_s + assignment = mn.gsub!(/=/,"") + mn_dash = mn.gsub(/_/,"-") + if self[mn] + if assignment + self[mn] = args[0] + self[mn_dash] = args[0] + end + return self[mn] + elsif self[mn_dash] + if assignment + self[mn_dash] = args[0] + self[mn] = args[0] + end + return self[mn_dash] + elsif self[mn.to_sym] + return self[mn.to_sym] + elsif assignment + self[mn] = args[0] + self[mn_dash] = args[0] + return self[mn] + else + return nil + #raise "called unknown method #{method_name} with #{args.inspect}" + end + end + + def [](name) + try_these = [name, name.to_s.gsub(/_/,'-'), name.to_sym] + if try_these.include?(:nickname) + try_these += ["name", :name] + end + try_these.each do |t| + if @params[t] + return @params[t] + elsif hash_of_links[t] + return hash_of_links[t] + end + end + return nil + end + + def []=(name,val) + try_these = [name, name.to_s.gsub(/_/,'-'), name.to_sym] + if try_these.include?(:nickname) + try_these += ["name", :name] + end + try_these.each do |t| + if @params[t] + @params[t] = val + elsif hash_of_links[t] + hash_of_links[t] = val + end + end + val + end end module GatewayExtend @@ -44,6 +144,30 @@ def connection end @@gateway_connection end + + def find_by(attrib, cloud_id=nil, &block) + attrib = :name if attrib == :nickname + self.find_all.select do |s| + yield(s[attrib.to_s]) + end + end + + def find_all(cloud_id=nil) + a = Array.new + url = self.resource_plural_name + url = "clouds/#{cloud_id}/#{self.resource_plural_name}" if cloud_id + connection.get(url).each do |object| + a << self.new(object) + end + return a + end + + def create(opts) + location = connection.post(self.resource_plural_name, self.resource_singular_name.to_sym => opts) + newrecord = self.new('links' => [ {'rel' => 'self', 'href' => location } ]) + newrecord.reload + newrecord + end end end end diff --git a/lib/rest_connection/rightscale/rightscale_api_resources.rb b/lib/rest_connection/rightscale/rightscale_api_resources.rb index baba634..5ec08df 100644 --- a/lib/rest_connection/rightscale/rightscale_api_resources.rb +++ b/lib/rest_connection/rightscale/rightscale_api_resources.rb @@ -45,3 +45,5 @@ require 'rest_connection/rightscale/multi_cloud_image_internal' require 'rest_connection/rightscale/multi_cloud_image_cloud_setting_internal' require 'rest_connection/rightscale/ec2_server_array' +require 'rest_connection/rightscale/mc_security_group' +require 'rest_connection/rightscale/mc_datacenter' diff --git a/lib/rest_connection/rightscale/server_interface.rb b/lib/rest_connection/rightscale/server_interface.rb index fda2525..1497f82 100644 --- a/lib/rest_connection/rightscale/server_interface.rb +++ b/lib/rest_connection/rightscale/server_interface.rb @@ -24,124 +24,126 @@ def initialize(cloud_id = 1, params = {}) def create(opts) location = connection.post(resource_plural_name, translate_create_opts(opts)) @impl = (@multicloud ? McServer.new('href' => location) : Server.new('href' => location)) - reload + settings self end - def href - if @multicloud - return @impl.href - else - return - end - end - def name nickname end def nickname - param = :nickname - param = :name if @multicloud - @impl.__send__(param) + @impl.nickname unless @multicloud + @impl.name if @multicloud end def method_missing(method_name, *args, &block) @impl.__send__(method_name, *args, &block) end - def ruby_1_8_7_keep_if(hsh, &block) - temp_a = hsh.select &block - temp_h = {} - temp_a.each { |array| temp_h[array.first] = array.last } - hsh.replace(temp_h) - end - - def deep_duplicate(obj) - copy = {"Array" => lambda { |array| elem = deep_duplicate(elem) }, - "Hash" => lambda { |key,val| - key = deep_duplicate(key) - val = deep_duplicate(val) - }} - new_obj = obj.dup.each - return new_obj + def clean_and_translate_server_params(it) + it.each do |k, v| + clean_and_translate_server_params(v) if v.is_a?(Hash) + end + it.reject! { |k, v| v == nil or v == "" } + it.each { |k, v| it[k] = translate_href(v) if k.to_s =~ /href/ } + it end def translate_create_opts(old_opts) + fields = [{"1.0" => [:server_template_href], "1.5" => [:server_template_href]}, + {"1.0" => [:cloud_id], "fn" => :map_cloud_id, "1.5" => [:cloud_href]}, + {"1.0" => [:aki_image_href, :ari_image_href, :ec2_image_href], "1.5" => [:image_href]}, + {"1.0" => [:ec2_user_data], "1.5" => [:user_data]}, + {"1.0" => [:instance_type], "fn" => :map_instance, "1.5" => [:instance_type_href]}, + {"1.0" => [:ec2_security_groups_href], "1.5" => [:security_group_hrefs]}, + {"1.0" => [:ec2_ssh_key_href], "1.5" => [:ssh_key_href]}, + {"1.0" => [:vpc_subnet_href]}, + {"1.0" => [:ec2_availability_zone]}, + {"1.0" => [:pricing]}, + {"1.0" => [:max_spot_price]}, + { "1.5" => [:inputs]}, + { "1.5" => [:mci_href, :multi_cloud_image_href]}, + { "1.5" => [:datacenter_href]}, + { "1.5" => [:kernel_image_href]}, + { "1.5" => [:ramdisk_image_href]}] + opts = old_opts.dup - server = {} - server[:deployment_href] = opts[:deployment_href] if @multicloud - server[:name] = (opts[:nickname] or opts[:name]) - server[:instance] = {} - server[:instance][:server_template_href] = opts[:server_template_href] - server[:instance][:cloud_href] = opts[:cloud_href] if opts[:cloud_href] - server[:instance][:cloud_href] = "https://my.rightscale.com/api/clouds/#{opts[:cloud_id]}" if opts[:cloud_id] - server[:instance][:multi_cloud_image_href] = (opts[:mci_href] or opts[:multi_cloud_image_href]) - server[:instance][:instance_type_href] = (map_ec2instance_type(opts[:instance_type]) or - opts[:instance_type_href]) - server[:instance][:inputs] = opts[:inputs] - server[:instance][:user_data] = (opts[:ec2_user_data] or opts[:user_data]) - server[:instance][:image_href] = (opts[:aki_image_href] or opts[:ari_image_href] or opts[:ec2_image_href]) - server[:instance][:security_groups_href] = (opts[:ec2_security_groups_href] or opts[:security_groups_href]) - server[:instance][:ssh_key_href] = (opts[:ec2_ssh_key_href] or opts[:ssh_key_href]) - server[:instance][:datacenter_href] = opts[:datacenter_href] - server[:instance][:kernel_image_href] = opts[:kernel_image_href] - server[:instance][:ramdisk_image_href] = opts[:ramdisk_image_href] - server[:description] = opts[:description] - ruby_1_8_7_keep_if(server) { |key,val| - if val.is_a?(Hash) - val.delete_if { |k,v| v.nil? or v == "" } - val.each { |k,v| v = translate_href(v) if k.to_s =~ /href/ } - ret = true - elsif val.nil? or val == "" - ret = false - else - val = translate_href(val) if key.to_s =~ /href/ - ret = true - end - ret - } - return {:server => server} - else #API 1.0 - server[:nickname] = (opts[:nickname] or opts[:name]) + to = "1.5" + ret = {:server => {:instance => {}}} + ret[:server][:name] = (opts[:name] ? opts[:name] : opts[:nickname]) + ret[:server][:description] = opts[:description] + ret[:server][:deployment_href] = opts[:deployment_href] + server = ret[:server][:instance] + else + to = "1.0" + server = {:nickname => (opts[:nickname] ? opts[:nickname] : opts[:name])} server[:deployment_href] = opts[:deployment_href] - server[:server_template_href] = opts[:server_template_href] - server[:aki_image_href] = opts[:aki_image_href] - server[:ari_image_href] = opts[:ari_image_href] - server[:ec2_image_href] = opts[:ec2_image_href] - server[:ec2_user_data] = (opts[:ec2_user_data] or opts[:user_data]) - server[:instance_type] = (opts[:instance_type] or unmap_ec2_instance_href(opts[:instance_type_href])) - server[:ec2_security_groups_href] = (opts[:ec2_security_groups_href] or opts[:security_groups_href]) - server[:vpc_subnet_href] = opts[:vpc_subnet_href] - server[:ec2_availability_zone] = opts[:ec2_availability_zone] - server[:pricing] = opts[:pricing] - server[:max_spot_price] = opts[:max_spot_price] + ret = {:server => server} begin - cloud_id = opts[:cloud_href].split(/\/clouds\//).last + ret[:cloud_id] = opts[:cloud_href].split(/\/clouds\//).last rescue Exception => e - cloud_id = opts[:cloud_id] + ret[:cloud_id] = opts[:cloud_id] end - ruby_1_8_7_keep_if(server) { |key,val| - if val.is_a?(Hash) - val.delete_if { |k,v| v.nil? or v == "" } - val.each { |k,v| v = translate_href(v) if k.to_s =~ /href/ } - ret = true - elsif val.nil? or val == "" - ret = false + end + + fields.each { |hsh| + next unless hsh[to] + hsh[to].each { |field| + vals = opts.select {|k,v| [[hsh["1.0"]] + [hsh["1.5"]]].flatten.include?(k.to_sym) } + vals.flatten! + vals.compact! + if hsh["fn"] + server[field] = __send__(hsh["fn"], to, opts[vals.first]) unless vals.first.nil? else - val = translate_href(val) if key.to_s =~ /href/ - ret = true +# case field +# when :inputs +# server[field] = opts[field] +# when :security_group_hrefs +# server[field] = opts[field] +# else + server[field] = opts[vals.first] unless vals.first.nil? +# end end - ret } - return {:server => server, :cloud_id => cloud_id} + } + clean_and_translate_server_params(ret) + return ret + end + + def map_cloud_id(to, val) + if val.is_a?(String) + begin + val = val.split(/\//).last + rescue Exception => e + end end + if to == "1.5" + return "https://my.rightscale.com/api/clouds/#{val}" + elsif to == "1.0" + return "#{val}" + end + end + + def map_instance(to, val) + nil end - def translate_href(href) - if href.include?("acct") #API 1.0 - return href.gsub!(/\/acct\/[0-9]*/,'').gsub!(/ec2_/,'') if @multicloud + def translate_href(old_href) + if old_href.is_a?(Array) + new_array = [] + old_href.each { |url| new_array << translate_href(url) } + return new_array + else + href = old_href.dup + if @multicloud + href.gsub!(/ec2_/,'') + href.gsub!(/\/acct\/[0-9]*/,'') + end + return href + end +# if href.include?("acct") # my_base_href, @account = href.split(/\/acct\//) # @account, *remaining = @account.split(/\//) # if @multicloud @@ -150,8 +152,7 @@ def translate_href(href) # return href # end # else #API 1.5 - end - href +# end end # The RightScale api returns the server parameters as a hash with "name" and "value". @@ -229,6 +230,13 @@ def translate_sketchy_params(params) # monitor=server.get_sketchy_data({'start'=>-60,'end'=>-20,'plugin_name'=>"cpu-0",'plugin_type'=>"cpu-idle"}) end + def wait_for_state(st,timeout=1200) + if @multicloud and st == "stopped" + st = "inactive" + end + @impl.wait_for_state(st,timeout) + end + # takes Bool argument to wait for state change (insurance that we can detect a reboot happened) def reboot(wait_for_state = false) connection.logger("WARNING: Gateway Servers do not support reboot. Ignoring.") if @multicloud From e02a61c00334d0683fd110c191784e9a90f0b12d Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Wed, 9 Feb 2011 13:27:21 -0800 Subject: [PATCH 009/239] More multicloud resources, lots of fixes --- lib/rest_connection/rightscale/mc_instance.rb | 50 +++++++++++++++++-- lib/rest_connection/rightscale/mc_server.rb | 12 +++-- .../rightscale/monitoring_metric.rb | 14 ------ .../rightscale/rightscale_api_base.rb | 2 +- .../rightscale/rightscale_api_gateway.rb | 6 +-- .../rightscale/rightscale_api_resources.rb | 1 + .../rightscale/server_interface.rb | 2 + lib/rest_connection/rightscale/task.rb | 38 ++++++++++++++ spec/mcserver_spec.rb | 17 +++++++ 9 files changed, 113 insertions(+), 29 deletions(-) create mode 100644 lib/rest_connection/rightscale/task.rb create mode 100644 spec/mcserver_spec.rb diff --git a/lib/rest_connection/rightscale/mc_instance.rb b/lib/rest_connection/rightscale/mc_instance.rb index 9c55cd8..47374fe 100644 --- a/lib/rest_connection/rightscale/mc_instance.rb +++ b/lib/rest_connection/rightscale/mc_instance.rb @@ -19,6 +19,7 @@ class McInstance include RightScale::Api::Gateway extend RightScale::Api::GatewayExtend + attr_accessor :monitoring_metrics def resource_plural_name "instances" @@ -56,11 +57,50 @@ def terminate connection.post(inst_href.path + '/terminate') end + def transform_inputs(sym, parameters) + ret = nil + if parameters.is_a?(Array) and sym == :to_h + ret = {} + parameters.each { |hash| ret[hash['name']] = hash['value'] } + elsif parameters.is_a?(Hash) and sym == :to_a + ret = [] + parameters.each { |key,val| ret << {'name' => key, 'value' => val} } + end + ret + end + + def translate_href(old_href) + href = old_href.dup + href.gsub!(/ec2_/,'') + href.gsub!(/\/acct\/[0-9]*/,'') + return href + end + def run_executable(executable, opts=nil) - raise "Congratulations on making it this far into the Multicloud Monkey." -# script_options = { :server => {} } -# if executable.is_a?(Executable) or executable.is_a?(RightScript) -# executable = Task.convert_from(executable) -# inst_href = URI.parse(self.href) + run_options = Hash.new + if executable.is_a?(Executable) + if executable.recipe? + run_options[:recipe_name] = executable.recipe + else + run_options[:right_script_href] = translate_href(executable.right_script.href) + end + elsif executable.is_a?(RightScript) + run_options[:right_script_href] = translate_href(executable.href) + else + raise "Invalid class passed to run_executable, needs Executable or RightScript, was:#{executable.class}" + end + + inst_href = URI.parse(self.href) + run_options[:inputs] = transform_inputs(:to_a, opts) unless opts.nil? + location = connection.post(inst_href.path + '/run_executable', run_options) + Task.new('href' => location) + end + + def fetch_monitoring_metrics + @monitoring_metrics = [] + connection.get(URI.parse(self.href).path + '/monitoring_metrics').each { |mm| + @monitoring_metrics << MonitoringMetric.new(mm) + } + @monitoring_metrics end end diff --git a/lib/rest_connection/rightscale/mc_server.rb b/lib/rest_connection/rightscale/mc_server.rb index e8960c5..bfbc2aa 100644 --- a/lib/rest_connection/rightscale/mc_server.rb +++ b/lib/rest_connection/rightscale/mc_server.rb @@ -49,6 +49,7 @@ def terminate if actions.include?("terminate") t = URI.parse(self.href) connection.post(t.path + '/terminate') + @current_instance = nil else connection.logger("WARNING: was in #{self.state} so skipping terminate call") end @@ -63,7 +64,8 @@ def stop #stop_ebs end def run_executable(executable, opts=nil) - @instance.run_executable(executable, opts) + raise "Instance isn't running; Can't run executable" unless @current_instance + @current_instance.run_executable(executable, opts) end def transform_inputs(sym, parameters) @@ -89,9 +91,11 @@ def set_inputs(hash = {}) def settings #show serv_href = URI.parse(self.href) @params.merge! connection.get(serv_href.path, 'view' => 'instance_detail') - @current_instance = McInstance.new(self.current_instance) if self.current_instance + if self.current_instance + @current_instance = McInstance.new(self.current_instance) + @current_instance.fetch_monitoring_metrics + end @next_instance = McInstance.new(self.next_instance) -# @monitoring update @params end @@ -104,7 +108,7 @@ def get_sketchy_data(params = {}) end def monitoring - get_sketchy_data ? true : false + @current_instance.fetch_monitoring_metrics end def relaunch diff --git a/lib/rest_connection/rightscale/monitoring_metric.rb b/lib/rest_connection/rightscale/monitoring_metric.rb index 36b8655..ec4a015 100644 --- a/lib/rest_connection/rightscale/monitoring_metric.rb +++ b/lib/rest_connection/rightscale/monitoring_metric.rb @@ -19,18 +19,4 @@ class MonitoringMetric include RightScale::Api::Gateway extend RightScale::Api::GatewayExtend - - def self.href(cloud_id, instance_id) - "/clouds/#{cloud_id}/instances/#{instance_id}/#{self.resource_plural_name}" - end - -# def self.find_all(cloud_id, instance_id) -# a = Array.new -# connection.get(self.href).each -# end - - def show - mm_href = URI.parse(self.href) - @params.merge! connection.get(mm.path) - end end diff --git a/lib/rest_connection/rightscale/rightscale_api_base.rb b/lib/rest_connection/rightscale/rightscale_api_base.rb index f930013..4cc2555 100644 --- a/lib/rest_connection/rightscale/rightscale_api_base.rb +++ b/lib/rest_connection/rightscale/rightscale_api_base.rb @@ -191,7 +191,7 @@ def [](name) if @params[t] return @params[t] else - @params[t] + return @params[t] end end end diff --git a/lib/rest_connection/rightscale/rightscale_api_gateway.rb b/lib/rest_connection/rightscale/rightscale_api_gateway.rb index 8a65eee..884fa11 100644 --- a/lib/rest_connection/rightscale/rightscale_api_gateway.rb +++ b/lib/rest_connection/rightscale/rightscale_api_gateway.rb @@ -59,12 +59,8 @@ def save update end - def reload - settings - end - def method_missing(method_name, *args) - puts "#{method_name}" + puts "DEBUG: method_missing in #{self.class.to_s}: #{method_name}" if ENV['REST_CONNECT_DEBUG'] mn = method_name.to_s assignment = mn.gsub!(/=/,"") mn_dash = mn.gsub(/_/,"-") diff --git a/lib/rest_connection/rightscale/rightscale_api_resources.rb b/lib/rest_connection/rightscale/rightscale_api_resources.rb index 5ec08df..2ac0221 100644 --- a/lib/rest_connection/rightscale/rightscale_api_resources.rb +++ b/lib/rest_connection/rightscale/rightscale_api_resources.rb @@ -28,6 +28,7 @@ require 'rest_connection/rightscale/ec2_ssh_key' require 'rest_connection/rightscale/multi_cloud_image' require 'rest_connection/rightscale/tag' +require 'rest_connection/rightscale/task' require 'rest_connection/rightscale/rs_internal' require 'rest_connection/rightscale/audit_entry' require 'rest_connection/rightscale/alert_spec' diff --git a/lib/rest_connection/rightscale/server_interface.rb b/lib/rest_connection/rightscale/server_interface.rb index 1497f82..c5ef4f2 100644 --- a/lib/rest_connection/rightscale/server_interface.rb +++ b/lib/rest_connection/rightscale/server_interface.rb @@ -16,6 +16,8 @@ require 'rest_connection/ssh_hax' class ServerInterface + attr_reader :multicloud + def initialize(cloud_id = 1, params = {}) @multicloud = (cloud_id.to_i > 10 ? true : false) @impl = (@multicloud ? McServer.new(params) : Server.new(params)) diff --git a/lib/rest_connection/rightscale/task.rb b/lib/rest_connection/rightscale/task.rb new file mode 100644 index 0000000..3bd8d83 --- /dev/null +++ b/lib/rest_connection/rightscale/task.rb @@ -0,0 +1,38 @@ +# This file is part of RestConnection +# +# RestConnection is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# RestConnection is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with RestConnection. If not, see . + +# +# You must have Beta v1.5 API access to use these internal API calls. +# +class Task + include RightScale::Api::Gateway + extend RightScale::Api::GatewayExtend + + def wait_for_state(state, timeout=900) + while(timeout > 0) + reload + connection.logger("state is #{self.summary}, waiting for #{state}") + raise "FATAL error, #{self.summary}\n" if self.summary.include?('failed') + sleep 30 + timeout -= 30 + return true if self.summary.include?(state) + end + raise "FATAL: Timeout waiting for Executable to complete. State was #{self.state}" if timeout <= 0 + end + + def wait_for_completed(legacy=nil) + wait_for_state("completed") + end +end diff --git a/spec/mcserver_spec.rb b/spec/mcserver_spec.rb new file mode 100644 index 0000000..3aa1c10 --- /dev/null +++ b/spec/mcserver_spec.rb @@ -0,0 +1,17 @@ +require 'rubygems' +require 'rest_connection' +require 'spec' +require 'ruby-debug' + +describe McServer, "server api object exercise" do + before(:all) do + @mcserver_v5 = McServer.find("/api/clouds/850/instances/AA5AOKVUOJPC9") # a v5 server + end + + it "should run a recipe on a v5 server" do + this_template = ServerTemplate.find(@mcserver_v5.server_template_href) + run_first = this_template.executables.first + audit = @mcserver_v5.run_executable(run_first) + audit.wait_for_completed + end +end From 891837192fbee28342449d397e8dd532e3a3dd60 Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Wed, 9 Feb 2011 14:32:29 -0800 Subject: [PATCH 010/239] dns_name temp fix --- lib/rest_connection/rightscale/mc_server.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/rest_connection/rightscale/mc_server.rb b/lib/rest_connection/rightscale/mc_server.rb index bfbc2aa..de569c6 100644 --- a/lib/rest_connection/rightscale/mc_server.rb +++ b/lib/rest_connection/rightscale/mc_server.rb @@ -140,4 +140,16 @@ def deployment_href def current_instance_href hash_of_links["current_instance"] end + + def wait_for_operational_with_dns + timeout = 600 + wait_for_state("operational") + end + + def dns_name + if @current_instance + return @current_instance.public_ip_addresses.first + end + nil + end end From 10640d526b04e251325b0809383e4c68e6645f42 Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Wed, 9 Feb 2011 22:35:29 +0000 Subject: [PATCH 011/239] [McSshKey] new --- lib/rest_connection/rightscale/mc_ssh_key.rb | 39 +++++++++++++++++++ .../rightscale/rightscale_api_resources.rb | 1 + 2 files changed, 40 insertions(+) create mode 100644 lib/rest_connection/rightscale/mc_ssh_key.rb diff --git a/lib/rest_connection/rightscale/mc_ssh_key.rb b/lib/rest_connection/rightscale/mc_ssh_key.rb new file mode 100644 index 0000000..83e55a2 --- /dev/null +++ b/lib/rest_connection/rightscale/mc_ssh_key.rb @@ -0,0 +1,39 @@ +# This file is part of RestConnection +# +# RestConnection is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# RestConnection is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with RestConnection. If not, see . + +# +# You must have Beta v1.5 API access to use these internal API calls. +# +class McSshKey + include RightScale::Api::Gateway + extend RightScale::Api::GatewayExtend + + def resource_plural_name + "ssh_keys" + end + + def resource_singular_name + "ssh_key" + end + + def self.resource_plural_name + "ssh_keys" + end + + def self.resource_singular_name + "ssh_key" + end + +end diff --git a/lib/rest_connection/rightscale/rightscale_api_resources.rb b/lib/rest_connection/rightscale/rightscale_api_resources.rb index 2ac0221..3bb8f30 100644 --- a/lib/rest_connection/rightscale/rightscale_api_resources.rb +++ b/lib/rest_connection/rightscale/rightscale_api_resources.rb @@ -48,3 +48,4 @@ require 'rest_connection/rightscale/ec2_server_array' require 'rest_connection/rightscale/mc_security_group' require 'rest_connection/rightscale/mc_datacenter' +require 'rest_connection/rightscale/mc_ssh_key' From d7ae2669a8edd68f8ae6146b32ac656cc21dac54 Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Wed, 9 Feb 2011 14:36:49 -0800 Subject: [PATCH 012/239] status code 202 add --- lib/rest_connection.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rest_connection.rb b/lib/rest_connection.rb index 072c8a1..80b80a6 100644 --- a/lib/rest_connection.rb +++ b/lib/rest_connection.rb @@ -149,7 +149,7 @@ def delete(href, additional_parameters = {}) # # decoding and post processing goes here. This is where you may need some customization if you want to handle the response differently (or not at all!). Luckily it's easy to modify based on this handler. def handle_response(res) - if res.code.to_i == 201 + if res.code.to_i == 201 && res.code.to_i == 202 return res['Location'] elsif [200,203,204,302].detect { |d| d == res.code.to_i } if res.body From 7d0b24687acfc7e3ed62778e2d65f7d65e6a8bad Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Wed, 9 Feb 2011 14:47:27 -0800 Subject: [PATCH 013/239] only fetch monitoring metrics if state is operational --- lib/rest_connection/rightscale/mc_instance.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/rest_connection/rightscale/mc_instance.rb b/lib/rest_connection/rightscale/mc_instance.rb index 47374fe..34d6e0a 100644 --- a/lib/rest_connection/rightscale/mc_instance.rb +++ b/lib/rest_connection/rightscale/mc_instance.rb @@ -98,6 +98,7 @@ def run_executable(executable, opts=nil) def fetch_monitoring_metrics @monitoring_metrics = [] + return @monitoring_metrics if self.state == "operational" connection.get(URI.parse(self.href).path + '/monitoring_metrics').each { |mm| @monitoring_metrics << MonitoringMetric.new(mm) } From 46c4f91afc2a9a8cb14e3073ba2949381218c8ae Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Wed, 9 Feb 2011 15:43:01 -0800 Subject: [PATCH 014/239] typo --- lib/rest_connection.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rest_connection.rb b/lib/rest_connection.rb index 80b80a6..d4f8eea 100644 --- a/lib/rest_connection.rb +++ b/lib/rest_connection.rb @@ -149,7 +149,7 @@ def delete(href, additional_parameters = {}) # # decoding and post processing goes here. This is where you may need some customization if you want to handle the response differently (or not at all!). Luckily it's easy to modify based on this handler. def handle_response(res) - if res.code.to_i == 201 && res.code.to_i == 202 + if res.code.to_i == 201 or res.code.to_i == 202 return res['Location'] elsif [200,203,204,302].detect { |d| d == res.code.to_i } if res.body From 66bd5219c24c7b4f7d64b11ca553c51e17697914 Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Wed, 9 Feb 2011 15:47:52 -0800 Subject: [PATCH 015/239] typo --- lib/rest_connection/rightscale/mc_instance.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rest_connection/rightscale/mc_instance.rb b/lib/rest_connection/rightscale/mc_instance.rb index 34d6e0a..9610528 100644 --- a/lib/rest_connection/rightscale/mc_instance.rb +++ b/lib/rest_connection/rightscale/mc_instance.rb @@ -98,7 +98,7 @@ def run_executable(executable, opts=nil) def fetch_monitoring_metrics @monitoring_metrics = [] - return @monitoring_metrics if self.state == "operational" + return @monitoring_metrics if self.state != "operational" connection.get(URI.parse(self.href).path + '/monitoring_metrics').each { |mm| @monitoring_metrics << MonitoringMetric.new(mm) } From 4b8e1a3378422fe4c59b301a2694fa7d0db10130 Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Wed, 9 Feb 2011 15:58:32 -0800 Subject: [PATCH 016/239] monitoring check fix --- lib/rest_connection/rightscale/mc_server.rb | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/rest_connection/rightscale/mc_server.rb b/lib/rest_connection/rightscale/mc_server.rb index de569c6..ebc4252 100644 --- a/lib/rest_connection/rightscale/mc_server.rb +++ b/lib/rest_connection/rightscale/mc_server.rb @@ -91,10 +91,7 @@ def set_inputs(hash = {}) def settings #show serv_href = URI.parse(self.href) @params.merge! connection.get(serv_href.path, 'view' => 'instance_detail') - if self.current_instance - @current_instance = McInstance.new(self.current_instance) - @current_instance.fetch_monitoring_metrics - end + @current_instance = McInstance.new(self.current_instance) if self.current_instance @next_instance = McInstance.new(self.next_instance) @params end From 3c69ced443b70d153b9e3704da7bd0a0b5151f18 Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Wed, 9 Feb 2011 16:56:50 -0800 Subject: [PATCH 017/239] quickfix --- lib/rest_connection/rightscale/mc_server.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/rest_connection/rightscale/mc_server.rb b/lib/rest_connection/rightscale/mc_server.rb index ebc4252..b836b8e 100644 --- a/lib/rest_connection/rightscale/mc_server.rb +++ b/lib/rest_connection/rightscale/mc_server.rb @@ -123,6 +123,7 @@ def server_template_href if @current_instance return @current_instance.server_template end + self.settings unless @next_instance return @next_instance.server_template end From 6cbab6d260ec2f7eb470d94d70571bd3bc2f8f67 Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Wed, 9 Feb 2011 17:27:40 -0800 Subject: [PATCH 018/239] debugging statement cleanup --- lib/rest_connection/rightscale/rightscale_api_gateway.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/rest_connection/rightscale/rightscale_api_gateway.rb b/lib/rest_connection/rightscale/rightscale_api_gateway.rb index 884fa11..32d1cab 100644 --- a/lib/rest_connection/rightscale/rightscale_api_gateway.rb +++ b/lib/rest_connection/rightscale/rightscale_api_gateway.rb @@ -26,7 +26,7 @@ def hash_of_links ret = {} unless @params['links']# and not (@params['nickname'] or @params['name']) @params = Kernel.const_get(self.class.to_s).find_by(:name) { |n| n == self.nickname }.first.params - connection.logger("#{@params.inspect}") + connection.logger("in hash_of_links: @params = #{@params.inspect}") if ENV['REST_CONNECT_DEBUG'] end @params['links'].each { |link| ret[link['rel']] = link['href'] } if @params['links'] ret @@ -38,7 +38,7 @@ def href unless @params['links'] raise "Cannot find attribute 'nickname' or 'name' in #{self.inspect}. Aborting." unless self.nickname @params = Kernel.const_get(self.class.to_s).find_by(:name) { |n| n == self.nickname }.first.params - connection.logger("#{@params.inspect}") + connection.logger("in href: @params = #{@params.inspect}") if ENV['REST_CONNECT_DEBUG'] end @params['links'].each { |link| ret = link['href'] if link['rel'] == 'self' } ret @@ -49,7 +49,7 @@ def actions unless @params['actions'] raise "Cannot find attribute 'nickname' or 'name' in #{self.inspect}. Aborting." unless self.nickname @params = Kernel.const_get(self.class.to_s).find_by(:name) { |n| n == self.nickname }.first.params - connection.logger("#{@params.inspect}") + connection.logger("in actions: @params = #{@params.inspect}") if ENV['REST_CONNECT_DEBUG'] end @params['actions'].each { |action| ret << action['rel'] } ret From 70646984ecef20313cd064ab3518dcd62e38e470 Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Fri, 11 Feb 2011 14:52:34 -0800 Subject: [PATCH 019/239] quickfix --- lib/rest_connection/rightscale/server_interface.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/rest_connection/rightscale/server_interface.rb b/lib/rest_connection/rightscale/server_interface.rb index c5ef4f2..bf53929 100644 --- a/lib/rest_connection/rightscale/server_interface.rb +++ b/lib/rest_connection/rightscale/server_interface.rb @@ -35,8 +35,8 @@ def name end def nickname - @impl.nickname unless @multicloud - @impl.name if @multicloud + return @impl.nickname unless @multicloud + return @impl.name if @multicloud end def method_missing(method_name, *args, &block) From 5041fe9e73ae7c80cd0213a3e67d5b69956138e1 Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Tue, 15 Feb 2011 15:59:32 -0800 Subject: [PATCH 020/239] [Ec2ElasticIp][API 1.0] adding api for ec2_elastic_ip Conflicts: lib/rest_connection/rightscale/rightscale_api_resources.rb rest_connection.gemspec --- .../rightscale/ec2_elastic_ip.rb | 20 +++++++++++++++++++ .../rightscale/rightscale_api_resources.rb | 1 + rest_connection.gemspec | 4 ++-- 3 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 lib/rest_connection/rightscale/ec2_elastic_ip.rb diff --git a/lib/rest_connection/rightscale/ec2_elastic_ip.rb b/lib/rest_connection/rightscale/ec2_elastic_ip.rb new file mode 100644 index 0000000..157f030 --- /dev/null +++ b/lib/rest_connection/rightscale/ec2_elastic_ip.rb @@ -0,0 +1,20 @@ +# This file is part of RestConnection +# +# RestConnection is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# RestConnection is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with RestConnection. If not, see . +# + +class Ec2ElasticIp + include RightScale::Api::Base + extend RightScale::Api::BaseExtend +end diff --git a/lib/rest_connection/rightscale/rightscale_api_resources.rb b/lib/rest_connection/rightscale/rightscale_api_resources.rb index 3bb8f30..ce851fe 100644 --- a/lib/rest_connection/rightscale/rightscale_api_resources.rb +++ b/lib/rest_connection/rightscale/rightscale_api_resources.rb @@ -49,3 +49,4 @@ require 'rest_connection/rightscale/mc_security_group' require 'rest_connection/rightscale/mc_datacenter' require 'rest_connection/rightscale/mc_ssh_key' +require 'rest_connection/rightscale/ec2_elastic_ip' diff --git a/rest_connection.gemspec b/rest_connection.gemspec index e69ed20..f42f94b 100644 --- a/rest_connection.gemspec +++ b/rest_connection.gemspec @@ -5,11 +5,11 @@ Gem::Specification.new do |s| s.name = %q{rest_connection} - s.version = "0.0.14" + s.version = "0.0.15" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["Jeremy Deininger"] - s.date = %q{2010-12-01} + s.date = %q{2010-12-13} s.description = %q{provides rest_connection} s.email = %q{jeremy@rubyonlinux.org} s.extra_rdoc_files = [ From a59c63ddf96f9d820dae913721ee05e36095668e Mon Sep 17 00:00:00 2001 From: Jeremy Deininger Date: Wed, 9 Feb 2011 09:14:54 -0800 Subject: [PATCH 021/239] [Credential][API 1.0] adding credential api support --- lib/rest_connection/rightscale/credential.rb | 20 +++++++++++++++++++ .../rightscale/rightscale_api_resources.rb | 1 + 2 files changed, 21 insertions(+) create mode 100644 lib/rest_connection/rightscale/credential.rb diff --git a/lib/rest_connection/rightscale/credential.rb b/lib/rest_connection/rightscale/credential.rb new file mode 100644 index 0000000..5ea8f05 --- /dev/null +++ b/lib/rest_connection/rightscale/credential.rb @@ -0,0 +1,20 @@ +# This file is part of RestConnection +# +# RestConnection is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# RestConnection is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with RestConnection. If not, see . +# + +class Credential + include RightScale::Api::Base + extend RightScale::Api::BaseExtend +end diff --git a/lib/rest_connection/rightscale/rightscale_api_resources.rb b/lib/rest_connection/rightscale/rightscale_api_resources.rb index ce851fe..698d915 100644 --- a/lib/rest_connection/rightscale/rightscale_api_resources.rb +++ b/lib/rest_connection/rightscale/rightscale_api_resources.rb @@ -50,3 +50,4 @@ require 'rest_connection/rightscale/mc_datacenter' require 'rest_connection/rightscale/mc_ssh_key' require 'rest_connection/rightscale/ec2_elastic_ip' +require 'rest_connection/rightscale/credential' From 365a59b4e219a1e3828c7b3c43a0a615e9db30cc Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Tue, 15 Feb 2011 16:02:04 -0800 Subject: [PATCH 022/239] [ActiveSupport] pinning verison of active_support to 2.3.10 for maximum compatibility with older rubies such as 1.8.5 and 1.8.6 Conflicts: rest_connection.gemspec --- Rakefile | 2 +- rest_connection.gemspec | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Rakefile b/Rakefile index f5bfa00..3abb5a3 100644 --- a/Rakefile +++ b/Rakefile @@ -7,7 +7,7 @@ Jeweler::Tasks.new do |gemspec| gemspec.email = "jeremy@rubyonlinux.org" gemspec.homepage = "http://github.com/jeremyd/rest_connection" gemspec.authors = ["Jeremy Deininger"] - gemspec.add_dependency('activesupport') + gemspec.add_dependency('activesupport', "=2.3.10") gemspec.add_dependency('net-ssh') gemspec.add_dependency('json') end diff --git a/rest_connection.gemspec b/rest_connection.gemspec index f42f94b..5371c94 100644 --- a/rest_connection.gemspec +++ b/rest_connection.gemspec @@ -9,7 +9,7 @@ Gem::Specification.new do |s| s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["Jeremy Deininger"] - s.date = %q{2010-12-13} + s.date = %q{2011-02-15} s.description = %q{provides rest_connection} s.email = %q{jeremy@rubyonlinux.org} s.extra_rdoc_files = [ @@ -104,16 +104,16 @@ Gem::Specification.new do |s| s.specification_version = 3 if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then - s.add_runtime_dependency(%q, [">= 0"]) + s.add_runtime_dependency(%q, ["= 2.3.10"]) s.add_runtime_dependency(%q, [">= 0"]) s.add_runtime_dependency(%q, [">= 0"]) else - s.add_dependency(%q, [">= 0"]) + s.add_dependency(%q, ["= 2.3.10"]) s.add_dependency(%q, [">= 0"]) s.add_dependency(%q, [">= 0"]) end else - s.add_dependency(%q, [">= 0"]) + s.add_dependency(%q, ["= 2.3.10"]) s.add_dependency(%q, [">= 0"]) s.add_dependency(%q, [">= 0"]) end From 7d6788202288902b48ed27eb7effddd98690aee7 Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Fri, 25 Feb 2011 23:45:22 +0000 Subject: [PATCH 023/239] [ServerInterface] fixing up aki vs. ari conversion --- lib/rest_connection/rightscale/server_interface.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/rest_connection/rightscale/server_interface.rb b/lib/rest_connection/rightscale/server_interface.rb index bf53929..b29858e 100644 --- a/lib/rest_connection/rightscale/server_interface.rb +++ b/lib/rest_connection/rightscale/server_interface.rb @@ -55,7 +55,7 @@ def clean_and_translate_server_params(it) def translate_create_opts(old_opts) fields = [{"1.0" => [:server_template_href], "1.5" => [:server_template_href]}, {"1.0" => [:cloud_id], "fn" => :map_cloud_id, "1.5" => [:cloud_href]}, - {"1.0" => [:aki_image_href, :ari_image_href, :ec2_image_href], "1.5" => [:image_href]}, + {"1.0" => [:ec2_image_href], "1.5" => [:image_href]}, {"1.0" => [:ec2_user_data], "1.5" => [:user_data]}, {"1.0" => [:instance_type], "fn" => :map_instance, "1.5" => [:instance_type_href]}, {"1.0" => [:ec2_security_groups_href], "1.5" => [:security_group_hrefs]}, @@ -67,8 +67,8 @@ def translate_create_opts(old_opts) { "1.5" => [:inputs]}, { "1.5" => [:mci_href, :multi_cloud_image_href]}, { "1.5" => [:datacenter_href]}, - { "1.5" => [:kernel_image_href]}, - { "1.5" => [:ramdisk_image_href]}] + {"1.0" => [:aki_image_href], "1.5" => [:kernel_image_href]}, + {"1.0" => [:ari_image_href], "1.5" => [:ramdisk_image_href]}] opts = old_opts.dup if @multicloud @@ -129,7 +129,9 @@ def map_cloud_id(to, val) end def map_instance(to, val) - nil + if to == "1.0" + return val + end end def translate_href(old_href) From ced8d30cf0dce5d7fd989088cc3e151fdfee5cc7 Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Tue, 1 Mar 2011 16:51:39 -0800 Subject: [PATCH 024/239] updated for sshkey generation --- lib/rest_connection/rightscale/ec2_ssh_key.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/rest_connection/rightscale/ec2_ssh_key.rb b/lib/rest_connection/rightscale/ec2_ssh_key.rb index fb55f0b..143bfea 100644 --- a/lib/rest_connection/rightscale/ec2_ssh_key.rb +++ b/lib/rest_connection/rightscale/ec2_ssh_key.rb @@ -16,4 +16,13 @@ class Ec2SshKey include RightScale::Api::Base extend RightScale::Api::BaseExtend + + def self.create(opts) + create_opts = { self.resource_singular_name.to_sym => opts } + create_opts['cloud_id'] = opts['cloud_id'] if opts['cloud_id'] + location = connection.post(self.resource_plural_name, create_opts) + newrecord = self.new('href' => location) + newrecord.reload + newrecord + end end From 9f33fb495c294ae34e38bffbf936fa19b498bc94 Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Mon, 7 Mar 2011 15:27:18 -0800 Subject: [PATCH 025/239] couple fixes, catches unexpected termination --- lib/rest_connection/rightscale/server.rb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/rest_connection/rightscale/server.rb b/lib/rest_connection/rightscale/server.rb index 77838dc..aff42c5 100644 --- a/lib/rest_connection/rightscale/server.rb +++ b/lib/rest_connection/rightscale/server.rb @@ -70,15 +70,18 @@ def wait_for_state(st,timeout=1200) sleep 30 timeout -= 30 connection.logger("waiting for server #{nickname} to go #{st}, state is #{state}") + if state =~ /terminated/ + raise "FATAL error, this server terminated when waiting for #{st}: #{nickname}, see audit #{self.audit_link}" + end reload end raise "FATAL, this server #{self.audit_link} timed out waiting for the state to be #{st}" if timeout <= 0 end # waits until the server is operational and dns_name is available - def wait_for_operational_with_dns + def wait_for_operational_with_dns(state_wait_timeout=1200) timeout = 600 - wait_for_state("operational") + wait_for_state("operational", state_wait_timeout) while(timeout > 0) self.settings break if self['dns-name'] && !self['dns-name'].empty? && self['private-dns-name'] && !self['private-dns-name'].empty? @@ -93,7 +96,7 @@ def wait_for_operational_with_dns def audit_link # proof of concept for now server_id = self.href.split(/\//).last - audit_href = "https://my.rightscale.com/servers/#{server_id}#audit_entries" + audit_href = "https://my.rightscale.com/servers/#{server_id}#auditentries" "#{audit_href}" end From 771dc478aaefdd345a6fa54700a29d33de241185 Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Tue, 8 Mar 2011 11:20:46 -0800 Subject: [PATCH 026/239] better at catching unexpected terminates --- lib/rest_connection/rightscale/server.rb | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/rest_connection/rightscale/server.rb b/lib/rest_connection/rightscale/server.rb index aff42c5..dc8240d 100644 --- a/lib/rest_connection/rightscale/server.rb +++ b/lib/rest_connection/rightscale/server.rb @@ -64,15 +64,19 @@ def save def wait_for_state(st,timeout=1200) reload connection.logger("#{nickname} is #{self.state}") + catch_early_terminated = 4 while(timeout > 0) return true if state =~ /#{st}/ raise "FATAL error, this server is stranded and needs to be #{st}: #{nickname}, see audit: #{self.audit_link}" if state.include?('stranded') && !st.include?('stranded') - sleep 30 - timeout -= 30 connection.logger("waiting for server #{nickname} to go #{st}, state is #{state}") - if state =~ /terminated/ - raise "FATAL error, this server terminated when waiting for #{st}: #{nickname}, see audit #{self.audit_link}" + if state =~ /terminated|stopped/ and st !~ /terminated|stopped/ + if catch_early_terminated <= 0 + raise "FATAL error, this server terminated when waiting for #{st}: #{nickname}" + end + catch_early_terminated -= 1 end + sleep 30 + timeout -= 30 reload end raise "FATAL, this server #{self.audit_link} timed out waiting for the state to be #{st}" if timeout <= 0 From b7e83d5e31c4e72ea422715aa32777861b68ce18 Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Fri, 18 Mar 2011 13:05:01 -0700 Subject: [PATCH 027/239] mc bugfix and faster wait_for_state refresh --- lib/rest_connection/rightscale/mc_server.rb | 4 ++-- lib/rest_connection/rightscale/server.rb | 12 +++++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/rest_connection/rightscale/mc_server.rb b/lib/rest_connection/rightscale/mc_server.rb index b836b8e..60bf746 100644 --- a/lib/rest_connection/rightscale/mc_server.rb +++ b/lib/rest_connection/rightscale/mc_server.rb @@ -139,9 +139,9 @@ def current_instance_href hash_of_links["current_instance"] end - def wait_for_operational_with_dns + def wait_for_operational_with_dns(state_wait_timeout=1200) timeout = 600 - wait_for_state("operational") + wait_for_state("operational", state_wait_timeout) end def dns_name diff --git a/lib/rest_connection/rightscale/server.rb b/lib/rest_connection/rightscale/server.rb index dc8240d..b30754e 100644 --- a/lib/rest_connection/rightscale/server.rb +++ b/lib/rest_connection/rightscale/server.rb @@ -64,7 +64,8 @@ def save def wait_for_state(st,timeout=1200) reload connection.logger("#{nickname} is #{self.state}") - catch_early_terminated = 4 + step = 15 + catch_early_terminated = 120 / step while(timeout > 0) return true if state =~ /#{st}/ raise "FATAL error, this server is stranded and needs to be #{st}: #{nickname}, see audit: #{self.audit_link}" if state.include?('stranded') && !st.include?('stranded') @@ -75,8 +76,8 @@ def wait_for_state(st,timeout=1200) end catch_early_terminated -= 1 end - sleep 30 - timeout -= 30 + sleep step + timeout -= step reload end raise "FATAL, this server #{self.audit_link} timed out waiting for the state to be #{st}" if timeout <= 0 @@ -86,12 +87,13 @@ def wait_for_state(st,timeout=1200) def wait_for_operational_with_dns(state_wait_timeout=1200) timeout = 600 wait_for_state("operational", state_wait_timeout) + step = 15 while(timeout > 0) self.settings break if self['dns-name'] && !self['dns-name'].empty? && self['private-dns-name'] && !self['private-dns-name'].empty? connection.logger "waiting for dns-name for #{self.nickname}" - sleep 30 - timeout -= 30 + sleep step + timeout -= step end connection.logger "got DNS: #{self['dns-name']}" raise "FATAL, this server #{self.audit_link} timed out waiting for DNS" if timeout <= 0 From f64bcd3edf85595b7c0f4453ea41333087a66bb3 Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Fri, 18 Mar 2011 16:38:27 -0700 Subject: [PATCH 028/239] wait_for_operational_with_dns fix --- lib/rest_connection/rightscale/mc_server.rb | 10 ++++++++++ lib/rest_connection/rightscale/server_interface.rb | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/rest_connection/rightscale/mc_server.rb b/lib/rest_connection/rightscale/mc_server.rb index 60bf746..e2784f3 100644 --- a/lib/rest_connection/rightscale/mc_server.rb +++ b/lib/rest_connection/rightscale/mc_server.rb @@ -142,6 +142,16 @@ def current_instance_href def wait_for_operational_with_dns(state_wait_timeout=1200) timeout = 600 wait_for_state("operational", state_wait_timeout) + step = 15 + while(timeout > 0) + self.settings + break if self.dns_name + connection.logger "waiting for a public IP for #{self.nickname}" + sleep step + timeout -= step + end + connection.logger "got IP: #{self.dns_name}" + raise "FATAL, this server #{self.audit_link} timed out waiting for DNS" if timeout <= 0 end def dns_name diff --git a/lib/rest_connection/rightscale/server_interface.rb b/lib/rest_connection/rightscale/server_interface.rb index b29858e..8e4c79d 100644 --- a/lib/rest_connection/rightscale/server_interface.rb +++ b/lib/rest_connection/rightscale/server_interface.rb @@ -55,7 +55,7 @@ def clean_and_translate_server_params(it) def translate_create_opts(old_opts) fields = [{"1.0" => [:server_template_href], "1.5" => [:server_template_href]}, {"1.0" => [:cloud_id], "fn" => :map_cloud_id, "1.5" => [:cloud_href]}, - {"1.0" => [:ec2_image_href], "1.5" => [:image_href]}, + {"1.0" => [:ec2_image_href], "1.5" => [:image_href]}, {"1.0" => [:ec2_user_data], "1.5" => [:user_data]}, {"1.0" => [:instance_type], "fn" => :map_instance, "1.5" => [:instance_type_href]}, {"1.0" => [:ec2_security_groups_href], "1.5" => [:security_group_hrefs]}, From 0be3c6b842e0f01b5db5f249bbd9ca87e32cb554 Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Fri, 25 Mar 2011 14:55:21 -0700 Subject: [PATCH 029/239] cloud_id fixes for robustness --- lib/rest_connection/rightscale/deployment.rb | 9 ++++++++- lib/rest_connection/rightscale/mc_server.rb | 6 ++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/rest_connection/rightscale/deployment.rb b/lib/rest_connection/rightscale/deployment.rb index 4453084..2ebfada 100644 --- a/lib/rest_connection/rightscale/deployment.rb +++ b/lib/rest_connection/rightscale/deployment.rb @@ -25,7 +25,14 @@ def reload end def cloud_id - @cloud_id = self.nickname.match(/cloud_[0-9]+/)[0].match(/[0-9]+/)[0].to_i unless @cloud_id + unless @cloud_id + if self.nickname =~ /cloud_[0-9]+/ + @cloud_id = self.nickname.match(/cloud_[0-9]+/)[0].match(/[0-9]+/)[0].to_i + else + @cloud_id = servers.first.cloud_id + end + @cloud_id = nil if self.nickname =~ /cloud_multicloud/ + end @cloud_id end diff --git a/lib/rest_connection/rightscale/mc_server.rb b/lib/rest_connection/rightscale/mc_server.rb index e2784f3..8e64f5d 100644 --- a/lib/rest_connection/rightscale/mc_server.rb +++ b/lib/rest_connection/rightscale/mc_server.rb @@ -139,6 +139,12 @@ def current_instance_href hash_of_links["current_instance"] end + def cloud_id + cloud_href = @current_instance.hash_of_links["cloud"] if @current_instance + cloud_href = @next_instance.hash_of_links["cloud"] unless cloud_href + return cloud_href.split("/").last.to_i + end + def wait_for_operational_with_dns(state_wait_timeout=1200) timeout = 600 wait_for_state("operational", state_wait_timeout) From 06b2912dff1d06b2a0b46c0e6360ba1097810024 Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Tue, 29 Mar 2011 14:14:30 -0700 Subject: [PATCH 030/239] Improved find_all modularity for gateway resources --- lib/rest_connection/rightscale/cloud.rb | 22 +++++++++++++ .../rightscale/instance_type.rb | 31 +++++++++++++++++++ .../rightscale/mc_datacenter.rb | 4 +++ lib/rest_connection/rightscale/mc_instance.rb | 4 +++ .../rightscale/mc_security_group.rb | 11 ++----- lib/rest_connection/rightscale/mc_server.rb | 4 +++ lib/rest_connection/rightscale/mc_ssh_key.rb | 4 +++ .../rightscale/monitoring_metric.rb | 4 +++ .../rightscale/rightscale_api_gateway.rb | 9 +++--- .../rightscale/rightscale_api_resources.rb | 2 ++ lib/rest_connection/rightscale/task.rb | 4 +++ 11 files changed, 85 insertions(+), 14 deletions(-) create mode 100644 lib/rest_connection/rightscale/cloud.rb create mode 100644 lib/rest_connection/rightscale/instance_type.rb diff --git a/lib/rest_connection/rightscale/cloud.rb b/lib/rest_connection/rightscale/cloud.rb new file mode 100644 index 0000000..320700b --- /dev/null +++ b/lib/rest_connection/rightscale/cloud.rb @@ -0,0 +1,22 @@ +# This file is part of RestConnection +# +# RestConnection is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# RestConnection is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with RestConnection. If not, see . + +# +# You must have Beta v1.5 API access to use these internal API calls. +# +class Cloud + include RightScale::Api::Gateway + extend RightScale::Api::GatewayExtend +end diff --git a/lib/rest_connection/rightscale/instance_type.rb b/lib/rest_connection/rightscale/instance_type.rb new file mode 100644 index 0000000..c817c7d --- /dev/null +++ b/lib/rest_connection/rightscale/instance_type.rb @@ -0,0 +1,31 @@ +# This file is part of RestConnection +# +# RestConnection is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# RestConnection is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with RestConnection. If not, see . + +# +# You must have Beta v1.5 API access to use these internal API calls. +# +class Cloud + include RightScale::Api::Gateway + extend RightScale::Api::GatewayExtend + + def self.parse_args(cloud_id) + "clouds/#{cloud_id}/" + end + + def show + inst_href = URI.parse(self.href) + @params.merge! connection.get(inst_href.path, 'view' => "default") + end +end diff --git a/lib/rest_connection/rightscale/mc_datacenter.rb b/lib/rest_connection/rightscale/mc_datacenter.rb index da8dff8..f2e1098 100644 --- a/lib/rest_connection/rightscale/mc_datacenter.rb +++ b/lib/rest_connection/rightscale/mc_datacenter.rb @@ -36,6 +36,10 @@ def self.resource_singular_name "datacenter" end + def self.parse_args(cloud_id) + "clouds/#{cloud_id}/" + end + def show inst_href = URI.parse(self.href) @params.merge! connection.get(inst_href.path, 'view' => "full") diff --git a/lib/rest_connection/rightscale/mc_instance.rb b/lib/rest_connection/rightscale/mc_instance.rb index 9610528..a5159f5 100644 --- a/lib/rest_connection/rightscale/mc_instance.rb +++ b/lib/rest_connection/rightscale/mc_instance.rb @@ -37,6 +37,10 @@ def self.resource_singular_name "instance" end + def self.parse_args(cloud_id) + "clouds/#{cloud_id}/" + end + def show inst_href = URI.parse(self.href) @params.merge! connection.get(inst_href.path, 'view' => "full") diff --git a/lib/rest_connection/rightscale/mc_security_group.rb b/lib/rest_connection/rightscale/mc_security_group.rb index cd5c7d3..9ef5b48 100644 --- a/lib/rest_connection/rightscale/mc_security_group.rb +++ b/lib/rest_connection/rightscale/mc_security_group.rb @@ -36,14 +36,7 @@ def self.resource_singular_name "security_group" end - def show - inst_href = URI.parse(self.href) - @params.merge! connection.get(inst_href.path, 'view' => "full") + def self.parse_args(cloud_id) + "clouds/#{cloud_id}/" end - - def save - inst_href = URI.parse(self.href) - connection.put(inst_href.path, @params) - end - end diff --git a/lib/rest_connection/rightscale/mc_server.rb b/lib/rest_connection/rightscale/mc_server.rb index 8e64f5d..a104a13 100644 --- a/lib/rest_connection/rightscale/mc_server.rb +++ b/lib/rest_connection/rightscale/mc_server.rb @@ -36,6 +36,10 @@ def self.resource_singular_name "server" end + def self.parse_args(deployment_id=nil) + deployment_id ? "deployments/#{deployment_id}/" : "" + end + def launch if actions.include?("launch") t = URI.parse(self.href) diff --git a/lib/rest_connection/rightscale/mc_ssh_key.rb b/lib/rest_connection/rightscale/mc_ssh_key.rb index 83e55a2..0b803ee 100644 --- a/lib/rest_connection/rightscale/mc_ssh_key.rb +++ b/lib/rest_connection/rightscale/mc_ssh_key.rb @@ -36,4 +36,8 @@ def self.resource_singular_name "ssh_key" end + def self.parse_args(cloud_id) + "clouds/#{cloud_id}/" + end + end diff --git a/lib/rest_connection/rightscale/monitoring_metric.rb b/lib/rest_connection/rightscale/monitoring_metric.rb index ec4a015..07791be 100644 --- a/lib/rest_connection/rightscale/monitoring_metric.rb +++ b/lib/rest_connection/rightscale/monitoring_metric.rb @@ -19,4 +19,8 @@ class MonitoringMetric include RightScale::Api::Gateway extend RightScale::Api::GatewayExtend + + def self.parse_args(cloud_id, instance_id) + "clouds/#{cloud_id}/instances/#{instance_id}/" + end end diff --git a/lib/rest_connection/rightscale/rightscale_api_gateway.rb b/lib/rest_connection/rightscale/rightscale_api_gateway.rb index 32d1cab..613b927 100644 --- a/lib/rest_connection/rightscale/rightscale_api_gateway.rb +++ b/lib/rest_connection/rightscale/rightscale_api_gateway.rb @@ -141,17 +141,16 @@ def connection @@gateway_connection end - def find_by(attrib, cloud_id=nil, &block) + def find_by(attrib, *args, &block) attrib = :name if attrib == :nickname - self.find_all.select do |s| + self.find_all(*args).select do |s| yield(s[attrib.to_s]) end end - def find_all(cloud_id=nil) + def find_all(*args) a = Array.new - url = self.resource_plural_name - url = "clouds/#{cloud_id}/#{self.resource_plural_name}" if cloud_id + url = "#{parse_args(*args)}#{self.resource_plural_name}" connection.get(url).each do |object| a << self.new(object) end diff --git a/lib/rest_connection/rightscale/rightscale_api_resources.rb b/lib/rest_connection/rightscale/rightscale_api_resources.rb index 698d915..66c851e 100644 --- a/lib/rest_connection/rightscale/rightscale_api_resources.rb +++ b/lib/rest_connection/rightscale/rightscale_api_resources.rb @@ -51,3 +51,5 @@ require 'rest_connection/rightscale/mc_ssh_key' require 'rest_connection/rightscale/ec2_elastic_ip' require 'rest_connection/rightscale/credential' +require 'rest_connection/rightscale/cloud' +require 'rest_connection/rightscale/instance_type' diff --git a/lib/rest_connection/rightscale/task.rb b/lib/rest_connection/rightscale/task.rb index 3bd8d83..e3e13e5 100644 --- a/lib/rest_connection/rightscale/task.rb +++ b/lib/rest_connection/rightscale/task.rb @@ -19,6 +19,10 @@ class Task include RightScale::Api::Gateway extend RightScale::Api::GatewayExtend + + def self.parse_args(cloud_id, instance_id) + "clouds/#{cloud_id}/instances/#{instance_id}/live/" + end def wait_for_state(state, timeout=900) while(timeout > 0) From e0edb794274d7ac8927b4bc730ae0dc9d01b5a76 Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Tue, 29 Mar 2011 17:33:20 -0700 Subject: [PATCH 031/239] bugfix --- lib/rest_connection/rightscale/deployment.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rest_connection/rightscale/deployment.rb b/lib/rest_connection/rightscale/deployment.rb index 2ebfada..f86a25a 100644 --- a/lib/rest_connection/rightscale/deployment.rb +++ b/lib/rest_connection/rightscale/deployment.rb @@ -29,7 +29,7 @@ def cloud_id if self.nickname =~ /cloud_[0-9]+/ @cloud_id = self.nickname.match(/cloud_[0-9]+/)[0].match(/[0-9]+/)[0].to_i else - @cloud_id = servers.first.cloud_id + @cloud_id = 1 end @cloud_id = nil if self.nickname =~ /cloud_multicloud/ end From 7bf0276ed096ca45982906068c2d5893bcb87b90 Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Mon, 4 Apr 2011 11:57:27 -0700 Subject: [PATCH 032/239] username/password prompting --- lib/rest_connection.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/rest_connection.rb b/lib/rest_connection.rb index 09ceeaf..1d294aa 100644 --- a/lib/rest_connection.rb +++ b/lib/rest_connection.rb @@ -20,6 +20,7 @@ require 'cgi' require 'rest_connection/rightscale/rightscale_api_resources' require 'logger' +require 'highline/import' module RestConnection class Connection @@ -50,6 +51,8 @@ def initialize(config_yaml = File.join(File.expand_path("~"), ".rest_connection" end @settings[:extension] = ".js" @settings[:api_href] = @settings[:api_url] unless @settings[:api_href] + @settings[:user] = ask("Username: ") unless @settings[:user] + @settings[:pass] = ask("Password: ") { |q| q.echo = false } unless @settings[:pass] end # Main HTTP connection loop. Common settings are set here, then we yield(BASE_URI, OPTIONAL_HEADERS) to other methods for each type of HTTP request: GET, PUT, POST, DELETE From 96b06ca0821bd80a7a4e89aa5cc23fbd0ea45846 Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Mon, 4 Apr 2011 13:05:00 -0700 Subject: [PATCH 033/239] bugfix --- lib/rest_connection.rb | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/rest_connection.rb b/lib/rest_connection.rb index 1d294aa..d4462ba 100644 --- a/lib/rest_connection.rb +++ b/lib/rest_connection.rb @@ -39,6 +39,8 @@ class Connection # def initialize(config_yaml = File.join(File.expand_path("~"), ".rest_connection", "rest_api_config.yaml")) @@logger = nil + @@user = nil + @@pass = nil etc_config = File.join("#{File::SEPARATOR}etc", "rest_connection", "rest_api_config.yaml") if File.exists?(config_yaml) @settings = YAML::load(IO.read(config_yaml)) @@ -51,8 +53,14 @@ def initialize(config_yaml = File.join(File.expand_path("~"), ".rest_connection" end @settings[:extension] = ".js" @settings[:api_href] = @settings[:api_url] unless @settings[:api_href] - @settings[:user] = ask("Username: ") unless @settings[:user] - @settings[:pass] = ask("Password: ") { |q| q.echo = false } unless @settings[:pass] + unless @settings[:user] + @@user = ask("Username:") unless @@user + @settings[:user] = @@user + end + unless @settings[:pass] + @@pass = ask("Password:") { |q| q.echo = false } unless @@pass + @settings[:pass] = @@pass + end end # Main HTTP connection loop. Common settings are set here, then we yield(BASE_URI, OPTIONAL_HEADERS) to other methods for each type of HTTP request: GET, PUT, POST, DELETE From 999888093bcda6f9dcbf9b659bfb50dbf0f37f96 Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Fri, 8 Apr 2011 16:23:11 -0700 Subject: [PATCH 034/239] wait_for_servers option for destroy --- lib/rest_connection/rightscale/deployment.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/rest_connection/rightscale/deployment.rb b/lib/rest_connection/rightscale/deployment.rb index f86a25a..807487a 100644 --- a/lib/rest_connection/rightscale/deployment.rb +++ b/lib/rest_connection/rightscale/deployment.rb @@ -69,7 +69,15 @@ def duplicate end def clone - deploy_href = URI.parse(@deploy.href) + deploy_href = URI.parse(self.href) Deployment.new(:href => connection.post(deploy_href.path + "/duplicate")) end + + def destroy(wait_for_servers = nil) + deploy_href = URI.parse(self.href) + if wait_for_servers + servers_no_reload.each { |s| s.wait_for_state("stopped") } + end + connection.delete(deploy_href.path) + end end From a16ecd497f76c3842ae2ef94a3733583b96ef6b9 Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Fri, 15 Apr 2011 13:56:43 -0700 Subject: [PATCH 035/239] added optional do_not_log_result arg for spot_check --- lib/rest_connection/ssh_hax.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/rest_connection/ssh_hax.rb b/lib/rest_connection/ssh_hax.rb index 5d5d675..c262f8c 100644 --- a/lib/rest_connection/ssh_hax.rb +++ b/lib/rest_connection/ssh_hax.rb @@ -144,7 +144,7 @@ def spot_check_command?(command, ssh_key=nil, host_dns=self.dns_name) # returns hash of exit_status and output from command - def spot_check_command(command, ssh_key=nil, host_dns=self.dns_name) + def spot_check_command(command, ssh_key=nil, host_dns=self.dns_name, do_not_log_result=false) raise "FATAL: spot_check_command called on a server with no dns_name. You need to run .settings on the server to populate this attribute." unless host_dns connection.logger "SSHing to #{host_dns} using key(s) #{ssh_key_config(ssh_key)}" status = nil @@ -177,7 +177,7 @@ def spot_check_command(command, ssh_key=nil, host_dns=self.dns_name) sleep 10 end end - connection.logger "SSH Run: #{command} on #{host_dns}. Retry was #{retry_count}. Exit status was #{status}. Output below ---\n#{output}\n---" + connection.logger "SSH Run: #{command} on #{host_dns}. Retry was #{retry_count}. Exit status was #{status}. Output below ---\n#{output}\n---" unless do_not_log_result return {:status => status, :output => output} end From ff13c6a6a11984d86b52a8d231e5eaedab42fa43 Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Tue, 19 Apr 2011 11:50:55 -0700 Subject: [PATCH 036/239] cloud list fix --- lib/rest_connection/rightscale/rightscale_api_gateway.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/rest_connection/rightscale/rightscale_api_gateway.rb b/lib/rest_connection/rightscale/rightscale_api_gateway.rb index 613b927..88e8c5a 100644 --- a/lib/rest_connection/rightscale/rightscale_api_gateway.rb +++ b/lib/rest_connection/rightscale/rightscale_api_gateway.rb @@ -157,6 +157,10 @@ def find_all(*args) return a end + def parse_args(*args) + nil + end + def create(opts) location = connection.post(self.resource_plural_name, self.resource_singular_name.to_sym => opts) newrecord = self.new('links' => [ {'rel' => 'self', 'href' => location } ]) From a8f133b838541d443eb3c431fca14d3bb3ff4912 Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Tue, 19 Apr 2011 13:20:16 -0700 Subject: [PATCH 037/239] bugfix --- lib/rest_connection/rightscale/cloud.rb | 4 ++++ lib/rest_connection/rightscale/rightscale_api_gateway.rb | 4 ---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/rest_connection/rightscale/cloud.rb b/lib/rest_connection/rightscale/cloud.rb index 320700b..f65884f 100644 --- a/lib/rest_connection/rightscale/cloud.rb +++ b/lib/rest_connection/rightscale/cloud.rb @@ -19,4 +19,8 @@ class Cloud include RightScale::Api::Gateway extend RightScale::Api::GatewayExtend + + def self.parse_args() + "" + end end diff --git a/lib/rest_connection/rightscale/rightscale_api_gateway.rb b/lib/rest_connection/rightscale/rightscale_api_gateway.rb index 88e8c5a..613b927 100644 --- a/lib/rest_connection/rightscale/rightscale_api_gateway.rb +++ b/lib/rest_connection/rightscale/rightscale_api_gateway.rb @@ -157,10 +157,6 @@ def find_all(*args) return a end - def parse_args(*args) - nil - end - def create(opts) location = connection.post(self.resource_plural_name, self.resource_singular_name.to_sym => opts) newrecord = self.new('links' => [ {'rel' => 'self', 'href' => location } ]) From 2a94cdaed40b4e33c639ca8059a5919e76eb9152 Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Tue, 19 Apr 2011 13:38:10 -0700 Subject: [PATCH 038/239] bugfixes --- lib/rest_connection/rightscale/cloud.rb | 4 ---- lib/rest_connection/rightscale/instance_type.rb | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/lib/rest_connection/rightscale/cloud.rb b/lib/rest_connection/rightscale/cloud.rb index f65884f..320700b 100644 --- a/lib/rest_connection/rightscale/cloud.rb +++ b/lib/rest_connection/rightscale/cloud.rb @@ -19,8 +19,4 @@ class Cloud include RightScale::Api::Gateway extend RightScale::Api::GatewayExtend - - def self.parse_args() - "" - end end diff --git a/lib/rest_connection/rightscale/instance_type.rb b/lib/rest_connection/rightscale/instance_type.rb index c817c7d..9d87161 100644 --- a/lib/rest_connection/rightscale/instance_type.rb +++ b/lib/rest_connection/rightscale/instance_type.rb @@ -16,7 +16,7 @@ # # You must have Beta v1.5 API access to use these internal API calls. # -class Cloud +class InstanceType include RightScale::Api::Gateway extend RightScale::Api::GatewayExtend From d757ebf52226709bd9f3e09666acd28c0b6d6719 Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Tue, 19 Apr 2011 13:41:10 -0700 Subject: [PATCH 039/239] bugfix --- lib/rest_connection/rightscale/rightscale_api_gateway.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/rest_connection/rightscale/rightscale_api_gateway.rb b/lib/rest_connection/rightscale/rightscale_api_gateway.rb index 613b927..79835e7 100644 --- a/lib/rest_connection/rightscale/rightscale_api_gateway.rb +++ b/lib/rest_connection/rightscale/rightscale_api_gateway.rb @@ -157,6 +157,10 @@ def find_all(*args) return a end + def parse_args() + nil + end + def create(opts) location = connection.post(self.resource_plural_name, self.resource_singular_name.to_sym => opts) newrecord = self.new('links' => [ {'rel' => 'self', 'href' => location } ]) From 775e40c55692d64b95aa91dac5bb59fffc484fda Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Wed, 20 Apr 2011 09:26:19 -0700 Subject: [PATCH 040/239] Updates for cloud_var autonomy --- lib/rest_connection/rightscale/cloud.rb | 4 ++++ lib/rest_connection/rightscale/mc_ssh_key.rb | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/lib/rest_connection/rightscale/cloud.rb b/lib/rest_connection/rightscale/cloud.rb index 320700b..ecbc008 100644 --- a/lib/rest_connection/rightscale/cloud.rb +++ b/lib/rest_connection/rightscale/cloud.rb @@ -19,4 +19,8 @@ class Cloud include RightScale::Api::Gateway extend RightScale::Api::GatewayExtend + + def cloud_id + self.href.split("/").last + end end diff --git a/lib/rest_connection/rightscale/mc_ssh_key.rb b/lib/rest_connection/rightscale/mc_ssh_key.rb index 0b803ee..cd4573d 100644 --- a/lib/rest_connection/rightscale/mc_ssh_key.rb +++ b/lib/rest_connection/rightscale/mc_ssh_key.rb @@ -40,4 +40,11 @@ def self.parse_args(cloud_id) "clouds/#{cloud_id}/" end + def self.create(opts) + create_opts = { self.resource_singular_name.to_sym => opts } + location = connection.post("clouds/#{opts['cloud_id']}/#{self.resource_plural_name}", create_opts) + newrecord = self.new('href' => location) + newrecord.reload + newrecord + end end From 682530cf99b66caaa1b381dbbacd913751c1c39e Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Thu, 21 Apr 2011 16:32:28 -0700 Subject: [PATCH 041/239] Add McImage resource for 1.5 --- lib/rest_connection/rightscale/mc_image.rb | 42 +++++++++++++++++++ .../rightscale/rightscale_api_resources.rb | 1 + 2 files changed, 43 insertions(+) create mode 100644 lib/rest_connection/rightscale/mc_image.rb diff --git a/lib/rest_connection/rightscale/mc_image.rb b/lib/rest_connection/rightscale/mc_image.rb new file mode 100644 index 0000000..8d8d370 --- /dev/null +++ b/lib/rest_connection/rightscale/mc_image.rb @@ -0,0 +1,42 @@ +# This file is part of RestConnection +# +# RestConnection is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# RestConnection is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with RestConnection. If not, see . + +# +# You must have Beta v1.5 API access to use these internal API calls. +# +class McImage + include RightScale::Api::Gateway + extend RightScale::Api::GatewayExtend + + def resource_plural_name + "images" + end + + def resource_singular_name + "image" + end + + def self.resource_plural_name + "images" + end + + def self.resource_singular_name + "image" + end + + def self.parse_args(cloud_id) + "clouds/#{cloud_id}/" + end +end diff --git a/lib/rest_connection/rightscale/rightscale_api_resources.rb b/lib/rest_connection/rightscale/rightscale_api_resources.rb index 66c851e..8346749 100644 --- a/lib/rest_connection/rightscale/rightscale_api_resources.rb +++ b/lib/rest_connection/rightscale/rightscale_api_resources.rb @@ -53,3 +53,4 @@ require 'rest_connection/rightscale/credential' require 'rest_connection/rightscale/cloud' require 'rest_connection/rightscale/instance_type' +require 'rest_connection/rightscale/mc_image' From 5612cbe25aa23f8ab0f02bbeae5e34d894b89eed Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Wed, 4 May 2011 11:48:02 -0700 Subject: [PATCH 042/239] Experimental functionality to update multicloud server parameters --- lib/rest_connection/rightscale/mc_server.rb | 25 ++++++++- .../rightscale/server_interface.rb | 52 +++++++++---------- 2 files changed, 47 insertions(+), 30 deletions(-) diff --git a/lib/rest_connection/rightscale/mc_server.rb b/lib/rest_connection/rightscale/mc_server.rb index a104a13..eb90ea1 100644 --- a/lib/rest_connection/rightscale/mc_server.rb +++ b/lib/rest_connection/rightscale/mc_server.rb @@ -19,6 +19,7 @@ class McServer < Server include RightScale::Api::Gateway extend RightScale::Api::GatewayExtend + attr_accessor :current_instance, :next_instance, :inputs def resource_plural_name "servers" @@ -95,8 +96,8 @@ def set_inputs(hash = {}) def settings #show serv_href = URI.parse(self.href) @params.merge! connection.get(serv_href.path, 'view' => 'instance_detail') - @current_instance = McInstance.new(self.current_instance) if self.current_instance - @next_instance = McInstance.new(self.next_instance) + @current_instance = McInstance.new(self['current_instance']) if self['current_instance'] + @next_instance = McInstance.new(self['next_instance']) @params end @@ -170,4 +171,24 @@ def dns_name end nil end + + def save + @next_instance.save + end + + def update + @next_instance.save + end + + def save_current + @current_instance.update if @current_instance + end + + def settings_current + settings # Gets all instance (including current) information + end + + def reload_current + settings # Gets all instance (including current) information + end end diff --git a/lib/rest_connection/rightscale/server_interface.rb b/lib/rest_connection/rightscale/server_interface.rb index 8e4c79d..71d132e 100644 --- a/lib/rest_connection/rightscale/server_interface.rb +++ b/lib/rest_connection/rightscale/server_interface.rb @@ -52,7 +52,7 @@ def clean_and_translate_server_params(it) it end - def translate_create_opts(old_opts) + def translate_create_opts(old_opts, instance_only=false) fields = [{"1.0" => [:server_template_href], "1.5" => [:server_template_href]}, {"1.0" => [:cloud_id], "fn" => :map_cloud_id, "1.5" => [:cloud_href]}, {"1.0" => [:ec2_image_href], "1.5" => [:image_href]}, @@ -73,11 +73,16 @@ def translate_create_opts(old_opts) opts = old_opts.dup if @multicloud to = "1.5" - ret = {:server => {:instance => {}}} - ret[:server][:name] = (opts[:name] ? opts[:name] : opts[:nickname]) - ret[:server][:description] = opts[:description] - ret[:server][:deployment_href] = opts[:deployment_href] - server = ret[:server][:instance] + if instance_only + ret = {:instance => {}} + server = ret[:instance] + else + ret = {:server => {:instance => {}}} + ret[:server][:name] = (opts[:name] ? opts[:name] : opts[:nickname]) + ret[:server][:description] = opts[:description] + ret[:server][:deployment_href] = opts[:deployment_href] + server = ret[:server][:instance] + end else to = "1.0" server = {:nickname => (opts[:nickname] ? opts[:nickname] : opts[:name])} @@ -99,14 +104,7 @@ def translate_create_opts(old_opts) if hsh["fn"] server[field] = __send__(hsh["fn"], to, opts[vals.first]) unless vals.first.nil? else -# case field -# when :inputs -# server[field] = opts[field] -# when :security_group_hrefs -# server[field] = opts[field] -# else - server[field] = opts[vals.first] unless vals.first.nil? -# end + server[field] = opts[vals.first] unless vals.first.nil? end } } @@ -247,21 +245,19 @@ def reboot(wait_for_state = false) @impl.reboot(wait_for_state) unless @multicloud end - # Save the servers parameters to the current server (instead of the next server) - def save_current - connection.logger("WARNING: Gateway Servers do not currently support save_current. Ignoring.") if @multicloud - @impl.save_current unless @multicloud - end - - # Load server's settings from the current server (instead of the next server) - def settings_current - connection.logger("WARNING: Gateway Servers do not support settings_current. Ignoring.") if @multicloud - @impl.settings_current unless @multicloud + def save(new_params = nil) + if new_params + @impl.settings + if @multicloud + @impl.next_instance.params = translate_create_opts(new_params, :instance_only) + else + @impl.params = translate_create_opts(new_params) + end + end + @impl.save end - # Reload the server's basic information from the current server. - def reload_current - connection.logger("WARNING: Gateway Servers do not support reload_current. Ignoring.") if @multicloud - @impl.reload_current unless @multicloud + def update(new_params = nil) + save(new_params) end end From 2ebc9a5e8b69ccc3f1006e67098cd384ce1f27bd Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Thu, 5 May 2011 23:57:07 +0000 Subject: [PATCH 043/239] bugfix for saving server params through ServerInterface --- .../rightscale/server_interface.rb | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/rest_connection/rightscale/server_interface.rb b/lib/rest_connection/rightscale/server_interface.rb index 71d132e..0d02545 100644 --- a/lib/rest_connection/rightscale/server_interface.rb +++ b/lib/rest_connection/rightscale/server_interface.rb @@ -74,24 +74,24 @@ def translate_create_opts(old_opts, instance_only=false) if @multicloud to = "1.5" if instance_only - ret = {:instance => {}} - server = ret[:instance] + ret = {"instance" => {}} + server = ret["instance"] else - ret = {:server => {:instance => {}}} - ret[:server][:name] = (opts[:name] ? opts[:name] : opts[:nickname]) - ret[:server][:description] = opts[:description] - ret[:server][:deployment_href] = opts[:deployment_href] - server = ret[:server][:instance] + ret = {"server" => {"instance" => {}}} + ret["server"]["name"] = (opts["name"] ? opts["name"] : opts["nickname"]) + ret["server"]["description"] = opts["description"] + ret["server"]["deployment_href"] = opts["deployment_href"] + server = ret["server"]["instance"] end else to = "1.0" - server = {:nickname => (opts[:nickname] ? opts[:nickname] : opts[:name])} - server[:deployment_href] = opts[:deployment_href] - ret = {:server => server} + server = {"nickname" => (opts["nickname"] ? opts["nickname"] : opts["name"])} + server["deployment_href"] = opts["deployment_href"] + ret = {"server" => server} begin - ret[:cloud_id] = opts[:cloud_href].split(/\/clouds\//).last + ret["cloud_id"] = opts["cloud_href"].split(/\/clouds\//).last rescue Exception => e - ret[:cloud_id] = opts[:cloud_id] + ret["cloud_id"] = opts["cloud_id"] end end @@ -102,9 +102,9 @@ def translate_create_opts(old_opts, instance_only=false) vals.flatten! vals.compact! if hsh["fn"] - server[field] = __send__(hsh["fn"], to, opts[vals.first]) unless vals.first.nil? + server[field.to_s] = __send__(hsh["fn"], to, opts[vals.first]) unless vals.first.nil? else - server[field] = opts[vals.first] unless vals.first.nil? + server[field.to_s] = opts[vals.first] unless vals.first.nil? end } } @@ -249,9 +249,9 @@ def save(new_params = nil) if new_params @impl.settings if @multicloud - @impl.next_instance.params = translate_create_opts(new_params, :instance_only) + @impl.next_instance.params.merge!(translate_create_opts(new_params, :instance_only)["instance"]) else - @impl.params = translate_create_opts(new_params) + @impl.params.merge!(translate_create_opts(new_params)["server"]) end end @impl.save From fce22669759f7d2031b63c44903b266c8b68c895 Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Fri, 6 May 2011 13:53:51 -0700 Subject: [PATCH 044/239] Updates for API 1.5 changes --- .../rightscale/rightscale_api_base.rb | 12 ++++++++++++ .../rightscale/rightscale_api_gateway.rb | 10 +++++----- lib/rest_connection/rightscale/server_interface.rb | 14 ++++++++++++++ 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/lib/rest_connection/rightscale/rightscale_api_base.rb b/lib/rest_connection/rightscale/rightscale_api_base.rb index 8d0f730..94becd5 100644 --- a/lib/rest_connection/rightscale/rightscale_api_base.rb +++ b/lib/rest_connection/rightscale/rightscale_api_base.rb @@ -117,6 +117,18 @@ def find_with_filter(filter = {}) end return a end + + def [](*args) + ret = [] + args.each { |arg| + begin + ret << (arg.is_a?(Hash) ? find_with_filter(arg) : find(arg)) + rescue + ret << find_by_nickname_speed(arg) + end + } + return (args.empty? ? find_all : ret.flatten) + end end module Base diff --git a/lib/rest_connection/rightscale/rightscale_api_gateway.rb b/lib/rest_connection/rightscale/rightscale_api_gateway.rb index 79835e7..e54e361 100644 --- a/lib/rest_connection/rightscale/rightscale_api_gateway.rb +++ b/lib/rest_connection/rightscale/rightscale_api_gateway.rb @@ -14,10 +14,10 @@ def connection resp = @@gateway_connection.post("session", params) raise "ERROR: Login failed. #{resp.message}. Code:#{resp.code}" unless resp.code == "302" || resp.code == "204" @@gateway_connection.cookie = resp.response['set-cookie'] - + # test session - resp, data = @@gateway_connection.get("session") - raise "ERROR: Invalid session. #{resp.message}. Code:#{resp.code}" unless resp.code == "200" + resp = @@gateway_connection.get("session") + raise "ERROR: Invalid session. #{resp["message"]}." unless resp.is_a?(Hash) end @@gateway_connection end @@ -135,8 +135,8 @@ def connection @@gateway_connection.cookie = resp.response['set-cookie'] # test session - resp, data = @@gateway_connection.get("session") - raise "ERROR: Invalid session. #{resp.message}. Code:#{resp.code}" unless resp.code == "200" + resp = @@gateway_connection.get("session") + raise "ERROR: Invalid session. #{resp["message"]}." unless resp.is_a?(Hash) end @@gateway_connection end diff --git a/lib/rest_connection/rightscale/server_interface.rb b/lib/rest_connection/rightscale/server_interface.rb index 0d02545..c1b8c30 100644 --- a/lib/rest_connection/rightscale/server_interface.rb +++ b/lib/rest_connection/rightscale/server_interface.rb @@ -34,6 +34,20 @@ def name nickname end + def inspect + @impl.inspect + end + + def self.[](*args) + begin + ret = Server[*args] + raise "" if ret.empty? + rescue + ret = McServer[*args] + end + return ret + end + def nickname return @impl.nickname unless @multicloud return @impl.name if @multicloud From 1ac069587dcde2d6ca87f8c5a72f2331764f6116 Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Tue, 10 May 2011 13:21:19 -0700 Subject: [PATCH 045/239] additional shorthand --- lib/rest_connection/rightscale/rightscale_api_base.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/rest_connection/rightscale/rightscale_api_base.rb b/lib/rest_connection/rightscale/rightscale_api_base.rb index 94becd5..f59cd40 100644 --- a/lib/rest_connection/rightscale/rightscale_api_base.rb +++ b/lib/rest_connection/rightscale/rightscale_api_base.rb @@ -124,7 +124,11 @@ def [](*args) begin ret << (arg.is_a?(Hash) ? find_with_filter(arg) : find(arg)) rescue - ret << find_by_nickname_speed(arg) + if arg.is_a?(Hash) + ret << find_by(arg.keys.first) { |v| v =~ /#{arg.values.first}/ } + else + ret << find_by_nickname_speed(arg) + end end } return (args.empty? ? find_all : ret.flatten) From aeed96bf0c9eca570a28af93decb9430ddd25e3c Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Tue, 10 May 2011 13:29:53 -0700 Subject: [PATCH 046/239] more shorthand --- lib/rest_connection/rightscale/rightscale_api_base.rb | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/rest_connection/rightscale/rightscale_api_base.rb b/lib/rest_connection/rightscale/rightscale_api_base.rb index f59cd40..feaf896 100644 --- a/lib/rest_connection/rightscale/rightscale_api_base.rb +++ b/lib/rest_connection/rightscale/rightscale_api_base.rb @@ -121,15 +121,20 @@ def find_with_filter(filter = {}) def [](*args) ret = [] args.each { |arg| + temp = [] begin - ret << (arg.is_a?(Hash) ? find_with_filter(arg) : find(arg)) + temp << (arg.is_a?(Hash) ? find_with_filter(arg) : find(arg)) rescue + end + temp.flatten! + if temp.empty? if arg.is_a?(Hash) - ret << find_by(arg.keys.first) { |v| v =~ /#{arg.values.first}/ } + temp << find_by(arg.keys.first) { |v| v =~ /#{arg.values.first}/ } else - ret << find_by_nickname_speed(arg) + temp << find_by_nickname_speed(arg) end end + ret += temp } return (args.empty? ? find_all : ret.flatten) end From 487a23da9e960a5e498f817b8e0ce8d2fa04fdbb Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Tue, 10 May 2011 17:17:12 -0700 Subject: [PATCH 047/239] bugfix for 1.0 -> 1.5 translations --- lib/rest_connection/rightscale/deployment.rb | 2 +- .../rightscale/rightscale_api_base.rb | 4 ++++ .../rightscale/rightscale_api_gateway.rb | 11 ++++++++++- lib/rest_connection/rightscale/server_interface.rb | 13 +++++++++++-- 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/lib/rest_connection/rightscale/deployment.rb b/lib/rest_connection/rightscale/deployment.rb index 807487a..2dbf330 100644 --- a/lib/rest_connection/rightscale/deployment.rb +++ b/lib/rest_connection/rightscale/deployment.rb @@ -54,7 +54,7 @@ def set_input(name, value) end def servers_no_reload - @params['servers'].map { |s| ServerInterface.new(cloud_id, s) } + @params['servers'].map { |s| ServerInterface.new(cloud_id, s, self.rs_id) } end def servers diff --git a/lib/rest_connection/rightscale/rightscale_api_base.rb b/lib/rest_connection/rightscale/rightscale_api_base.rb index feaf896..df703c8 100644 --- a/lib/rest_connection/rightscale/rightscale_api_base.rb +++ b/lib/rest_connection/rightscale/rightscale_api_base.rb @@ -219,6 +219,10 @@ def [](name) end end + def rs_id + self.href.split(/\//).last + end + end end end diff --git a/lib/rest_connection/rightscale/rightscale_api_gateway.rb b/lib/rest_connection/rightscale/rightscale_api_gateway.rb index e54e361..7e9b59d 100644 --- a/lib/rest_connection/rightscale/rightscale_api_gateway.rb +++ b/lib/rest_connection/rightscale/rightscale_api_gateway.rb @@ -2,7 +2,16 @@ module RightScale module Api module Gateway include RightScale::Api::Base - def connection + + def initialize(params = {}) + @params = parse_params(params) + end + + def parse_params(params = {}) + params + end + + def connection @@gateway_connection ||= RestConnection::Connection.new settings = @@gateway_connection.settings settings[:common_headers]["X_API_VERSION"] = "1.5" diff --git a/lib/rest_connection/rightscale/server_interface.rb b/lib/rest_connection/rightscale/server_interface.rb index c1b8c30..500a701 100644 --- a/lib/rest_connection/rightscale/server_interface.rb +++ b/lib/rest_connection/rightscale/server_interface.rb @@ -18,9 +18,18 @@ class ServerInterface attr_reader :multicloud - def initialize(cloud_id = 1, params = {}) + def initialize(cloud_id = 1, params = {}, deployment_id = nil) @multicloud = (cloud_id.to_i > 10 ? true : false) - @impl = (@multicloud ? McServer.new(params) : Server.new(params)) + if @multicloud + if deployment_id + name = params["nickname"] || params["name"] || params[:nickname] || params[:name] + @impl = McServer.find_by(:name, deployment_id) { |n| n == name }.first + else + @impl = McServer.new(params) + end + else + @impl = Server.new(params) + end end def create(opts) From 5d8f8b72e694c657d1e0440b1cc4beb73f2e8726 Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Wed, 11 May 2011 15:02:44 -0700 Subject: [PATCH 048/239] Added Macro resource and hacked multicloud reboot --- lib/rest_connection/rightscale/macro.rb | 19 +++++++++++++++++++ .../rightscale/rightscale_api_resources.rb | 1 + .../rightscale/server_interface.rb | 14 +++++++++++--- 3 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 lib/rest_connection/rightscale/macro.rb diff --git a/lib/rest_connection/rightscale/macro.rb b/lib/rest_connection/rightscale/macro.rb new file mode 100644 index 0000000..a903d7e --- /dev/null +++ b/lib/rest_connection/rightscale/macro.rb @@ -0,0 +1,19 @@ +# This file is part of RestConnection +# +# RestConnection is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# RestConnection is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with RestConnection. If not, see . +# +class Macro + include RightScale::Api::Base + extend RightScale::Api::BaseExtend +end diff --git a/lib/rest_connection/rightscale/rightscale_api_resources.rb b/lib/rest_connection/rightscale/rightscale_api_resources.rb index 8346749..6d89c2c 100644 --- a/lib/rest_connection/rightscale/rightscale_api_resources.rb +++ b/lib/rest_connection/rightscale/rightscale_api_resources.rb @@ -54,3 +54,4 @@ require 'rest_connection/rightscale/cloud' require 'rest_connection/rightscale/instance_type' require 'rest_connection/rightscale/mc_image' +require 'rest_connection/rightscale/macro' diff --git a/lib/rest_connection/rightscale/server_interface.rb b/lib/rest_connection/rightscale/server_interface.rb index 500a701..8a00750 100644 --- a/lib/rest_connection/rightscale/server_interface.rb +++ b/lib/rest_connection/rightscale/server_interface.rb @@ -263,9 +263,17 @@ def wait_for_state(st,timeout=1200) end # takes Bool argument to wait for state change (insurance that we can detect a reboot happened) - def reboot(wait_for_state = false) - connection.logger("WARNING: Gateway Servers do not support reboot. Ignoring.") if @multicloud - @impl.reboot(wait_for_state) unless @multicloud + def reboot(wait = false) + if @multicloud + connection.logger("WARNING: Gateway Servers do not support reboot natively. Using SshHax for now.") + old_state = self.state + @impl.spot_check_command?("init 6") + if wait + wait_for_state_change(old_change) + wait_for_state("operational") + end + end + @impl.reboot(wait) unless @multicloud end def save(new_params = nil) From 39d5d4be97e0e9c228b604b76b435845519623fa Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Wed, 11 May 2011 15:06:53 -0700 Subject: [PATCH 049/239] Adding find_by_cloud_id to shorthand --- lib/rest_connection/rightscale/rightscale_api_base.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/rest_connection/rightscale/rightscale_api_base.rb b/lib/rest_connection/rightscale/rightscale_api_base.rb index df703c8..40dabeb 100644 --- a/lib/rest_connection/rightscale/rightscale_api_base.rb +++ b/lib/rest_connection/rightscale/rightscale_api_base.rb @@ -123,7 +123,15 @@ def [](*args) args.each { |arg| temp = [] begin - temp << (arg.is_a?(Hash) ? find_with_filter(arg) : find(arg)) + if arg.is_a?(Hash) + if arg.keys.first.to_s == "cloud_id" + temp << find_by_cloud_id(arg.values.first.to_i) + else + temp << find_with_filter(arg) + end + else + temp << find(arg) + end rescue end temp.flatten! From 8efbb2ec0c481ff4676b5b2cce9d7477e84c7733 Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Fri, 20 May 2011 14:36:01 -0700 Subject: [PATCH 050/239] some bugfixes + S3Bucket resource --- .../rightscale/rightscale_api_base.rb | 5 +-- .../rightscale/rightscale_api_resources.rb | 1 + lib/rest_connection/rightscale/s3_bucket.rb | 36 +++++++++++++++++++ lib/rest_connection/rightscale/server.rb | 5 +-- 4 files changed, 43 insertions(+), 4 deletions(-) create mode 100644 lib/rest_connection/rightscale/s3_bucket.rb diff --git a/lib/rest_connection/rightscale/rightscale_api_base.rb b/lib/rest_connection/rightscale/rightscale_api_base.rb index 40dabeb..bec2c82 100644 --- a/lib/rest_connection/rightscale/rightscale_api_base.rb +++ b/lib/rest_connection/rightscale/rightscale_api_base.rb @@ -139,12 +139,13 @@ def [](*args) if arg.is_a?(Hash) temp << find_by(arg.keys.first) { |v| v =~ /#{arg.values.first}/ } else - temp << find_by_nickname_speed(arg) + temp << find_by(:name) { |n| n =~ /#{arg}/ } + temp << find_by(:nickname) { |n| n =~ /#{arg}/ } if temp.empty? end end ret += temp } - return (args.empty? ? find_all : ret.flatten) + return (args.empty? ? find_all : ret.flatten.uniq) end end diff --git a/lib/rest_connection/rightscale/rightscale_api_resources.rb b/lib/rest_connection/rightscale/rightscale_api_resources.rb index 6d89c2c..47ae8db 100644 --- a/lib/rest_connection/rightscale/rightscale_api_resources.rb +++ b/lib/rest_connection/rightscale/rightscale_api_resources.rb @@ -55,3 +55,4 @@ require 'rest_connection/rightscale/instance_type' require 'rest_connection/rightscale/mc_image' require 'rest_connection/rightscale/macro' +require 'rest_connection/rightscale/s3_bucket' diff --git a/lib/rest_connection/rightscale/s3_bucket.rb b/lib/rest_connection/rightscale/s3_bucket.rb new file mode 100644 index 0000000..f5b0fc8 --- /dev/null +++ b/lib/rest_connection/rightscale/s3_bucket.rb @@ -0,0 +1,36 @@ +# This file is part of RestConnection +# +# RestConnection is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# RestConnection is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with RestConnection. If not, see . +# +class S3Bucket + include RightScale::Api::Base + extend RightScale::Api::BaseExtend + + def self.resource_singular_name + "s3_bucket" + end + + def self.resource_plural_name + "s3_buckets" + end + + def resource_singular_name + "s3_bucket" + end + + def resource_plural_name + "s3_buckets" + end + +end diff --git a/lib/rest_connection/rightscale/server.rb b/lib/rest_connection/rightscale/server.rb index ac8af50..2e16eee 100644 --- a/lib/rest_connection/rightscale/server.rb +++ b/lib/rest_connection/rightscale/server.rb @@ -103,8 +103,9 @@ def wait_for_operational_with_dns(state_wait_timeout=1200) def audit_link # proof of concept for now - server_id = self.href.split(/\//).last - audit_href = "https://my.rightscale.com/servers/#{server_id}#auditentries" +# server_id = self.href.split(/\//).last +# audit_href = "https://my.rightscale.com/servers/#{server_id}#auditentries" + audit_href = self.href.gsub(/api\//,"") + "#auditentries" "#{audit_href}" end From dde1064eba74cf0b259fceb27de2458d1a446315 Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Tue, 31 May 2011 11:37:48 -0700 Subject: [PATCH 051/239] Warning message if no servers in the deployment --- lib/rest_connection/rightscale/deployment.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/rest_connection/rightscale/deployment.rb b/lib/rest_connection/rightscale/deployment.rb index 2dbf330..899b2b5 100644 --- a/lib/rest_connection/rightscale/deployment.rb +++ b/lib/rest_connection/rightscale/deployment.rb @@ -54,6 +54,7 @@ def set_input(name, value) end def servers_no_reload + connection.logger("WARNING: No Servers in the Deployment!") if @params['servers'].empty? @params['servers'].map { |s| ServerInterface.new(cloud_id, s, self.rs_id) } end From 6e697938dc070606ae2cf5d98652b6726ae256c6 Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Fri, 10 Dec 2010 14:15:15 -0800 Subject: [PATCH 052/239] merged jeremyd's --- lib/rest_connection/rightscale/server.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rest_connection/rightscale/server.rb b/lib/rest_connection/rightscale/server.rb index a2786b1..da899d5 100644 --- a/lib/rest_connection/rightscale/server.rb +++ b/lib/rest_connection/rightscale/server.rb @@ -169,7 +169,7 @@ def set_input(name, value) connection.put(serv_href.path, :server => {:parameters => {name.to_sym => value} }) end - def set_inputs(hash) + def set_inputs(hash = {}) serv_href = URI.parse(self.href) connection.put(serv_href.path, :server => {:parameters => hash}) end From a31c7c6f4675bd98610c8fd543f4294fed6b1d0f Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Fri, 14 Jan 2011 11:24:59 -0800 Subject: [PATCH 053/239] multicloud support --- lib/rest_connection/rightscale/deployment.rb | 6 +++++- lib/rest_connection/rightscale/mc_server.rb | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/rest_connection/rightscale/deployment.rb b/lib/rest_connection/rightscale/deployment.rb index fa8679a..7517b61 100644 --- a/lib/rest_connection/rightscale/deployment.rb +++ b/lib/rest_connection/rightscale/deployment.rb @@ -25,7 +25,11 @@ def set_input(name, value) def servers_no_reload server_list = [] @params['servers'].each do |s| - server_list << Server.new(s) + if s["server_type"] == "ec2" + server_list << Server.new(s) + else + server_list << McServer.new(s) + end end return server_list end diff --git a/lib/rest_connection/rightscale/mc_server.rb b/lib/rest_connection/rightscale/mc_server.rb index 9f87f9a..62b94cf 100644 --- a/lib/rest_connection/rightscale/mc_server.rb +++ b/lib/rest_connection/rightscale/mc_server.rb @@ -16,7 +16,7 @@ # # You must have Beta v1.5 API access to use these internal API calls. # -class McServer +class McServer < Server include RightScale::Api::Gateway extend RightScale::Api::GatewayExtend From 95bb9f62aaf7dcbe80105212435c5ccf1cca804e Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Tue, 18 Jan 2011 14:43:29 -0800 Subject: [PATCH 054/239] some more upgrades for multicloud --- lib/rest_connection/rightscale/mc_server.rb | 13 +++++++++++++ lib/rest_connection/rightscale/server.rb | 2 ++ 2 files changed, 15 insertions(+) diff --git a/lib/rest_connection/rightscale/mc_server.rb b/lib/rest_connection/rightscale/mc_server.rb index 62b94cf..e8d591c 100644 --- a/lib/rest_connection/rightscale/mc_server.rb +++ b/lib/rest_connection/rightscale/mc_server.rb @@ -36,4 +36,17 @@ def self.resource_singular_name "server" end + def self.create(opts) + server = {} + server[:name] = opts[:nickname] if opts[:nickname] + server[:deployment_href] = opts[:deployment_href] if opts[:deployment_href] + server[:instance] = {:server_template_href => opts[:server_template_href]} + server[:instance][:cloud_href] = "https://my.rightscale.com/api/clouds/#{opts[:cloud_id]}" + server[:instance][:multi_cloud_image_href] = opts[:mci_href] + server[:instance][:instance_type_href] = nil #TODO..... + server[:instance][:inputs] = opts[:inputs] + location = connection.post(self.resource_plural_name, {self.resource_singular_name.to_sym => server}) + newrecord = self.new('href' => location) + newrecord.reload + newrecord end diff --git a/lib/rest_connection/rightscale/server.rb b/lib/rest_connection/rightscale/server.rb index da899d5..81373a8 100644 --- a/lib/rest_connection/rightscale/server.rb +++ b/lib/rest_connection/rightscale/server.rb @@ -24,6 +24,8 @@ def self.create(opts) create_options = Hash.new create_options[self.resource_singular_name.to_sym] = opts create_options["cloud_id"] = opts[:cloud_id] if opts[:cloud_id] + create_options[self.resource_singular_name.to_sum][:mci_href] = nil + create_options[self.resource_singular_name.to_sum][:inputs] = nil location = connection.post(self.resource_plural_name,create_options) newrecord = self.new('href' => location) newrecord.reload From 96accf64621b22a7daafa77bfb2d3ab8640511fb Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Tue, 18 Jan 2011 17:30:17 -0800 Subject: [PATCH 055/239] more multicloud support + bugfixes --- lib/rest_connection/rightscale/deployment.rb | 68 ++++++++++++++++++-- lib/rest_connection/rightscale/mc_server.rb | 1 + 2 files changed, 64 insertions(+), 5 deletions(-) diff --git a/lib/rest_connection/rightscale/deployment.rb b/lib/rest_connection/rightscale/deployment.rb index 7517b61..a4e47bf 100644 --- a/lib/rest_connection/rightscale/deployment.rb +++ b/lib/rest_connection/rightscale/deployment.rb @@ -13,12 +13,70 @@ # You should have received a copy of the GNU General Public License # along with RestConnection. If not, see . -class Deployment - include RightScale::Api::Base - extend RightScale::Api::BaseExtend +class Deployment + class McDeployment + include RightScale::Api::Gateway + extend RightScale::Api::GatewayExtend + + def resource_plural_name + "deployments" + end + + def resource_singular_name + "deployment" + end + + def self.resource_plural_name + "deployments" + end + + def self.resource_singular_name + "deployment" + end + end + + class EC2Deployment + include RightScale::Api::Base + extend RightScale::Api::BaseExtend + + def resource_plural_name + "deployments" + end + + def resource_singular_name + "deployment" + end + + def self.resource_plural_name + "deployments" + end + + def self.resource_singular_name + "deployment" + end + end + + def initialize(params = {}) + if params[:cloud_id].to_i < 10 + @deploy = Deployment::EC2Deployment.new(params) + else + @deploy = Deployment::McDeployment.new(params) + end + end + + def method_missing(method_name, *args) + @deploy.method_missing(method_name, *args) + end + + def create(opts) + location = connection.post(@deploy.resource_plural_name, @deploy.resource_singular_name.to_sym => opts) + newrecord = self.new('href' => location) + newrecord.reload + newrecord + end def set_input(name, value) - deploy_href = URI.parse(self.href) + deploy_href = URI.parse(@deploy.href) connection.put(deploy_href.path, :deployment => {:parameters => {name => value} }) end @@ -46,7 +104,7 @@ def duplicate end def clone - deploy_href = URI.parse(self.href) + deploy_href = URI.parse(@deploy.href) Deployment.new(:href => connection.post(deploy_href.path + "/duplicate")) end end diff --git a/lib/rest_connection/rightscale/mc_server.rb b/lib/rest_connection/rightscale/mc_server.rb index e8d591c..3034352 100644 --- a/lib/rest_connection/rightscale/mc_server.rb +++ b/lib/rest_connection/rightscale/mc_server.rb @@ -49,4 +49,5 @@ def self.create(opts) newrecord = self.new('href' => location) newrecord.reload newrecord + end end From f0510591536b8c43bbdad7fe50c26bb5078adfd2 Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Tue, 31 May 2011 13:53:19 -0700 Subject: [PATCH 056/239] [Logger] If request body contains "password", don't log. --- lib/rest_connection.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rest_connection.rb b/lib/rest_connection.rb index cbc0e41..8bde475 100644 --- a/lib/rest_connection.rb +++ b/lib/rest_connection.rb @@ -76,7 +76,7 @@ def rest_connect(&block) req.basic_auth(@settings[:user], @settings[:pass]) if @settings[:user] end logger("#{req.method}: #{req.path}") - logger("\trequest body: #{req.body}") if req.body + logger("\trequest body: #{req.body}") if req.body and req.body !~ /password/ response, body = http.request(req) handle_response(response) end From cd5cf4131e4e09cfaae7a758c8c1c28defdffbf5 Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Tue, 31 May 2011 13:53:19 -0700 Subject: [PATCH 057/239] [Logger] If request body contains "password", don't log. --- lib/rest_connection.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rest_connection.rb b/lib/rest_connection.rb index d4462ba..68a99bc 100644 --- a/lib/rest_connection.rb +++ b/lib/rest_connection.rb @@ -87,7 +87,7 @@ def rest_connect(&block) req.basic_auth(@settings[:user], @settings[:pass]) if @settings[:user] end logger("#{req.method}: #{req.path}") - logger("\trequest body: #{req.body}") if req.body + logger("\trequest body: #{req.body}") if req.body and req.body !~ /password/ response, body = http.request(req) handle_response(response) end From a54a15abb9bd1db5c78f1bd1e94aefdf800bb835 Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Thu, 2 Jun 2011 18:15:10 -0700 Subject: [PATCH 058/239] Added input manipulation to mc_instances --- lib/rest_connection/rightscale/inputs.rb | 50 ------------------- lib/rest_connection/rightscale/mc_instance.rb | 5 ++ lib/rest_connection/rightscale/mc_server.rb | 16 +++++- .../rightscale/rightscale_api_resources.rb | 1 - .../rightscale/server_interface.rb | 23 +++------ 5 files changed, 26 insertions(+), 69 deletions(-) delete mode 100644 lib/rest_connection/rightscale/inputs.rb diff --git a/lib/rest_connection/rightscale/inputs.rb b/lib/rest_connection/rightscale/inputs.rb deleted file mode 100644 index 08f9666..0000000 --- a/lib/rest_connection/rightscale/inputs.rb +++ /dev/null @@ -1,50 +0,0 @@ -# This file is part of RestConnection -# -# RestConnection is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# RestConnection is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with RestConnection. If not, see . - -# -# You must have Beta v1.5 API access to use these internal API calls. -# -class Inputs - include RightScale::Api::Gateway - extend RightScale::Api::GatewayExtend - - def resource_plural_name - "inputs" - end - - def resource_singular_name - "inputs" - end - - def self.resource_plural_name - "inputs" - end - - def self.resource_singular_name - "inputs" - end - - def self.create - - end - - def show - #TODO - end - - def multi_update - #TODO - end -end diff --git a/lib/rest_connection/rightscale/mc_instance.rb b/lib/rest_connection/rightscale/mc_instance.rb index a5159f5..89617c3 100644 --- a/lib/rest_connection/rightscale/mc_instance.rb +++ b/lib/rest_connection/rightscale/mc_instance.rb @@ -61,6 +61,11 @@ def terminate connection.post(inst_href.path + '/terminate') end + def multi_update(input_ary) + inst_href = URI.parse(self.href) + connection.put(inst_href.path + '/inputs/multi_update', {'inputs' => input_ary}) + end + def transform_inputs(sym, parameters) ret = nil if parameters.is_a?(Array) and sym == :to_h diff --git a/lib/rest_connection/rightscale/mc_server.rb b/lib/rest_connection/rightscale/mc_server.rb index eb90ea1..ab350c1 100644 --- a/lib/rest_connection/rightscale/mc_server.rb +++ b/lib/rest_connection/rightscale/mc_server.rb @@ -85,12 +85,24 @@ def transform_inputs(sym, parameters) ret end + def inputs + if @current_instance + @current_instance.show + return transform_inputs(:to_h, @current_instance.inputs) + else + @next_instance.show + return transform_inputs(:to_h, @next_instance.inputs) + end + end + def set_input(name, value) - @inputs.multi_update([{'name' => name, 'value' => value}]) + @current_instance.multi_update([{'name' => name, 'value' => value}]) if @current_instance + @next_instance.multi_update([{'name' => name, 'value' => value}]) end def set_inputs(hash = {}) - @inputs.multi_update(transform_inputs(:to_a, hash)) + @current_instance.multi_update(transform_inputs(:to_a, hash)) if @current_instance + @next_instance.multi_update(transform_inputs(:to_a, hash)) end def settings #show diff --git a/lib/rest_connection/rightscale/rightscale_api_resources.rb b/lib/rest_connection/rightscale/rightscale_api_resources.rb index 47ae8db..f476c49 100644 --- a/lib/rest_connection/rightscale/rightscale_api_resources.rb +++ b/lib/rest_connection/rightscale/rightscale_api_resources.rb @@ -38,7 +38,6 @@ require 'rest_connection/rightscale/mc_server' require 'rest_connection/rightscale/server_interface' require 'rest_connection/rightscale/mc_instance' -require 'rest_connection/rightscale/inputs' require 'rest_connection/rightscale/monitoring_metric' require 'rest_connection/rightscale/ec2_ssh_key_internal' require 'rest_connection/rightscale/server_template_internal' diff --git a/lib/rest_connection/rightscale/server_interface.rb b/lib/rest_connection/rightscale/server_interface.rb index 8a00750..d8bf805 100644 --- a/lib/rest_connection/rightscale/server_interface.rb +++ b/lib/rest_connection/rightscale/server_interface.rb @@ -180,24 +180,15 @@ def translate_href(old_href) # end end - # The RightScale api returns the server parameters as a hash with "name" and "value". - # This must be transformed into a hash in case we want to PUT this back to the API. - def transform_parameters(parameters) - new_params_hash = {} - parameters.each do |parameter_hash| - new_params_hash[parameter_hash["name"]] = parameter_hash["value"] - end - new_params_hash - end - # Since RightScale hands back the parameters with a "name" and "value" tags we should # transform them into the proper hash. This it the same for setting and getting. def parameters - # if the parameters are an array of hashes, that means we need to transform. - if @params['parameters'].is_a?(Array) - @params['parameters'] = transform_parameters(@params['parameters']) - end - @params['parameters'] + @impl.parameters unless @multicloud + @impl.inputs if @multicloud + end + + def inputs + parameters end def start @@ -230,7 +221,7 @@ def stop_ebs # This should be used with v4 images only. def run_script(script,opts=nil) - connection.logger("WARNING: Gateway Servers do not support run_script. Ignoring.") if @multicloud + connection.logger("WARNING: Gateway Servers do not support run_script. Did you mean run_executable?") if @multicloud @impl.run_script(script,opts) unless @multicloud end From 2c154f8d2f8df1209410cfc15908e0de19565979 Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Mon, 6 Jun 2011 16:50:30 -0700 Subject: [PATCH 059/239] [Server] Much more robust cloud_id deciphering --- lib/rest_connection.rb | 6 +++ lib/rest_connection/rightscale/deployment.rb | 5 +-- .../rightscale/rightscale_api_base.rb | 4 +- lib/rest_connection/rightscale/server.rb | 38 +++++++++++++++++++ .../rightscale/server_interface.rb | 10 ++++- 5 files changed, 56 insertions(+), 7 deletions(-) diff --git a/lib/rest_connection.rb b/lib/rest_connection.rb index 68a99bc..0273372 100644 --- a/lib/rest_connection.rb +++ b/lib/rest_connection.rb @@ -23,6 +23,12 @@ require 'highline/import' module RestConnection + AWS_CLOUDS = [{"cloud_id" => 1, "name" => "AWS US-East"}, + {"cloud_id" => 2, "name" => "AWS EU"}, + {"cloud_id" => 3, "name" => "AWS US-West"}, + {"cloud_id" => 4, "name" => "AWS AP-Singapore"}, + {"cloud_id" => 5, "name" => "AWS AP-Tokyo"}] + class Connection # Settings is a hash of options for customizing the connection. # settings.merge! { diff --git a/lib/rest_connection/rightscale/deployment.rb b/lib/rest_connection/rightscale/deployment.rb index 899b2b5..1c21018 100644 --- a/lib/rest_connection/rightscale/deployment.rb +++ b/lib/rest_connection/rightscale/deployment.rb @@ -29,9 +29,8 @@ def cloud_id if self.nickname =~ /cloud_[0-9]+/ @cloud_id = self.nickname.match(/cloud_[0-9]+/)[0].match(/[0-9]+/)[0].to_i else - @cloud_id = 1 + @cloud_id = nil # if self.nickname =~ /cloud_multicloud/ end - @cloud_id = nil if self.nickname =~ /cloud_multicloud/ end @cloud_id end @@ -55,7 +54,7 @@ def set_input(name, value) def servers_no_reload connection.logger("WARNING: No Servers in the Deployment!") if @params['servers'].empty? - @params['servers'].map { |s| ServerInterface.new(cloud_id, s, self.rs_id) } + @params['servers'].map { |s| ServerInterface.new(self.cloud_id, s, self.rs_id) } end def servers diff --git a/lib/rest_connection/rightscale/rightscale_api_base.rb b/lib/rest_connection/rightscale/rightscale_api_base.rb index bec2c82..6abfa98 100644 --- a/lib/rest_connection/rightscale/rightscale_api_base.rb +++ b/lib/rest_connection/rightscale/rightscale_api_base.rb @@ -139,8 +139,8 @@ def [](*args) if arg.is_a?(Hash) temp << find_by(arg.keys.first) { |v| v =~ /#{arg.values.first}/ } else - temp << find_by(:name) { |n| n =~ /#{arg}/ } - temp << find_by(:nickname) { |n| n =~ /#{arg}/ } if temp.empty? + temp += find_by(:name) { |n| n =~ /#{arg}/ } + temp += find_by(:nickname) { |n| n =~ /#{arg}/ } if temp.empty? end end ret += temp diff --git a/lib/rest_connection/rightscale/server.rb b/lib/rest_connection/rightscale/server.rb index 2e16eee..88de04e 100644 --- a/lib/rest_connection/rightscale/server.rb +++ b/lib/rest_connection/rightscale/server.rb @@ -263,5 +263,43 @@ def reload_current @params ? @params.merge!(connection.get(uri.path + "/current")) : @params = connection.get(uri.path) end + # Complex logic for determining the cloud_id of even a stopped server + def cloud_id + self.settings + if self.state == "operational" + return self["cloud_id"] + end + cloud_ids = RestConnection::AWS_CLOUDS.map { |hsh| hsh["cloud_id"] } + + api0_1 = false + begin + api0_1 = true if Ec2SshKeyInternal.find_all + rescue + end + + # Try ssh keys + if self.ec2_ssh_key_href and api0_1 + ref = self.ec2_ssh_key_href + cloud_ids.each { |cloud| + if Ec2SshKeyInternal.find_by_cloud_id(cloud.to_s).select { |o| o.href == ref }.first + return cloud + end + } + end + + # Try security groups + if self.ec2_security_groups_href + self.ec2_security_groups_href.each { |sg| + cloud_ids.each { |cloud| + if Ec2SecurityGroup.find_by_cloud_id(cloud.to_s).select { |o| o.href == sg }.first + return cloud + end + } + } + end + + raise "Could not determine cloud_id...try setting an ssh key or security group" + end + end diff --git a/lib/rest_connection/rightscale/server_interface.rb b/lib/rest_connection/rightscale/server_interface.rb index d8bf805..4fc38a6 100644 --- a/lib/rest_connection/rightscale/server_interface.rb +++ b/lib/rest_connection/rightscale/server_interface.rb @@ -18,8 +18,14 @@ class ServerInterface attr_reader :multicloud - def initialize(cloud_id = 1, params = {}, deployment_id = nil) - @multicloud = (cloud_id.to_i > 10 ? true : false) + def initialize(cid = nil, params = {}, deployment_id = nil) + if cid + @multicloud = (cid.to_i > 10 ? true : false) + elsif params["href"] + @multicloud = false + else + @multicloud = true + end if @multicloud if deployment_id name = params["nickname"] || params["name"] || params[:nickname] || params[:name] From d27ac34328953affa9fd90fa1c5541a6f5b82b7f Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Wed, 22 Jun 2011 10:36:24 -0700 Subject: [PATCH 060/239] [API 1.5] Fix for Euca dns_name --- lib/rest_connection/rightscale/mc_server.rb | 8 ++++++-- .../rightscale/rightscale_api_base.rb | 12 +++++++++--- lib/rest_connection/rightscale/server.rb | 4 ++++ 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/lib/rest_connection/rightscale/mc_server.rb b/lib/rest_connection/rightscale/mc_server.rb index ab350c1..0a7c8d5 100644 --- a/lib/rest_connection/rightscale/mc_server.rb +++ b/lib/rest_connection/rightscale/mc_server.rb @@ -108,8 +108,12 @@ def set_inputs(hash = {}) def settings #show serv_href = URI.parse(self.href) @params.merge! connection.get(serv_href.path, 'view' => 'instance_detail') - @current_instance = McInstance.new(self['current_instance']) if self['current_instance'] + if self['current_instance'] + @current_instance = McInstance.new(self['current_instance']) + @current_instance.show + end @next_instance = McInstance.new(self['next_instance']) + @next_instance.show @params end @@ -179,7 +183,7 @@ def wait_for_operational_with_dns(state_wait_timeout=1200) def dns_name if @current_instance - return @current_instance.public_ip_addresses.first + return @current_instance.public_ip_addresses.first || @current_instance.public_dns_names.first end nil end diff --git a/lib/rest_connection/rightscale/rightscale_api_base.rb b/lib/rest_connection/rightscale/rightscale_api_base.rb index 6abfa98..9c84964 100644 --- a/lib/rest_connection/rightscale/rightscale_api_base.rb +++ b/lib/rest_connection/rightscale/rightscale_api_base.rb @@ -129,6 +129,8 @@ def [](*args) else temp << find_with_filter(arg) end + elsif arg.is_a?(Regexp) + temp << find_by(:nickname) { |n| n =~ arg } else temp << find(arg) end @@ -136,11 +138,15 @@ def [](*args) end temp.flatten! if temp.empty? + all = find_all if arg.is_a?(Hash) - temp << find_by(arg.keys.first) { |v| v =~ /#{arg.values.first}/ } + temp << all.select { |v| v.__send__(arg.keys.first.to_sym) =~ /#{arg.values.first}/ } + elsif arg.is_a?(Regexp) + temp += all.select { |n| n.name =~ arg } + temp += all.select { |n| n.nickname =~ arg } if temp.empty? else - temp += find_by(:name) { |n| n =~ /#{arg}/ } - temp += find_by(:nickname) { |n| n =~ /#{arg}/ } if temp.empty? + temp += all.select { |n| n.name =~ /#{arg}/ } + temp += all.select { |n| n.nickname =~ /#{arg}/ } if temp.empty? end end ret += temp diff --git a/lib/rest_connection/rightscale/server.rb b/lib/rest_connection/rightscale/server.rb index 88de04e..68337a5 100644 --- a/lib/rest_connection/rightscale/server.rb +++ b/lib/rest_connection/rightscale/server.rb @@ -301,5 +301,9 @@ def cloud_id raise "Could not determine cloud_id...try setting an ssh key or security group" end + def run_executable_and_wait_for_completed(executable, opts=nil) + run_executable(executable, opts).wait_for_completed + end + end From 3ac72d87bfcea1145bbd0f8e2add2ad054e61779 Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Fri, 24 Jun 2011 13:33:20 -0700 Subject: [PATCH 061/239] Workaround for broken 'full' instance view on non-euca clouds --- lib/rest_connection/rightscale/mc_instance.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/rest_connection/rightscale/mc_instance.rb b/lib/rest_connection/rightscale/mc_instance.rb index 89617c3..b7f83fb 100644 --- a/lib/rest_connection/rightscale/mc_instance.rb +++ b/lib/rest_connection/rightscale/mc_instance.rb @@ -42,8 +42,11 @@ def self.parse_args(cloud_id) end def show + # Remove this hack-y workaround once 1.5 is fixed + c = Cloud[self.cloud].first + view = (c.name =~ /euca/i or c.description =~ /euca/i ? "full" : "default") inst_href = URI.parse(self.href) - @params.merge! connection.get(inst_href.path, 'view' => "full") + @params.merge! connection.get(inst_href.path, 'view' => view) end def update From 8835fb774cfb58784cce096ea84de3f054c9c07c Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Mon, 27 Jun 2011 14:48:30 -0700 Subject: [PATCH 062/239] Added Taggable mixin --- lib/rest_connection.rb | 1 + lib/rest_connection/patches.rb | 78 ++++++++++++++++ lib/rest_connection/rightscale/deployment.rb | 2 + .../rightscale/ec2_ebs_snapshot.rb | 2 + .../rightscale/ec2_ebs_volume.rb | 2 + .../rightscale/ec2_server_array.rb | 2 + lib/rest_connection/rightscale/instance.rb | 2 + .../rightscale/rightscale_api_gateway.rb | 33 +++++++ .../rightscale/rightscale_api_resources.rb | 1 + .../rightscale/rightscale_api_taggable.rb | 91 +++++++++++++++++++ lib/rest_connection/rightscale/server.rb | 43 ++++++++- .../rightscale/server_template.rb | 3 + 12 files changed, 259 insertions(+), 1 deletion(-) create mode 100644 lib/rest_connection/patches.rb create mode 100644 lib/rest_connection/rightscale/rightscale_api_taggable.rb diff --git a/lib/rest_connection.rb b/lib/rest_connection.rb index 0273372..64a1946 100644 --- a/lib/rest_connection.rb +++ b/lib/rest_connection.rb @@ -19,6 +19,7 @@ require 'yaml' require 'cgi' require 'rest_connection/rightscale/rightscale_api_resources' +require 'rest_connection/patches' require 'logger' require 'highline/import' diff --git a/lib/rest_connection/patches.rb b/lib/rest_connection/patches.rb new file mode 100644 index 0000000..6052c9f --- /dev/null +++ b/lib/rest_connection/patches.rb @@ -0,0 +1,78 @@ +# Hash Patches + +class Hash + # Merges self with another second, recursively. + # + # This code was lovingly stolen from some random gem: + # http://gemjack.com/gems/tartan-0.1.1/classes/Hash.html + # + # Thanks to whoever made it. + # + # Modified to provide same functionality with Arrays + + def deep_merge(second) + target = dup + return target unless second + second.keys.each do |k| + if second[k].is_a? Array and self[k].is_a? Array + target[k] = target[k].deep_merge(second[k]) + next + elsif second[k].is_a? Hash and self[k].is_a? Hash + target[k] = target[k].deep_merge(second[k]) + next + end + target[k] = second[k] + end + target + end + + # From: http://www.gemtacular.com/gemdocs/cerberus-0.2.2/doc/classes/Hash.html + # File lib/cerberus/utils.rb, line 42 + # Modified to provide same functionality with Arrays + + def deep_merge!(second) + return nil unless second + second.each_pair do |k,v| + if self[k].is_a?(Array) and second[k].is_a?(Array) + self[k].deep_merge!(second[k]) + elsif self[k].is_a?(Hash) and second[k].is_a?(Hash) + self[k].deep_merge!(second[k]) + else + self[k] = second[k] + end + end + end +end + +# Array Patches + +class Array + def deep_merge(second) + target = dup + return target unless second + second.each_index do |k| + if second[k].is_a? Array and self[k].is_a? Array + target[k] = target[k].deep_merge(second[k]) + next + elsif second[k].is_a? Hash and self[k].is_a? Hash + target[k] = target[k].deep_merge(second[k]) + next + end + target << second[k] unless target.include?(second[k]) + end + target + end + + def deep_merge!(second) + return nil unless second + second.each_index do |k| + if self[k].is_a?(Array) and second[k].is_a?(Array) + self[k].deep_merge!(second[k]) + elsif self[k].is_a?(Hash) and second[k].is_a?(Hash) + self[k].deep_merge!(second[k]) + else + self << second[k] unless self.include?(second[k]) + end + end + end +end diff --git a/lib/rest_connection/rightscale/deployment.rb b/lib/rest_connection/rightscale/deployment.rb index 1c21018..befedd6 100644 --- a/lib/rest_connection/rightscale/deployment.rb +++ b/lib/rest_connection/rightscale/deployment.rb @@ -16,6 +16,8 @@ class Deployment include RightScale::Api::Base extend RightScale::Api::BaseExtend + include RightScale::Api::Taggable + extend RightScale::Api::TaggableExtend def reload uri = URI.parse(self.href) diff --git a/lib/rest_connection/rightscale/ec2_ebs_snapshot.rb b/lib/rest_connection/rightscale/ec2_ebs_snapshot.rb index ab6654d..fcb1f1f 100644 --- a/lib/rest_connection/rightscale/ec2_ebs_snapshot.rb +++ b/lib/rest_connection/rightscale/ec2_ebs_snapshot.rb @@ -17,4 +17,6 @@ class Ec2EbsSnapshot include RightScale::Api::Base extend RightScale::Api::BaseExtend + include RightScale::Api::Taggable + extend RightScale::Api::TaggableExtend end diff --git a/lib/rest_connection/rightscale/ec2_ebs_volume.rb b/lib/rest_connection/rightscale/ec2_ebs_volume.rb index 2c4feaf..0e197fa 100644 --- a/lib/rest_connection/rightscale/ec2_ebs_volume.rb +++ b/lib/rest_connection/rightscale/ec2_ebs_volume.rb @@ -17,6 +17,8 @@ class Ec2EbsVolume include RightScale::Api::Base extend RightScale::Api::BaseExtend + include RightScale::Api::Taggable + extend RightScale::Api::TaggableExtend def attach(params) connection.post('component_ec2_ebs_volumes.js' , :component_ec2_ebs_volume => params) diff --git a/lib/rest_connection/rightscale/ec2_server_array.rb b/lib/rest_connection/rightscale/ec2_server_array.rb index a28a0b9..f9906eb 100644 --- a/lib/rest_connection/rightscale/ec2_server_array.rb +++ b/lib/rest_connection/rightscale/ec2_server_array.rb @@ -16,6 +16,8 @@ class Ec2ServerArray include RightScale::Api::Base extend RightScale::Api::BaseExtend + include RightScale::Api::Taggable + extend RightScale::Api::TaggableExtend # Example: # right_script = @server_template.executables.first diff --git a/lib/rest_connection/rightscale/instance.rb b/lib/rest_connection/rightscale/instance.rb index d802fe1..cfd5deb 100644 --- a/lib/rest_connection/rightscale/instance.rb +++ b/lib/rest_connection/rightscale/instance.rb @@ -19,6 +19,8 @@ class Instance include RightScale::Api::Base extend RightScale::Api::BaseExtend + include RightScale::Api::Taggable + extend RightScale::Api::TaggableExtend #def create_ebs_volume_from_snap(snap_aws_id) # connection.post('create_ebs_volume.js', :aws_id => snap_aws_id ) #end diff --git a/lib/rest_connection/rightscale/rightscale_api_gateway.rb b/lib/rest_connection/rightscale/rightscale_api_gateway.rb index 7e9b59d..388d747 100644 --- a/lib/rest_connection/rightscale/rightscale_api_gateway.rb +++ b/lib/rest_connection/rightscale/rightscale_api_gateway.rb @@ -126,6 +126,27 @@ def []=(name,val) end val end + + def load(resource) + if resource.is_a?(Class) + param_string = resource.resource_singular_name + class_name = resource + elsif resource.is_a?(String) or resource.is_a?(Symbol) + param_string = resource + begin + class_name = Kernel.const_get(resource.singularize.camelize) + rescue + class_name = Kernel.const_get("Mc#{resource.singularize.camelize}") + end + end + if self[param_string].nil? + return class_name.load_all(self[param_string.pluralize]) + elsif param_string.pluralize == param_string + return class_name.load_all(self[param_string]) + else + return class_name.load(self[param_string]) + end + end end module GatewayExtend @@ -166,6 +187,18 @@ def find_all(*args) return a end + def load(url) + return self.new(connection.get(url)) + end + + def load_all(url) + a = Array.new + connection.get(url).each do |object| + a << self.new(object) + end + return a + end + def parse_args() nil end diff --git a/lib/rest_connection/rightscale/rightscale_api_resources.rb b/lib/rest_connection/rightscale/rightscale_api_resources.rb index f476c49..267c979 100644 --- a/lib/rest_connection/rightscale/rightscale_api_resources.rb +++ b/lib/rest_connection/rightscale/rightscale_api_resources.rb @@ -17,6 +17,7 @@ require 'rest_connection/rightscale/rightscale_api_base' require 'rest_connection/rightscale/rightscale_api_internal' require 'rest_connection/rightscale/rightscale_api_gateway' +require 'rest_connection/rightscale/rightscale_api_taggable' require 'rest_connection/rightscale/executable' require 'rest_connection/rightscale/server' require 'rest_connection/rightscale/deployment' diff --git a/lib/rest_connection/rightscale/rightscale_api_taggable.rb b/lib/rest_connection/rightscale/rightscale_api_taggable.rb new file mode 100644 index 0000000..5860651 --- /dev/null +++ b/lib/rest_connection/rightscale/rightscale_api_taggable.rb @@ -0,0 +1,91 @@ +# This file is part of RestConnection +# +# RestConnection is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# RestConnection is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with RestConnection. If not, see . + +module RightScale + module Api + module Taggable + def add_tags(*args) + return false if args.empty? + Tag.set(self.href, args.uniq) + self.tags(true) + end + + def remove_tags(*args) + return false if args.empty? + Tag.unset(self.href, args.uniq) + self.tags(true) + end + + def tags(reload=false) + @params["tags"] = Tag.search_by_href(self.href) if reload + @params["tags"] + end + + def remove_tags_by_keys(*tag_keys) + tags_to_unset = [] + tags = get_tag_values(*(tag_keys.uniq)) + tags.each { |res,hsh| + hsh.each { |k,v| + tags_to_unset << "info:#{k}=#{v}" + } + } + self.remove_tags(*tags_to_unset) + end + + def set_tags_by_keys(hsh={}) + keys_to_change = [] + tags_to_set = [] + hsh.each { |k,v| keys_to_change << k; tags_to_set << "info:#{k}=#{v}" } + self.remove_tags_by_keys(*keys_to_change) + self.add_tags(*tags_to_set) + end + + def get_tag_values(*tag_keys) + ret = {} + tags = {"self" => self.tags(true)} + tags.each { |res,ary| + ret[res] ||= {} + ary.each { |hsh| + next unless hsh["name"].start_with?("info:") + key, value = hsh["name"].split(":").last.split("=") + ret[res][key] = value if tag_keys.include?(key) + } + } + return ret + end + + def set_tags_to(*args) + self.clear_tags("info") + self.add_tags(*(args.uniq)) + end + + def clear_tags(namespace = nil) + tag_ary = self.tags(true) + tag_ary = tag_ary.select { |hsh| hsh["name"].start_with?("#{namespace}:") } if namespace + self.remove_tags(*(tag_ary.map { |k,v| v })) + end + end + + module TaggableExtend + def find_by_tags(*args) + a = Array.new + Tag.search(self.resource_singular_name, args.uniq).each do |object| + a << self.new(object) + end + return a + end + end + end +end diff --git a/lib/rest_connection/rightscale/server.rb b/lib/rest_connection/rightscale/server.rb index 68337a5..5b84b82 100644 --- a/lib/rest_connection/rightscale/server.rb +++ b/lib/rest_connection/rightscale/server.rb @@ -19,6 +19,8 @@ class Server include RightScale::Api::Base extend RightScale::Api::BaseExtend include SshHax + include RightScale::Api::Taggable + extend RightScale::Api::TaggableExtend def self.create(opts) create_options = Hash.new @@ -305,5 +307,44 @@ def run_executable_and_wait_for_completed(executable, opts=nil) run_executable(executable, opts).wait_for_completed end -end + # Override Taggable mixin so that it sets tags on both next and current instances + def add_tags(*args) + return false if args.empty? + args.uniq! + Tag.set(self.href, args) + Tag.set(self.current_instance_href, args) if self.current_instance_href + self.tags(true) + end + + def remove_tags(*args) + return false if args.empty? + args.uniq! + Tag.unset(self.href, args) + Tag.unset(self.current_instance_href, args) if self.current_instance_href + self.tags(true) + end + def get_tag_values(*tag_keys) + ret = {} + tags = {"self" => Tag.search_by_href(self.href)} + if self.current_instance_href + tags["current_instance"] = Tag.search_by_href(self.current_instance_href) + end + tags.each { |res,ary| + ret[res] ||= {} + ary.each { |hsh| + next unless hsh["name"].start_with?("info:") + key, value = hsh["name"].split(":").last.split("=") + ret[res][key] = value if tag_keys.include?(key) + } + } + return ret + end + + def clear_tags(namespace = nil) + tags = Tag.search_by_href(self.href) + tags.deep_merge! Tag.search_by_href(self.current_instance_href) if self.current_instance_href + tags = tags.select { |hsh| hsh["name"].start_with?("#{namespace}:") } if namespace + self.remove_tags(*(tags.map { |k,v| v })) + end +end diff --git a/lib/rest_connection/rightscale/server_template.rb b/lib/rest_connection/rightscale/server_template.rb index 5c5ce4a..3ab4758 100644 --- a/lib/rest_connection/rightscale/server_template.rb +++ b/lib/rest_connection/rightscale/server_template.rb @@ -16,6 +16,9 @@ class ServerTemplate include RightScale::Api::Base extend RightScale::Api::BaseExtend + include RightScale::Api::Taggable + extend RightScale::Api::TaggableExtend + def initialize(params) @params = params end From a069870f798ba87a4972fa0c4f704f4d248f9f39 Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Mon, 27 Jun 2011 15:01:24 -0700 Subject: [PATCH 063/239] [Taggable] changed info tag function names --- lib/rest_connection/rightscale/rightscale_api_taggable.rb | 6 +++--- lib/rest_connection/rightscale/server.rb | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/rest_connection/rightscale/rightscale_api_taggable.rb b/lib/rest_connection/rightscale/rightscale_api_taggable.rb index 5860651..f37b3b8 100644 --- a/lib/rest_connection/rightscale/rightscale_api_taggable.rb +++ b/lib/rest_connection/rightscale/rightscale_api_taggable.rb @@ -33,7 +33,7 @@ def tags(reload=false) @params["tags"] end - def remove_tags_by_keys(*tag_keys) + def remove_info_tags(*tag_keys) tags_to_unset = [] tags = get_tag_values(*(tag_keys.uniq)) tags.each { |res,hsh| @@ -44,7 +44,7 @@ def remove_tags_by_keys(*tag_keys) self.remove_tags(*tags_to_unset) end - def set_tags_by_keys(hsh={}) + def set_info_tags(hsh={}) keys_to_change = [] tags_to_set = [] hsh.each { |k,v| keys_to_change << k; tags_to_set << "info:#{k}=#{v}" } @@ -52,7 +52,7 @@ def set_tags_by_keys(hsh={}) self.add_tags(*tags_to_set) end - def get_tag_values(*tag_keys) + def get_info_tags(*tag_keys) ret = {} tags = {"self" => self.tags(true)} tags.each { |res,ary| diff --git a/lib/rest_connection/rightscale/server.rb b/lib/rest_connection/rightscale/server.rb index 5b84b82..c11ad20 100644 --- a/lib/rest_connection/rightscale/server.rb +++ b/lib/rest_connection/rightscale/server.rb @@ -324,7 +324,7 @@ def remove_tags(*args) self.tags(true) end - def get_tag_values(*tag_keys) + def get_info_tags(*tag_keys) ret = {} tags = {"self" => Tag.search_by_href(self.href)} if self.current_instance_href From 5f224b32a1041a0b41ae395465f7da4103ce7f9f Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Mon, 27 Jun 2011 16:45:32 -0700 Subject: [PATCH 064/239] Fixes --- .../rightscale/rightscale_api_base.rb | 13 +++++++++++-- lib/rest_connection/rightscale/server.rb | 5 +++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/lib/rest_connection/rightscale/rightscale_api_base.rb b/lib/rest_connection/rightscale/rightscale_api_base.rb index 9c84964..7a0d25e 100644 --- a/lib/rest_connection/rightscale/rightscale_api_base.rb +++ b/lib/rest_connection/rightscale/rightscale_api_base.rb @@ -228,10 +228,19 @@ def [](name) try_these.each do |t| if @params[t] return @params[t] - else - return @params[t] end end + nil + end + + def []=(name,val) + try_these = [name, name.to_s.gsub(/_/,'-'), name.to_sym] + try_these.each do |t| + if @params[t] + @params[t] = val + end + end + val end def rs_id diff --git a/lib/rest_connection/rightscale/server.rb b/lib/rest_connection/rightscale/server.rb index c11ad20..6aacd3d 100644 --- a/lib/rest_connection/rightscale/server.rb +++ b/lib/rest_connection/rightscale/server.rb @@ -307,6 +307,11 @@ def run_executable_and_wait_for_completed(executable, opts=nil) run_executable(executable, opts).wait_for_completed end + def dns_name + self.settings unless self["dns_name"] + self["dns_name"] + end + # Override Taggable mixin so that it sets tags on both next and current instances def add_tags(*args) return false if args.empty? From edc587fb502fd2a201f083454c34ac25c43f2d10 Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Tue, 5 Jul 2011 18:05:29 -0700 Subject: [PATCH 065/239] bug fixes; new API 1.5 resources --- lib/rest_connection/rightscale/deployment.rb | 11 --- lib/rest_connection/rightscale/mc_instance.rb | 20 +++- .../rightscale/mc_multi_cloud_image.rb | 54 +++++++++++ .../mc_multi_cloud_image_setting.rb | 42 +++++++++ lib/rest_connection/rightscale/mc_server.rb | 8 ++ .../rightscale/mc_server_template.rb | 46 +++++++++ lib/rest_connection/rightscale/mc_tag.rb | 67 +++++++++++++ .../rightscale/monitoring_metric.rb | 9 ++ .../rightscale/rightscale_api_mc_taggable.rb | 94 +++++++++++++++++++ .../rightscale/rightscale_api_resources.rb | 4 + .../rightscale/server_interface.rb | 30 ------ 11 files changed, 340 insertions(+), 45 deletions(-) create mode 100644 lib/rest_connection/rightscale/mc_multi_cloud_image.rb create mode 100644 lib/rest_connection/rightscale/mc_multi_cloud_image_setting.rb create mode 100644 lib/rest_connection/rightscale/mc_server_template.rb create mode 100644 lib/rest_connection/rightscale/mc_tag.rb create mode 100644 lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb diff --git a/lib/rest_connection/rightscale/deployment.rb b/lib/rest_connection/rightscale/deployment.rb index befedd6..1979d33 100644 --- a/lib/rest_connection/rightscale/deployment.rb +++ b/lib/rest_connection/rightscale/deployment.rb @@ -26,17 +26,6 @@ def reload @params end - def cloud_id - unless @cloud_id - if self.nickname =~ /cloud_[0-9]+/ - @cloud_id = self.nickname.match(/cloud_[0-9]+/)[0].match(/[0-9]+/)[0].to_i - else - @cloud_id = nil # if self.nickname =~ /cloud_multicloud/ - end - end - @cloud_id - end - def self.create(opts) location = connection.post(self.resource_plural_name, self.resource_singular_name.to_sym => opts) newrecord = self.new('href' => location) diff --git a/lib/rest_connection/rightscale/mc_instance.rb b/lib/rest_connection/rightscale/mc_instance.rb index b7f83fb..e86219f 100644 --- a/lib/rest_connection/rightscale/mc_instance.rb +++ b/lib/rest_connection/rightscale/mc_instance.rb @@ -19,6 +19,8 @@ class McInstance include RightScale::Api::Gateway extend RightScale::Api::GatewayExtend + include RightScale::Api::McTaggable + extend RightScale::Api::McTaggableExtend attr_accessor :monitoring_metrics def resource_plural_name @@ -42,11 +44,10 @@ def self.parse_args(cloud_id) end def show - # Remove this hack-y workaround once 1.5 is fixed - c = Cloud[self.cloud].first - view = (c.name =~ /euca/i or c.description =~ /euca/i ? "full" : "default") +# c = Cloud[self.cloud].first +# view = (c.name =~ /euca/i or c.description =~ /euca/i ? "full" : "default") inst_href = URI.parse(self.href) - @params.merge! connection.get(inst_href.path, 'view' => view) + @params.merge! connection.get(inst_href.path, 'view' => "full") end def update @@ -116,4 +117,15 @@ def fetch_monitoring_metrics } @monitoring_metrics end + + def get_sketchy_data(params) + metric = fetch_monitoring_metrics.detect { |mm| mm.plugin == params['plugin_name'] and mm.view == params['plugin_type'] } + raise "Metric not found!" unless metric + metric.data(params['start'], params['end']) + end + + def reboot + self.show + connection.post(URI.parse(self.href).path + '/reboot') + end end diff --git a/lib/rest_connection/rightscale/mc_multi_cloud_image.rb b/lib/rest_connection/rightscale/mc_multi_cloud_image.rb new file mode 100644 index 0000000..b738c4b --- /dev/null +++ b/lib/rest_connection/rightscale/mc_multi_cloud_image.rb @@ -0,0 +1,54 @@ +# This file is part of RestConnection +# +# RestConnection is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# RestConnection is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with RestConnection. If not, see . + +# +# You must have Beta v1.5 API access to use these internal API calls. +# +class McMultiCloudImage + include RightScale::Api::Gateway + extend RightScale::Api::GatewayExtend + include RightScale::Api::McTaggable + extend RightScale::Api::McTaggableExtend + attr_reader :settings + + def resource_plural_name + "multi_cloud_images" + end + + def resource_singular_name + "multi_cloud_image" + end + + def self.resource_plural_name + "multi_cloud_images" + end + + def self.resource_singular_name + "multi_cloud_image" + end + + def self.parse_args(server_template_id=nil) + server_template_id ? "server_templates/#{server_template_id}/" : "" + end + + def get_settings + @settings = [] + url = URI.parse(self.href) + connection.get(url.path + '/settings').each { |s| + @settings << McMultiCloudImageSetting.new(s) + } + @settings + end +end diff --git a/lib/rest_connection/rightscale/mc_multi_cloud_image_setting.rb b/lib/rest_connection/rightscale/mc_multi_cloud_image_setting.rb new file mode 100644 index 0000000..6c16073 --- /dev/null +++ b/lib/rest_connection/rightscale/mc_multi_cloud_image_setting.rb @@ -0,0 +1,42 @@ +# This file is part of RestConnection +# +# RestConnection is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# RestConnection is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with RestConnection. If not, see . + +# +# You must have Beta v1.5 API access to use these internal API calls. +# +class McMultiCloudImageSetting + include RightScale::Api::Gateway + extend RightScale::Api::GatewayExtend + + def resource_plural_name + "settings" + end + + def resource_singular_name + "setting" + end + + def self.resource_plural_name + "settings" + end + + def self.resource_singular_name + "setting" + end + + def self.parse_args(multi_cloud_image_id) + "multi_cloud_images/#{multi_cloud_image_id}/" + end +end diff --git a/lib/rest_connection/rightscale/mc_server.rb b/lib/rest_connection/rightscale/mc_server.rb index 0a7c8d5..1f6d115 100644 --- a/lib/rest_connection/rightscale/mc_server.rb +++ b/lib/rest_connection/rightscale/mc_server.rb @@ -19,6 +19,8 @@ class McServer < Server include RightScale::Api::Gateway extend RightScale::Api::GatewayExtend + include RightScale::Api::McTaggable + extend RightScale::Api::McTaggableExtend attr_accessor :current_instance, :next_instance, :inputs def resource_plural_name @@ -207,4 +209,10 @@ def settings_current def reload_current settings # Gets all instance (including current) information end + + def get_sketchy_data(params) + settings + raise "No current instance found!" unless @current_instance + @current_instance.get_sketchy_data(params) + end end diff --git a/lib/rest_connection/rightscale/mc_server_template.rb b/lib/rest_connection/rightscale/mc_server_template.rb new file mode 100644 index 0000000..b7b707b --- /dev/null +++ b/lib/rest_connection/rightscale/mc_server_template.rb @@ -0,0 +1,46 @@ +# This file is part of RestConnection +# +# RestConnection is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# RestConnection is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with RestConnection. If not, see . + +# +# You must have Beta v1.5 API access to use these internal API calls. +# +class McServerTemplate + include RightScale::Api::Gateway + extend RightScale::Api::GatewayExtend + include RightScale::Api::McTaggable + extend RightScale::Api::McTaggableExtend + attr_reader :mcis + + def resource_plural_name + "server_templates" + end + + def resource_singular_name + "server_template" + end + + def self.resource_plural_name + "server_templates" + end + + def self.resource_singular_name + "server_template" + end + + def get_mcis_and_settings + @mcis = McMultiCloudImage.find_all(self.rs_id) + @mcis.each { |mci| mci.get_settings } + end +end diff --git a/lib/rest_connection/rightscale/mc_tag.rb b/lib/rest_connection/rightscale/mc_tag.rb new file mode 100644 index 0000000..8f7fe6a --- /dev/null +++ b/lib/rest_connection/rightscale/mc_tag.rb @@ -0,0 +1,67 @@ +# This file is part of RestConnection +# +# RestConnection is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# RestConnection is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with RestConnection. If not, see . + +# +# You must have Beta v1.5 API access to use these internal API calls. +# +class McTag + include RightScale::Api::Gateway + extend RightScale::Api::GatewayExtend + + def resource_plural_name + "tags" + end + + def resource_singular_name + "tag" + end + + def self.resource_plural_name + "tags" + end + + def self.resource_singular_name + "tag" + end + + def self.search(resource_type, tags) #, include_tags_with_prefix = false) + result = connection.get("tags/by_tag", :resource_type => resource_type.to_s, :tags => tags) + end + + def self.search_by_href(*resource_hrefs) + connection.get("tags/by_resource", :resource_hrefs => resource_hrefs) + end + #TAGGABLE_RESOURCES = [ 'Server', 'Ec2EbsSnapshot', 'Ec2EbsVolume', 'Ec2Image', 'Image', 'ServerArray', 'Ec2Instance', + # 'Instance', 'Deployment', 'ServerTemplate', 'Ec2ServerTemplate' ] + # + # Tag.set( resource_href, tags ) where tags is an array of tags to set on the resource. + def self.multi_add(resource_hrefs, tags) + resource_hrefs = [resource_hrefs] unless resource_hrefs.is_a?(Array) + connection.post("tags/multi_add", :resource_hrefs => resource_hrefs, :tags => tags) + end + + def self.set(resource_hrefs, tags) + self.multi_add(resource_hrefs, tags) + end + + def self.multi_delete(resource_hrefs, tags) + resource_hrefs = [resource_hrefs] unless resource_hrefs.is_a?(Array) + connection.post("tags/multi_delete", :resource_hrefs => resource_hrefs, :tags => tags) + end + + def self.unset(resource_hrefs, tags) + self.multi_delete(resource_hrefs, tags) + end +end diff --git a/lib/rest_connection/rightscale/monitoring_metric.rb b/lib/rest_connection/rightscale/monitoring_metric.rb index 07791be..5138a01 100644 --- a/lib/rest_connection/rightscale/monitoring_metric.rb +++ b/lib/rest_connection/rightscale/monitoring_metric.rb @@ -23,4 +23,13 @@ class MonitoringMetric def self.parse_args(cloud_id, instance_id) "clouds/#{cloud_id}/instances/#{instance_id}/" end + + def data(start_time = "-60", end_time = "0") + params = {'start' => start_time.to_s, 'end' => end_time.to_s} + monitor = connection.get(URI.parse(self.href).path + "/data", params) + # NOTE: The following is a dirty hack + monitor['data'] = monitor['variables_data'].first + monitor['data']['value'] = monitor['data']['points'] + monitor + end end diff --git a/lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb b/lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb new file mode 100644 index 0000000..c4b8e46 --- /dev/null +++ b/lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb @@ -0,0 +1,94 @@ +# This file is part of RestConnection +# +# RestConnection is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# RestConnection is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with RestConnection. If not, see . + +# +# You must have Beta v1.5 API access to use these internal API calls. +# +module RightScale + module Api + module McTaggable + def add_tags(*args) + return false if args.empty? + McTag.set(self.href, args.uniq) + self.tags(true) + end + + def remove_tags(*args) + return false if args.empty? + McTag.unset(self.href, args.uniq) + self.tags(true) + end + + def tags(reload=false) + @params["tags"] = McTag.search_by_href(self.href) if reload + @params["tags"] + end + + def remove_info_tags(*tag_keys) + tags_to_unset = [] + tags = get_tag_values(*(tag_keys.uniq)) + tags.each { |res,hsh| + hsh.each { |k,v| + tags_to_unset << "info:#{k}=#{v}" + } + } + self.remove_tags(*tags_to_unset) + end + + def set_info_tags(hsh={}) + keys_to_change = [] + tags_to_set = [] + hsh.each { |k,v| keys_to_change << k; tags_to_set << "info:#{k}=#{v}" } + self.remove_tags_by_keys(*keys_to_change) + self.add_tags(*tags_to_set) + end + + def get_info_tags(*tag_keys) + ret = {} + tags = {"self" => self.tags(true)} + tags.each { |res,ary| + ret[res] ||= {} + ary.each { |hsh| + next unless hsh["name"].start_with?("info:") + key, value = hsh["name"].split(":").last.split("=") + ret[res][key] = value if tag_keys.include?(key) + } + } + return ret + end + + def set_tags_to(*args) + self.clear_tags("info") + self.add_tags(*(args.uniq)) + end + + def clear_tags(namespace = nil) + tag_ary = self.tags(true) + tag_ary = tag_ary.select { |hsh| hsh["name"].start_with?("#{namespace}:") } if namespace + self.remove_tags(*(tag_ary.map { |k,v| v })) + end + end + + module McTaggableExtend + def find_by_tags(*args) + a = Array.new + McTag.search(self.resource_singular_name, args.uniq).each do |object| + a << self.new(object) + end + return a + end + end + end +end diff --git a/lib/rest_connection/rightscale/rightscale_api_resources.rb b/lib/rest_connection/rightscale/rightscale_api_resources.rb index 267c979..97b7720 100644 --- a/lib/rest_connection/rightscale/rightscale_api_resources.rb +++ b/lib/rest_connection/rightscale/rightscale_api_resources.rb @@ -18,6 +18,7 @@ require 'rest_connection/rightscale/rightscale_api_internal' require 'rest_connection/rightscale/rightscale_api_gateway' require 'rest_connection/rightscale/rightscale_api_taggable' +require 'rest_connection/rightscale/rightscale_api_mc_taggable' require 'rest_connection/rightscale/executable' require 'rest_connection/rightscale/server' require 'rest_connection/rightscale/deployment' @@ -40,6 +41,9 @@ require 'rest_connection/rightscale/server_interface' require 'rest_connection/rightscale/mc_instance' require 'rest_connection/rightscale/monitoring_metric' +require 'rest_connection/rightscale/mc_multi_cloud_image_setting' +require 'rest_connection/rightscale/mc_multi_cloud_image' +require 'rest_connection/rightscale/mc_server_template' require 'rest_connection/rightscale/ec2_ssh_key_internal' require 'rest_connection/rightscale/server_template_internal' require 'rest_connection/rightscale/right_script_internal' diff --git a/lib/rest_connection/rightscale/server_interface.rb b/lib/rest_connection/rightscale/server_interface.rb index 4fc38a6..b7d9de1 100644 --- a/lib/rest_connection/rightscale/server_interface.rb +++ b/lib/rest_connection/rightscale/server_interface.rb @@ -236,22 +236,6 @@ def attach_volume(params) @impl.attach_volume(params) unless @multicloud end - def get_sketchy_data(params = {}) - @impl.get_sketchy_data(translate_sketchy_params(params)) - end - - def translate_sketchy_params(params) - return params - #TODO -# ret = {} -# if @multicloud #API 1.5 -# ret['period'] = (ret['period'] or (ret['start'] -# else #API 1.0 -# ret['start'] = -# end -# monitor=server.get_sketchy_data({'start'=>-60,'end'=>-20,'plugin_name'=>"cpu-0",'plugin_type'=>"cpu-idle"}) - end - def wait_for_state(st,timeout=1200) if @multicloud and st == "stopped" st = "inactive" @@ -259,20 +243,6 @@ def wait_for_state(st,timeout=1200) @impl.wait_for_state(st,timeout) end - # takes Bool argument to wait for state change (insurance that we can detect a reboot happened) - def reboot(wait = false) - if @multicloud - connection.logger("WARNING: Gateway Servers do not support reboot natively. Using SshHax for now.") - old_state = self.state - @impl.spot_check_command?("init 6") - if wait - wait_for_state_change(old_change) - wait_for_state("operational") - end - end - @impl.reboot(wait) unless @multicloud - end - def save(new_params = nil) if new_params @impl.settings From 901fad5a40e751458a18dcd43c517fb860bc7cba Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Thu, 7 Jul 2011 14:49:01 -0700 Subject: [PATCH 066/239] Updates for cross-API ST and MCI support --- lib/rest_connection.rb | 39 +++++++++++++++++++ .../mc_multi_cloud_image_setting.rb | 4 ++ .../rightscale/mc_server_template.rb | 12 ++++-- .../rightscale/multi_cloud_image_internal.rb | 15 +++++++ .../rightscale/rightscale_api_resources.rb | 2 +- .../rightscale/server_template.rb | 10 ++++- 6 files changed, 77 insertions(+), 5 deletions(-) diff --git a/lib/rest_connection.rb b/lib/rest_connection.rb index 64a1946..f199c39 100644 --- a/lib/rest_connection.rb +++ b/lib/rest_connection.rb @@ -30,6 +30,45 @@ module RestConnection {"cloud_id" => 4, "name" => "AWS AP-Singapore"}, {"cloud_id" => 5, "name" => "AWS AP-Tokyo"}] + # Check for API 0.1 Access + def self.api0_1? + unless class_variable_defined?("@@api0_1") + begin + Ec2SshKeyInternal.find_all + @@api0_1 = true + rescue + @@api0_1 = false + end + end + return @@api0_1 + end + + # Check for API 1.0 Access + def self.api1_0? + unless class_variable_defined?("@@api1_0") + begin + Ec2SecurityGroup.find_all + @@api1_0 = true + rescue + @@api1_0 = false + end + end + return @@api1_0 + end + + # Check for API 1.5 Beta Access + def self.api1_5? + unless class_variable_defined?("@@api1_5") + begin + Cloud.find_all + @@api1_5 = true + rescue + @@api1_5 = false + end + end + return @@api1_5 + end + class Connection # Settings is a hash of options for customizing the connection. # settings.merge! { diff --git a/lib/rest_connection/rightscale/mc_multi_cloud_image_setting.rb b/lib/rest_connection/rightscale/mc_multi_cloud_image_setting.rb index 6c16073..659b76d 100644 --- a/lib/rest_connection/rightscale/mc_multi_cloud_image_setting.rb +++ b/lib/rest_connection/rightscale/mc_multi_cloud_image_setting.rb @@ -39,4 +39,8 @@ def self.resource_singular_name def self.parse_args(multi_cloud_image_id) "multi_cloud_images/#{multi_cloud_image_id}/" end + + def cloud_id + self.cloud.split(/\//).last.to_i + end end diff --git a/lib/rest_connection/rightscale/mc_server_template.rb b/lib/rest_connection/rightscale/mc_server_template.rb index b7b707b..e0ce17f 100644 --- a/lib/rest_connection/rightscale/mc_server_template.rb +++ b/lib/rest_connection/rightscale/mc_server_template.rb @@ -21,7 +21,6 @@ class McServerTemplate extend RightScale::Api::GatewayExtend include RightScale::Api::McTaggable extend RightScale::Api::McTaggableExtend - attr_reader :mcis def resource_plural_name "server_templates" @@ -40,7 +39,14 @@ def self.resource_singular_name end def get_mcis_and_settings - @mcis = McMultiCloudImage.find_all(self.rs_id) - @mcis.each { |mci| mci.get_settings } + @params["multi_cloud_images"] = McMultiCloudImage.find_all(self.rs_id) + @params["multi_cloud_images"].each { |mci| mci.get_settings } + end + + def multi_cloud_images + unless @params["multi_cloud_images"] + get_mcis_and_settings + end + @params["multi_cloud_images"] end end diff --git a/lib/rest_connection/rightscale/multi_cloud_image_internal.rb b/lib/rest_connection/rightscale/multi_cloud_image_internal.rb index 2a227dd..c4b5f2f 100644 --- a/lib/rest_connection/rightscale/multi_cloud_image_internal.rb +++ b/lib/rest_connection/rightscale/multi_cloud_image_internal.rb @@ -45,4 +45,19 @@ def clone MultiCloudImage.new(:href => connection.post(t.path + "/clone")) end + def initialize(params={}) + @params = params + if @params["multi_cloud_image_cloud_settings"] + @params["multi_cloud_image_cloud_settings"].map! { |setting| + # Have to reject because API0.1 returns all clouds + next if setting["fingerprint"] || setting["cloud_id"] > 10 + MultiCloudImageCloudSettingInternal.new(setting) + } + @params["multi_cloud_image_cloud_settings"].compact! + end + end + + def supported_cloud_ids + @params["multi_cloud_image_cloud_settings"].map { |mcics| mcics.cloud_id } + end end diff --git a/lib/rest_connection/rightscale/rightscale_api_resources.rb b/lib/rest_connection/rightscale/rightscale_api_resources.rb index 97b7720..ec547c6 100644 --- a/lib/rest_connection/rightscale/rightscale_api_resources.rb +++ b/lib/rest_connection/rightscale/rightscale_api_resources.rb @@ -47,8 +47,8 @@ require 'rest_connection/rightscale/ec2_ssh_key_internal' require 'rest_connection/rightscale/server_template_internal' require 'rest_connection/rightscale/right_script_internal' -require 'rest_connection/rightscale/multi_cloud_image_internal' require 'rest_connection/rightscale/multi_cloud_image_cloud_setting_internal' +require 'rest_connection/rightscale/multi_cloud_image_internal' require 'rest_connection/rightscale/ec2_server_array' require 'rest_connection/rightscale/mc_security_group' require 'rest_connection/rightscale/mc_datacenter' diff --git a/lib/rest_connection/rightscale/server_template.rb b/lib/rest_connection/rightscale/server_template.rb index 3ab4758..e25b71e 100644 --- a/lib/rest_connection/rightscale/server_template.rb +++ b/lib/rest_connection/rightscale/server_template.rb @@ -63,7 +63,15 @@ def fetch_executables end def fetch_multi_cloud_images - @params["multi_cloud_images"] = RsInternal.get_server_template_multi_cloud_images(self.href) + @params["multi_cloud_images"] = [] + ServerTemplateInternal.new(:href => self.href).multi_cloud_images.each { |mci_params| + @params["multi_cloud_images"] << MultiCloudImageInternal.new(mci_params) + } + mcis = McServerTemplate.find(self.rs_id.to_i).multi_cloud_images + @params["multi_cloud_images"].each_index { |i| + @params["multi_cloud_images"][i]["multi_cloud_image_cloud_settings"] += mcis[i].settings + } + @params["multi_cloud_images"] end # The RightScale api calls this 'duplicate' but is more popularly known as 'clone' from a users perspective From 0d8947f17f5a2b7681730093666217bc3876df76 Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Fri, 8 Jul 2011 10:54:14 -0700 Subject: [PATCH 067/239] [API 1.5] Added McInstanceType resource --- .../rightscale/mc_instance_type.rb | 47 +++++++++++++++++++ .../rightscale/rightscale_api_resources.rb | 1 + 2 files changed, 48 insertions(+) create mode 100644 lib/rest_connection/rightscale/mc_instance_type.rb diff --git a/lib/rest_connection/rightscale/mc_instance_type.rb b/lib/rest_connection/rightscale/mc_instance_type.rb new file mode 100644 index 0000000..4244007 --- /dev/null +++ b/lib/rest_connection/rightscale/mc_instance_type.rb @@ -0,0 +1,47 @@ +# This file is part of RestConnection +# +# RestConnection is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# RestConnection is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with RestConnection. If not, see . + +# +# You must have Beta v1.5 API access to use these internal API calls. +# +class McInstanceType + include RightScale::Api::Gateway + extend RightScale::Api::GatewayExtend + + def resource_plural_name + "instance_types" + end + + def resource_singular_name + "instance_type" + end + + def self.resource_plural_name + "instance_types" + end + + def self.resource_singular_name + "instance_type" + end + + def self.parse_args(cloud_id) + "clouds/#{cloud_id}/" + end + + def show + inst_href = URI.parse(self.href) + @params.merge! connection.get(inst_href.path, 'view' => "default") + end +end diff --git a/lib/rest_connection/rightscale/rightscale_api_resources.rb b/lib/rest_connection/rightscale/rightscale_api_resources.rb index ec547c6..86cfe86 100644 --- a/lib/rest_connection/rightscale/rightscale_api_resources.rb +++ b/lib/rest_connection/rightscale/rightscale_api_resources.rb @@ -57,6 +57,7 @@ require 'rest_connection/rightscale/credential' require 'rest_connection/rightscale/cloud' require 'rest_connection/rightscale/instance_type' +require 'rest_connection/rightscale/mc_instance_type' require 'rest_connection/rightscale/mc_image' require 'rest_connection/rightscale/macro' require 'rest_connection/rightscale/s3_bucket' From 9909ccf751c9e34cef30ebfb87dec5f65d9c3db8 Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Fri, 8 Jul 2011 18:51:58 +0000 Subject: [PATCH 068/239] adding private-ip method for *servers --- .../rightscale/mc_multi_cloud_image.rb | 4 ++++ lib/rest_connection/rightscale/mc_server.rb | 7 +++++++ .../rightscale/multi_cloud_image.rb | 14 ++++++++++++++ .../rightscale/multi_cloud_image_internal.rb | 15 ++++++++++++--- lib/rest_connection/rightscale/server.rb | 5 +++++ .../rightscale/server_interface.rb | 1 + spec/multi.rb | 16 ++++++++++++++++ 7 files changed, 59 insertions(+), 3 deletions(-) create mode 100644 spec/multi.rb diff --git a/lib/rest_connection/rightscale/mc_multi_cloud_image.rb b/lib/rest_connection/rightscale/mc_multi_cloud_image.rb index b738c4b..68925f6 100644 --- a/lib/rest_connection/rightscale/mc_multi_cloud_image.rb +++ b/lib/rest_connection/rightscale/mc_multi_cloud_image.rb @@ -43,6 +43,10 @@ def self.parse_args(server_template_id=nil) server_template_id ? "server_templates/#{server_template_id}/" : "" end + def supported_cloud_ids + @settings.map { |mcics| mcics.cloud_id } + end + def get_settings @settings = [] url = URI.parse(self.href) diff --git a/lib/rest_connection/rightscale/mc_server.rb b/lib/rest_connection/rightscale/mc_server.rb index 1f6d115..921a078 100644 --- a/lib/rest_connection/rightscale/mc_server.rb +++ b/lib/rest_connection/rightscale/mc_server.rb @@ -190,6 +190,13 @@ def dns_name nil end + def private_ip + if @current_instance + return @current_instance.private_ip_addresses.first || @current_instance.private_dns_names.first + end + nil + end + def save @next_instance.save end diff --git a/lib/rest_connection/rightscale/multi_cloud_image.rb b/lib/rest_connection/rightscale/multi_cloud_image.rb index 6594a67..2b9d420 100644 --- a/lib/rest_connection/rightscale/multi_cloud_image.rb +++ b/lib/rest_connection/rightscale/multi_cloud_image.rb @@ -16,4 +16,18 @@ class MultiCloudImage include RightScale::Api::Base extend RightScale::Api::BaseExtend + + def supported_cloud_ids + @params["multi_cloud_image_cloud_settings"].map { |mcics| mcics.cloud_id } + end + + # You must have access to multiple APIs for this (0.1, and 1.5) + def find_and_flatten_settings() + some_settings = McMultiCloudImage.find(rs_id.to_i).get_settings + internal = MultiCloudImageInternal.new("href" => self.href) + internal.reload + more_settings = internal.settings + @params["multi_cloud_image_cloud_settings"] = some_settings + more_settings + end + end diff --git a/lib/rest_connection/rightscale/multi_cloud_image_internal.rb b/lib/rest_connection/rightscale/multi_cloud_image_internal.rb index c4b5f2f..45ee630 100644 --- a/lib/rest_connection/rightscale/multi_cloud_image_internal.rb +++ b/lib/rest_connection/rightscale/multi_cloud_image_internal.rb @@ -45,9 +45,8 @@ def clone MultiCloudImage.new(:href => connection.post(t.path + "/clone")) end - def initialize(params={}) - @params = params - if @params["multi_cloud_image_cloud_settings"] + def transform_settings + if @params["multi_cloud_image_cloud_settings"] && @params["multi_cloud_image_cloud_settings"].first.is_a?(Hash) @params["multi_cloud_image_cloud_settings"].map! { |setting| # Have to reject because API0.1 returns all clouds next if setting["fingerprint"] || setting["cloud_id"] > 10 @@ -57,6 +56,16 @@ def initialize(params={}) end end + def initialize(params={}) + @params = params + transform_settings + end + + def settings + transform_settings + @params["multi_cloud_image_cloud_settings"] + end + def supported_cloud_ids @params["multi_cloud_image_cloud_settings"].map { |mcics| mcics.cloud_id } end diff --git a/lib/rest_connection/rightscale/server.rb b/lib/rest_connection/rightscale/server.rb index 6aacd3d..07a4acd 100644 --- a/lib/rest_connection/rightscale/server.rb +++ b/lib/rest_connection/rightscale/server.rb @@ -312,6 +312,11 @@ def dns_name self["dns_name"] end + def private_ip + self.settings unless @params["private-ip-address"] + @params["private-ip-address"] + end + # Override Taggable mixin so that it sets tags on both next and current instances def add_tags(*args) return false if args.empty? diff --git a/lib/rest_connection/rightscale/server_interface.rb b/lib/rest_connection/rightscale/server_interface.rb index b7d9de1..8a03d80 100644 --- a/lib/rest_connection/rightscale/server_interface.rb +++ b/lib/rest_connection/rightscale/server_interface.rb @@ -159,6 +159,7 @@ def map_instance(to, val) if to == "1.0" return val end + val end def translate_href(old_href) diff --git a/spec/multi.rb b/spec/multi.rb new file mode 100644 index 0000000..beb64da --- /dev/null +++ b/spec/multi.rb @@ -0,0 +1,16 @@ +require 'rubygems' +require 'rest_connection' +require 'spec' +require 'ruby-debug' + +describe MultiCloudImage do + it "goes" do + + mci = MultiCloudImage.find(46563) + mci = MultiCloudImage.find(57499) + settings = mci.find_and_flatten_settings + debugger +puts "blah" + + end +end From cd01d066b3ba53273dabff8df596fda49ec59e4a Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Fri, 8 Jul 2011 16:58:26 -0700 Subject: [PATCH 069/239] Added get_sketchy_data, set_inputs, and reload_as_next --- lib/rest_connection/rightscale/mc_server.rb | 22 +++++----------- lib/rest_connection/rightscale/server.rb | 25 ++++++++----------- .../rightscale/server_interface.rb | 13 ++++++++++ 3 files changed, 29 insertions(+), 31 deletions(-) diff --git a/lib/rest_connection/rightscale/mc_server.rb b/lib/rest_connection/rightscale/mc_server.rb index 921a078..017bd65 100644 --- a/lib/rest_connection/rightscale/mc_server.rb +++ b/lib/rest_connection/rightscale/mc_server.rb @@ -119,12 +119,9 @@ def settings #show @params end - def get_sketchy_data(params = {}) - raise "Congratulations on making it this far into the Multicloud Monkey." -# TODO: Inprogress -# base_href = self.href.split(/\/server/).first -# base_href = base_href.split(/\/deployment/).first if base_href.include?(/\/deployment/) -# @monitors ? @monitors = MonitoringMetric.new('href' => MonitoringMetric.href(find_all(@cloud_id + def get_sketchy_data(params) + raise "No current instance found to check!" unless @current_instance + @current_instance.get_sketchy_data(params) end def monitoring @@ -150,10 +147,6 @@ def server_template_href return @next_instance.server_template end - def tags - [] - end - def deployment_href hash_of_links["deployment"] end @@ -199,21 +192,18 @@ def private_ip def save @next_instance.save + @current_instance.update if @current_instance end def update @next_instance.save end - def save_current - @current_instance.update if @current_instance - end - - def settings_current + def reload_as_current settings # Gets all instance (including current) information end - def reload_current + def reload_as_next settings # Gets all instance (including current) information end diff --git a/lib/rest_connection/rightscale/server.rb b/lib/rest_connection/rightscale/server.rb index 07a4acd..adb1e84 100644 --- a/lib/rest_connection/rightscale/server.rb +++ b/lib/rest_connection/rightscale/server.rb @@ -185,7 +185,8 @@ def set_input(name, value) def set_inputs(hash = {}) serv_href = URI.parse(self.href) - connection.put(serv_href.path, :server => {:parameters => hash}) + params = self.parameters.deep_merge hash + connection.put(serv_href.path, :server => {:parameters => params}) end def set_template(href) @@ -247,22 +248,16 @@ def wait_for_state_change(old_state = nil) raise("FATAL: timeout after #{timeout}s waiting for state change") end - # Save the servers parameters to the current server (instead of the next server) - def save_current - uri = URI.parse(self.href) - connection.put(uri.path + "/current", resource_singular_name.to_sym => @params) + # Reload the server's basic information from the current server instance + def reload_as_current + uri = URI.parse(self.href + "/current") + @params.merge! connection.get(uri.path) end - # Load server's settings from the current server (instead of the next server) - def settings_current - serv_href = URI.parse(self.href) - @params.merge! connection.get(serv_href.path + "/current" + "/settings") - end - - # Reload the server's basic information from the current server. - def reload_current - uri = URI.parse(self.href) - @params ? @params.merge!(connection.get(uri.path + "/current")) : @params = connection.get(uri.path) + # Reload the server's basic information from the next server instance + def reload_as_next + uri = URI.parse(self.href.gsub(/\/current/,"")) + @params.merge! connection.get(uri.path) end # Complex logic for determining the cloud_id of even a stopped server diff --git a/lib/rest_connection/rightscale/server_interface.rb b/lib/rest_connection/rightscale/server_interface.rb index 8a03d80..c46a212 100644 --- a/lib/rest_connection/rightscale/server_interface.rb +++ b/lib/rest_connection/rightscale/server_interface.rb @@ -256,6 +256,19 @@ def save(new_params = nil) @impl.save end + def set_inputs(hash = {}) + if @multicloud + @impl.set_inputs(hash) + else + if @impl.current_instance_href and @impl.state != "stopped" + @impl.reload_as_current + @impl.set_inputs(hash) + @impl.reload_as_next + end + @impl.set_inputs(hash) + end + end + def update(new_params = nil) save(new_params) end From 72dda7184a43e162f5c159d3d0888671aee729cf Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Mon, 11 Jul 2011 12:04:28 -0700 Subject: [PATCH 070/239] bugfix: parameters should return a hash, even if empty --- lib/rest_connection/rightscale/server.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rest_connection/rightscale/server.rb b/lib/rest_connection/rightscale/server.rb index adb1e84..7bc3c84 100644 --- a/lib/rest_connection/rightscale/server.rb +++ b/lib/rest_connection/rightscale/server.rb @@ -52,7 +52,7 @@ def parameters if @params['parameters'].is_a?(Array) @params['parameters'] = transform_parameters(@params['parameters']) end - @params['parameters'] + @params['parameters'] ||= {} end # This is overriding the default save with one that can massage the parameters From 3577a3adeee002a9f6f004c50fde594af73ac2cc Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Fri, 15 Jul 2011 17:15:41 -0700 Subject: [PATCH 071/239] Swapped order of sleep and check state --- lib/rest_connection/rightscale/audit_entry.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rest_connection/rightscale/audit_entry.rb b/lib/rest_connection/rightscale/audit_entry.rb index b897740..61d6f3c 100644 --- a/lib/rest_connection/rightscale/audit_entry.rb +++ b/lib/rest_connection/rightscale/audit_entry.rb @@ -31,13 +31,13 @@ class AuditEntry def wait_for_state(state, timeout=900) while(timeout > 0) reload + return true if state == self.state connection.logger("state is #{self.state}, waiting for #{state}") friendly_url = "https://my.rightscale.com/audit_entries/" friendly_url += self.href.split(/\//).last raise "FATAL error, #{self.summary}\nSee Audit: API:#{self.href}, WWW:#{friendly_url}\n" if self.state == 'failed' sleep 30 timeout -= 30 - return true if state == self.state end raise "FATAL: Timeout waiting for Executable to complete. State was #{self.state}" if timeout <= 0 end From f3d1602e3cb88043b102645fa90ce71bc102ab48 Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Mon, 18 Jul 2011 16:28:44 -0700 Subject: [PATCH 072/239] bugfix --- lib/rest_connection/rightscale/rightscale_api_resources.rb | 1 + lib/rest_connection/rightscale/task.rb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/rest_connection/rightscale/rightscale_api_resources.rb b/lib/rest_connection/rightscale/rightscale_api_resources.rb index 86cfe86..15dbd37 100644 --- a/lib/rest_connection/rightscale/rightscale_api_resources.rb +++ b/lib/rest_connection/rightscale/rightscale_api_resources.rb @@ -30,6 +30,7 @@ require 'rest_connection/rightscale/ec2_ssh_key' require 'rest_connection/rightscale/multi_cloud_image' require 'rest_connection/rightscale/tag' +require 'rest_connection/rightscale/mc_tag' require 'rest_connection/rightscale/task' require 'rest_connection/rightscale/rs_internal' require 'rest_connection/rightscale/audit_entry' diff --git a/lib/rest_connection/rightscale/task.rb b/lib/rest_connection/rightscale/task.rb index e3e13e5..a6fae96 100644 --- a/lib/rest_connection/rightscale/task.rb +++ b/lib/rest_connection/rightscale/task.rb @@ -27,11 +27,11 @@ def self.parse_args(cloud_id, instance_id) def wait_for_state(state, timeout=900) while(timeout > 0) reload + return true if self.summary.include?(state) connection.logger("state is #{self.summary}, waiting for #{state}") raise "FATAL error, #{self.summary}\n" if self.summary.include?('failed') sleep 30 timeout -= 30 - return true if self.summary.include?(state) end raise "FATAL: Timeout waiting for Executable to complete. State was #{self.state}" if timeout <= 0 end From 6eedcfdd7a7250fad1cd1314e2bce3f01a83d6d0 Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Mon, 18 Jul 2011 16:46:46 -0700 Subject: [PATCH 073/239] API 1.5 uses posts instead of gets --- lib/rest_connection/rightscale/mc_tag.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/rest_connection/rightscale/mc_tag.rb b/lib/rest_connection/rightscale/mc_tag.rb index 8f7fe6a..b1b7238 100644 --- a/lib/rest_connection/rightscale/mc_tag.rb +++ b/lib/rest_connection/rightscale/mc_tag.rb @@ -37,11 +37,11 @@ def self.resource_singular_name end def self.search(resource_type, tags) #, include_tags_with_prefix = false) - result = connection.get("tags/by_tag", :resource_type => resource_type.to_s, :tags => tags) + result = connection.post("tags/by_tag", :resource_type => resource_type.to_s, :tags => tags) end def self.search_by_href(*resource_hrefs) - connection.get("tags/by_resource", :resource_hrefs => resource_hrefs) + connection.post("tags/by_resource", :resource_hrefs => resource_hrefs) end #TAGGABLE_RESOURCES = [ 'Server', 'Ec2EbsSnapshot', 'Ec2EbsVolume', 'Ec2Image', 'Image', 'ServerArray', 'Ec2Instance', # 'Instance', 'Deployment', 'ServerTemplate', 'Ec2ServerTemplate' ] From f54cc830246873bde7e42578819140d7645db51d Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Mon, 18 Jul 2011 17:38:47 -0700 Subject: [PATCH 074/239] bugfix for API 1.5 return --- lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb b/lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb index c4b8e46..23fe010 100644 --- a/lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb +++ b/lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb @@ -32,7 +32,7 @@ def remove_tags(*args) end def tags(reload=false) - @params["tags"] = McTag.search_by_href(self.href) if reload + @params["tags"] = McTag.search_by_href(self.href).first["tags"] if reload @params["tags"] end From e990834f6e0e03574672dede8c6d9b6b3b312684 Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Tue, 26 Jul 2011 16:23:10 -0700 Subject: [PATCH 075/239] McDeployment, McServerArray, several fixes --- .../rightscale/mc_deployment.rb | 64 +++++++++++++++++++ lib/rest_connection/rightscale/mc_instance.rb | 2 - lib/rest_connection/rightscale/mc_server.rb | 9 +++ .../rightscale/mc_server_array.rb | 44 +++++++++++++ .../rightscale/rightscale_api_resources.rb | 2 + lib/rest_connection/rightscale/server.rb | 10 +++ lib/rest_connection/rightscale/task.rb | 9 ++- 7 files changed, 136 insertions(+), 4 deletions(-) create mode 100644 lib/rest_connection/rightscale/mc_deployment.rb create mode 100644 lib/rest_connection/rightscale/mc_server_array.rb diff --git a/lib/rest_connection/rightscale/mc_deployment.rb b/lib/rest_connection/rightscale/mc_deployment.rb new file mode 100644 index 0000000..c402386 --- /dev/null +++ b/lib/rest_connection/rightscale/mc_deployment.rb @@ -0,0 +1,64 @@ +# This file is part of RestConnection +# +# RestConnection is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# RestConnection is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with RestConnection. If not, see . + +# +# You must have Beta v1.5 API access to use these internal API calls. +# +class McDeployment + include RightScale::Api::Gateway + extend RightScale::Api::GatewayExtend + include RightScale::Api::McTaggable + extend RightScale::Api::McTaggableExtend + + def resource_plural_name + "deployments" + end + + def resource_singular_name + "deployment" + end + + def self.resource_plural_name + "deployments" + end + + def self.resource_singular_name + "deployment" + end + + def show + inst_href = URI.parse(self.href) + @params.merge! connection.get(inst_href.path, 'view' => "inputs") + end + + def self.create(opts) + location = connection.post(resource_plural_name, opts) + newrecord = self.new('href' => location) + newrecord.show + newrecord + end + + def save + inst_href = URI.parse(self.href) + connection.put(inst_href.path, @params) + end + + # TODO Add server method + + def destroy + deploy_href = URI.parse(self.href) + connection.delete(deploy_href.path) + end +end diff --git a/lib/rest_connection/rightscale/mc_instance.rb b/lib/rest_connection/rightscale/mc_instance.rb index e86219f..4998ea2 100644 --- a/lib/rest_connection/rightscale/mc_instance.rb +++ b/lib/rest_connection/rightscale/mc_instance.rb @@ -44,8 +44,6 @@ def self.parse_args(cloud_id) end def show -# c = Cloud[self.cloud].first -# view = (c.name =~ /euca/i or c.description =~ /euca/i ? "full" : "default") inst_href = URI.parse(self.href) @params.merge! connection.get(inst_href.path, 'view' => "full") end diff --git a/lib/rest_connection/rightscale/mc_server.rb b/lib/rest_connection/rightscale/mc_server.rb index 017bd65..524804d 100644 --- a/lib/rest_connection/rightscale/mc_server.rb +++ b/lib/rest_connection/rightscale/mc_server.rb @@ -61,6 +61,13 @@ def terminate connection.logger("WARNING: was in #{self.state} so skipping terminate call") end end + + def force_terminate + t = URI.parse(self.href) + connection.post(t.path + '/terminate') + connection.post(t.path + '/terminate') + @current_instance = nil + end def start #start_ebs raise "You shouldn't be here." @@ -177,6 +184,7 @@ def wait_for_operational_with_dns(state_wait_timeout=1200) end def dns_name + self.settings if @current_instance return @current_instance.public_ip_addresses.first || @current_instance.public_dns_names.first end @@ -184,6 +192,7 @@ def dns_name end def private_ip + self.settings if @current_instance return @current_instance.private_ip_addresses.first || @current_instance.private_dns_names.first end diff --git a/lib/rest_connection/rightscale/mc_server_array.rb b/lib/rest_connection/rightscale/mc_server_array.rb new file mode 100644 index 0000000..b55e6b3 --- /dev/null +++ b/lib/rest_connection/rightscale/mc_server_array.rb @@ -0,0 +1,44 @@ +# This file is part of RestConnection +# +# RestConnection is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# RestConnection is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with RestConnection. If not, see . + +# +# You must have Beta v1.5 API access to use these internal API calls. +# +class McServerArray + include RightScale::Api::Gateway + extend RightScale::Api::GatewayExtend + include RightScale::Api::McTaggable + extend RightScale::Api::McTaggableExtend + + def resource_plural_name + "server_arrays" + end + + def resource_singular_name + "server_array" + end + + def self.resource_plural_name + "server_arrays" + end + + def self.resource_singular_name + "server_array" + end + + def self.parse_args(deployment_id=nil) + (deployment_id ? "deployments/#{deployment_id}/" : "") + end +end diff --git a/lib/rest_connection/rightscale/rightscale_api_resources.rb b/lib/rest_connection/rightscale/rightscale_api_resources.rb index 15dbd37..cb8cae0 100644 --- a/lib/rest_connection/rightscale/rightscale_api_resources.rb +++ b/lib/rest_connection/rightscale/rightscale_api_resources.rb @@ -51,7 +51,9 @@ require 'rest_connection/rightscale/multi_cloud_image_cloud_setting_internal' require 'rest_connection/rightscale/multi_cloud_image_internal' require 'rest_connection/rightscale/ec2_server_array' +require 'rest_connection/rightscale/mc_server_array' require 'rest_connection/rightscale/mc_security_group' +require 'rest_connection/rightscale/mc_deployment' require 'rest_connection/rightscale/mc_datacenter' require 'rest_connection/rightscale/mc_ssh_key' require 'rest_connection/rightscale/ec2_elastic_ip' diff --git a/lib/rest_connection/rightscale/server.rb b/lib/rest_connection/rightscale/server.rb index 7bc3c84..de19f6c 100644 --- a/lib/rest_connection/rightscale/server.rb +++ b/lib/rest_connection/rightscale/server.rb @@ -130,6 +130,16 @@ def stop end end + def force_stop + if self.current_instance_href + t = URI.parse(self.href) + connection.post(t.path + '/stop') + connection.post(t.path + '/stop') + else + connection.logger("WARNING: was in #{self.state} and had a current_instance_href so skiping stop call") + end + end + # Uses ServerInternal api to start and stop EBS based instances def start_ebs @server_internal = ServerInternal.new(:href => self.href) diff --git a/lib/rest_connection/rightscale/task.rb b/lib/rest_connection/rightscale/task.rb index a6fae96..5f21731 100644 --- a/lib/rest_connection/rightscale/task.rb +++ b/lib/rest_connection/rightscale/task.rb @@ -24,12 +24,17 @@ def self.parse_args(cloud_id, instance_id) "clouds/#{cloud_id}/instances/#{instance_id}/live/" end + def show + url = URI.parse(self.href) + @params.merge! connection.get(url.path, 'view' => "extended") + end + def wait_for_state(state, timeout=900) while(timeout > 0) - reload + show return true if self.summary.include?(state) connection.logger("state is #{self.summary}, waiting for #{state}") - raise "FATAL error, #{self.summary}\n" if self.summary.include?('failed') + raise "FATAL error:\n\n #{self.detail} \n\n" if self.summary.include?('failed') sleep 30 timeout -= 30 end From 5ff1a011a8e89669827793b3ab32e837e56d51aa Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Wed, 27 Jul 2011 14:46:15 -0700 Subject: [PATCH 076/239] Ability to list all "info:" machine tags --- lib/rest_connection/rightscale/mc_server.rb | 51 +++++++++++++++++-- .../rightscale/rightscale_api_mc_taggable.rb | 6 ++- .../rightscale/rightscale_api_taggable.rb | 6 ++- lib/rest_connection/rightscale/server.rb | 6 ++- 4 files changed, 61 insertions(+), 8 deletions(-) diff --git a/lib/rest_connection/rightscale/mc_server.rb b/lib/rest_connection/rightscale/mc_server.rb index 524804d..d4b68ae 100644 --- a/lib/rest_connection/rightscale/mc_server.rb +++ b/lib/rest_connection/rightscale/mc_server.rb @@ -126,11 +126,6 @@ def settings #show @params end - def get_sketchy_data(params) - raise "No current instance found to check!" unless @current_instance - @current_instance.get_sketchy_data(params) - end - def monitoring @current_instance.fetch_monitoring_metrics end @@ -221,4 +216,50 @@ def get_sketchy_data(params) raise "No current instance found!" unless @current_instance @current_instance.get_sketchy_data(params) end + + # Override Taggable mixin so that it sets tags on both next and current instances + # TODO: do we need to tweak + def add_tags(*args) + return false if args.empty? + args.uniq! + McTag.set(self.href, args) + McTag.set(self.current_instance_href, args) if @current_instance + self.tags(true) + end + + def remove_tags(*args) + return false if args.empty? + args.uniq! + McTag.unset(self.href, args) + McTag.unset(self.current_instance_href, args) if @current_instance + self.tags(true) + end + + def get_info_tags(*tag_keys) + ret = {} + tags = {"self" => McTag.search_by_href(self.href)} + if @current_instance + tags["current_instance"] = McTag.search_by_href(self.current_instance_href) + end + tags.each { |res,ary| + ret[res] ||= {} + ary.each { |hsh| + next unless hsh["name"].start_with?("info:") + key, value = hsh["name"].split(":").last.split("=") + if tag_keys.empty? + ret[res][key] = value + else + ret[res][key] = value if tag_keys.include?(key) + end + } + } + return ret + end + + def clear_tags(namespace = nil) + tags = McTag.search_by_href(self.href) + tags.deep_merge! McTag.search_by_href(self.current_instance_href) if @current_instance + tags = tags.select { |hsh| hsh["name"].start_with?("#{namespace}:") } if namespace + self.remove_tags(*(tags.map { |k,v| v })) + end end diff --git a/lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb b/lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb index 23fe010..0e4bcc5 100644 --- a/lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb +++ b/lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb @@ -63,7 +63,11 @@ def get_info_tags(*tag_keys) ary.each { |hsh| next unless hsh["name"].start_with?("info:") key, value = hsh["name"].split(":").last.split("=") - ret[res][key] = value if tag_keys.include?(key) + if tag_keys.empty? + ret[res][key] = value + else + ret[res][key] = value if tag_keys.include?(key) + end } } return ret diff --git a/lib/rest_connection/rightscale/rightscale_api_taggable.rb b/lib/rest_connection/rightscale/rightscale_api_taggable.rb index f37b3b8..7a789f5 100644 --- a/lib/rest_connection/rightscale/rightscale_api_taggable.rb +++ b/lib/rest_connection/rightscale/rightscale_api_taggable.rb @@ -60,7 +60,11 @@ def get_info_tags(*tag_keys) ary.each { |hsh| next unless hsh["name"].start_with?("info:") key, value = hsh["name"].split(":").last.split("=") - ret[res][key] = value if tag_keys.include?(key) + if tag_keys.empty? + ret[res][key] = value + else + ret[res][key] = value if tag_keys.include?(key) + end } } return ret diff --git a/lib/rest_connection/rightscale/server.rb b/lib/rest_connection/rightscale/server.rb index de19f6c..ede4737 100644 --- a/lib/rest_connection/rightscale/server.rb +++ b/lib/rest_connection/rightscale/server.rb @@ -350,7 +350,11 @@ def get_info_tags(*tag_keys) ary.each { |hsh| next unless hsh["name"].start_with?("info:") key, value = hsh["name"].split(":").last.split("=") - ret[res][key] = value if tag_keys.include?(key) + if tag_keys.empty? + ret[res][key] = value + else + ret[res][key] = value if tag_keys.include?(key) + end } } return ret From ce5ce560e29ab346a7d52aef82415c18c033bdb8 Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Tue, 9 Aug 2011 13:40:38 -0700 Subject: [PATCH 077/239] [API 1.5] added find_with_filter; [Server] added reachable_ip fn --- lib/rest_connection/rightscale/mc_server.rb | 1 - .../rightscale/rightscale_api_gateway.rb | 16 ++++++++++++++++ lib/rest_connection/rightscale/server.rb | 7 +++++++ .../rightscale/server_interface.rb | 1 + 4 files changed, 24 insertions(+), 1 deletion(-) diff --git a/lib/rest_connection/rightscale/mc_server.rb b/lib/rest_connection/rightscale/mc_server.rb index d4b68ae..08bc5bf 100644 --- a/lib/rest_connection/rightscale/mc_server.rb +++ b/lib/rest_connection/rightscale/mc_server.rb @@ -218,7 +218,6 @@ def get_sketchy_data(params) end # Override Taggable mixin so that it sets tags on both next and current instances - # TODO: do we need to tweak def add_tags(*args) return false if args.empty? args.uniq! diff --git a/lib/rest_connection/rightscale/rightscale_api_gateway.rb b/lib/rest_connection/rightscale/rightscale_api_gateway.rb index 388d747..1cda686 100644 --- a/lib/rest_connection/rightscale/rightscale_api_gateway.rb +++ b/lib/rest_connection/rightscale/rightscale_api_gateway.rb @@ -179,6 +179,7 @@ def find_by(attrib, *args, &block) end def find_all(*args) +# self.find_with_filter(*args, {}) a = Array.new url = "#{parse_args(*args)}#{self.resource_plural_name}" connection.get(url).each do |object| @@ -187,6 +188,21 @@ def find_all(*args) return a end + def find_with_filter(*args) + filter_params = [] + filter = {} + filter = args.pop if args.last.is_a?(Hash) + filter.each { |key,val| + filter_params << "#{key}==#{val}" + } + a = Array.new + url = "#{parse_args(*args)}#{self.resource_plural_name}" + connection.get(url, :filter => filter_params).each do |object| + a << self.new(object) + end + return a + end + def load(url) return self.new(connection.get(url)) end diff --git a/lib/rest_connection/rightscale/server.rb b/lib/rest_connection/rightscale/server.rb index ede4737..89887e5 100644 --- a/lib/rest_connection/rightscale/server.rb +++ b/lib/rest_connection/rightscale/server.rb @@ -73,6 +73,7 @@ def wait_for_state(st,timeout=1200) while(timeout > 0) return true if state =~ /#{st}/ raise "FATAL error, this server is stranded and needs to be #{st}: #{nickname}, see audit: #{self.audit_link}" if state.include?('stranded') && !st.include?('stranded') + raise "FATAL error, this server went to error state and needs to be #{st}: #{nickname}, see audit: #{self.audit_link}" if state.include?('error') && !st.include?('error') connection.logger("waiting for server #{nickname} to go #{st}, state is #{state}") if state =~ /terminated|stopped/ and st !~ /terminated|stopped/ if catch_early_terminated <= 0 @@ -322,6 +323,12 @@ def private_ip @params["private-ip-address"] end + def reachable_ip + return self.dns_name if self.dns_name + return self.private_ip if self.private_ip + nil + end + # Override Taggable mixin so that it sets tags on both next and current instances def add_tags(*args) return false if args.empty? diff --git a/lib/rest_connection/rightscale/server_interface.rb b/lib/rest_connection/rightscale/server_interface.rb index c46a212..65c3530 100644 --- a/lib/rest_connection/rightscale/server_interface.rb +++ b/lib/rest_connection/rightscale/server_interface.rb @@ -36,6 +36,7 @@ def initialize(cid = nil, params = {}, deployment_id = nil) else @impl = Server.new(params) end + self end def create(opts) From 1c67186e7e9d3fa003c6c54aff927cb9e2c6d82d Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Wed, 10 Aug 2011 16:37:08 -0700 Subject: [PATCH 078/239] [ServerInterface] Inputs can't be an empty array --- lib/rest_connection/rightscale/server_interface.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/rest_connection/rightscale/server_interface.rb b/lib/rest_connection/rightscale/server_interface.rb index 65c3530..78b29df 100644 --- a/lib/rest_connection/rightscale/server_interface.rb +++ b/lib/rest_connection/rightscale/server_interface.rb @@ -136,6 +136,7 @@ def translate_create_opts(old_opts, instance_only=false) else server[field.to_s] = opts[vals.first] unless vals.first.nil? end + server.delete("inputs") if field == :inputs and server["inputs"].empty? # Inputs cannot be empty for 1.5 } } clean_and_translate_server_params(ret) From 410db3158c63249299e48da887ef9e77caa39519 Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Thu, 11 Aug 2011 12:10:12 -0700 Subject: [PATCH 079/239] bugfixes --- lib/rest_connection/rightscale/mc_instance.rb | 2 +- lib/rest_connection/rightscale/mc_server.rb | 6 +++--- lib/rest_connection/rightscale/server_interface.rb | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/rest_connection/rightscale/mc_instance.rb b/lib/rest_connection/rightscale/mc_instance.rb index 4998ea2..2632035 100644 --- a/lib/rest_connection/rightscale/mc_instance.rb +++ b/lib/rest_connection/rightscale/mc_instance.rb @@ -50,7 +50,7 @@ def show def update inst_href = URI.parse(self.href) - connection.put(inst_href.path, @params) + connection.put(inst_href.path, {"instance" => @params}) end def launch diff --git a/lib/rest_connection/rightscale/mc_server.rb b/lib/rest_connection/rightscale/mc_server.rb index 08bc5bf..3db508d 100644 --- a/lib/rest_connection/rightscale/mc_server.rb +++ b/lib/rest_connection/rightscale/mc_server.rb @@ -195,12 +195,12 @@ def private_ip end def save - @next_instance.save - @current_instance.update if @current_instance + update end def update - @next_instance.save + @next_instance.update + @current_instance.update if @current_instance end def reload_as_current diff --git a/lib/rest_connection/rightscale/server_interface.rb b/lib/rest_connection/rightscale/server_interface.rb index 78b29df..4cb5188 100644 --- a/lib/rest_connection/rightscale/server_interface.rb +++ b/lib/rest_connection/rightscale/server_interface.rb @@ -246,7 +246,7 @@ def wait_for_state(st,timeout=1200) @impl.wait_for_state(st,timeout) end - def save(new_params = nil) + def update(new_params = nil) if new_params @impl.settings if @multicloud @@ -255,7 +255,7 @@ def save(new_params = nil) @impl.params.merge!(translate_create_opts(new_params)["server"]) end end - @impl.save + @impl.update end def set_inputs(hash = {}) @@ -271,7 +271,7 @@ def set_inputs(hash = {}) end end - def update(new_params = nil) - save(new_params) + def save(new_params = nil) + update(new_params) end end From 391d5f5ac4e617e732198c3a2e850c5c77ff5df5 Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Thu, 11 Aug 2011 15:42:06 -0700 Subject: [PATCH 080/239] [API 1.0, 1.5] Several bugfixes regarding updating params --- lib/rest_connection/rightscale/mc_instance.rb | 38 ++++++++++++++++++- .../rightscale/rightscale_api_base.rb | 4 +- .../rightscale/rightscale_api_gateway.rb | 8 ++-- .../rightscale/server_interface.rb | 2 +- 4 files changed, 45 insertions(+), 7 deletions(-) diff --git a/lib/rest_connection/rightscale/mc_instance.rb b/lib/rest_connection/rightscale/mc_instance.rb index 2632035..2283114 100644 --- a/lib/rest_connection/rightscale/mc_instance.rb +++ b/lib/rest_connection/rightscale/mc_instance.rb @@ -48,9 +48,45 @@ def show @params.merge! connection.get(inst_href.path, 'view' => "full") end + def save + update + end + + def map_security_groups(to, sg_ary) + sg_ary.map { |hsh| hsh["href"] } + end + + def map_user_data(to, user_data) + user_data + end + def update + fields = [{"attr" => :datacenter, "api" => :datacenter_href}, + {"attr" => :image, "api" => :image_href}, + {"attr" => :instance_type, "api" => :instance_type_href}, + { "api" => :kernel_image_href}, + {"attr" => :multi_cloud_image, "api" => :multi_cloud_image_href}, + { "api" => :ramdisk_image_href}, + {"attr" => :security_groups, "fn" => :map_security_groups, "api" => :security_group_hrefs}, + {"attr" => :server_template, "api" => :server_template_href}, + {"attr" => :ssh_key, "api" => :ssh_key_href}, + {"attr" => :user_data, "fn" => :map_user_data, "api" => :user_data}] + + opts = {"instance" => {}} + instance = opts["instance"] + to = "api" + from = "attr" + fields.each { |hsh| + next unless hsh[from] + val = self[hsh[from]] + if hsh["fn"] + instance[hsh[to].to_s] = __send__(hsh["fn"], to, val) unless val.nil? || val.empty? + else + instance[hsh[to].to_s] = val unless val.nil? || val.empty? + end + } inst_href = URI.parse(self.href) - connection.put(inst_href.path, {"instance" => @params}) + connection.put(inst_href.path, opts) end def launch diff --git a/lib/rest_connection/rightscale/rightscale_api_base.rb b/lib/rest_connection/rightscale/rightscale_api_base.rb index 7a0d25e..d0db91b 100644 --- a/lib/rest_connection/rightscale/rightscale_api_base.rb +++ b/lib/rest_connection/rightscale/rightscale_api_base.rb @@ -224,7 +224,7 @@ def method_missing(method_name, *args) end def [](name) - try_these = [name, name.to_s.gsub(/_/,'-'), name.to_sym] + try_these = [name.to_s, name.to_s.gsub(/_/,'-'), name.to_sym] try_these.each do |t| if @params[t] return @params[t] @@ -234,7 +234,7 @@ def [](name) end def []=(name,val) - try_these = [name, name.to_s.gsub(/_/,'-'), name.to_sym] + try_these = [name.to_s, name.to_s.gsub(/_/,'-'), name.to_sym] try_these.each do |t| if @params[t] @params[t] = val diff --git a/lib/rest_connection/rightscale/rightscale_api_gateway.rb b/lib/rest_connection/rightscale/rightscale_api_gateway.rb index 1cda686..480a208 100644 --- a/lib/rest_connection/rightscale/rightscale_api_gateway.rb +++ b/lib/rest_connection/rightscale/rightscale_api_gateway.rb @@ -98,7 +98,7 @@ def method_missing(method_name, *args) end def [](name) - try_these = [name, name.to_s.gsub(/_/,'-'), name.to_sym] + try_these = [name.to_s, name.to_s.gsub(/_/,'-'), name.to_sym] if try_these.include?(:nickname) try_these += ["name", :name] end @@ -113,7 +113,7 @@ def [](name) end def []=(name,val) - try_these = [name, name.to_s.gsub(/_/,'-'), name.to_sym] + try_these = [name.to_s, name.to_s.gsub(/_/,'-'), name.to_sym] if try_these.include?(:nickname) try_these += ["name", :name] end @@ -121,7 +121,9 @@ def []=(name,val) if @params[t] @params[t] = val elsif hash_of_links[t] - hash_of_links[t] = val + @params['links'].each { |link| + link['href'] = val if link['rel'] == t + } end end val diff --git a/lib/rest_connection/rightscale/server_interface.rb b/lib/rest_connection/rightscale/server_interface.rb index 4cb5188..86a6c03 100644 --- a/lib/rest_connection/rightscale/server_interface.rb +++ b/lib/rest_connection/rightscale/server_interface.rb @@ -136,7 +136,7 @@ def translate_create_opts(old_opts, instance_only=false) else server[field.to_s] = opts[vals.first] unless vals.first.nil? end - server.delete("inputs") if field == :inputs and server["inputs"].empty? # Inputs cannot be empty for 1.5 + server.delete("inputs") if server["inputs"] && server["inputs"].empty? # Inputs cannot be empty for 1.5 } } clean_and_translate_server_params(ret) From 4f84517ac050d23f7748f4c420ec84a484982ce1 Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Fri, 12 Aug 2011 13:04:35 -0700 Subject: [PATCH 081/239] bugfixes --- lib/rest_connection/rightscale/mc_server.rb | 4 +++- lib/rest_connection/rightscale/server_interface.rb | 8 ++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/rest_connection/rightscale/mc_server.rb b/lib/rest_connection/rightscale/mc_server.rb index 3db508d..d24bca2 100644 --- a/lib/rest_connection/rightscale/mc_server.rb +++ b/lib/rest_connection/rightscale/mc_server.rb @@ -127,7 +127,9 @@ def settings #show end def monitoring - @current_instance.fetch_monitoring_metrics + ret = @current_instance.fetch_monitoring_metrics + raise "FATAL: Monitoring not available!" if ret.empty? + ret end def relaunch diff --git a/lib/rest_connection/rightscale/server_interface.rb b/lib/rest_connection/rightscale/server_interface.rb index 86a6c03..d9203e2 100644 --- a/lib/rest_connection/rightscale/server_interface.rb +++ b/lib/rest_connection/rightscale/server_interface.rb @@ -246,7 +246,7 @@ def wait_for_state(st,timeout=1200) @impl.wait_for_state(st,timeout) end - def update(new_params = nil) + def save(new_params = nil) if new_params @impl.settings if @multicloud @@ -255,7 +255,7 @@ def update(new_params = nil) @impl.params.merge!(translate_create_opts(new_params)["server"]) end end - @impl.update + @impl.save end def set_inputs(hash = {}) @@ -271,7 +271,7 @@ def set_inputs(hash = {}) end end - def save(new_params = nil) - update(new_params) + def update(new_params = nil) + save(new_params) end end From 8bbb396c747a36d50865889e97854c6dd5aba49f Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Tue, 23 Aug 2011 15:51:22 -0700 Subject: [PATCH 082/239] AuditEntry timeout bubble up, tag bugfixes, McServer bugfix --- lib/rest_connection/rightscale/audit_entry.rb | 4 ++-- lib/rest_connection/rightscale/mc_server.rb | 19 +++++++++--------- .../rightscale/rightscale_api_mc_taggable.rb | 13 ++++++------ .../rightscale/rightscale_api_taggable.rb | 13 ++++++------ lib/rest_connection/rightscale/server.rb | 20 ++++++++++--------- 5 files changed, 37 insertions(+), 32 deletions(-) diff --git a/lib/rest_connection/rightscale/audit_entry.rb b/lib/rest_connection/rightscale/audit_entry.rb index 61d6f3c..9e9975d 100644 --- a/lib/rest_connection/rightscale/audit_entry.rb +++ b/lib/rest_connection/rightscale/audit_entry.rb @@ -42,7 +42,7 @@ def wait_for_state(state, timeout=900) raise "FATAL: Timeout waiting for Executable to complete. State was #{self.state}" if timeout <= 0 end - def wait_for_completed(legacy=nil) - wait_for_state("completed") + def wait_for_completed(timeout=900) + wait_for_state("completed", timeout) end end diff --git a/lib/rest_connection/rightscale/mc_server.rb b/lib/rest_connection/rightscale/mc_server.rb index d24bca2..0eb2028 100644 --- a/lib/rest_connection/rightscale/mc_server.rb +++ b/lib/rest_connection/rightscale/mc_server.rb @@ -116,7 +116,7 @@ def set_inputs(hash = {}) def settings #show serv_href = URI.parse(self.href) - @params.merge! connection.get(serv_href.path, 'view' => 'instance_detail') + @params = connection.get(serv_href.path, 'view' => 'instance_detail') if self['current_instance'] @current_instance = McInstance.new(self['current_instance']) @current_instance.show @@ -238,15 +238,16 @@ def remove_tags(*args) def get_info_tags(*tag_keys) ret = {} - tags = {"self" => McTag.search_by_href(self.href)} + tags = {"self" => McTag.search_by_href(self.href).first["tags"].map { |h| h["name"] }} if @current_instance - tags["current_instance"] = McTag.search_by_href(self.current_instance_href) + tags["current_instance"] = McTag.search_by_href(self.current_instance_href).first["tags"].map { |h| h["name"] } end tags.each { |res,ary| ret[res] ||= {} - ary.each { |hsh| - next unless hsh["name"].start_with?("info:") - key, value = hsh["name"].split(":").last.split("=") + ary.each { |tag| + next unless tag.start_with?("info:") + key = tag.split(":").first + value = tag.split(":")[1..-1].join(":").split("=")[1..-1].join("=") if tag_keys.empty? ret[res][key] = value else @@ -258,9 +259,9 @@ def get_info_tags(*tag_keys) end def clear_tags(namespace = nil) - tags = McTag.search_by_href(self.href) - tags.deep_merge! McTag.search_by_href(self.current_instance_href) if @current_instance + tags = McTag.search_by_href(self.href).first["tags"].map { |h| h["name"] } + tags.deep_merge! McTag.search_by_href(self.current_instance_href).first["tags"].map { |h| h["name"] } if @current_instance tags = tags.select { |hsh| hsh["name"].start_with?("#{namespace}:") } if namespace - self.remove_tags(*(tags.map { |k,v| v })) + self.remove_tags(*tags) end end diff --git a/lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb b/lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb index 0e4bcc5..487cae8 100644 --- a/lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb +++ b/lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb @@ -32,7 +32,7 @@ def remove_tags(*args) end def tags(reload=false) - @params["tags"] = McTag.search_by_href(self.href).first["tags"] if reload + @params["tags"] = McTag.search_by_href(self.href).first["tags"].map { |hsh| hsh["name"] } if reload @params["tags"] end @@ -60,9 +60,10 @@ def get_info_tags(*tag_keys) tags = {"self" => self.tags(true)} tags.each { |res,ary| ret[res] ||= {} - ary.each { |hsh| - next unless hsh["name"].start_with?("info:") - key, value = hsh["name"].split(":").last.split("=") + ary.each { |tag| + next unless tag.start_with?("info:") + key = tag.split(":").first + value = tag.split(":")[1..-1].join(":").split("=")[1..-1].join("=") if tag_keys.empty? ret[res][key] = value else @@ -80,8 +81,8 @@ def set_tags_to(*args) def clear_tags(namespace = nil) tag_ary = self.tags(true) - tag_ary = tag_ary.select { |hsh| hsh["name"].start_with?("#{namespace}:") } if namespace - self.remove_tags(*(tag_ary.map { |k,v| v })) + tag_ary = tag_ary.select { |tag| tag.start_with?("#{namespace}:") } if namespace + self.remove_tags(*tag_ary) end end diff --git a/lib/rest_connection/rightscale/rightscale_api_taggable.rb b/lib/rest_connection/rightscale/rightscale_api_taggable.rb index 7a789f5..7454eab 100644 --- a/lib/rest_connection/rightscale/rightscale_api_taggable.rb +++ b/lib/rest_connection/rightscale/rightscale_api_taggable.rb @@ -29,7 +29,7 @@ def remove_tags(*args) end def tags(reload=false) - @params["tags"] = Tag.search_by_href(self.href) if reload + @params["tags"] = Tag.search_by_href(self.href).map { |hsh| hsh["name"] } if reload @params["tags"] end @@ -57,9 +57,10 @@ def get_info_tags(*tag_keys) tags = {"self" => self.tags(true)} tags.each { |res,ary| ret[res] ||= {} - ary.each { |hsh| - next unless hsh["name"].start_with?("info:") - key, value = hsh["name"].split(":").last.split("=") + ary.each { |tag| + next unless tag.start_with?("info:") + key = tag.split(":").first + value = tag.split(":")[1..-1].join(":").split("=")[1..-1].join("=") if tag_keys.empty? ret[res][key] = value else @@ -77,8 +78,8 @@ def set_tags_to(*args) def clear_tags(namespace = nil) tag_ary = self.tags(true) - tag_ary = tag_ary.select { |hsh| hsh["name"].start_with?("#{namespace}:") } if namespace - self.remove_tags(*(tag_ary.map { |k,v| v })) + tag_ary = tag_ary.select { |tag| tag.start_with?("#{namespace}:") } if namespace + self.remove_tags(*tag_ary) end end diff --git a/lib/rest_connection/rightscale/server.rb b/lib/rest_connection/rightscale/server.rb index 89887e5..d417997 100644 --- a/lib/rest_connection/rightscale/server.rb +++ b/lib/rest_connection/rightscale/server.rb @@ -58,6 +58,7 @@ def parameters # This is overriding the default save with one that can massage the parameters def save self.parameters #transform the parameters, if they're not already!! + self.tags #transform the tags, if they're not already!! uri = URI.parse(self.href) connection.put(uri.path, resource_singular_name.to_sym => @params) end @@ -348,15 +349,16 @@ def remove_tags(*args) def get_info_tags(*tag_keys) ret = {} - tags = {"self" => Tag.search_by_href(self.href)} + tags = {"self" => Tag.search_by_href(self.href).map { |h| h["name"] }} if self.current_instance_href - tags["current_instance"] = Tag.search_by_href(self.current_instance_href) + tags["current_instance"] = Tag.search_by_href(self.current_instance_href).map { |h| h["name"] } end tags.each { |res,ary| ret[res] ||= {} - ary.each { |hsh| - next unless hsh["name"].start_with?("info:") - key, value = hsh["name"].split(":").last.split("=") + ary.each { |tag| + next unless tag.start_with?("info:") + key = tag.split(":").first + value = tag.split(":")[1..-1].join(":").split("=")[1..-1].join("=") if tag_keys.empty? ret[res][key] = value else @@ -368,9 +370,9 @@ def get_info_tags(*tag_keys) end def clear_tags(namespace = nil) - tags = Tag.search_by_href(self.href) - tags.deep_merge! Tag.search_by_href(self.current_instance_href) if self.current_instance_href - tags = tags.select { |hsh| hsh["name"].start_with?("#{namespace}:") } if namespace - self.remove_tags(*(tags.map { |k,v| v })) + tags = Tag.search_by_href(self.href).map { |h| h["name"] } + tags.deep_merge! Tag.search_by_href(self.current_instance_href).map { |h| h["name"] } if self.current_instance_href + tags = tags.select { |tag| tag.start_with?("#{namespace}:") } if namespace + self.remove_tags(*tags) end end From ef74116192d7b75561a7875500b63a9d544ae661 Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Tue, 23 Aug 2011 16:01:16 -0700 Subject: [PATCH 083/239] Tag bugfixes --- lib/rest_connection/rightscale/mc_server.rb | 2 +- lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb | 2 +- lib/rest_connection/rightscale/rightscale_api_taggable.rb | 2 +- lib/rest_connection/rightscale/server.rb | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/rest_connection/rightscale/mc_server.rb b/lib/rest_connection/rightscale/mc_server.rb index 0eb2028..ad624eb 100644 --- a/lib/rest_connection/rightscale/mc_server.rb +++ b/lib/rest_connection/rightscale/mc_server.rb @@ -246,7 +246,7 @@ def get_info_tags(*tag_keys) ret[res] ||= {} ary.each { |tag| next unless tag.start_with?("info:") - key = tag.split(":").first + key = tag.split("=").first.split(":").last value = tag.split(":")[1..-1].join(":").split("=")[1..-1].join("=") if tag_keys.empty? ret[res][key] = value diff --git a/lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb b/lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb index 487cae8..9c1ff8b 100644 --- a/lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb +++ b/lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb @@ -62,7 +62,7 @@ def get_info_tags(*tag_keys) ret[res] ||= {} ary.each { |tag| next unless tag.start_with?("info:") - key = tag.split(":").first + key = tag.split("=").first.split(":").last value = tag.split(":")[1..-1].join(":").split("=")[1..-1].join("=") if tag_keys.empty? ret[res][key] = value diff --git a/lib/rest_connection/rightscale/rightscale_api_taggable.rb b/lib/rest_connection/rightscale/rightscale_api_taggable.rb index 7454eab..3055a43 100644 --- a/lib/rest_connection/rightscale/rightscale_api_taggable.rb +++ b/lib/rest_connection/rightscale/rightscale_api_taggable.rb @@ -59,7 +59,7 @@ def get_info_tags(*tag_keys) ret[res] ||= {} ary.each { |tag| next unless tag.start_with?("info:") - key = tag.split(":").first + key = tag.split("=").first.split(":").last value = tag.split(":")[1..-1].join(":").split("=")[1..-1].join("=") if tag_keys.empty? ret[res][key] = value diff --git a/lib/rest_connection/rightscale/server.rb b/lib/rest_connection/rightscale/server.rb index d417997..86de3a7 100644 --- a/lib/rest_connection/rightscale/server.rb +++ b/lib/rest_connection/rightscale/server.rb @@ -357,7 +357,7 @@ def get_info_tags(*tag_keys) ret[res] ||= {} ary.each { |tag| next unless tag.start_with?("info:") - key = tag.split(":").first + key = tag.split("=").first.split(":").last value = tag.split(":")[1..-1].join(":").split("=")[1..-1].join("=") if tag_keys.empty? ret[res][key] = value From 24b7b066cb41bf645a6586973712d570c73fba49 Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Thu, 25 Aug 2011 17:08:59 -0700 Subject: [PATCH 084/239] [Server] Added ignore_lock option to run_executable --- lib/rest_connection/rightscale/server.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/rest_connection/rightscale/server.rb b/lib/rest_connection/rightscale/server.rb index 86de3a7..bfcf5e0 100644 --- a/lib/rest_connection/rightscale/server.rb +++ b/lib/rest_connection/rightscale/server.rb @@ -155,7 +155,7 @@ def stop_ebs # Works on v4 and v5 images. # *executable can be an <~Executable> or <~RightScript> - def run_executable(executable, opts=nil) + def run_executable(executable, opts=nil, ignore_lock=false) script_options = Hash.new script_options[:server] = Hash.new if executable.is_a?(Executable) @@ -172,6 +172,7 @@ def run_executable(executable, opts=nil) serv_href = URI.parse(self.href) script_options[:server][:parameters] = opts unless opts.nil? + script_options[:server][:ignore_lock] = true if ignore_lock location = connection.post(serv_href.path + '/run_executable', script_options) AuditEntry.new('href' => location) end From 105bfb61b6ab9c7d803a87d03f600be7da82309b Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Fri, 26 Aug 2011 11:21:35 -0700 Subject: [PATCH 085/239] bugfix --- lib/rest_connection.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rest_connection.rb b/lib/rest_connection.rb index f199c39..33e7164 100644 --- a/lib/rest_connection.rb +++ b/lib/rest_connection.rb @@ -146,7 +146,7 @@ def rest_connect(&block) def get(href, additional_parameters = "") rest_connect do |base_uri,headers| href = "#{base_uri}/#{href}" unless begins_with_slash(href) - new_path = URI.escape(href + @settings[:extension] + "?") + requestify(additional_parameters) + new_path = "#{URI.escape(href + @settings[:extension] + "?")}#{requestify(additional_parameters)}" Net::HTTP::Get.new(new_path, headers) end end From f72e4c2bfa3ff2f52379fc423c397f5f78200eb7 Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Tue, 30 Aug 2011 20:47:56 -0700 Subject: [PATCH 086/239] tags merge instead of reload --- lib/rest_connection/rightscale/mc_server.rb | 2 +- lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb | 3 ++- lib/rest_connection/rightscale/rightscale_api_taggable.rb | 3 ++- lib/rest_connection/rightscale/server.rb | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/rest_connection/rightscale/mc_server.rb b/lib/rest_connection/rightscale/mc_server.rb index ad624eb..d8bf027 100644 --- a/lib/rest_connection/rightscale/mc_server.rb +++ b/lib/rest_connection/rightscale/mc_server.rb @@ -238,7 +238,7 @@ def remove_tags(*args) def get_info_tags(*tag_keys) ret = {} - tags = {"self" => McTag.search_by_href(self.href).first["tags"].map { |h| h["name"] }} + tags = {"self" => self.tags(true)} if @current_instance tags["current_instance"] = McTag.search_by_href(self.current_instance_href).first["tags"].map { |h| h["name"] } end diff --git a/lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb b/lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb index 9c1ff8b..aed74a7 100644 --- a/lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb +++ b/lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb @@ -32,7 +32,8 @@ def remove_tags(*args) end def tags(reload=false) - @params["tags"] = McTag.search_by_href(self.href).first["tags"].map { |hsh| hsh["name"] } if reload + @params["tags"] ||= [] + @params["tags"].deep_merge! McTag.search_by_href(self.href).first["tags"].map { |hsh| hsh["name"] } if reload @params["tags"] end diff --git a/lib/rest_connection/rightscale/rightscale_api_taggable.rb b/lib/rest_connection/rightscale/rightscale_api_taggable.rb index 3055a43..ab0f5c6 100644 --- a/lib/rest_connection/rightscale/rightscale_api_taggable.rb +++ b/lib/rest_connection/rightscale/rightscale_api_taggable.rb @@ -29,7 +29,8 @@ def remove_tags(*args) end def tags(reload=false) - @params["tags"] = Tag.search_by_href(self.href).map { |hsh| hsh["name"] } if reload + @params["tags"] ||= [] + @params["tags"].deep_merge! Tag.search_by_href(self.href).map { |hsh| hsh["name"] } if reload @params["tags"] end diff --git a/lib/rest_connection/rightscale/server.rb b/lib/rest_connection/rightscale/server.rb index bfcf5e0..98fb8f8 100644 --- a/lib/rest_connection/rightscale/server.rb +++ b/lib/rest_connection/rightscale/server.rb @@ -350,7 +350,7 @@ def remove_tags(*args) def get_info_tags(*tag_keys) ret = {} - tags = {"self" => Tag.search_by_href(self.href).map { |h| h["name"] }} + tags = {"self" => self.tags(true)} if self.current_instance_href tags["current_instance"] = Tag.search_by_href(self.current_instance_href).map { |h| h["name"] } end From 26bf1b6653510fef8de52c831370f10219b8f37a Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Tue, 30 Aug 2011 21:10:10 -0700 Subject: [PATCH 087/239] bugfix --- lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb | 2 +- lib/rest_connection/rightscale/rightscale_api_taggable.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb b/lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb index aed74a7..179587f 100644 --- a/lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb +++ b/lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb @@ -33,7 +33,7 @@ def remove_tags(*args) def tags(reload=false) @params["tags"] ||= [] - @params["tags"].deep_merge! McTag.search_by_href(self.href).first["tags"].map { |hsh| hsh["name"] } if reload + @params["tags"].deep_merge!(McTag.search_by_href(self.href).first["tags"].map { |hsh| hsh["name"] }) if reload @params["tags"] end diff --git a/lib/rest_connection/rightscale/rightscale_api_taggable.rb b/lib/rest_connection/rightscale/rightscale_api_taggable.rb index ab0f5c6..b20a010 100644 --- a/lib/rest_connection/rightscale/rightscale_api_taggable.rb +++ b/lib/rest_connection/rightscale/rightscale_api_taggable.rb @@ -30,7 +30,7 @@ def remove_tags(*args) def tags(reload=false) @params["tags"] ||= [] - @params["tags"].deep_merge! Tag.search_by_href(self.href).map { |hsh| hsh["name"] } if reload + @params["tags"].deep_merge!(Tag.search_by_href(self.href).map { |hsh| hsh["name"] }) if reload @params["tags"] end From ffd232af029a8ba851f83a1a5305a32e7db687a2 Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Tue, 30 Aug 2011 21:18:29 -0700 Subject: [PATCH 088/239] Revert "bugfix" This reverts commit 26bf1b6653510fef8de52c831370f10219b8f37a. --- lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb | 2 +- lib/rest_connection/rightscale/rightscale_api_taggable.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb b/lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb index 179587f..aed74a7 100644 --- a/lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb +++ b/lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb @@ -33,7 +33,7 @@ def remove_tags(*args) def tags(reload=false) @params["tags"] ||= [] - @params["tags"].deep_merge!(McTag.search_by_href(self.href).first["tags"].map { |hsh| hsh["name"] }) if reload + @params["tags"].deep_merge! McTag.search_by_href(self.href).first["tags"].map { |hsh| hsh["name"] } if reload @params["tags"] end diff --git a/lib/rest_connection/rightscale/rightscale_api_taggable.rb b/lib/rest_connection/rightscale/rightscale_api_taggable.rb index b20a010..ab0f5c6 100644 --- a/lib/rest_connection/rightscale/rightscale_api_taggable.rb +++ b/lib/rest_connection/rightscale/rightscale_api_taggable.rb @@ -30,7 +30,7 @@ def remove_tags(*args) def tags(reload=false) @params["tags"] ||= [] - @params["tags"].deep_merge!(Tag.search_by_href(self.href).map { |hsh| hsh["name"] }) if reload + @params["tags"].deep_merge! Tag.search_by_href(self.href).map { |hsh| hsh["name"] } if reload @params["tags"] end From f6671fa11b69776e0edc1d230088bc1373e17c2b Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Tue, 30 Aug 2011 21:18:41 -0700 Subject: [PATCH 089/239] Revert "tags merge instead of reload" This reverts commit f72e4c2bfa3ff2f52379fc423c397f5f78200eb7. --- lib/rest_connection/rightscale/mc_server.rb | 2 +- lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb | 3 +-- lib/rest_connection/rightscale/rightscale_api_taggable.rb | 3 +-- lib/rest_connection/rightscale/server.rb | 2 +- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/rest_connection/rightscale/mc_server.rb b/lib/rest_connection/rightscale/mc_server.rb index d8bf027..ad624eb 100644 --- a/lib/rest_connection/rightscale/mc_server.rb +++ b/lib/rest_connection/rightscale/mc_server.rb @@ -238,7 +238,7 @@ def remove_tags(*args) def get_info_tags(*tag_keys) ret = {} - tags = {"self" => self.tags(true)} + tags = {"self" => McTag.search_by_href(self.href).first["tags"].map { |h| h["name"] }} if @current_instance tags["current_instance"] = McTag.search_by_href(self.current_instance_href).first["tags"].map { |h| h["name"] } end diff --git a/lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb b/lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb index aed74a7..9c1ff8b 100644 --- a/lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb +++ b/lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb @@ -32,8 +32,7 @@ def remove_tags(*args) end def tags(reload=false) - @params["tags"] ||= [] - @params["tags"].deep_merge! McTag.search_by_href(self.href).first["tags"].map { |hsh| hsh["name"] } if reload + @params["tags"] = McTag.search_by_href(self.href).first["tags"].map { |hsh| hsh["name"] } if reload @params["tags"] end diff --git a/lib/rest_connection/rightscale/rightscale_api_taggable.rb b/lib/rest_connection/rightscale/rightscale_api_taggable.rb index ab0f5c6..3055a43 100644 --- a/lib/rest_connection/rightscale/rightscale_api_taggable.rb +++ b/lib/rest_connection/rightscale/rightscale_api_taggable.rb @@ -29,8 +29,7 @@ def remove_tags(*args) end def tags(reload=false) - @params["tags"] ||= [] - @params["tags"].deep_merge! Tag.search_by_href(self.href).map { |hsh| hsh["name"] } if reload + @params["tags"] = Tag.search_by_href(self.href).map { |hsh| hsh["name"] } if reload @params["tags"] end diff --git a/lib/rest_connection/rightscale/server.rb b/lib/rest_connection/rightscale/server.rb index 98fb8f8..bfcf5e0 100644 --- a/lib/rest_connection/rightscale/server.rb +++ b/lib/rest_connection/rightscale/server.rb @@ -350,7 +350,7 @@ def remove_tags(*args) def get_info_tags(*tag_keys) ret = {} - tags = {"self" => self.tags(true)} + tags = {"self" => Tag.search_by_href(self.href).map { |h| h["name"] }} if self.current_instance_href tags["current_instance"] = Tag.search_by_href(self.current_instance_href).map { |h| h["name"] } end From 03f36bece039f67a9d604c5d8956ea94606fd623 Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Wed, 31 Aug 2011 14:58:13 -0700 Subject: [PATCH 090/239] [API 1.5] Added Volume, VolumeAttachment, VolumeSnapshot, VolumeType --- lib/rest_connection/rightscale/mc_volume.rb | 53 ++++++++++++++++++ .../rightscale/mc_volume_attachment.rb | 48 ++++++++++++++++ .../rightscale/mc_volume_snapshot.rb | 55 +++++++++++++++++++ .../rightscale/mc_volume_type.rb | 47 ++++++++++++++++ .../rightscale/rightscale_api_mc_taggable.rb | 2 +- .../rightscale/rightscale_api_resources.rb | 4 ++ .../rightscale/rightscale_api_taggable.rb | 2 +- 7 files changed, 209 insertions(+), 2 deletions(-) create mode 100644 lib/rest_connection/rightscale/mc_volume.rb create mode 100644 lib/rest_connection/rightscale/mc_volume_attachment.rb create mode 100644 lib/rest_connection/rightscale/mc_volume_snapshot.rb create mode 100644 lib/rest_connection/rightscale/mc_volume_type.rb diff --git a/lib/rest_connection/rightscale/mc_volume.rb b/lib/rest_connection/rightscale/mc_volume.rb new file mode 100644 index 0000000..9a591fc --- /dev/null +++ b/lib/rest_connection/rightscale/mc_volume.rb @@ -0,0 +1,53 @@ +# This file is part of RestConnection +# +# RestConnection is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# RestConnection is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with RestConnection. If not, see . + +# +# You must have Beta v1.5 API access to use these internal API calls. +# +class McVolume + include RightScale::Api::Gateway + extend RightScale::Api::GatewayExtend + include RightScale::Api::McTaggable + extend RightScale::Api::McTaggableExtend + + def resource_plural_name + "volumes" + end + + def resource_singular_name + "volume" + end + + def self.resource_plural_name + "volumes" + end + + def self.resource_singular_name + "volume" + end + + def self.parse_args(cloud_id) + "clouds/#{cloud_id}/" + end + + def show + inst_href = URI.parse(self.href) + @params.merge! connection.get(inst_href.path, 'view' => 'extended') + end + + def attachment + connection.get(self.current_volume_attachment) + end +end diff --git a/lib/rest_connection/rightscale/mc_volume_attachment.rb b/lib/rest_connection/rightscale/mc_volume_attachment.rb new file mode 100644 index 0000000..7ecf6c5 --- /dev/null +++ b/lib/rest_connection/rightscale/mc_volume_attachment.rb @@ -0,0 +1,48 @@ +# This file is part of RestConnection +# +# RestConnection is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# RestConnection is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with RestConnection. If not, see . + +# +# You must have Beta v1.5 API access to use these internal API calls. +# +class McVolumeAttachment + include RightScale::Api::Gateway + extend RightScale::Api::GatewayExtend + + def resource_plural_name + "volume_attachments" + end + + def resource_singular_name + "volume_attachment" + end + + def self.resource_plural_name + "volume_attachments" + end + + def self.resource_singular_name + "volume_attachment" + end + + def self.parse_args(cloud_id, instance_id=nil) + return "clouds/#{cloud_id}/" unless instance_id + return "clouds/#{cloud_id}/volumes/#{instance_id}/" if instance_id + end + + def show + inst_href = URI.parse(self.href) + @params.merge! connection.get(inst_href.path) + end +end diff --git a/lib/rest_connection/rightscale/mc_volume_snapshot.rb b/lib/rest_connection/rightscale/mc_volume_snapshot.rb new file mode 100644 index 0000000..546b18b --- /dev/null +++ b/lib/rest_connection/rightscale/mc_volume_snapshot.rb @@ -0,0 +1,55 @@ +# This file is part of RestConnection +# +# RestConnection is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# RestConnection is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with RestConnection. If not, see . + +# +# You must have Beta v1.5 API access to use these internal API calls. +# +class McVolumeSnapshot + include RightScale::Api::Gateway + extend RightScale::Api::GatewayExtend + include RightScale::Api::McTaggable + extend RightScale::Api::McTaggableExtend + + def resource_plural_name + "volume_snapshots" + end + + def resource_singular_name + "volume_snapshot" + end + + def self.resource_plural_name + "volume_snapshots" + end + + def self.resource_singular_name + "volume_snapshot" + end + + def self.parse_args(cloud_id, volume_id=nil) + return "clouds/#{cloud_id}/" unless volume_id + return "clouds/#{cloud_id}/volumes/#{volume_id}/" if volume_id + end + + def show + inst_href = URI.parse(self.href) + @params.merge! connection.get(inst_href.path) + end + + def save + inst_href = URI.parse(self.href) + connection.put(inst_href.path, @params) + end +end diff --git a/lib/rest_connection/rightscale/mc_volume_type.rb b/lib/rest_connection/rightscale/mc_volume_type.rb new file mode 100644 index 0000000..8ca2eeb --- /dev/null +++ b/lib/rest_connection/rightscale/mc_volume_type.rb @@ -0,0 +1,47 @@ +# This file is part of RestConnection +# +# RestConnection is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# RestConnection is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with RestConnection. If not, see . + +# +# You must have Beta v1.5 API access to use these internal API calls. +# +class McVolumeType + include RightScale::Api::Gateway + extend RightScale::Api::GatewayExtend + + def resource_plural_name + "volume_types" + end + + def resource_singular_name + "volume_type" + end + + def self.resource_plural_name + "volume_types" + end + + def self.resource_singular_name + "volume_type" + end + + def self.parse_args(cloud_id) + "clouds/#{cloud_id}/" + end + + def show + inst_href = URI.parse(self.href) + @params.merge! connection.get(inst_href.path) + end +end diff --git a/lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb b/lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb index 9c1ff8b..80a158b 100644 --- a/lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb +++ b/lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb @@ -32,7 +32,7 @@ def remove_tags(*args) end def tags(reload=false) - @params["tags"] = McTag.search_by_href(self.href).first["tags"].map { |hsh| hsh["name"] } if reload + @params["tags"] = McTag.search_by_href(self.href).first["tags"].map { |hsh| hsh["name"] } if reload or @params["tags"].nil? @params["tags"] end diff --git a/lib/rest_connection/rightscale/rightscale_api_resources.rb b/lib/rest_connection/rightscale/rightscale_api_resources.rb index cb8cae0..4910d63 100644 --- a/lib/rest_connection/rightscale/rightscale_api_resources.rb +++ b/lib/rest_connection/rightscale/rightscale_api_resources.rb @@ -37,6 +37,10 @@ require 'rest_connection/rightscale/alert_spec' require 'rest_connection/rightscale/ec2_ebs_volume' require 'rest_connection/rightscale/ec2_ebs_snapshot' +require 'rest_connection/rightscale/mc_volume_attachment' +require 'rest_connection/rightscale/mc_volume' +require 'rest_connection/rightscale/mc_volume_snapshot' +require 'rest_connection/rightscale/mc_volume_type' require 'rest_connection/rightscale/server_internal' require 'rest_connection/rightscale/mc_server' require 'rest_connection/rightscale/server_interface' diff --git a/lib/rest_connection/rightscale/rightscale_api_taggable.rb b/lib/rest_connection/rightscale/rightscale_api_taggable.rb index 3055a43..5d2aea5 100644 --- a/lib/rest_connection/rightscale/rightscale_api_taggable.rb +++ b/lib/rest_connection/rightscale/rightscale_api_taggable.rb @@ -29,7 +29,7 @@ def remove_tags(*args) end def tags(reload=false) - @params["tags"] = Tag.search_by_href(self.href).map { |hsh| hsh["name"] } if reload + @params["tags"] = Tag.search_by_href(self.href).map { |hsh| hsh["name"] } if reload or @params["tags"].nil? @params["tags"] end From 2c67820714d837af6e62fa3b23edbea93a6da37e Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Wed, 31 Aug 2011 17:04:01 -0700 Subject: [PATCH 091/239] [API 1.0 & API 1.5] Tag fixes --- lib/rest_connection/rightscale/mc_server.rb | 2 +- lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb | 4 +++- lib/rest_connection/rightscale/rightscale_api_taggable.rb | 4 +++- lib/rest_connection/rightscale/server.rb | 5 ++++- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/rest_connection/rightscale/mc_server.rb b/lib/rest_connection/rightscale/mc_server.rb index ad624eb..d8bf027 100644 --- a/lib/rest_connection/rightscale/mc_server.rb +++ b/lib/rest_connection/rightscale/mc_server.rb @@ -238,7 +238,7 @@ def remove_tags(*args) def get_info_tags(*tag_keys) ret = {} - tags = {"self" => McTag.search_by_href(self.href).first["tags"].map { |h| h["name"] }} + tags = {"self" => self.tags(true)} if @current_instance tags["current_instance"] = McTag.search_by_href(self.current_instance_href).first["tags"].map { |h| h["name"] } end diff --git a/lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb b/lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb index 80a158b..bd6af84 100644 --- a/lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb +++ b/lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb @@ -32,7 +32,9 @@ def remove_tags(*args) end def tags(reload=false) - @params["tags"] = McTag.search_by_href(self.href).first["tags"].map { |hsh| hsh["name"] } if reload or @params["tags"].nil? + @params["tags"] ||= [] + @params["tags"].map! { |item| item.is_a?(Hash) ? item["name"] : item } + @params["tags"].deep_merge!(McTag.search_by_href(self.href).first["tags"].map { |hsh| hsh["name"] }) if reload or @params["tags"].empty? @params["tags"] end diff --git a/lib/rest_connection/rightscale/rightscale_api_taggable.rb b/lib/rest_connection/rightscale/rightscale_api_taggable.rb index 5d2aea5..dff294d 100644 --- a/lib/rest_connection/rightscale/rightscale_api_taggable.rb +++ b/lib/rest_connection/rightscale/rightscale_api_taggable.rb @@ -29,7 +29,9 @@ def remove_tags(*args) end def tags(reload=false) - @params["tags"] = Tag.search_by_href(self.href).map { |hsh| hsh["name"] } if reload or @params["tags"].nil? + @params["tags"] ||= [] + @params["tags"].map! { |item| item.is_a?(Hash) ? item["name"] : item } + @params["tags"].deep_merge!(Tag.search_by_href(self.href).map { |hsh| hsh["name"] }) if reload or @params["tags"].empty? @params["tags"] end diff --git a/lib/rest_connection/rightscale/server.rb b/lib/rest_connection/rightscale/server.rb index bfcf5e0..a6d5807 100644 --- a/lib/rest_connection/rightscale/server.rb +++ b/lib/rest_connection/rightscale/server.rb @@ -200,6 +200,9 @@ def set_inputs(hash = {}) serv_href = URI.parse(self.href) params = self.parameters.deep_merge hash connection.put(serv_href.path, :server => {:parameters => params}) +# TODO Test this!!! +# connection.put(serv_href.path, :server => {:parameters => hash}) +# settings end def set_template(href) @@ -350,7 +353,7 @@ def remove_tags(*args) def get_info_tags(*tag_keys) ret = {} - tags = {"self" => Tag.search_by_href(self.href).map { |h| h["name"] }} + tags = {"self" => self.tags(true)} if self.current_instance_href tags["current_instance"] = Tag.search_by_href(self.current_instance_href).map { |h| h["name"] } end From 805e72207daf2179e95f8dd5dd2af30637c883dc Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Wed, 31 Aug 2011 20:20:54 -0700 Subject: [PATCH 092/239] McTag fixes --- lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb b/lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb index bd6af84..1bdc3a4 100644 --- a/lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb +++ b/lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb @@ -91,8 +91,8 @@ def clear_tags(namespace = nil) module McTaggableExtend def find_by_tags(*args) a = Array.new - McTag.search(self.resource_singular_name, args.uniq).each do |object| - a << self.new(object) + McTag.search(self.resource_plural_name, args.uniq).first["links"].each do |hash| + a << self.find(hash["href"]) end return a end From c00092614649537dbaf85eeb278a6d7f296f4af1 Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Thu, 1 Sep 2011 10:12:26 -0700 Subject: [PATCH 093/239] Bugfix for McTaggable search --- .../rightscale/rightscale_api_mc_taggable.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb b/lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb index 1bdc3a4..32678ff 100644 --- a/lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb +++ b/lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb @@ -91,8 +91,11 @@ def clear_tags(namespace = nil) module McTaggableExtend def find_by_tags(*args) a = Array.new - McTag.search(self.resource_plural_name, args.uniq).first["links"].each do |hash| - a << self.find(hash["href"]) + search = McTag.search(self.resource_plural_name, args.uniq).first + if search + search["links"].each do |hash| + a << self.find(hash["href"]) + end end return a end From 9fbca32ac54ec0b57e35283a97a0553f6ab24efa Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Fri, 2 Sep 2011 11:50:05 -0700 Subject: [PATCH 094/239] bugfix --- lib/rest_connection/rightscale/task.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rest_connection/rightscale/task.rb b/lib/rest_connection/rightscale/task.rb index 5f21731..82908eb 100644 --- a/lib/rest_connection/rightscale/task.rb +++ b/lib/rest_connection/rightscale/task.rb @@ -38,7 +38,7 @@ def wait_for_state(state, timeout=900) sleep 30 timeout -= 30 end - raise "FATAL: Timeout waiting for Executable to complete. State was #{self.state}" if timeout <= 0 + raise "FATAL: Timeout waiting for Executable to complete. State was #{self.summary}" if timeout <= 0 end def wait_for_completed(legacy=nil) From cce4ad9878ae4e05b554018024604b7df48b9ed7 Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Wed, 7 Sep 2011 09:14:39 -0700 Subject: [PATCH 095/239] remove_info_tag fixes --- lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb | 2 +- lib/rest_connection/rightscale/rightscale_api_taggable.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb b/lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb index 32678ff..01f89cd 100644 --- a/lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb +++ b/lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb @@ -40,7 +40,7 @@ def tags(reload=false) def remove_info_tags(*tag_keys) tags_to_unset = [] - tags = get_tag_values(*(tag_keys.uniq)) + tags = get_info_tags(*(tag_keys.uniq)) tags.each { |res,hsh| hsh.each { |k,v| tags_to_unset << "info:#{k}=#{v}" diff --git a/lib/rest_connection/rightscale/rightscale_api_taggable.rb b/lib/rest_connection/rightscale/rightscale_api_taggable.rb index dff294d..ecd54c8 100644 --- a/lib/rest_connection/rightscale/rightscale_api_taggable.rb +++ b/lib/rest_connection/rightscale/rightscale_api_taggable.rb @@ -37,7 +37,7 @@ def tags(reload=false) def remove_info_tags(*tag_keys) tags_to_unset = [] - tags = get_tag_values(*(tag_keys.uniq)) + tags = get_info_tags(*(tag_keys.uniq)) tags.each { |res,hsh| hsh.each { |k,v| tags_to_unset << "info:#{k}=#{v}" From 9ad5d1dc4a94c231353bd6756685273836fe8814 Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Fri, 9 Sep 2011 14:34:22 -0700 Subject: [PATCH 096/239] Changed all dns_name references to reachable_ip for Private Clouds --- lib/rest_connection/rightscale/mc_server.rb | 8 ++++---- lib/rest_connection/rightscale/server.rb | 9 +++++---- lib/rest_connection/ssh_hax.rb | 18 +++++++++--------- 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/lib/rest_connection/rightscale/mc_server.rb b/lib/rest_connection/rightscale/mc_server.rb index d8bf027..a770419 100644 --- a/lib/rest_connection/rightscale/mc_server.rb +++ b/lib/rest_connection/rightscale/mc_server.rb @@ -171,13 +171,13 @@ def wait_for_operational_with_dns(state_wait_timeout=1200) step = 15 while(timeout > 0) self.settings - break if self.dns_name - connection.logger "waiting for a public IP for #{self.nickname}" + break if self.reachable_ip + connection.logger "waiting for any IP for #{self.nickname}" sleep step timeout -= step end - connection.logger "got IP: #{self.dns_name}" - raise "FATAL, this server #{self.audit_link} timed out waiting for DNS" if timeout <= 0 + connection.logger "got IP: #{self.reachable_ip}" + raise "FATAL, this server #{self.audit_link} timed out waiting for an IP" if timeout <= 0 end def dns_name diff --git a/lib/rest_connection/rightscale/server.rb b/lib/rest_connection/rightscale/server.rb index a6d5807..49039d7 100644 --- a/lib/rest_connection/rightscale/server.rb +++ b/lib/rest_connection/rightscale/server.rb @@ -96,13 +96,14 @@ def wait_for_operational_with_dns(state_wait_timeout=1200) step = 15 while(timeout > 0) self.settings - break if self['dns-name'] && !self['dns-name'].empty? && self['private-dns-name'] && !self['private-dns-name'].empty? - connection.logger "waiting for dns-name for #{self.nickname}" +# break if self['dns-name'] && !self['dns-name'].empty? && self['private-dns-name'] && !self['private-dns-name'].empty? + break if self.reachable_ip + connection.logger "waiting for IP for #{self.nickname}" sleep step timeout -= step end - connection.logger "got DNS: #{self['dns-name']}" - raise "FATAL, this server #{self.audit_link} timed out waiting for DNS" if timeout <= 0 + connection.logger "got IP: #{self.reachable_ip}" + raise "FATAL, this server #{self.audit_link} timed out waiting for IP" if timeout <= 0 end def audit_link diff --git a/lib/rest_connection/ssh_hax.rb b/lib/rest_connection/ssh_hax.rb index c262f8c..24ffef7 100644 --- a/lib/rest_connection/ssh_hax.rb +++ b/lib/rest_connection/ssh_hax.rb @@ -37,7 +37,7 @@ def ssh_key_config(item) ssh_keys end - def run_and_tail(run_this, tail_command, expect, ssh_key=nil, host_dns=self.dns_name) + def run_and_tail(run_this, tail_command, expect, ssh_key=nil, host_dns=self.reachable_ip) status = nil result = nil output = "" @@ -96,7 +96,7 @@ def run_and_tail(run_this, tail_command, expect, ssh_key=nil, host_dns=self.dns_ # script is an Executable object with minimally nick or id set def run_executable_with_ssh(script, options={}, ssh_key=nil) - raise "FATAL: run_executable called on a server with no dns_name. You need to run .settings on the server to populate this attribute." unless self.dns_name + raise "FATAL: run_executable called on a server with no reachable_ip. You need to run .settings on the server to populate this attribute." unless self.reachable_ip if script.is_a?(Executable) script = script.right_script end @@ -116,9 +116,9 @@ def run_executable_with_ssh(script, options={}, ssh_key=nil) end # recipe can be either a String, or an Executable - # host_dns is optional and will default to objects self.dns_name - def run_recipe_with_ssh(recipe, ssh_key=nil, host_dns=self.dns_name) - raise "FATAL: run_script called on a server with no dns_name. You need to run .settings on the server to populate this attribute." unless self.dns_name + # host_dns is optional and will default to objects self.reachable_ip + def run_recipe_with_ssh(recipe, ssh_key=nil, host_dns=self.reachable_ip) + raise "FATAL: run_script called on a server with no reachable_ip. You need to run .settings on the server to populate this attribute." unless self.reachable_ip if recipe.is_a?(Executable) recipe = recipe.recipe end @@ -128,7 +128,7 @@ def run_recipe_with_ssh(recipe, ssh_key=nil, host_dns=self.dns_name) run_and_tail(run_this, tail_command, expect, ssh_key) end - def spot_check(command, ssh_key=nil, host_dns=self.dns_name, &block) + def spot_check(command, ssh_key=nil, host_dns=self.reachable_ip, &block) connection.logger "SSHing to #{host_dns}" Net::SSH.start(host_dns, 'root', :keys => ssh_key_config(ssh_key)) do |ssh| result = ssh.exec!(command) @@ -137,15 +137,15 @@ def spot_check(command, ssh_key=nil, host_dns=self.dns_name, &block) end # returns true or false based on command success - def spot_check_command?(command, ssh_key=nil, host_dns=self.dns_name) + def spot_check_command?(command, ssh_key=nil, host_dns=self.reachable_ip) results = spot_check_command(command, ssh_key, host_dns) return results[:status] == 0 end # returns hash of exit_status and output from command - def spot_check_command(command, ssh_key=nil, host_dns=self.dns_name, do_not_log_result=false) - raise "FATAL: spot_check_command called on a server with no dns_name. You need to run .settings on the server to populate this attribute." unless host_dns + def spot_check_command(command, ssh_key=nil, host_dns=self.reachable_ip, do_not_log_result=false) + raise "FATAL: spot_check_command called on a server with no reachable_ip. You need to run .settings on the server to populate this attribute." unless host_dns connection.logger "SSHing to #{host_dns} using key(s) #{ssh_key_config(ssh_key)}" status = nil output = "" From 1f3789a815d23084647e4a918cd5c33e1ae7f16b Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Fri, 9 Sep 2011 14:46:41 -0700 Subject: [PATCH 097/239] net-ssh gem version conflict with fog-0.11 --- rest_connection.gemspec | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rest_connection.gemspec b/rest_connection.gemspec index 2186607..8c404e9 100644 --- a/rest_connection.gemspec +++ b/rest_connection.gemspec @@ -104,16 +104,16 @@ Gem::Specification.new do |s| if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then s.add_runtime_dependency(%q, ["= 2.3.10"]) - s.add_runtime_dependency(%q, [">= 0"]) + s.add_runtime_dependency(%q, ["= 2.1.4"]) s.add_runtime_dependency(%q, [">= 0"]) else s.add_dependency(%q, ["= 2.3.10"]) - s.add_dependency(%q, [">= 0"]) + s.add_dependency(%q, ["= 2.1.4"]) s.add_dependency(%q, [">= 0"]) end else s.add_dependency(%q, ["= 2.3.10"]) - s.add_dependency(%q, [">= 0"]) + s.add_dependency(%q, ["= 2.1.4"]) s.add_dependency(%q, [">= 0"]) end end From aa2a14d526d1483b2ff0fa2cb7d2949cb5a424c6 Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Fri, 9 Sep 2011 15:53:47 -0700 Subject: [PATCH 098/239] net-ssh gem version conflict with fog-0.11 --- Rakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Rakefile b/Rakefile index 3abb5a3..0e0e171 100644 --- a/Rakefile +++ b/Rakefile @@ -8,7 +8,7 @@ Jeweler::Tasks.new do |gemspec| gemspec.homepage = "http://github.com/jeremyd/rest_connection" gemspec.authors = ["Jeremy Deininger"] gemspec.add_dependency('activesupport', "=2.3.10") - gemspec.add_dependency('net-ssh') + gemspec.add_dependency('net-ssh', "=2.1.4") gemspec.add_dependency('json') end Jeweler::GemcutterTasks.new From 0925b4fdf1ad2e4140c26f2c07d91eceb16ee8ef Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Thu, 15 Sep 2011 17:52:55 -0700 Subject: [PATCH 099/239] Merge fixes, ServerInterface fixes --- lib/rest_connection/rightscale/mc_server.rb | 2 ++ lib/rest_connection/rightscale/mc_tag.rb | 6 ++-- lib/rest_connection/rightscale/server.rb | 6 ++-- .../rightscale/server_interface.rb | 32 +++++++++---------- 4 files changed, 25 insertions(+), 21 deletions(-) diff --git a/lib/rest_connection/rightscale/mc_server.rb b/lib/rest_connection/rightscale/mc_server.rb index a770419..b8aac37 100644 --- a/lib/rest_connection/rightscale/mc_server.rb +++ b/lib/rest_connection/rightscale/mc_server.rb @@ -165,6 +165,7 @@ def cloud_id return cloud_href.split("/").last.to_i end +=begin def wait_for_operational_with_dns(state_wait_timeout=1200) timeout = 600 wait_for_state("operational", state_wait_timeout) @@ -179,6 +180,7 @@ def wait_for_operational_with_dns(state_wait_timeout=1200) connection.logger "got IP: #{self.reachable_ip}" raise "FATAL, this server #{self.audit_link} timed out waiting for an IP" if timeout <= 0 end +=end def dns_name self.settings diff --git a/lib/rest_connection/rightscale/mc_tag.rb b/lib/rest_connection/rightscale/mc_tag.rb index b1b7238..46244e1 100644 --- a/lib/rest_connection/rightscale/mc_tag.rb +++ b/lib/rest_connection/rightscale/mc_tag.rb @@ -36,8 +36,10 @@ def self.resource_singular_name "tag" end - def self.search(resource_type, tags) #, include_tags_with_prefix = false) - result = connection.post("tags/by_tag", :resource_type => resource_type.to_s, :tags => tags) + def self.search(resource_name, tags, opts=nil) #, include_tags_with_prefix = false) + parameters = { :resource_type => resource_name.to_s, :tags => tags } + parameters.merge!(opts) unless opts.nil? + result = connection.post("tags/by_tag", parameters) end def self.search_by_href(*resource_hrefs) diff --git a/lib/rest_connection/rightscale/server.rb b/lib/rest_connection/rightscale/server.rb index 352febb..3023265 100644 --- a/lib/rest_connection/rightscale/server.rb +++ b/lib/rest_connection/rightscale/server.rb @@ -74,9 +74,9 @@ def wait_for_state(st,timeout=1200) while(timeout > 0) return true if state =~ /#{st}/ raise "FATAL error, this server is stranded and needs to be #{st}: #{nickname}, see audit: #{self.audit_link}" if state.include?('stranded') && !st.include?('stranded') - raise "FATAL error, this server went to error state and needs to be #{st}: #{nickname}, see audit: #{self.audit_link}" if state.include?('error') && !st.include?('error') + raise "FATAL error, this server went to error state and needs to be #{st}: #{nickname}, see audit: #{self.audit_link}" if state.include?('error') && st !~ /error|terminated|stopped/ connection.logger("waiting for server #{nickname} to go #{st}, state is #{state}") - if state =~ /terminated|stopped/ and st !~ /terminated|stopped/ + if state =~ /terminated|stopped|error/ and st !~ /terminated|stopped|error/ if catch_early_terminated <= 0 raise "FATAL error, this server terminated when waiting for #{st}: #{nickname}" end @@ -178,7 +178,7 @@ def run_executable(executable, opts=nil, ignore_lock=false) serv_href = URI.parse(self.href) script_options[:server][:parameters] = opts unless opts.nil? - script_options[:server][:ignore_lock] = true if ignore_lock + script_options[:server][:ignore_lock] = "true" if ignore_lock location = connection.post(serv_href.path + '/run_executable', script_options) AuditEntry.new('href' => location) end diff --git a/lib/rest_connection/rightscale/server_interface.rb b/lib/rest_connection/rightscale/server_interface.rb index d9203e2..44f0c82 100644 --- a/lib/rest_connection/rightscale/server_interface.rb +++ b/lib/rest_connection/rightscale/server_interface.rb @@ -192,8 +192,8 @@ def translate_href(old_href) # Since RightScale hands back the parameters with a "name" and "value" tags we should # transform them into the proper hash. This it the same for setting and getting. def parameters - @impl.parameters unless @multicloud - @impl.inputs if @multicloud + return @impl.parameters unless @multicloud + return @impl.inputs if @multicloud end def inputs @@ -209,34 +209,34 @@ def stop end def launch - @impl.launch if @multicloud - @impl.start unless @multicloud + return @impl.launch if @multicloud + return @impl.start unless @multicloud end def terminate - @impl.terminate if @multicloud - @impl.stop unless @multicloud + return @impl.terminate if @multicloud + return @impl.stop unless @multicloud end def start_ebs - connection.logger("WARNING: Gateway Servers do not support start_ebs. Ignoring.") if @multicloud - @impl.start_ebs unless @multicloud + return connection.logger("WARNING: Gateway Servers do not support start_ebs. Ignoring.") if @multicloud + return @impl.start_ebs unless @multicloud end def stop_ebs - connection.logger("WARNING: Gateway Servers do not support stop_ebs. Ignoring.") if @multicloud - @impl.stop_ebs unless @multicloud + return connection.logger("WARNING: Gateway Servers do not support stop_ebs. Ignoring.") if @multicloud + return @impl.stop_ebs unless @multicloud end # This should be used with v4 images only. def run_script(script,opts=nil) - connection.logger("WARNING: Gateway Servers do not support run_script. Did you mean run_executable?") if @multicloud - @impl.run_script(script,opts) unless @multicloud + return connection.logger("WARNING: Gateway Servers do not support run_script. Did you mean run_executable?") if @multicloud + return @impl.run_script(script,opts) unless @multicloud end def attach_volume(params) - connection.logger("WARNING: Gateway Servers do not support attach_volume. Ignoring.") if @multicloud - @impl.attach_volume(params) unless @multicloud + return connection.logger("WARNING: Gateway Servers do not support attach_volume. Ignoring.") if @multicloud + return @impl.attach_volume(params) unless @multicloud end def wait_for_state(st,timeout=1200) @@ -260,14 +260,14 @@ def save(new_params = nil) def set_inputs(hash = {}) if @multicloud - @impl.set_inputs(hash) + return @impl.set_inputs(hash) else if @impl.current_instance_href and @impl.state != "stopped" @impl.reload_as_current @impl.set_inputs(hash) @impl.reload_as_next end - @impl.set_inputs(hash) + return @impl.set_inputs(hash) end end From bf35791ae2f94d781842df1f907ae081f58d5bf4 Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Wed, 21 Sep 2011 12:39:47 -0700 Subject: [PATCH 100/239] Bugfix for clear_tags --- lib/rest_connection/rightscale/mc_server.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rest_connection/rightscale/mc_server.rb b/lib/rest_connection/rightscale/mc_server.rb index b8aac37..3e3dab2 100644 --- a/lib/rest_connection/rightscale/mc_server.rb +++ b/lib/rest_connection/rightscale/mc_server.rb @@ -263,7 +263,7 @@ def get_info_tags(*tag_keys) def clear_tags(namespace = nil) tags = McTag.search_by_href(self.href).first["tags"].map { |h| h["name"] } tags.deep_merge! McTag.search_by_href(self.current_instance_href).first["tags"].map { |h| h["name"] } if @current_instance - tags = tags.select { |hsh| hsh["name"].start_with?("#{namespace}:") } if namespace + tags = tags.select { |tag| tag.start_with?("#{namespace}:") } if namespace self.remove_tags(*tags) end end From 829075bba3e82ad3138b8849b929d0d65a359afb Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Wed, 21 Sep 2011 13:31:29 -0700 Subject: [PATCH 101/239] Whitespace cleanup and Taggable interface improvements --- lib/rest_connection/rightscale/alert_spec.rb | 4 +- lib/rest_connection/rightscale/audit_entry.rb | 4 +- lib/rest_connection/rightscale/cloud.rb | 6 +- lib/rest_connection/rightscale/credential.rb | 2 +- lib/rest_connection/rightscale/deployment.rb | 2 +- .../rightscale/ec2_ebs_snapshot.rb | 2 +- .../rightscale/ec2_ebs_volume.rb | 2 +- .../rightscale/ec2_elastic_ip.rb | 2 +- .../rightscale/ec2_security_group.rb | 4 +- .../rightscale/ec2_server_array.rb | 10 ++-- lib/rest_connection/rightscale/ec2_ssh_key.rb | 4 +- .../rightscale/ec2_ssh_key_internal.rb | 4 +- lib/rest_connection/rightscale/executable.rb | 8 +-- lib/rest_connection/rightscale/instance.rb | 6 +- .../rightscale/instance_type.rb | 10 ++-- lib/rest_connection/rightscale/macro.rb | 4 +- .../rightscale/mc_datacenter.rb | 10 ++-- .../rightscale/mc_deployment.rb | 10 ++-- lib/rest_connection/rightscale/mc_image.rb | 10 ++-- lib/rest_connection/rightscale/mc_instance.rb | 12 ++-- .../rightscale/mc_instance_type.rb | 10 ++-- .../rightscale/mc_multi_cloud_image.rb | 10 ++-- .../mc_multi_cloud_image_setting.rb | 10 ++-- .../rightscale/mc_security_group.rb | 10 ++-- lib/rest_connection/rightscale/mc_server.rb | 40 +++++++------- .../rightscale/mc_server_array.rb | 10 ++-- .../rightscale/mc_server_template.rb | 10 ++-- lib/rest_connection/rightscale/mc_ssh_key.rb | 12 ++-- lib/rest_connection/rightscale/mc_tag.rb | 6 +- lib/rest_connection/rightscale/mc_volume.rb | 10 ++-- .../rightscale/mc_volume_attachment.rb | 10 ++-- .../rightscale/mc_volume_snapshot.rb | 10 ++-- .../rightscale/mc_volume_type.rb | 10 ++-- .../rightscale/monitoring_metric.rb | 8 +-- .../rightscale/multi_cloud_image.rb | 6 +- ...ulti_cloud_image_cloud_setting_internal.rb | 4 +- .../rightscale/multi_cloud_image_internal.rb | 6 +- .../rightscale/right_script.rb | 8 +-- .../rightscale/right_script_internal.rb | 8 +-- .../rightscale/rightscale_api_base.rb | 32 +++++------ .../rightscale/rightscale_api_gateway.rb | 24 ++++---- .../rightscale/rightscale_api_internal.rb | 6 +- .../rightscale/rightscale_api_mc_taggable.rb | 55 ++++++++++++------- .../rightscale/rightscale_api_resources.rb | 2 +- .../rightscale/rightscale_api_taggable.rb | 51 +++++++++++------ lib/rest_connection/rightscale/rs_internal.rb | 12 ++-- lib/rest_connection/rightscale/s3_bucket.rb | 4 +- lib/rest_connection/rightscale/server.rb | 48 ++++++++-------- .../rightscale/server_interface.rb | 6 +- .../rightscale/server_internal.rb | 6 +- .../rightscale/server_template.rb | 6 +- .../rightscale/server_template_internal.rb | 8 +-- lib/rest_connection/rightscale/status.rb | 4 +- lib/rest_connection/rightscale/tag.rb | 4 +- lib/rest_connection/rightscale/task.rb | 8 +-- 55 files changed, 314 insertions(+), 276 deletions(-) diff --git a/lib/rest_connection/rightscale/alert_spec.rb b/lib/rest_connection/rightscale/alert_spec.rb index 7bf7a44..e6ff403 100644 --- a/lib/rest_connection/rightscale/alert_spec.rb +++ b/lib/rest_connection/rightscale/alert_spec.rb @@ -1,4 +1,4 @@ -# This file is part of RestConnection +# This file is part of RestConnection # # RestConnection is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -24,4 +24,4 @@ def attach(params) end -end +end diff --git a/lib/rest_connection/rightscale/audit_entry.rb b/lib/rest_connection/rightscale/audit_entry.rb index 9e9975d..9a2a8bb 100644 --- a/lib/rest_connection/rightscale/audit_entry.rb +++ b/lib/rest_connection/rightscale/audit_entry.rb @@ -1,4 +1,4 @@ -# This file is part of RestConnection +# This file is part of RestConnection # # RestConnection is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -45,4 +45,4 @@ def wait_for_state(state, timeout=900) def wait_for_completed(timeout=900) wait_for_state("completed", timeout) end -end +end diff --git a/lib/rest_connection/rightscale/cloud.rb b/lib/rest_connection/rightscale/cloud.rb index ecbc008..c648362 100644 --- a/lib/rest_connection/rightscale/cloud.rb +++ b/lib/rest_connection/rightscale/cloud.rb @@ -1,4 +1,4 @@ -# This file is part of RestConnection +# This file is part of RestConnection # # RestConnection is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -13,9 +13,9 @@ # You should have received a copy of the GNU General Public License # along with RestConnection. If not, see . -# +# # You must have Beta v1.5 API access to use these internal API calls. -# +# class Cloud include RightScale::Api::Gateway extend RightScale::Api::GatewayExtend diff --git a/lib/rest_connection/rightscale/credential.rb b/lib/rest_connection/rightscale/credential.rb index 5ea8f05..171f4f4 100644 --- a/lib/rest_connection/rightscale/credential.rb +++ b/lib/rest_connection/rightscale/credential.rb @@ -1,4 +1,4 @@ -# This file is part of RestConnection +# This file is part of RestConnection # # RestConnection is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/lib/rest_connection/rightscale/deployment.rb b/lib/rest_connection/rightscale/deployment.rb index 1979d33..5daf0bd 100644 --- a/lib/rest_connection/rightscale/deployment.rb +++ b/lib/rest_connection/rightscale/deployment.rb @@ -1,4 +1,4 @@ -# This file is part of RestConnection +# This file is part of RestConnection # # RestConnection is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/lib/rest_connection/rightscale/ec2_ebs_snapshot.rb b/lib/rest_connection/rightscale/ec2_ebs_snapshot.rb index fcb1f1f..16d5ef0 100644 --- a/lib/rest_connection/rightscale/ec2_ebs_snapshot.rb +++ b/lib/rest_connection/rightscale/ec2_ebs_snapshot.rb @@ -1,4 +1,4 @@ -# This file is part of RestConnection +# This file is part of RestConnection # # RestConnection is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/lib/rest_connection/rightscale/ec2_ebs_volume.rb b/lib/rest_connection/rightscale/ec2_ebs_volume.rb index 0e197fa..d2b437e 100644 --- a/lib/rest_connection/rightscale/ec2_ebs_volume.rb +++ b/lib/rest_connection/rightscale/ec2_ebs_volume.rb @@ -1,4 +1,4 @@ -# This file is part of RestConnection +# This file is part of RestConnection # # RestConnection is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/lib/rest_connection/rightscale/ec2_elastic_ip.rb b/lib/rest_connection/rightscale/ec2_elastic_ip.rb index 157f030..baf044a 100644 --- a/lib/rest_connection/rightscale/ec2_elastic_ip.rb +++ b/lib/rest_connection/rightscale/ec2_elastic_ip.rb @@ -1,4 +1,4 @@ -# This file is part of RestConnection +# This file is part of RestConnection # # RestConnection is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/lib/rest_connection/rightscale/ec2_security_group.rb b/lib/rest_connection/rightscale/ec2_security_group.rb index ead9e01..921d6e6 100644 --- a/lib/rest_connection/rightscale/ec2_security_group.rb +++ b/lib/rest_connection/rightscale/ec2_security_group.rb @@ -1,4 +1,4 @@ -# This file is part of RestConnection +# This file is part of RestConnection # # RestConnection is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -13,7 +13,7 @@ # You should have received a copy of the GNU General Public License # along with RestConnection. If not, see . -class Ec2SecurityGroup +class Ec2SecurityGroup include RightScale::Api::Base extend RightScale::Api::BaseExtend end diff --git a/lib/rest_connection/rightscale/ec2_server_array.rb b/lib/rest_connection/rightscale/ec2_server_array.rb index f9906eb..29c3cf7 100644 --- a/lib/rest_connection/rightscale/ec2_server_array.rb +++ b/lib/rest_connection/rightscale/ec2_server_array.rb @@ -1,4 +1,4 @@ -# This file is part of RestConnection +# This file is part of RestConnection # # RestConnection is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -13,7 +13,7 @@ # You should have received a copy of the GNU General Public License # along with RestConnection. If not, see . -class Ec2ServerArray +class Ec2ServerArray include RightScale::Api::Base extend RightScale::Api::BaseExtend include RightScale::Api::Taggable @@ -25,7 +25,7 @@ class Ec2ServerArray def run_script_on_all(script, server_template_hrefs, inputs=nil) serv_href = URI.parse(self.href) options = Hash.new - options[:ec2_server_array] = Hash.new + options[:ec2_server_array] = Hash.new options[:ec2_server_array][:right_script_href] = script.href options[:ec2_server_array][:parameters] = inputs unless inputs.nil? options[:ec2_server_array][:server_template_hrefs] = server_template_hrefs @@ -38,8 +38,8 @@ def instances connection.get("#{serv_href.path}/instances") rescue [] # raise an error on self.href which we want, it'll just rescue on rackspace and return an empty array. - end - + end + def terminate_all serv_href = URI.parse(self.href) connection.post("#{serv_href.path}/terminate_all") diff --git a/lib/rest_connection/rightscale/ec2_ssh_key.rb b/lib/rest_connection/rightscale/ec2_ssh_key.rb index 143bfea..8964024 100644 --- a/lib/rest_connection/rightscale/ec2_ssh_key.rb +++ b/lib/rest_connection/rightscale/ec2_ssh_key.rb @@ -1,4 +1,4 @@ -# This file is part of RestConnection +# This file is part of RestConnection # # RestConnection is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -13,7 +13,7 @@ # You should have received a copy of the GNU General Public License # along with RestConnection. If not, see . -class Ec2SshKey +class Ec2SshKey include RightScale::Api::Base extend RightScale::Api::BaseExtend diff --git a/lib/rest_connection/rightscale/ec2_ssh_key_internal.rb b/lib/rest_connection/rightscale/ec2_ssh_key_internal.rb index c9fbe99..3d1106a 100644 --- a/lib/rest_connection/rightscale/ec2_ssh_key_internal.rb +++ b/lib/rest_connection/rightscale/ec2_ssh_key_internal.rb @@ -1,4 +1,4 @@ -# This file is part of RestConnection +# This file is part of RestConnection # # RestConnection is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -13,7 +13,7 @@ # You should have received a copy of the GNU General Public License # along with RestConnection. If not, see . -class Ec2SshKeyInternal +class Ec2SshKeyInternal include RightScale::Api::Base extend RightScale::Api::BaseExtend diff --git a/lib/rest_connection/rightscale/executable.rb b/lib/rest_connection/rightscale/executable.rb index 2cfc787..23ffc6c 100644 --- a/lib/rest_connection/rightscale/executable.rb +++ b/lib/rest_connection/rightscale/executable.rb @@ -1,4 +1,4 @@ -class Executable +class Executable include RightScale::Api::Base extend RightScale::Api::BaseExtend @@ -9,8 +9,8 @@ class Executable # { :recipe => # :position => 12, # :apply => "operational", - # :right_script => { "href" => "http://blah", - # "name" => "blah" + # :right_script => { "href" => "http://blah", + # "name" => "blah" # ... # } @@ -37,7 +37,7 @@ def name end def href - if right_script? + if right_script? return right_script.href else #recipes do not have hrefs, only names diff --git a/lib/rest_connection/rightscale/instance.rb b/lib/rest_connection/rightscale/instance.rb index cfd5deb..d5ab268 100644 --- a/lib/rest_connection/rightscale/instance.rb +++ b/lib/rest_connection/rightscale/instance.rb @@ -1,4 +1,4 @@ -# This file is part of RestConnection +# This file is part of RestConnection # # RestConnection is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -16,14 +16,14 @@ # This is an instance facing api and can only be used with # an authentication URL normally found in the instance's userdata called # RS_API_URL -class Instance +class Instance include RightScale::Api::Base extend RightScale::Api::BaseExtend include RightScale::Api::Taggable extend RightScale::Api::TaggableExtend #def create_ebs_volume_from_snap(snap_aws_id) # connection.post('create_ebs_volume.js', :aws_id => snap_aws_id ) - #end + #end def attach_ebs_volume(params) connection.put('attach_ebs_volume.js', params) diff --git a/lib/rest_connection/rightscale/instance_type.rb b/lib/rest_connection/rightscale/instance_type.rb index 9d87161..9a99e05 100644 --- a/lib/rest_connection/rightscale/instance_type.rb +++ b/lib/rest_connection/rightscale/instance_type.rb @@ -1,4 +1,4 @@ -# This file is part of RestConnection +# This file is part of RestConnection # # RestConnection is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -13,17 +13,17 @@ # You should have received a copy of the GNU General Public License # along with RestConnection. If not, see . -# +# # You must have Beta v1.5 API access to use these internal API calls. -# +# class InstanceType include RightScale::Api::Gateway extend RightScale::Api::GatewayExtend - + def self.parse_args(cloud_id) "clouds/#{cloud_id}/" end - + def show inst_href = URI.parse(self.href) @params.merge! connection.get(inst_href.path, 'view' => "default") diff --git a/lib/rest_connection/rightscale/macro.rb b/lib/rest_connection/rightscale/macro.rb index a903d7e..843462f 100644 --- a/lib/rest_connection/rightscale/macro.rb +++ b/lib/rest_connection/rightscale/macro.rb @@ -1,4 +1,4 @@ -# This file is part of RestConnection +# This file is part of RestConnection # # RestConnection is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -16,4 +16,4 @@ class Macro include RightScale::Api::Base extend RightScale::Api::BaseExtend -end +end diff --git a/lib/rest_connection/rightscale/mc_datacenter.rb b/lib/rest_connection/rightscale/mc_datacenter.rb index f2e1098..decd54d 100644 --- a/lib/rest_connection/rightscale/mc_datacenter.rb +++ b/lib/rest_connection/rightscale/mc_datacenter.rb @@ -1,4 +1,4 @@ -# This file is part of RestConnection +# This file is part of RestConnection # # RestConnection is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -13,13 +13,13 @@ # You should have received a copy of the GNU General Public License # along with RestConnection. If not, see . -# +# # You must have Beta v1.5 API access to use these internal API calls. -# +# class McDatacenter include RightScale::Api::Gateway extend RightScale::Api::GatewayExtend - + def resource_plural_name "datacenters" end @@ -35,7 +35,7 @@ def self.resource_plural_name def self.resource_singular_name "datacenter" end - + def self.parse_args(cloud_id) "clouds/#{cloud_id}/" end diff --git a/lib/rest_connection/rightscale/mc_deployment.rb b/lib/rest_connection/rightscale/mc_deployment.rb index c402386..2fef765 100644 --- a/lib/rest_connection/rightscale/mc_deployment.rb +++ b/lib/rest_connection/rightscale/mc_deployment.rb @@ -1,4 +1,4 @@ -# This file is part of RestConnection +# This file is part of RestConnection # # RestConnection is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -13,15 +13,15 @@ # You should have received a copy of the GNU General Public License # along with RestConnection. If not, see . -# +# # You must have Beta v1.5 API access to use these internal API calls. -# +# class McDeployment include RightScale::Api::Gateway extend RightScale::Api::GatewayExtend include RightScale::Api::McTaggable extend RightScale::Api::McTaggableExtend - + def resource_plural_name "deployments" end @@ -37,7 +37,7 @@ def self.resource_plural_name def self.resource_singular_name "deployment" end - + def show inst_href = URI.parse(self.href) @params.merge! connection.get(inst_href.path, 'view' => "inputs") diff --git a/lib/rest_connection/rightscale/mc_image.rb b/lib/rest_connection/rightscale/mc_image.rb index 8d8d370..440598f 100644 --- a/lib/rest_connection/rightscale/mc_image.rb +++ b/lib/rest_connection/rightscale/mc_image.rb @@ -1,4 +1,4 @@ -# This file is part of RestConnection +# This file is part of RestConnection # # RestConnection is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -13,13 +13,13 @@ # You should have received a copy of the GNU General Public License # along with RestConnection. If not, see . -# +# # You must have Beta v1.5 API access to use these internal API calls. -# +# class McImage include RightScale::Api::Gateway extend RightScale::Api::GatewayExtend - + def resource_plural_name "images" end @@ -35,7 +35,7 @@ def self.resource_plural_name def self.resource_singular_name "image" end - + def self.parse_args(cloud_id) "clouds/#{cloud_id}/" end diff --git a/lib/rest_connection/rightscale/mc_instance.rb b/lib/rest_connection/rightscale/mc_instance.rb index 2283114..1986353 100644 --- a/lib/rest_connection/rightscale/mc_instance.rb +++ b/lib/rest_connection/rightscale/mc_instance.rb @@ -1,4 +1,4 @@ -# This file is part of RestConnection +# This file is part of RestConnection # # RestConnection is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -13,16 +13,16 @@ # You should have received a copy of the GNU General Public License # along with RestConnection. If not, see . -# +# # You must have Beta v1.5 API access to use these internal API calls. -# +# class McInstance include RightScale::Api::Gateway extend RightScale::Api::GatewayExtend include RightScale::Api::McTaggable extend RightScale::Api::McTaggableExtend attr_accessor :monitoring_metrics - + def resource_plural_name "instances" end @@ -38,11 +38,11 @@ def self.resource_plural_name def self.resource_singular_name "instance" end - + def self.parse_args(cloud_id) "clouds/#{cloud_id}/" end - + def show inst_href = URI.parse(self.href) @params.merge! connection.get(inst_href.path, 'view' => "full") diff --git a/lib/rest_connection/rightscale/mc_instance_type.rb b/lib/rest_connection/rightscale/mc_instance_type.rb index 4244007..2829a39 100644 --- a/lib/rest_connection/rightscale/mc_instance_type.rb +++ b/lib/rest_connection/rightscale/mc_instance_type.rb @@ -1,4 +1,4 @@ -# This file is part of RestConnection +# This file is part of RestConnection # # RestConnection is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -13,13 +13,13 @@ # You should have received a copy of the GNU General Public License # along with RestConnection. If not, see . -# +# # You must have Beta v1.5 API access to use these internal API calls. -# +# class McInstanceType include RightScale::Api::Gateway extend RightScale::Api::GatewayExtend - + def resource_plural_name "instance_types" end @@ -35,7 +35,7 @@ def self.resource_plural_name def self.resource_singular_name "instance_type" end - + def self.parse_args(cloud_id) "clouds/#{cloud_id}/" end diff --git a/lib/rest_connection/rightscale/mc_multi_cloud_image.rb b/lib/rest_connection/rightscale/mc_multi_cloud_image.rb index 68925f6..477cdc7 100644 --- a/lib/rest_connection/rightscale/mc_multi_cloud_image.rb +++ b/lib/rest_connection/rightscale/mc_multi_cloud_image.rb @@ -1,4 +1,4 @@ -# This file is part of RestConnection +# This file is part of RestConnection # # RestConnection is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -13,16 +13,16 @@ # You should have received a copy of the GNU General Public License # along with RestConnection. If not, see . -# +# # You must have Beta v1.5 API access to use these internal API calls. -# +# class McMultiCloudImage include RightScale::Api::Gateway extend RightScale::Api::GatewayExtend include RightScale::Api::McTaggable extend RightScale::Api::McTaggableExtend attr_reader :settings - + def resource_plural_name "multi_cloud_images" end @@ -38,7 +38,7 @@ def self.resource_plural_name def self.resource_singular_name "multi_cloud_image" end - + def self.parse_args(server_template_id=nil) server_template_id ? "server_templates/#{server_template_id}/" : "" end diff --git a/lib/rest_connection/rightscale/mc_multi_cloud_image_setting.rb b/lib/rest_connection/rightscale/mc_multi_cloud_image_setting.rb index 659b76d..e584d7a 100644 --- a/lib/rest_connection/rightscale/mc_multi_cloud_image_setting.rb +++ b/lib/rest_connection/rightscale/mc_multi_cloud_image_setting.rb @@ -1,4 +1,4 @@ -# This file is part of RestConnection +# This file is part of RestConnection # # RestConnection is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -13,13 +13,13 @@ # You should have received a copy of the GNU General Public License # along with RestConnection. If not, see . -# +# # You must have Beta v1.5 API access to use these internal API calls. -# +# class McMultiCloudImageSetting include RightScale::Api::Gateway extend RightScale::Api::GatewayExtend - + def resource_plural_name "settings" end @@ -35,7 +35,7 @@ def self.resource_plural_name def self.resource_singular_name "setting" end - + def self.parse_args(multi_cloud_image_id) "multi_cloud_images/#{multi_cloud_image_id}/" end diff --git a/lib/rest_connection/rightscale/mc_security_group.rb b/lib/rest_connection/rightscale/mc_security_group.rb index 9ef5b48..acbee31 100644 --- a/lib/rest_connection/rightscale/mc_security_group.rb +++ b/lib/rest_connection/rightscale/mc_security_group.rb @@ -1,4 +1,4 @@ -# This file is part of RestConnection +# This file is part of RestConnection # # RestConnection is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -13,13 +13,13 @@ # You should have received a copy of the GNU General Public License # along with RestConnection. If not, see . -# +# # You must have Beta v1.5 API access to use these internal API calls. -# +# class McSecurityGroup include RightScale::Api::Gateway extend RightScale::Api::GatewayExtend - + def resource_plural_name "security_groups" end @@ -35,7 +35,7 @@ def self.resource_plural_name def self.resource_singular_name "security_group" end - + def self.parse_args(cloud_id) "clouds/#{cloud_id}/" end diff --git a/lib/rest_connection/rightscale/mc_server.rb b/lib/rest_connection/rightscale/mc_server.rb index 3e3dab2..5863fb9 100644 --- a/lib/rest_connection/rightscale/mc_server.rb +++ b/lib/rest_connection/rightscale/mc_server.rb @@ -1,4 +1,4 @@ -# This file is part of RestConnection +# This file is part of RestConnection # # RestConnection is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -13,16 +13,16 @@ # You should have received a copy of the GNU General Public License # along with RestConnection. If not, see . -# +# # You must have Beta v1.5 API access to use these internal API calls. -# +# class McServer < Server include RightScale::Api::Gateway extend RightScale::Api::GatewayExtend include RightScale::Api::McTaggable extend RightScale::Api::McTaggableExtend attr_accessor :current_instance, :next_instance, :inputs - + def resource_plural_name "servers" end @@ -38,11 +38,11 @@ def self.resource_plural_name def self.resource_singular_name "server" end - + def self.parse_args(deployment_id=nil) deployment_id ? "deployments/#{deployment_id}/" : "" end - + def launch if actions.include?("launch") t = URI.parse(self.href) @@ -68,7 +68,7 @@ def force_terminate connection.post(t.path + '/terminate') @current_instance = nil end - + def start #start_ebs raise "You shouldn't be here." end @@ -222,6 +222,14 @@ def get_sketchy_data(params) end # Override Taggable mixin so that it sets tags on both next and current instances + def current_tags(reload=true) + ret = [] + if @current_instance + ret = McTag.search_by_href(self.current_instance_href).first["tags"].map { |h| h["name"] } + end + ret + end + def add_tags(*args) return false if args.empty? args.uniq! @@ -238,31 +246,25 @@ def remove_tags(*args) self.tags(true) end - def get_info_tags(*tag_keys) + def get_tags_by_namespace(namespace) ret = {} tags = {"self" => self.tags(true)} - if @current_instance - tags["current_instance"] = McTag.search_by_href(self.current_instance_href).first["tags"].map { |h| h["name"] } - end + tags["current_instance"] = self.current_tags if @current_instance tags.each { |res,ary| ret[res] ||= {} ary.each { |tag| - next unless tag.start_with?("info:") + next unless tag.start_with?("#{namespace}:") key = tag.split("=").first.split(":").last value = tag.split(":")[1..-1].join(":").split("=")[1..-1].join("=") - if tag_keys.empty? - ret[res][key] = value - else - ret[res][key] = value if tag_keys.include?(key) - end + ret[res][key] = value } } return ret end def clear_tags(namespace = nil) - tags = McTag.search_by_href(self.href).first["tags"].map { |h| h["name"] } - tags.deep_merge! McTag.search_by_href(self.current_instance_href).first["tags"].map { |h| h["name"] } if @current_instance + tags = self.tags(true) + tags.deep_merge! self.current_tags if @current_instance tags = tags.select { |tag| tag.start_with?("#{namespace}:") } if namespace self.remove_tags(*tags) end diff --git a/lib/rest_connection/rightscale/mc_server_array.rb b/lib/rest_connection/rightscale/mc_server_array.rb index b55e6b3..f400d9f 100644 --- a/lib/rest_connection/rightscale/mc_server_array.rb +++ b/lib/rest_connection/rightscale/mc_server_array.rb @@ -1,4 +1,4 @@ -# This file is part of RestConnection +# This file is part of RestConnection # # RestConnection is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -13,15 +13,15 @@ # You should have received a copy of the GNU General Public License # along with RestConnection. If not, see . -# +# # You must have Beta v1.5 API access to use these internal API calls. -# +# class McServerArray include RightScale::Api::Gateway extend RightScale::Api::GatewayExtend include RightScale::Api::McTaggable extend RightScale::Api::McTaggableExtend - + def resource_plural_name "server_arrays" end @@ -37,7 +37,7 @@ def self.resource_plural_name def self.resource_singular_name "server_array" end - + def self.parse_args(deployment_id=nil) (deployment_id ? "deployments/#{deployment_id}/" : "") end diff --git a/lib/rest_connection/rightscale/mc_server_template.rb b/lib/rest_connection/rightscale/mc_server_template.rb index e0ce17f..2094bcc 100644 --- a/lib/rest_connection/rightscale/mc_server_template.rb +++ b/lib/rest_connection/rightscale/mc_server_template.rb @@ -1,4 +1,4 @@ -# This file is part of RestConnection +# This file is part of RestConnection # # RestConnection is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -13,15 +13,15 @@ # You should have received a copy of the GNU General Public License # along with RestConnection. If not, see . -# +# # You must have Beta v1.5 API access to use these internal API calls. -# +# class McServerTemplate include RightScale::Api::Gateway extend RightScale::Api::GatewayExtend include RightScale::Api::McTaggable extend RightScale::Api::McTaggableExtend - + def resource_plural_name "server_templates" end @@ -37,7 +37,7 @@ def self.resource_plural_name def self.resource_singular_name "server_template" end - + def get_mcis_and_settings @params["multi_cloud_images"] = McMultiCloudImage.find_all(self.rs_id) @params["multi_cloud_images"].each { |mci| mci.get_settings } diff --git a/lib/rest_connection/rightscale/mc_ssh_key.rb b/lib/rest_connection/rightscale/mc_ssh_key.rb index cd4573d..b7791df 100644 --- a/lib/rest_connection/rightscale/mc_ssh_key.rb +++ b/lib/rest_connection/rightscale/mc_ssh_key.rb @@ -1,4 +1,4 @@ -# This file is part of RestConnection +# This file is part of RestConnection # # RestConnection is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -13,13 +13,13 @@ # You should have received a copy of the GNU General Public License # along with RestConnection. If not, see . -# +# # You must have Beta v1.5 API access to use these internal API calls. -# +# class McSshKey include RightScale::Api::Gateway extend RightScale::Api::GatewayExtend - + def resource_plural_name "ssh_keys" end @@ -35,11 +35,11 @@ def self.resource_plural_name def self.resource_singular_name "ssh_key" end - + def self.parse_args(cloud_id) "clouds/#{cloud_id}/" end - + def self.create(opts) create_opts = { self.resource_singular_name.to_sym => opts } location = connection.post("clouds/#{opts['cloud_id']}/#{self.resource_plural_name}", create_opts) diff --git a/lib/rest_connection/rightscale/mc_tag.rb b/lib/rest_connection/rightscale/mc_tag.rb index 46244e1..3880f27 100644 --- a/lib/rest_connection/rightscale/mc_tag.rb +++ b/lib/rest_connection/rightscale/mc_tag.rb @@ -1,4 +1,4 @@ -# This file is part of RestConnection +# This file is part of RestConnection # # RestConnection is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -13,9 +13,9 @@ # You should have received a copy of the GNU General Public License # along with RestConnection. If not, see . -# +# # You must have Beta v1.5 API access to use these internal API calls. -# +# class McTag include RightScale::Api::Gateway extend RightScale::Api::GatewayExtend diff --git a/lib/rest_connection/rightscale/mc_volume.rb b/lib/rest_connection/rightscale/mc_volume.rb index 9a591fc..055e540 100644 --- a/lib/rest_connection/rightscale/mc_volume.rb +++ b/lib/rest_connection/rightscale/mc_volume.rb @@ -1,4 +1,4 @@ -# This file is part of RestConnection +# This file is part of RestConnection # # RestConnection is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -13,15 +13,15 @@ # You should have received a copy of the GNU General Public License # along with RestConnection. If not, see . -# +# # You must have Beta v1.5 API access to use these internal API calls. -# +# class McVolume include RightScale::Api::Gateway extend RightScale::Api::GatewayExtend include RightScale::Api::McTaggable extend RightScale::Api::McTaggableExtend - + def resource_plural_name "volumes" end @@ -37,7 +37,7 @@ def self.resource_plural_name def self.resource_singular_name "volume" end - + def self.parse_args(cloud_id) "clouds/#{cloud_id}/" end diff --git a/lib/rest_connection/rightscale/mc_volume_attachment.rb b/lib/rest_connection/rightscale/mc_volume_attachment.rb index 7ecf6c5..8be0284 100644 --- a/lib/rest_connection/rightscale/mc_volume_attachment.rb +++ b/lib/rest_connection/rightscale/mc_volume_attachment.rb @@ -1,4 +1,4 @@ -# This file is part of RestConnection +# This file is part of RestConnection # # RestConnection is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -13,13 +13,13 @@ # You should have received a copy of the GNU General Public License # along with RestConnection. If not, see . -# +# # You must have Beta v1.5 API access to use these internal API calls. -# +# class McVolumeAttachment include RightScale::Api::Gateway extend RightScale::Api::GatewayExtend - + def resource_plural_name "volume_attachments" end @@ -35,7 +35,7 @@ def self.resource_plural_name def self.resource_singular_name "volume_attachment" end - + def self.parse_args(cloud_id, instance_id=nil) return "clouds/#{cloud_id}/" unless instance_id return "clouds/#{cloud_id}/volumes/#{instance_id}/" if instance_id diff --git a/lib/rest_connection/rightscale/mc_volume_snapshot.rb b/lib/rest_connection/rightscale/mc_volume_snapshot.rb index 546b18b..fd3298e 100644 --- a/lib/rest_connection/rightscale/mc_volume_snapshot.rb +++ b/lib/rest_connection/rightscale/mc_volume_snapshot.rb @@ -1,4 +1,4 @@ -# This file is part of RestConnection +# This file is part of RestConnection # # RestConnection is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -13,15 +13,15 @@ # You should have received a copy of the GNU General Public License # along with RestConnection. If not, see . -# +# # You must have Beta v1.5 API access to use these internal API calls. -# +# class McVolumeSnapshot include RightScale::Api::Gateway extend RightScale::Api::GatewayExtend include RightScale::Api::McTaggable extend RightScale::Api::McTaggableExtend - + def resource_plural_name "volume_snapshots" end @@ -37,7 +37,7 @@ def self.resource_plural_name def self.resource_singular_name "volume_snapshot" end - + def self.parse_args(cloud_id, volume_id=nil) return "clouds/#{cloud_id}/" unless volume_id return "clouds/#{cloud_id}/volumes/#{volume_id}/" if volume_id diff --git a/lib/rest_connection/rightscale/mc_volume_type.rb b/lib/rest_connection/rightscale/mc_volume_type.rb index 8ca2eeb..a077d3a 100644 --- a/lib/rest_connection/rightscale/mc_volume_type.rb +++ b/lib/rest_connection/rightscale/mc_volume_type.rb @@ -1,4 +1,4 @@ -# This file is part of RestConnection +# This file is part of RestConnection # # RestConnection is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -13,13 +13,13 @@ # You should have received a copy of the GNU General Public License # along with RestConnection. If not, see . -# +# # You must have Beta v1.5 API access to use these internal API calls. -# +# class McVolumeType include RightScale::Api::Gateway extend RightScale::Api::GatewayExtend - + def resource_plural_name "volume_types" end @@ -35,7 +35,7 @@ def self.resource_plural_name def self.resource_singular_name "volume_type" end - + def self.parse_args(cloud_id) "clouds/#{cloud_id}/" end diff --git a/lib/rest_connection/rightscale/monitoring_metric.rb b/lib/rest_connection/rightscale/monitoring_metric.rb index 5138a01..8dfe498 100644 --- a/lib/rest_connection/rightscale/monitoring_metric.rb +++ b/lib/rest_connection/rightscale/monitoring_metric.rb @@ -1,4 +1,4 @@ -# This file is part of RestConnection +# This file is part of RestConnection # # RestConnection is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -13,13 +13,13 @@ # You should have received a copy of the GNU General Public License # along with RestConnection. If not, see . -# +# # You must have Beta v1.5 API access to use these internal API calls. -# +# class MonitoringMetric include RightScale::Api::Gateway extend RightScale::Api::GatewayExtend - + def self.parse_args(cloud_id, instance_id) "clouds/#{cloud_id}/instances/#{instance_id}/" end diff --git a/lib/rest_connection/rightscale/multi_cloud_image.rb b/lib/rest_connection/rightscale/multi_cloud_image.rb index 2b9d420..afba896 100644 --- a/lib/rest_connection/rightscale/multi_cloud_image.rb +++ b/lib/rest_connection/rightscale/multi_cloud_image.rb @@ -1,4 +1,4 @@ -# This file is part of RestConnection +# This file is part of RestConnection # # RestConnection is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -13,7 +13,7 @@ # You should have received a copy of the GNU General Public License # along with RestConnection. If not, see . -class MultiCloudImage +class MultiCloudImage include RightScale::Api::Base extend RightScale::Api::BaseExtend @@ -24,7 +24,7 @@ def supported_cloud_ids # You must have access to multiple APIs for this (0.1, and 1.5) def find_and_flatten_settings() some_settings = McMultiCloudImage.find(rs_id.to_i).get_settings - internal = MultiCloudImageInternal.new("href" => self.href) + internal = MultiCloudImageInternal.new("href" => self.href) internal.reload more_settings = internal.settings @params["multi_cloud_image_cloud_settings"] = some_settings + more_settings diff --git a/lib/rest_connection/rightscale/multi_cloud_image_cloud_setting_internal.rb b/lib/rest_connection/rightscale/multi_cloud_image_cloud_setting_internal.rb index b818a5b..7391a5c 100644 --- a/lib/rest_connection/rightscale/multi_cloud_image_cloud_setting_internal.rb +++ b/lib/rest_connection/rightscale/multi_cloud_image_cloud_setting_internal.rb @@ -1,4 +1,4 @@ -# This file is part of RestConnection +# This file is part of RestConnection # # RestConnection is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -40,5 +40,5 @@ def self.create(opts) location = connection.post(self.resource_plural_name, self.resource_singular_name.to_sym => opts) newrecord = self.new('href' => location) end - + end diff --git a/lib/rest_connection/rightscale/multi_cloud_image_internal.rb b/lib/rest_connection/rightscale/multi_cloud_image_internal.rb index 45ee630..5cc95d9 100644 --- a/lib/rest_connection/rightscale/multi_cloud_image_internal.rb +++ b/lib/rest_connection/rightscale/multi_cloud_image_internal.rb @@ -1,4 +1,4 @@ -# This file is part of RestConnection +# This file is part of RestConnection # # RestConnection is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -60,11 +60,11 @@ def initialize(params={}) @params = params transform_settings end - + def settings transform_settings @params["multi_cloud_image_cloud_settings"] - end + end def supported_cloud_ids @params["multi_cloud_image_cloud_settings"].map { |mcics| mcics.cloud_id } diff --git a/lib/rest_connection/rightscale/right_script.rb b/lib/rest_connection/rightscale/right_script.rb index 90ca5be..a4c1193 100644 --- a/lib/rest_connection/rightscale/right_script.rb +++ b/lib/rest_connection/rightscale/right_script.rb @@ -1,4 +1,4 @@ -# This file is part of RestConnection +# This file is part of RestConnection # # RestConnection is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -14,7 +14,7 @@ # along with RestConnection. If not, see . -class RightScript +class RightScript include RightScale::Api::Base extend RightScale::Api::BaseExtend def self.from_yaml(yaml) @@ -23,7 +23,7 @@ def self.from_yaml(yaml) x.keys.each do |script| scripts << self.new('href' => "right_scripts/#{script}", 'name' => x[script].ivars['name']) end - scripts + scripts end def self.from_instance_info(file = "/var/spool/ec2/rs_cache/info.yml") @@ -38,7 +38,7 @@ def self.from_instance_info(file = "/var/spool/ec2/rs_cache/info.yml") x.keys.each do |script| scripts << self.new('href' => "right_scripts/#{script}", 'name' => x[script].ivars['name']) end - scripts + scripts end end diff --git a/lib/rest_connection/rightscale/right_script_internal.rb b/lib/rest_connection/rightscale/right_script_internal.rb index 3270b65..3e49a93 100644 --- a/lib/rest_connection/rightscale/right_script_internal.rb +++ b/lib/rest_connection/rightscale/right_script_internal.rb @@ -1,4 +1,4 @@ -# This file is part of RestConnection +# This file is part of RestConnection # # RestConnection is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -14,7 +14,7 @@ # along with RestConnection. If not, see . -class RightScriptInternal +class RightScriptInternal include RightScale::Api::Base extend RightScale::Api::BaseExtend include RightScale::Api::Internal @@ -41,11 +41,11 @@ def commit(message) t = URI.parse(self.href) RightScript.new(:href => connection.post(t.path + "/commit", :commit_message => message)) end - + # clones a RightScript and returns the new RightScript resource that's been created. def clone t = URI.parse(self.href) RightScript.new(:href => connection.post(t.path + "/clone")) end - + end diff --git a/lib/rest_connection/rightscale/rightscale_api_base.rb b/lib/rest_connection/rightscale/rightscale_api_base.rb index d376a74..99dde51 100644 --- a/lib/rest_connection/rightscale/rightscale_api_base.rb +++ b/lib/rest_connection/rightscale/rightscale_api_base.rb @@ -1,4 +1,4 @@ -# This file is part of RestConnection +# This file is part of RestConnection # # RestConnection is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -21,7 +21,7 @@ module BaseExtend def connection() @@connection ||= RestConnection::Connection.new settings = @@connection.settings - settings[:common_headers]["X_API_VERSION"] = "1.0" + settings[:common_headers]["X_API_VERSION"] = "1.0" settings[:api_href] = settings[:api_url] settings[:extension] = ".js" @@connection @@ -29,7 +29,7 @@ def connection() def resource_plural_name self.to_s.underscore.pluralize - end + end def resource_singular_name self.to_s.underscore @@ -37,7 +37,7 @@ def resource_singular_name # matches using result of block match expression # ex: Server.find_by(:nickname) { |n| n =~ /production/ } def find_by(attrib, &block) - self.find_all.select do |s| + self.find_all.select do |s| yield(s[attrib.to_s]) end end @@ -63,8 +63,8 @@ def find_by_nickname(nickname) self.find_by(:nickname) { |n| n == nickname } end - # the argument can be - # 1) takes href (URI), + # the argument can be + # 1) takes href (URI), # 2) or id (Integer) # 3) or symbol :all, :first, :last def find(href, additional_params={}, &block) @@ -79,7 +79,7 @@ def find(href, additional_params={}, &block) return results elsif href == :first return results.first - elsif href == :last + elsif href == :last return results.last end elsif uri = URI.parse(href) @@ -107,8 +107,8 @@ def find_by_nickname_speed(nickname) # filter is only implemented on some api endpoints def find_with_filter(filter = {}) - filter_params = [] - filter.each { |key,val| + filter_params = [] + filter.each { |key,val| filter_params << "#{key}=#{val}" } a = Array.new @@ -165,12 +165,12 @@ def initialize(params = {}) def connection() @@connection ||= RestConnection::Connection.new settings = @@connection.settings - settings[:common_headers]["X_API_VERSION"] = "1.0" + settings[:common_headers]["X_API_VERSION"] = "1.0" settings[:api_href] = settings[:api_url] settings[:extension] = ".js" @@connection end - + def resource_plural_name self.class.to_s.underscore.pluralize end @@ -204,20 +204,20 @@ def method_missing(method_name, *args) @params[mn] = args[0] @params[mn_dash] = args[0] end - return @params[mn] + return @params[mn] elsif @params[mn_dash] if assignment - @params[mn_dash] = args[0] + @params[mn_dash] = args[0] @params[mn] = args[0] end - return @params[mn_dash] + return @params[mn_dash] elsif @params[mn.to_sym] return @params[mn.to_sym] elsif assignment @params[mn] = args[0] @params[mn_dash] = args[0] - return @params[mn] - else + return @params[mn] + else return nil #raise "called unknown method #{method_name} with #{args.inspect}" end diff --git a/lib/rest_connection/rightscale/rightscale_api_gateway.rb b/lib/rest_connection/rightscale/rightscale_api_gateway.rb index 480a208..01fae17 100644 --- a/lib/rest_connection/rightscale/rightscale_api_gateway.rb +++ b/lib/rest_connection/rightscale/rightscale_api_gateway.rb @@ -14,7 +14,7 @@ def parse_params(params = {}) def connection @@gateway_connection ||= RestConnection::Connection.new settings = @@gateway_connection.settings - settings[:common_headers]["X_API_VERSION"] = "1.5" + settings[:common_headers]["X_API_VERSION"] = "1.5" settings[:api_href], account = settings[:api_url].split(/\/acct\//) if settings[:api_url].include?("acct") settings[:extension] = ".json" unless @@gateway_connection.cookie @@ -77,24 +77,24 @@ def method_missing(method_name, *args) if assignment self[mn] = args[0] self[mn_dash] = args[0] - end + end return self[mn] elsif self[mn_dash] if assignment - self[mn_dash] = args[0] + self[mn_dash] = args[0] self[mn] = args[0] - end - return self[mn_dash] + end + return self[mn_dash] elsif self[mn.to_sym] return self[mn.to_sym] elsif assignment self[mn] = args[0] self[mn_dash] = args[0] - return self[mn] - else + return self[mn] + else return nil #raise "called unknown method #{method_name} with #{args.inspect}" - end + end end def [](name) @@ -153,10 +153,10 @@ def load(resource) module GatewayExtend include RightScale::Api::BaseExtend - def connection + def connection @@gateway_connection ||= RestConnection::Connection.new settings = @@gateway_connection.settings - settings[:common_headers]["X_API_VERSION"] = "1.5" + settings[:common_headers]["X_API_VERSION"] = "1.5" settings[:api_href], account = settings[:api_url].split(/\/acct\//) if settings[:api_url].include?("acct") settings[:extension] = ".json" unless @@gateway_connection.cookie @@ -165,7 +165,7 @@ def connection resp = @@gateway_connection.post("session", params) raise "ERROR: Login failed. #{resp.message}. Code:#{resp.code}" unless resp.code == "302" || resp.code == "204" @@gateway_connection.cookie = resp.response['set-cookie'] - + # test session resp = @@gateway_connection.get("session") raise "ERROR: Invalid session. #{resp["message"]}." unless resp.is_a?(Hash) @@ -230,4 +230,4 @@ def create(opts) end end end - + diff --git a/lib/rest_connection/rightscale/rightscale_api_internal.rb b/lib/rest_connection/rightscale/rightscale_api_internal.rb index 31fc078..7ff85ea 100644 --- a/lib/rest_connection/rightscale/rightscale_api_internal.rb +++ b/lib/rest_connection/rightscale/rightscale_api_internal.rb @@ -4,7 +4,7 @@ module Internal def connection @@little_brother_connection ||= RestConnection::Connection.new settings = @@little_brother_connection.settings - settings[:common_headers]["X_API_VERSION"] = "0.1" + settings[:common_headers]["X_API_VERSION"] = "0.1" settings[:api_href] = settings[:api_url] settings[:extension] = ".js" @@little_brother_connection @@ -15,7 +15,7 @@ module InternalExtend def connection @@little_brother_connection ||= RestConnection::Connection.new settings = @@little_brother_connection.settings - settings[:common_headers]["X_API_VERSION"] = "0.1" + settings[:common_headers]["X_API_VERSION"] = "0.1" settings[:api_href] = settings[:api_url] settings[:extension] = ".js" @@little_brother_connection @@ -23,4 +23,4 @@ def connection end end end - + diff --git a/lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb b/lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb index 01f89cd..dbd14a3 100644 --- a/lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb +++ b/lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb @@ -1,4 +1,4 @@ -# This file is part of RestConnection +# This file is part of RestConnection # # RestConnection is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -13,9 +13,9 @@ # You should have received a copy of the GNU General Public License # along with RestConnection. If not, see . -# +# # You must have Beta v1.5 API access to use these internal API calls. -# +# module RightScale module Api module McTaggable @@ -39,48 +39,65 @@ def tags(reload=false) end def remove_info_tags(*tag_keys) + remove_tags_by_namespace("info", *tag_keys) + end + + def set_info_tags(hsh={}) + set_tags_by_namespace("info", hsh) + end + + def get_info_tags(*tag_keys) + tags = get_tags_by_namespace("info") + tags.each { |resource,hsh| + hsh.reject! { |key,value| + rej = false + rej = !tag_keys.include?(key) unless tag_keys.empty? + rej + } + } + return ret + end + + def remove_tags_by_namespace(namespace, *tag_keys) tags_to_unset = [] - tags = get_info_tags(*(tag_keys.uniq)) + tags = get_tags_by_namespace(*(tag_keys.uniq)) tags.each { |res,hsh| hsh.each { |k,v| - tags_to_unset << "info:#{k}=#{v}" + tags_to_unset << "#{namespace}:#{k}=#{v}" } } self.remove_tags(*tags_to_unset) end - - def set_info_tags(hsh={}) + + def set_tags_by_namespace(namespace, hsh={}) keys_to_change = [] tags_to_set = [] - hsh.each { |k,v| keys_to_change << k; tags_to_set << "info:#{k}=#{v}" } - self.remove_tags_by_keys(*keys_to_change) + hsh.each { |k,v| keys_to_change << k; tags_to_set << "#{namespace}:#{k}=#{v}" } + self.remove_tags_by_namespace(namespace, *keys_to_change) self.add_tags(*tags_to_set) end - - def get_info_tags(*tag_keys) + + def get_tags_by_namespace(namespace) ret = {} tags = {"self" => self.tags(true)} tags.each { |res,ary| ret[res] ||= {} ary.each { |tag| - next unless tag.start_with?("info:") + next unless tag.start_with?("#{namespace}:") key = tag.split("=").first.split(":").last value = tag.split(":")[1..-1].join(":").split("=")[1..-1].join("=") - if tag_keys.empty? - ret[res][key] = value - else - ret[res][key] = value if tag_keys.include?(key) - end + ret[res][key] = value } } return ret end - + def set_tags_to(*args) + STDERR.puts "set_tags_to(...) is deprecated" self.clear_tags("info") self.add_tags(*(args.uniq)) end - + def clear_tags(namespace = nil) tag_ary = self.tags(true) tag_ary = tag_ary.select { |tag| tag.start_with?("#{namespace}:") } if namespace diff --git a/lib/rest_connection/rightscale/rightscale_api_resources.rb b/lib/rest_connection/rightscale/rightscale_api_resources.rb index 4910d63..d2e759b 100644 --- a/lib/rest_connection/rightscale/rightscale_api_resources.rb +++ b/lib/rest_connection/rightscale/rightscale_api_resources.rb @@ -1,4 +1,4 @@ -# This file is part of RestConnection +# This file is part of RestConnection # # RestConnection is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/lib/rest_connection/rightscale/rightscale_api_taggable.rb b/lib/rest_connection/rightscale/rightscale_api_taggable.rb index ecd54c8..b0d6bb1 100644 --- a/lib/rest_connection/rightscale/rightscale_api_taggable.rb +++ b/lib/rest_connection/rightscale/rightscale_api_taggable.rb @@ -1,4 +1,4 @@ -# This file is part of RestConnection +# This file is part of RestConnection # # RestConnection is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -36,48 +36,65 @@ def tags(reload=false) end def remove_info_tags(*tag_keys) + remove_tags_by_namespace("info", *tag_keys) + end + + def set_info_tags(hsh={}) + set_tags_by_namespace("info", hsh) + end + + def get_info_tags(*tag_keys) + tags = get_tags_by_namespace("info") + tags.each { |resource,hsh| + hsh.reject! { |key,value| + rej = false + rej = !tag_keys.include?(key) unless tag_keys.empty? + rej + } + } + return ret + end + + def remove_tags_by_namespace(namespace, *tag_keys) tags_to_unset = [] - tags = get_info_tags(*(tag_keys.uniq)) + tags = get_tags_by_namespace(*(tag_keys.uniq)) tags.each { |res,hsh| hsh.each { |k,v| - tags_to_unset << "info:#{k}=#{v}" + tags_to_unset << "#{namespace}:#{k}=#{v}" } } self.remove_tags(*tags_to_unset) end - - def set_info_tags(hsh={}) + + def set_tags_by_namespace(namespace, hsh={}) keys_to_change = [] tags_to_set = [] - hsh.each { |k,v| keys_to_change << k; tags_to_set << "info:#{k}=#{v}" } - self.remove_tags_by_keys(*keys_to_change) + hsh.each { |k,v| keys_to_change << k; tags_to_set << "#{namespace}:#{k}=#{v}" } + self.remove_tags_by_namespace(namespace, *keys_to_change) self.add_tags(*tags_to_set) end - - def get_info_tags(*tag_keys) + + def get_tags_by_namespace(namespace) ret = {} tags = {"self" => self.tags(true)} tags.each { |res,ary| ret[res] ||= {} ary.each { |tag| - next unless tag.start_with?("info:") + next unless tag.start_with?("#{namespace}:") key = tag.split("=").first.split(":").last value = tag.split(":")[1..-1].join(":").split("=")[1..-1].join("=") - if tag_keys.empty? - ret[res][key] = value - else - ret[res][key] = value if tag_keys.include?(key) - end + ret[res][key] = value } } return ret end - + def set_tags_to(*args) + STDERR.puts "set_tags_to(...) is deprecated" self.clear_tags("info") self.add_tags(*(args.uniq)) end - + def clear_tags(namespace = nil) tag_ary = self.tags(true) tag_ary = tag_ary.select { |tag| tag.start_with?("#{namespace}:") } if namespace diff --git a/lib/rest_connection/rightscale/rs_internal.rb b/lib/rest_connection/rightscale/rs_internal.rb index a3dbae3..4dc4864 100644 --- a/lib/rest_connection/rightscale/rs_internal.rb +++ b/lib/rest_connection/rightscale/rs_internal.rb @@ -1,4 +1,4 @@ -# This file is part of RestConnection +# This file is part of RestConnection # # RestConnection is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -13,17 +13,17 @@ # You should have received a copy of the GNU General Public License # along with RestConnection. If not, see . -# +# # You must have special API access to use these internal API calls. -# -class RsInternal +# +class RsInternal include RightScale::Api::Base extend RightScale::Api::BaseExtend def connection @@little_brother_connection ||= RestConnection::Connection.new settings = @@little_brother_connection.settings - settings[:common_headers]["X_API_VERSION"] = "0.1" + settings[:common_headers]["X_API_VERSION"] = "0.1" settings[:api_href] = settings[:api_url] settings[:extension] = ".js" @@little_brother_connection @@ -32,7 +32,7 @@ def connection def self.connection @@little_brother_connection ||= RestConnection::Connection.new settings = @@little_brother_connection.settings - settings[:common_headers]["X_API_VERSION"] = "0.1" + settings[:common_headers]["X_API_VERSION"] = "0.1" settings[:api_href] = settings[:api_url] settings[:extension] = ".js" @@little_brother_connection diff --git a/lib/rest_connection/rightscale/s3_bucket.rb b/lib/rest_connection/rightscale/s3_bucket.rb index f5b0fc8..3f2cb52 100644 --- a/lib/rest_connection/rightscale/s3_bucket.rb +++ b/lib/rest_connection/rightscale/s3_bucket.rb @@ -1,4 +1,4 @@ -# This file is part of RestConnection +# This file is part of RestConnection # # RestConnection is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -33,4 +33,4 @@ def resource_plural_name "s3_buckets" end -end +end diff --git a/lib/rest_connection/rightscale/server.rb b/lib/rest_connection/rightscale/server.rb index 3023265..b288776 100644 --- a/lib/rest_connection/rightscale/server.rb +++ b/lib/rest_connection/rightscale/server.rb @@ -1,4 +1,4 @@ -# This file is part of RestConnection +# This file is part of RestConnection # # RestConnection is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -15,7 +15,7 @@ require 'rest_connection/ssh_hax' -class Server +class Server include RightScale::Api::Base extend RightScale::Api::BaseExtend include SshHax @@ -28,14 +28,14 @@ def self.create(opts) create_options["cloud_id"] = opts[:cloud_id] if opts[:cloud_id] create_options[self.resource_singular_name.to_sym][:mci_href] = nil create_options[self.resource_singular_name.to_sym][:inputs] = nil - location = connection.post(self.resource_plural_name,create_options) + location = connection.post(self.resource_plural_name,create_options) newrecord = self.new('href' => location) newrecord.reload newrecord.parameters #transform the parameters! newrecord end - # The RightScale api returns the server parameters as a hash with "name" and "value". + # The RightScale api returns the server parameters as a hash with "name" and "value". # This must be transformed into a hash in case we want to PUT this back to the API. def transform_parameters(parameters) new_params_hash = {} @@ -96,8 +96,8 @@ def wait_for_operational_with_dns(state_wait_timeout=1200) step = 15 while(timeout > 0) self.settings -# break if self['dns-name'] && !self['dns-name'].empty? && self['private-dns-name'] && !self['private-dns-name'].empty? - break if self.reachable_ip +# break if self['dns-name'] && !self['dns-name'].empty? && self['private-dns-name'] && !self['private-dns-name'].empty? + break if self.reachable_ip connection.logger "waiting for IP for #{self.nickname}" sleep step timeout -= step @@ -170,7 +170,7 @@ def run_executable(executable, opts=nil, ignore_lock=false) else raise "Invalid class passed to run_executable, needs Executable or RightScript, was:#{executable.class}" end - + if not opts.nil? and opts.has_key?(:ignore_lock) script_options[:server][:ignore_lock] = "true" opts.delete(:ignore_lock) @@ -195,7 +195,7 @@ def run_script(script,opts=nil) script_options[:server][:parameters] = opts unless opts.nil? location = connection.post(serv_href.path + '/run_script', script_options) Status.new('href' => location) - end + end def set_input(name, value) serv_href = URI.parse(self.href) @@ -223,7 +223,7 @@ def settings def attach_volume(params) hash = {} - hash[:server] = params + hash[:server] = params serv_href = URI.parse(self.href) connection.post(serv_href.path + "/attach_volume", hash) end @@ -243,7 +243,7 @@ def reboot(wait_for_state = false) reload old_state = self.state serv_href = URI.parse(self.href) - connection.post(serv_href.path + "/reboot") + connection.post(serv_href.path + "/reboot") if wait_for_state wait_for_state_change(old_state) end @@ -252,7 +252,7 @@ def reboot(wait_for_state = false) def relaunch self.stop self.wait_for_state("stopped") - self.start + self.start end def wait_for_state_change(old_state = nil) @@ -341,6 +341,14 @@ def reachable_ip end # Override Taggable mixin so that it sets tags on both next and current instances + def current_tags(reload=true) + ret = [] + if self.current_instance_href + ret = Tag.search_by_href(self.current_instance_href).map { |h| h["name"] } + end + ret + end + def add_tags(*args) return false if args.empty? args.uniq! @@ -357,31 +365,25 @@ def remove_tags(*args) self.tags(true) end - def get_info_tags(*tag_keys) + def get_tags_by_namespace(namespace) ret = {} tags = {"self" => self.tags(true)} - if self.current_instance_href - tags["current_instance"] = Tag.search_by_href(self.current_instance_href).map { |h| h["name"] } - end + tags["current_instance"] = self.current_tags if self.current_instance_href tags.each { |res,ary| ret[res] ||= {} ary.each { |tag| - next unless tag.start_with?("info:") + next unless tag.start_with?("#{namespace}:") key = tag.split("=").first.split(":").last value = tag.split(":")[1..-1].join(":").split("=")[1..-1].join("=") - if tag_keys.empty? - ret[res][key] = value - else - ret[res][key] = value if tag_keys.include?(key) - end + ret[res][key] = value } } return ret end def clear_tags(namespace = nil) - tags = Tag.search_by_href(self.href).map { |h| h["name"] } - tags.deep_merge! Tag.search_by_href(self.current_instance_href).map { |h| h["name"] } if self.current_instance_href + tags = self.tags(true) + tags.deep_merge! self.current_tags if self.current_instance_href tags = tags.select { |tag| tag.start_with?("#{namespace}:") } if namespace self.remove_tags(*tags) end diff --git a/lib/rest_connection/rightscale/server_interface.rb b/lib/rest_connection/rightscale/server_interface.rb index 44f0c82..4e7d6b5 100644 --- a/lib/rest_connection/rightscale/server_interface.rb +++ b/lib/rest_connection/rightscale/server_interface.rb @@ -1,4 +1,4 @@ -# This file is part of RestConnection +# This file is part of RestConnection # # RestConnection is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -124,7 +124,7 @@ def translate_create_opts(old_opts, instance_only=false) ret["cloud_id"] = opts["cloud_id"] end end - + fields.each { |hsh| next unless hsh[to] hsh[to].each { |field| @@ -232,7 +232,7 @@ def stop_ebs def run_script(script,opts=nil) return connection.logger("WARNING: Gateway Servers do not support run_script. Did you mean run_executable?") if @multicloud return @impl.run_script(script,opts) unless @multicloud - end + end def attach_volume(params) return connection.logger("WARNING: Gateway Servers do not support attach_volume. Ignoring.") if @multicloud diff --git a/lib/rest_connection/rightscale/server_internal.rb b/lib/rest_connection/rightscale/server_internal.rb index 5fb01e9..9099268 100644 --- a/lib/rest_connection/rightscale/server_internal.rb +++ b/lib/rest_connection/rightscale/server_internal.rb @@ -1,4 +1,4 @@ -# This file is part of RestConnection +# This file is part of RestConnection # # RestConnection is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -13,9 +13,9 @@ # You should have received a copy of the GNU General Public License # along with RestConnection. If not, see . -# +# # You must have special API access to use these internal API calls. -# +# class ServerInternal include RightScale::Api::Base extend RightScale::Api::BaseExtend diff --git a/lib/rest_connection/rightscale/server_template.rb b/lib/rest_connection/rightscale/server_template.rb index e25b71e..bc3cb4a 100644 --- a/lib/rest_connection/rightscale/server_template.rb +++ b/lib/rest_connection/rightscale/server_template.rb @@ -1,4 +1,4 @@ -# This file is part of RestConnection +# This file is part of RestConnection # # RestConnection is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -13,7 +13,7 @@ # You should have received a copy of the GNU General Public License # along with RestConnection. If not, see . -class ServerTemplate +class ServerTemplate include RightScale::Api::Base extend RightScale::Api::BaseExtend include RightScale::Api::Taggable @@ -45,7 +45,7 @@ def fetch_alert_specs end @params["alert_specs"] = as end - + def multi_cloud_images unless @params["multi_cloud_images"] fetch_multi_cloud_images diff --git a/lib/rest_connection/rightscale/server_template_internal.rb b/lib/rest_connection/rightscale/server_template_internal.rb index ff4dc68..a96c688 100644 --- a/lib/rest_connection/rightscale/server_template_internal.rb +++ b/lib/rest_connection/rightscale/server_template_internal.rb @@ -1,4 +1,4 @@ -# This file is part of RestConnection +# This file is part of RestConnection # # RestConnection is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -13,7 +13,7 @@ # You should have received a copy of the GNU General Public License # along with RestConnection. If not, see . -class ServerTemplateInternal +class ServerTemplateInternal include RightScale::Api::Base extend RightScale::Api::BaseExtend include RightScale::Api::Internal @@ -39,7 +39,7 @@ def add_multi_cloud_image(mci_href) t = URI.parse(self.href) connection.put(t.path + "/add_multi_cloud_image", :multi_cloud_image_href => mci_href) end - + def delete_multi_cloud_image(mci_href) t = URI.parse(self.href) connection.put(t.path + "/delete_multi_cloud_image", :multi_cloud_image_href => mci_href) @@ -75,7 +75,7 @@ def add_executable(executable, apply="operational") connection.post(t.path + "/add_executable", params) end - # <~Executable> executable, an Executable object to delete + # <~Executable> executable, an Executable object to delete # <~String> Apply, a string designating the type of executable: "boot", "operational", "decommission". Default is operational def delete_executable(executable, apply="operational") t = URI.parse(self.href) diff --git a/lib/rest_connection/rightscale/status.rb b/lib/rest_connection/rightscale/status.rb index a91033a..11291ec 100644 --- a/lib/rest_connection/rightscale/status.rb +++ b/lib/rest_connection/rightscale/status.rb @@ -1,4 +1,4 @@ -# This file is part of RestConnection +# This file is part of RestConnection # # RestConnection is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -17,7 +17,7 @@ #This is the v4 image only work status api. # was used by Server#run_script (depricating..) -class Status +class Status include RightScale::Api::Base extend RightScale::Api::BaseExtend def wait_for_completed(audit_link = "no audit link available", timeout = 900) diff --git a/lib/rest_connection/rightscale/tag.rb b/lib/rest_connection/rightscale/tag.rb index 6fed092..0bdbb92 100644 --- a/lib/rest_connection/rightscale/tag.rb +++ b/lib/rest_connection/rightscale/tag.rb @@ -1,4 +1,4 @@ -# This file is part of RestConnection +# This file is part of RestConnection # # RestConnection is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -13,7 +13,7 @@ # You should have received a copy of the GNU General Public License # along with RestConnection. If not, see . -class Tag +class Tag include RightScale::Api::Base extend RightScale::Api::BaseExtend diff --git a/lib/rest_connection/rightscale/task.rb b/lib/rest_connection/rightscale/task.rb index 82908eb..6965a20 100644 --- a/lib/rest_connection/rightscale/task.rb +++ b/lib/rest_connection/rightscale/task.rb @@ -1,4 +1,4 @@ -# This file is part of RestConnection +# This file is part of RestConnection # # RestConnection is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -13,13 +13,13 @@ # You should have received a copy of the GNU General Public License # along with RestConnection. If not, see . -# +# # You must have Beta v1.5 API access to use these internal API calls. -# +# class Task include RightScale::Api::Gateway extend RightScale::Api::GatewayExtend - + def self.parse_args(cloud_id, instance_id) "clouds/#{cloud_id}/instances/#{instance_id}/live/" end From 4e21b696f41d93fcdd94664859d6fa68951450fd Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Wed, 21 Sep 2011 16:47:22 -0700 Subject: [PATCH 102/239] [API 1.5] Added standard Input interface --- .../rightscale/mc_deployment.rb | 6 +--- lib/rest_connection/rightscale/mc_instance.rb | 1 + .../rightscale/mc_server_template.rb | 1 + .../rightscale/rightscale_api_mc_input.rb | 32 +++++++++++++++++++ .../rightscale/rightscale_api_resources.rb | 1 + 5 files changed, 36 insertions(+), 5 deletions(-) create mode 100644 lib/rest_connection/rightscale/rightscale_api_mc_input.rb diff --git a/lib/rest_connection/rightscale/mc_deployment.rb b/lib/rest_connection/rightscale/mc_deployment.rb index 2fef765..e236a41 100644 --- a/lib/rest_connection/rightscale/mc_deployment.rb +++ b/lib/rest_connection/rightscale/mc_deployment.rb @@ -21,6 +21,7 @@ class McDeployment extend RightScale::Api::GatewayExtend include RightScale::Api::McTaggable extend RightScale::Api::McTaggableExtend + include RightScale::Api::McInput def resource_plural_name "deployments" @@ -38,11 +39,6 @@ def self.resource_singular_name "deployment" end - def show - inst_href = URI.parse(self.href) - @params.merge! connection.get(inst_href.path, 'view' => "inputs") - end - def self.create(opts) location = connection.post(resource_plural_name, opts) newrecord = self.new('href' => location) diff --git a/lib/rest_connection/rightscale/mc_instance.rb b/lib/rest_connection/rightscale/mc_instance.rb index 1986353..f12d6d6 100644 --- a/lib/rest_connection/rightscale/mc_instance.rb +++ b/lib/rest_connection/rightscale/mc_instance.rb @@ -21,6 +21,7 @@ class McInstance extend RightScale::Api::GatewayExtend include RightScale::Api::McTaggable extend RightScale::Api::McTaggableExtend + include RightScale::Api::McInput attr_accessor :monitoring_metrics def resource_plural_name diff --git a/lib/rest_connection/rightscale/mc_server_template.rb b/lib/rest_connection/rightscale/mc_server_template.rb index 2094bcc..f5bd66f 100644 --- a/lib/rest_connection/rightscale/mc_server_template.rb +++ b/lib/rest_connection/rightscale/mc_server_template.rb @@ -21,6 +21,7 @@ class McServerTemplate extend RightScale::Api::GatewayExtend include RightScale::Api::McTaggable extend RightScale::Api::McTaggableExtend + include RightScale::Api::McInput def resource_plural_name "server_templates" diff --git a/lib/rest_connection/rightscale/rightscale_api_mc_input.rb b/lib/rest_connection/rightscale/rightscale_api_mc_input.rb new file mode 100644 index 0000000..b92e894 --- /dev/null +++ b/lib/rest_connection/rightscale/rightscale_api_mc_input.rb @@ -0,0 +1,32 @@ +# This file is part of RestConnection +# +# RestConnection is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# RestConnection is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with RestConnection. If not, see . + +# +# You must have Beta v1.5 API access to use these internal API calls. +# +module RightScale + module Api + module McInput + def get_inputs + self["inputs"] = connection.get(self.href + "/inputs") + end + + def show + inst_href = URI.parse(self.href) + @params.merge! connection.get(inst_href.path, 'view' => "inputs") + end + end + end +end diff --git a/lib/rest_connection/rightscale/rightscale_api_resources.rb b/lib/rest_connection/rightscale/rightscale_api_resources.rb index d2e759b..26c8353 100644 --- a/lib/rest_connection/rightscale/rightscale_api_resources.rb +++ b/lib/rest_connection/rightscale/rightscale_api_resources.rb @@ -19,6 +19,7 @@ require 'rest_connection/rightscale/rightscale_api_gateway' require 'rest_connection/rightscale/rightscale_api_taggable' require 'rest_connection/rightscale/rightscale_api_mc_taggable' +require 'rest_connection/rightscale/rightscale_api_mc_input' require 'rest_connection/rightscale/executable' require 'rest_connection/rightscale/server' require 'rest_connection/rightscale/deployment' From 8fdb94aee2bbf858b5e2d02d40ecd0df686dcf9d Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Tue, 4 Oct 2011 11:50:05 -0700 Subject: [PATCH 103/239] [API 1.5] New Resources, Taggable fixes --- lib/rest_connection/patches.rb | 30 +++++++- lib/rest_connection/rightscale/account.rb | 27 ++++++++ .../rightscale/child_account.rb | 27 ++++++++ lib/rest_connection/rightscale/mc_instance.rb | 4 ++ lib/rest_connection/rightscale/permission.rb | 27 ++++++++ .../rightscale/rightscale_api_mc_taggable.rb | 68 +------------------ .../rightscale/rightscale_api_resources.rb | 4 ++ .../rightscale/rightscale_api_taggable.rb | 3 +- lib/rest_connection/rightscale/user.rb | 27 ++++++++ 9 files changed, 149 insertions(+), 68 deletions(-) create mode 100644 lib/rest_connection/rightscale/account.rb create mode 100644 lib/rest_connection/rightscale/child_account.rb create mode 100644 lib/rest_connection/rightscale/permission.rb create mode 100644 lib/rest_connection/rightscale/user.rb diff --git a/lib/rest_connection/patches.rb b/lib/rest_connection/patches.rb index 6052c9f..083f148 100644 --- a/lib/rest_connection/patches.rb +++ b/lib/rest_connection/patches.rb @@ -25,7 +25,7 @@ def deep_merge(second) end target end - + # From: http://www.gemtacular.com/gemdocs/cerberus-0.2.2/doc/classes/Hash.html # File lib/cerberus/utils.rb, line 42 # Modified to provide same functionality with Arrays @@ -75,4 +75,32 @@ def deep_merge!(second) end end end + + def *(second) + if second.is_a?(Integer) + ret = [] + second.times { |i| ret += dup } + return ret + elsif second.is_a?(Array) + ret = [] + each { |x| second.each { |y| ret << [x,y].flatten } } + return ret + else + raise TypeError.new("can't convert #{second.class} into Integer") + end + end + + def **(second) + if second.is_a?(Integer) + ret = dup + (second - 1).times { + temp = [] + ret.each { |x| each { |y| temp << [x,y].flatten } } + ret = temp + } + return ret + else + raise TypeError.new("can't convert #{second.class} into Integer") + end + end end diff --git a/lib/rest_connection/rightscale/account.rb b/lib/rest_connection/rightscale/account.rb new file mode 100644 index 0000000..9cc1878 --- /dev/null +++ b/lib/rest_connection/rightscale/account.rb @@ -0,0 +1,27 @@ +# This file is part of RestConnection +# +# RestConnection is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# RestConnection is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with RestConnection. If not, see . + +# +# You must have Beta v1.5 API access to use these internal API calls. +# + +# +# Account Resource requires "admin" role +# + +class Account + include RightScale::Api::Gateway + extend RightScale::Api::GatewayExtend +end diff --git a/lib/rest_connection/rightscale/child_account.rb b/lib/rest_connection/rightscale/child_account.rb new file mode 100644 index 0000000..84e4396 --- /dev/null +++ b/lib/rest_connection/rightscale/child_account.rb @@ -0,0 +1,27 @@ +# This file is part of RestConnection +# +# RestConnection is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# RestConnection is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with RestConnection. If not, see . + +# +# You must have Beta v1.5 API access to use these internal API calls. +# + +# +# ChildAccount Resource requires 'enterprise_manager' role and 'enterprise_master' account setting +# + +class ChildAccount + include RightScale::Api::Gateway + extend RightScale::Api::GatewayExtend +end diff --git a/lib/rest_connection/rightscale/mc_instance.rb b/lib/rest_connection/rightscale/mc_instance.rb index f12d6d6..2055b64 100644 --- a/lib/rest_connection/rightscale/mc_instance.rb +++ b/lib/rest_connection/rightscale/mc_instance.rb @@ -159,6 +159,10 @@ def get_sketchy_data(params) metric.data(params['start'], params['end']) end + def get_data(params) + get_sketchy_data(params) + end + def reboot self.show connection.post(URI.parse(self.href).path + '/reboot') diff --git a/lib/rest_connection/rightscale/permission.rb b/lib/rest_connection/rightscale/permission.rb new file mode 100644 index 0000000..7a8d66b --- /dev/null +++ b/lib/rest_connection/rightscale/permission.rb @@ -0,0 +1,27 @@ +# This file is part of RestConnection +# +# RestConnection is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# RestConnection is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with RestConnection. If not, see . + +# +# You must have Beta v1.5 API access to use these internal API calls. +# + +# +# Permission Resource requires "admin" role +# + +class Permission + include RightScale::Api::Gateway + extend RightScale::Api::GatewayExtend +end diff --git a/lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb b/lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb index dbd14a3..7df70af 100644 --- a/lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb +++ b/lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb @@ -19,6 +19,7 @@ module RightScale module Api module McTaggable + include RightScale::Api::Taggable def add_tags(*args) return false if args.empty? McTag.set(self.href, args.uniq) @@ -28,6 +29,7 @@ def add_tags(*args) def remove_tags(*args) return false if args.empty? McTag.unset(self.href, args.uniq) + @params["tags"] -= args self.tags(true) end @@ -37,72 +39,6 @@ def tags(reload=false) @params["tags"].deep_merge!(McTag.search_by_href(self.href).first["tags"].map { |hsh| hsh["name"] }) if reload or @params["tags"].empty? @params["tags"] end - - def remove_info_tags(*tag_keys) - remove_tags_by_namespace("info", *tag_keys) - end - - def set_info_tags(hsh={}) - set_tags_by_namespace("info", hsh) - end - - def get_info_tags(*tag_keys) - tags = get_tags_by_namespace("info") - tags.each { |resource,hsh| - hsh.reject! { |key,value| - rej = false - rej = !tag_keys.include?(key) unless tag_keys.empty? - rej - } - } - return ret - end - - def remove_tags_by_namespace(namespace, *tag_keys) - tags_to_unset = [] - tags = get_tags_by_namespace(*(tag_keys.uniq)) - tags.each { |res,hsh| - hsh.each { |k,v| - tags_to_unset << "#{namespace}:#{k}=#{v}" - } - } - self.remove_tags(*tags_to_unset) - end - - def set_tags_by_namespace(namespace, hsh={}) - keys_to_change = [] - tags_to_set = [] - hsh.each { |k,v| keys_to_change << k; tags_to_set << "#{namespace}:#{k}=#{v}" } - self.remove_tags_by_namespace(namespace, *keys_to_change) - self.add_tags(*tags_to_set) - end - - def get_tags_by_namespace(namespace) - ret = {} - tags = {"self" => self.tags(true)} - tags.each { |res,ary| - ret[res] ||= {} - ary.each { |tag| - next unless tag.start_with?("#{namespace}:") - key = tag.split("=").first.split(":").last - value = tag.split(":")[1..-1].join(":").split("=")[1..-1].join("=") - ret[res][key] = value - } - } - return ret - end - - def set_tags_to(*args) - STDERR.puts "set_tags_to(...) is deprecated" - self.clear_tags("info") - self.add_tags(*(args.uniq)) - end - - def clear_tags(namespace = nil) - tag_ary = self.tags(true) - tag_ary = tag_ary.select { |tag| tag.start_with?("#{namespace}:") } if namespace - self.remove_tags(*tag_ary) - end end module McTaggableExtend diff --git a/lib/rest_connection/rightscale/rightscale_api_resources.rb b/lib/rest_connection/rightscale/rightscale_api_resources.rb index 26c8353..67d02f1 100644 --- a/lib/rest_connection/rightscale/rightscale_api_resources.rb +++ b/lib/rest_connection/rightscale/rightscale_api_resources.rb @@ -69,3 +69,7 @@ require 'rest_connection/rightscale/mc_image' require 'rest_connection/rightscale/macro' require 'rest_connection/rightscale/s3_bucket' +require 'rest_connection/rightscale/account' +require 'rest_connection/rightscale/child_account' +require 'rest_connection/rightscale/permission' +require 'rest_connection/rightscale/user' diff --git a/lib/rest_connection/rightscale/rightscale_api_taggable.rb b/lib/rest_connection/rightscale/rightscale_api_taggable.rb index b0d6bb1..b181985 100644 --- a/lib/rest_connection/rightscale/rightscale_api_taggable.rb +++ b/lib/rest_connection/rightscale/rightscale_api_taggable.rb @@ -25,6 +25,7 @@ def add_tags(*args) def remove_tags(*args) return false if args.empty? Tag.unset(self.href, args.uniq) + @params["tags"] -= args self.tags(true) end @@ -52,7 +53,7 @@ def get_info_tags(*tag_keys) rej } } - return ret + return tags end def remove_tags_by_namespace(namespace, *tag_keys) diff --git a/lib/rest_connection/rightscale/user.rb b/lib/rest_connection/rightscale/user.rb new file mode 100644 index 0000000..0d9710b --- /dev/null +++ b/lib/rest_connection/rightscale/user.rb @@ -0,0 +1,27 @@ +# This file is part of RestConnection +# +# RestConnection is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# RestConnection is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with RestConnection. If not, see . + +# +# You must have Beta v1.5 API access to use these internal API calls. +# + +# +# User Resource requires "admin" role +# + +class User + include RightScale::Api::Gateway + extend RightScale::Api::GatewayExtend +end From 6d7ea6f900045bd4cf626495fc4d8d9962851661 Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Wed, 5 Oct 2011 10:50:27 -0700 Subject: [PATCH 104/239] [API 1.5] Added check for unlaunchable servers --- lib/rest_connection/rightscale/mc_server.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/rest_connection/rightscale/mc_server.rb b/lib/rest_connection/rightscale/mc_server.rb index 5863fb9..3cb984a 100644 --- a/lib/rest_connection/rightscale/mc_server.rb +++ b/lib/rest_connection/rightscale/mc_server.rb @@ -47,6 +47,8 @@ def launch if actions.include?("launch") t = URI.parse(self.href) connection.post(t.path + '/launch') + elsif self.state == "inactive" + raise "FATAL: Server is in an unlaunchable state!" else connection.logger("WARNING: was in #{self.state} so skipping launch call") end @@ -57,6 +59,8 @@ def terminate t = URI.parse(self.href) connection.post(t.path + '/terminate') @current_instance = nil +# elsif self.state != "inactive" +# raise "FATAL: Server is in an interminable state!" else connection.logger("WARNING: was in #{self.state} so skipping terminate call") end From 9e52fe05b6ee1a005e12d6a90b34046efd12270c Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Wed, 5 Oct 2011 14:58:21 -0700 Subject: [PATCH 105/239] [API 1.0] Ensure Server is set to next before tag changes; bugfixes --- lib/rest_connection/rightscale/server.rb | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/rest_connection/rightscale/server.rb b/lib/rest_connection/rightscale/server.rb index b288776..0a4a5e7 100644 --- a/lib/rest_connection/rightscale/server.rb +++ b/lib/rest_connection/rightscale/server.rb @@ -204,11 +204,8 @@ def set_input(name, value) def set_inputs(hash = {}) serv_href = URI.parse(self.href) - params = self.parameters.deep_merge hash - connection.put(serv_href.path, :server => {:parameters => params}) -# TODO Test this!!! -# connection.put(serv_href.path, :server => {:parameters => hash}) -# settings + connection.put(serv_href.path, :server => {:parameters => hash}) + settings end def set_template(href) @@ -341,7 +338,13 @@ def reachable_ip end # Override Taggable mixin so that it sets tags on both next and current instances + def tags(*args) + self.reload_as_next if self.href =~ /current/ + super(*args) + end + def current_tags(reload=true) + self.reload_as_next if self.href =~ /current/ ret = [] if self.current_instance_href ret = Tag.search_by_href(self.current_instance_href).map { |h| h["name"] } @@ -350,6 +353,7 @@ def current_tags(reload=true) end def add_tags(*args) + self.reload_as_next if self.href =~ /current/ return false if args.empty? args.uniq! Tag.set(self.href, args) @@ -358,6 +362,7 @@ def add_tags(*args) end def remove_tags(*args) + self.reload_as_next if self.href =~ /current/ return false if args.empty? args.uniq! Tag.unset(self.href, args) From 4c038a97f87150d11976640d08c294cb400c047d Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Thu, 13 Oct 2011 17:48:40 -0700 Subject: [PATCH 106/239] Added .set_current_inputs and .set_next_inputs --- git_hooks/post-commit.disabled | 4 ++ git_hooks/post-merge.disabled | 4 ++ git_hooks/pre-commit | 53 +++++++++++++++++++ lib/rest_connection/rightscale/mc_server.rb | 8 ++- .../rightscale/rightscale_api_taggable.rb | 2 +- lib/rest_connection/rightscale/server.rb | 17 +++++- .../rightscale/server_interface.rb | 13 ----- 7 files changed, 84 insertions(+), 17 deletions(-) create mode 100755 git_hooks/post-commit.disabled create mode 100755 git_hooks/post-merge.disabled create mode 100755 git_hooks/pre-commit diff --git a/git_hooks/post-commit.disabled b/git_hooks/post-commit.disabled new file mode 100755 index 0000000..a0f9eff --- /dev/null +++ b/git_hooks/post-commit.disabled @@ -0,0 +1,4 @@ +#!/bin/bash + +rake build +gem install ../pkg/virtualmonkey*.gem --no-rdoc --no-ri diff --git a/git_hooks/post-merge.disabled b/git_hooks/post-merge.disabled new file mode 100755 index 0000000..a0f9eff --- /dev/null +++ b/git_hooks/post-merge.disabled @@ -0,0 +1,4 @@ +#!/bin/bash + +rake build +gem install ../pkg/virtualmonkey*.gem --no-rdoc --no-ri diff --git a/git_hooks/pre-commit b/git_hooks/pre-commit new file mode 100755 index 0000000..50b332b --- /dev/null +++ b/git_hooks/pre-commit @@ -0,0 +1,53 @@ +#!/bin/bash + +whitespace="" +for FILE in `git diff-index --name-only HEAD --` ; do + if test -e $FILE; then + if [[ -n `grep "\\s\\s*$" $FILE` ]]; then whitespace="$whitespace $FILE"; fi + # Remove trailing whitespace + sed -i "s/\\s\\s*$//g" $FILE + # Remove tabs + sed -i "s/\t/ /g" $FILE + # If a file is ruby, check for syntax errors + if [[ -n `find $FILE -regex ".*\.rb$"` ]]; then + if [[ "$fail" -eq 0 || -z "$fail" ]]; then + `ruby -c $FILE 1> /dev/null`; fail=$? + else + `ruby -c $FILE 1> /dev/null` + fi + fi + fi +done + +# Built-in git checks +git diff-index --check HEAD -- + +if [[ "$fail" -ne 0 && -n "$fail" ]]; then + echo "Syntax Errors Found. Aborting commit" + exit 1 +fi + +for FILE in $whitespace; do + echo "Whitespace problem fixed. Please re-add '$FILE' to your commit" +done +if [[ -n "$whitespace" ]]; then exit 1; fi + +# Check that project metadata files exist +for FILE in "Rakefile" "README.rdoc" "VERSION" ".gitignore" "rest_connection.gemspec"; do + if test ! -e $FILE; then + echo "$FILE not present. Aborting commit" + exit 1 + fi +done + +# Check that username and user emails are filled properly +username=`git config --get user.name` +useremail=`git config --get user.email` +emaildomain=`echo $useremail | grep -o "[^@]*$"` +if [[ "$username" == "" ]]; then + echo "Please set your git user.name by running 'git config user.name '" + exit 1 +elif [[ "$useremail" == "" ]] || ! host "$emaildomain" &> /dev/null; then + echo "Please set your git user.email by running 'git config user.email '" + exit 1 +fi diff --git a/lib/rest_connection/rightscale/mc_server.rb b/lib/rest_connection/rightscale/mc_server.rb index 3cb984a..6388efa 100644 --- a/lib/rest_connection/rightscale/mc_server.rb +++ b/lib/rest_connection/rightscale/mc_server.rb @@ -113,11 +113,15 @@ def set_input(name, value) @next_instance.multi_update([{'name' => name, 'value' => value}]) end - def set_inputs(hash = {}) + def set_current_inputs(hash = {}) @current_instance.multi_update(transform_inputs(:to_a, hash)) if @current_instance + end + + def set_next_inputs(hash = {}) @next_instance.multi_update(transform_inputs(:to_a, hash)) end + def settings #show serv_href = URI.parse(self.href) @params = connection.get(serv_href.path, 'view' => 'instance_detail') @@ -258,7 +262,7 @@ def get_tags_by_namespace(namespace) ret[res] ||= {} ary.each { |tag| next unless tag.start_with?("#{namespace}:") - key = tag.split("=").first.split(":").last + key = tag.split("=").first.split(":")[1..-1].join(":") value = tag.split(":")[1..-1].join(":").split("=")[1..-1].join("=") ret[res][key] = value } diff --git a/lib/rest_connection/rightscale/rightscale_api_taggable.rb b/lib/rest_connection/rightscale/rightscale_api_taggable.rb index b181985..d81fe76 100644 --- a/lib/rest_connection/rightscale/rightscale_api_taggable.rb +++ b/lib/rest_connection/rightscale/rightscale_api_taggable.rb @@ -82,7 +82,7 @@ def get_tags_by_namespace(namespace) ret[res] ||= {} ary.each { |tag| next unless tag.start_with?("#{namespace}:") - key = tag.split("=").first.split(":").last + key = tag.split("=").first.split(":")[1..-1].join(":") value = tag.split(":")[1..-1].join(":").split("=")[1..-1].join("=") ret[res][key] = value } diff --git a/lib/rest_connection/rightscale/server.rb b/lib/rest_connection/rightscale/server.rb index 0a4a5e7..d99cb4d 100644 --- a/lib/rest_connection/rightscale/server.rb +++ b/lib/rest_connection/rightscale/server.rb @@ -203,6 +203,21 @@ def set_input(name, value) end def set_inputs(hash = {}) + set_current_inputs(hash) + set_next_inputs(hash) + end + + def set_current_inputs(hash = {}) + if self.current_instance_href and self.state != "stopped" + self.reload_as_current + serv_href = URI.parse(self.href) + connection.put(serv_href.path, :server => {:parameters => hash}) + settings + self.reload_as_next + end + end + + def set_next_inputs(hash = {}) serv_href = URI.parse(self.href) connection.put(serv_href.path, :server => {:parameters => hash}) settings @@ -378,7 +393,7 @@ def get_tags_by_namespace(namespace) ret[res] ||= {} ary.each { |tag| next unless tag.start_with?("#{namespace}:") - key = tag.split("=").first.split(":").last + key = tag.split("=").first.split(":")[1..-1].join(":") value = tag.split(":")[1..-1].join(":").split("=")[1..-1].join("=") ret[res][key] = value } diff --git a/lib/rest_connection/rightscale/server_interface.rb b/lib/rest_connection/rightscale/server_interface.rb index 4e7d6b5..6b0c724 100644 --- a/lib/rest_connection/rightscale/server_interface.rb +++ b/lib/rest_connection/rightscale/server_interface.rb @@ -258,19 +258,6 @@ def save(new_params = nil) @impl.save end - def set_inputs(hash = {}) - if @multicloud - return @impl.set_inputs(hash) - else - if @impl.current_instance_href and @impl.state != "stopped" - @impl.reload_as_current - @impl.set_inputs(hash) - @impl.reload_as_next - end - return @impl.set_inputs(hash) - end - end - def update(new_params = nil) save(new_params) end From 729c21d086c249ec30eb35215aa6eb634242aab8 Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Thu, 13 Oct 2011 17:51:26 -0700 Subject: [PATCH 107/239] Whitespace Fixes --- lib/rest_connection.rb | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/rest_connection.rb b/lib/rest_connection.rb index fb233dd..4d1af9c 100644 --- a/lib/rest_connection.rb +++ b/lib/rest_connection.rb @@ -1,4 +1,4 @@ -# This file is part of RestConnection +# This file is part of RestConnection # # RestConnection is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -110,23 +110,23 @@ def initialize(config_yaml = File.join(File.expand_path("~"), ".rest_connection" end # Main HTTP connection loop. Common settings are set here, then we yield(BASE_URI, OPTIONAL_HEADERS) to other methods for each type of HTTP request: GET, PUT, POST, DELETE - # + # # The block must return a Net::HTTP Request. You have a chance to taylor the request inside the block that you pass by modifying the url and headers. # # rest_connect do |base_uri, headers| # headers.merge! {:my_header => "blah"} # Net::HTTP::Get.new(base_uri, headers) # end - # + # def rest_connect(&block) uri = URI.parse(@settings[:api_href]) http = Net::HTTP.new(uri.host, uri.port) if uri.scheme == 'https' - http.use_ssl = true + http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_NONE end headers = @settings[:common_headers] - headers.merge!("Cookie" => @cookie) if @cookie + headers.merge!("Cookie" => @cookie) if @cookie http.start do |http| req = yield(uri, headers) unless @cookie @@ -151,7 +151,7 @@ def get(href, additional_parameters = "") Net::HTTP::Get.new(new_path, headers) end end - + # connection.post(server_url + "/start") # # href = "/api/base_new" if this begins with a slash then the url will be used as absolute path. @@ -179,7 +179,7 @@ def put(href, additional_parameters = {}) rest_connect do |base_uri, headers| href = "#{base_uri}/#{href}" unless begins_with_slash(href) new_path = URI.escape(href) - req = Net::HTTP::Put.new(new_path, headers) + req = Net::HTTP::Put.new(new_path, headers) req.set_content_type('application/json') req.body = additional_parameters.to_json req @@ -203,7 +203,7 @@ def delete(href, additional_parameters = {}) end # handle_response - # res = HTTP response + # res = HTTP response # # decoding and post processing goes here. This is where you may need some customization if you want to handle the response differently (or not at all!). Luckily it's easy to modify based on this handler. def handle_response(res) @@ -219,7 +219,7 @@ def handle_response(res) else return res end - else + else raise "invalid response HTTP code: #{res.code.to_i}, #{res.code}, #{res.body}" end end From faa8d29d82282ab54894865bdd543bfd82098161 Mon Sep 17 00:00:00 2001 From: Alex Pop Date: Fri, 14 Oct 2011 17:18:40 +0200 Subject: [PATCH 108/239] Edited lib/rest_connection.rb via GitHub --- lib/rest_connection.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/rest_connection.rb b/lib/rest_connection.rb index 4d1af9c..e535b8b 100644 --- a/lib/rest_connection.rb +++ b/lib/rest_connection.rb @@ -241,7 +241,13 @@ def logger(message) @@logger.info(init_message) end - @@logger.info("[API V#{@settings[:common_headers]["X_API_VERSION"]} ]" + message) + if @settings.nil? + @@logger.info(message) + else + @@logger.info("[API v#{@settings[:common_headers]['X_API_VERSION']} ]" + message) + end + end + end # used by requestify to build parameters strings From f96636d11afebb31e412f273fb1d8468dadfd6fc Mon Sep 17 00:00:00 2001 From: Alex Pop Date: Fri, 14 Oct 2011 17:20:27 +0200 Subject: [PATCH 109/239] highline --- Rakefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Rakefile b/Rakefile index 0e0e171..62c1bef 100644 --- a/Rakefile +++ b/Rakefile @@ -10,6 +10,7 @@ Jeweler::Tasks.new do |gemspec| gemspec.add_dependency('activesupport', "=2.3.10") gemspec.add_dependency('net-ssh', "=2.1.4") gemspec.add_dependency('json') + gemspec.add_dependency('highline') end Jeweler::GemcutterTasks.new From 9ca5d085e038e2b711c13dadad3bdd4e85dcd143 Mon Sep 17 00:00:00 2001 From: Alex Pop Date: Fri, 14 Oct 2011 21:15:58 +0200 Subject: [PATCH 110/239] overriding settings example --- lib/rest_connection.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/rest_connection.rb b/lib/rest_connection.rb index e535b8b..937f076 100644 --- a/lib/rest_connection.rb +++ b/lib/rest_connection.rb @@ -82,6 +82,8 @@ class Connection # Settings are loaded from a yaml configuration file in users home directory. # Copy the example config from the gemhome/config/rest_api_config.yaml.sample to ~/.rest_connection/rest_api_config.yaml # OR to /etc/rest_connection/rest_api_config.yaml + # Here's an example of overriding the settings in the configuration file: + # Server.connection.settings[:api_url] = "https://my.rightscale.com/api/acct/1234" # def initialize(config_yaml = File.join(File.expand_path("~"), ".rest_connection", "rest_api_config.yaml")) @@logger = nil From 8c1e6ffca3c2b139c47c1e1e137f9efbd5818b44 Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Fri, 14 Oct 2011 13:59:07 -0700 Subject: [PATCH 111/239] Added catch for "inactive" state during state wait --- lib/rest_connection/rightscale/server.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/rest_connection/rightscale/server.rb b/lib/rest_connection/rightscale/server.rb index d99cb4d..663528b 100644 --- a/lib/rest_connection/rightscale/server.rb +++ b/lib/rest_connection/rightscale/server.rb @@ -70,13 +70,13 @@ def wait_for_state(st,timeout=1200) reload connection.logger("#{nickname} is #{self.state}") step = 15 - catch_early_terminated = 120 / step + catch_early_terminated = 60 / step while(timeout > 0) return true if state =~ /#{st}/ raise "FATAL error, this server is stranded and needs to be #{st}: #{nickname}, see audit: #{self.audit_link}" if state.include?('stranded') && !st.include?('stranded') raise "FATAL error, this server went to error state and needs to be #{st}: #{nickname}, see audit: #{self.audit_link}" if state.include?('error') && st !~ /error|terminated|stopped/ connection.logger("waiting for server #{nickname} to go #{st}, state is #{state}") - if state =~ /terminated|stopped|error/ and st !~ /terminated|stopped|error/ + if state =~ /terminated|stopped|inactive|error/ and st !~ /terminated|stopped|inactive|error/ if catch_early_terminated <= 0 raise "FATAL error, this server terminated when waiting for #{st}: #{nickname}" end @@ -96,7 +96,6 @@ def wait_for_operational_with_dns(state_wait_timeout=1200) step = 15 while(timeout > 0) self.settings -# break if self['dns-name'] && !self['dns-name'].empty? && self['private-dns-name'] && !self['private-dns-name'].empty? break if self.reachable_ip connection.logger "waiting for IP for #{self.nickname}" sleep step From a82616645c9c7a680e7e7d947fe15324c4434107 Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Fri, 14 Oct 2011 14:02:09 -0700 Subject: [PATCH 112/239] bugfix --- lib/rest_connection.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/rest_connection.rb b/lib/rest_connection.rb index 937f076..36680c8 100644 --- a/lib/rest_connection.rb +++ b/lib/rest_connection.rb @@ -250,8 +250,6 @@ def logger(message) end end - end - # used by requestify to build parameters strings def name_with_prefix(prefix, name) prefix ? "#{prefix}[#{name}]" : name.to_s From d16b2a20004fda71749683154a3f6a4885716645 Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Sat, 15 Oct 2011 00:15:52 -0700 Subject: [PATCH 113/239] Bugfix for Taggable --- lib/rest_connection/rightscale/rightscale_api_taggable.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/rest_connection/rightscale/rightscale_api_taggable.rb b/lib/rest_connection/rightscale/rightscale_api_taggable.rb index d81fe76..8e4daf4 100644 --- a/lib/rest_connection/rightscale/rightscale_api_taggable.rb +++ b/lib/rest_connection/rightscale/rightscale_api_taggable.rb @@ -58,10 +58,10 @@ def get_info_tags(*tag_keys) def remove_tags_by_namespace(namespace, *tag_keys) tags_to_unset = [] - tags = get_tags_by_namespace(*(tag_keys.uniq)) + tags = get_tags_by_namespace(namespace) tags.each { |res,hsh| hsh.each { |k,v| - tags_to_unset << "#{namespace}:#{k}=#{v}" + tags_to_unset << "#{namespace}:#{k}=#{v}" if tag_keys.include?(k) } } self.remove_tags(*tags_to_unset) From 24a923db7704bf2c96748cb3bc9da37d3dc8384e Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Tue, 18 Oct 2011 18:11:13 -0700 Subject: [PATCH 114/239] Bugfix for mc_server set_inputs --- lib/rest_connection/rightscale/mc_server.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/rest_connection/rightscale/mc_server.rb b/lib/rest_connection/rightscale/mc_server.rb index 6388efa..43a5163 100644 --- a/lib/rest_connection/rightscale/mc_server.rb +++ b/lib/rest_connection/rightscale/mc_server.rb @@ -109,15 +109,18 @@ def inputs end def set_input(name, value) + settings unless @next_instance @current_instance.multi_update([{'name' => name, 'value' => value}]) if @current_instance @next_instance.multi_update([{'name' => name, 'value' => value}]) end def set_current_inputs(hash = {}) + settings unless @next_instance @current_instance.multi_update(transform_inputs(:to_a, hash)) if @current_instance end def set_next_inputs(hash = {}) + settings unless @next_instance @next_instance.multi_update(transform_inputs(:to_a, hash)) end From 42b1037062523b1fa2cb2f6ab6062bc1e3121573 Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Wed, 19 Oct 2011 15:16:39 -0700 Subject: [PATCH 115/239] Bugfix for cloud_id run before any .settings --- lib/rest_connection/rightscale/mc_server.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/rest_connection/rightscale/mc_server.rb b/lib/rest_connection/rightscale/mc_server.rb index 43a5163..7647cc3 100644 --- a/lib/rest_connection/rightscale/mc_server.rb +++ b/lib/rest_connection/rightscale/mc_server.rb @@ -171,6 +171,7 @@ def current_instance_href end def cloud_id + settings unless @next_instance cloud_href = @current_instance.hash_of_links["cloud"] if @current_instance cloud_href = @next_instance.hash_of_links["cloud"] unless cloud_href return cloud_href.split("/").last.to_i From bc1c740792530a8cd21861ffb8e2cc53c107978d Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Wed, 19 Oct 2011 17:57:32 -0700 Subject: [PATCH 116/239] Bugfix for Net::SSH hangs --- lib/rest_connection/ssh_hax.rb | 62 ++++++++++++++++++---------------- 1 file changed, 32 insertions(+), 30 deletions(-) diff --git a/lib/rest_connection/ssh_hax.rb b/lib/rest_connection/ssh_hax.rb index 24ffef7..ba194ab 100644 --- a/lib/rest_connection/ssh_hax.rb +++ b/lib/rest_connection/ssh_hax.rb @@ -1,4 +1,4 @@ -# This file is part of RestConnection +# This file is part of RestConnection # # RestConnection is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -75,7 +75,7 @@ def run_and_tail(run_this, tail_command, expect, ssh_key=nil, host_dns=self.reac ch.on_extended_data do |c, type, data| #STDERR.print data end - ch.on_close do + ch.on_close do end ch.on_process do |c| if result @@ -84,7 +84,7 @@ def run_and_tail(run_this, tail_command, expect, ssh_key=nil, host_dns=self.reac end end end - end + end cmd_channel.wait log_channel.wait end @@ -103,9 +103,9 @@ def run_executable_with_ssh(script, options={}, ssh_key=nil) raise "FATAL: unrecognized format for script. Must be an Executable or RightScript with href or name attributes" unless (script.is_a?(RightScript)) && (script.href || script.name) if script.href - run_this = "rs_run_right_script -i #{script.href.split(/\//).last}" + run_this = "rs_run_right_script -i #{script.href.split(/\//).last}" elsif script.name - run_this = "rs_run_right_script -n #{script.name}" + run_this = "rs_run_right_script -n #{script.name}" end tail_command ="tail -f -n1 /var/log/messages" expect = /RightLink.*RS> ([completed|failed]+:)/ @@ -134,7 +134,7 @@ def spot_check(command, ssh_key=nil, host_dns=self.reachable_ip, &block) result = ssh.exec!(command) yield result end - end + end # returns true or false based on command success def spot_check_command?(command, ssh_key=nil, host_dns=self.reachable_ip) @@ -152,35 +152,37 @@ def spot_check_command(command, ssh_key=nil, host_dns=self.reachable_ip, do_not_ success = false retry_count = 0 while (!success && retry_count < SSH_RETRY_COUNT) do - begin - Net::SSH.start(host_dns, 'root', :keys => ssh_key_config(ssh_key), :user_known_hosts_file => "/dev/null") do |ssh| - cmd_channel = ssh.open_channel do |ch1| - ch1.on_request('exit-status') do |ch, data| - status = data.read_long - end - ch1.exec(command) do |ch2, success| - unless success - status = 1 - end - ch2.on_data do |ch, data| - output += data - end - ch2.on_extended_data do |ch, type, data| - output += data + begin + # Test for ability to connect; Net::SSH.start sometimes hangs under certain server-side sshd configs + test_ssh = `ssh -o \"BatchMode=yes\" -o \"ConnectTimeout 5\" root@#{host_dns} 2>&1`.chomp + raise test_ssh unless test_ssh =~ /permission denied/i + + Net::SSH.start(host_dns, 'root', :keys => ssh_key_config(ssh_key), :user_known_hosts_file => "/dev/null") do |ssh| + cmd_channel = ssh.open_channel do |ch1| + ch1.on_request('exit-status') do |ch, data| + status = data.read_long + end + ch1.exec(command) do |ch2, success| + unless success + status = 1 + end + ch2.on_data do |ch, data| + output += data + end + ch2.on_extended_data do |ch, type, data| + output += data + end + end end end + rescue Exception => e + retry_count += 1 # opening the ssh channel failed -- try again. + connection.logger "ERROR during SSH session to #{host_dns}, retrying #{retry_count}: #{e} #{e.backtrace}" + sleep 10 end end - rescue Exception => e - retry_count += 1 # opening the ssh channel failed -- try again. - connection.logger "ERROR during SSH session to #{host_dns}, retrying #{retry_count}: #{e} #{e.backtrace}" - sleep 10 - end - end connection.logger "SSH Run: #{command} on #{host_dns}. Retry was #{retry_count}. Exit status was #{status}. Output below ---\n#{output}\n---" unless do_not_log_result return {:status => status, :output => output} - end + end end - - From 5d6fad1238e155f4130608a2f82791c3c4342119 Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Mon, 24 Oct 2011 14:31:33 -0700 Subject: [PATCH 117/239] Fix for certain ssh configs that allow successful logins without -i --- lib/rest_connection/ssh_hax.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/rest_connection/ssh_hax.rb b/lib/rest_connection/ssh_hax.rb index ba194ab..ce83190 100644 --- a/lib/rest_connection/ssh_hax.rb +++ b/lib/rest_connection/ssh_hax.rb @@ -154,8 +154,8 @@ def spot_check_command(command, ssh_key=nil, host_dns=self.reachable_ip, do_not_ while (!success && retry_count < SSH_RETRY_COUNT) do begin # Test for ability to connect; Net::SSH.start sometimes hangs under certain server-side sshd configs - test_ssh = `ssh -o \"BatchMode=yes\" -o \"ConnectTimeout 5\" root@#{host_dns} 2>&1`.chomp - raise test_ssh unless test_ssh =~ /permission denied/i + test_ssh = `ssh -o \"BatchMode=yes\" -o \"ConnectTimeout 5\" root@#{host_dns} -C \"exit\" 2>&1`.chomp + raise test_ssh unless test_ssh =~ /permission denied/i or test_ssh.empty? Net::SSH.start(host_dns, 'root', :keys => ssh_key_config(ssh_key), :user_known_hosts_file => "/dev/null") do |ssh| cmd_channel = ssh.open_channel do |ch1| From c0035ae8b239ac2a9a3c799340fb39e6121433e3 Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Mon, 31 Oct 2011 16:24:58 -0700 Subject: [PATCH 118/239] Workaround for API Bug --- lib/rest_connection/rightscale/task.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/rest_connection/rightscale/task.rb b/lib/rest_connection/rightscale/task.rb index 6965a20..c5e4e76 100644 --- a/lib/rest_connection/rightscale/task.rb +++ b/lib/rest_connection/rightscale/task.rb @@ -26,7 +26,7 @@ def self.parse_args(cloud_id, instance_id) def show url = URI.parse(self.href) - @params.merge! connection.get(url.path, 'view' => "extended") + @params.merge! connection.get(url.path)#, 'view' => "extended") end def wait_for_state(state, timeout=900) @@ -34,7 +34,7 @@ def wait_for_state(state, timeout=900) show return true if self.summary.include?(state) connection.logger("state is #{self.summary}, waiting for #{state}") - raise "FATAL error:\n\n #{self.detail} \n\n" if self.summary.include?('failed') + raise "FATAL error:\n\n #{self.summary} \n\n" if self.summary.include?('failed') # TODO #{self.detail} sleep 30 timeout -= 30 end From 1c75d503a904ba1ad8461788d5a80a682bdc9aa3 Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Tue, 1 Nov 2011 15:21:13 -0700 Subject: [PATCH 119/239] Version bump to 0.1.0 --- README.rdoc | 6 +++--- Rakefile | 6 +++--- VERSION | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README.rdoc b/README.rdoc index c9dfdbf..acd2e85 100644 --- a/README.rdoc +++ b/README.rdoc @@ -4,7 +4,7 @@ "gem install rest_connection" ==== Installing from source - "git clone http://github.com/jeremyd/rest_connection.git" + "git clone http://github.com/twrodriguez/rest_connection.git" "gem install jeweler rspec" "rake check_dependencies" <- Install any gems listed. "rake install" @@ -40,8 +40,8 @@ Copy the example from GEMHOME/rest_connection/examples/rest_api_config.yaml.samp my_servers.each { |s| s.wait_for_state("stopped") } === Activate an Ec2ServerArray / Display instances IPs - - my_array = Ec2ServerArray.find(opts[:href]) + + my_array = Ec2ServerArray.find(opts[:href]) my_array.active = true my_array.save diff --git a/Rakefile b/Rakefile index 62c1bef..17fe29b 100644 --- a/Rakefile +++ b/Rakefile @@ -4,9 +4,9 @@ Jeweler::Tasks.new do |gemspec| gemspec.name = "rest_connection" gemspec.summary = "lib for restful connections to the rightscale api" gemspec.description = "provides rest_connection" - gemspec.email = "jeremy@rubyonlinux.org" - gemspec.homepage = "http://github.com/jeremyd/rest_connection" - gemspec.authors = ["Jeremy Deininger"] + gemspec.email = ["jeremy@rubyonlinux.org", "tw.rodriguez@gmail.com"] + gemspec.homepage = "http://github.com/twrodriguez/rest_connection" + gemspec.authors = ["Jeremy Deininger", "Timothy Rodriguez"] gemspec.add_dependency('activesupport', "=2.3.10") gemspec.add_dependency('net-ssh', "=2.1.4") gemspec.add_dependency('json') diff --git a/VERSION b/VERSION index fe059cc..6c6aa7c 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.0.22 \ No newline at end of file +0.1.0 \ No newline at end of file From b12736b052eb8b4f2c405fafc615de4ae3eec5bd Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Tue, 1 Nov 2011 15:24:27 -0700 Subject: [PATCH 120/239] Updated gemspec --- rest_connection.gemspec | 57 ++++++++++++++++++++++++++++++++++------- 1 file changed, 48 insertions(+), 9 deletions(-) diff --git a/rest_connection.gemspec b/rest_connection.gemspec index 162e452..3d639c9 100644 --- a/rest_connection.gemspec +++ b/rest_connection.gemspec @@ -4,14 +4,14 @@ # -*- encoding: utf-8 -*- Gem::Specification.new do |s| - s.name = %q{rest_connection} - s.version = "0.0.22" + s.name = "rest_connection" + s.version = "0.1.0" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= - s.authors = ["Jeremy Deininger"] - s.date = %q{2011-09-10} - s.description = %q{provides rest_connection} - s.email = %q{jeremy@rubyonlinux.org} + s.authors = ["Jeremy Deininger", "Timothy Rodriguez"] + s.date = "2011-11-01" + s.description = "provides rest_connection" + s.email = ["jeremy@rubyonlinux.org", "tw.rodriguez@gmail.com"] s.extra_rdoc_files = [ "README.rdoc" ] @@ -29,9 +29,16 @@ Gem::Specification.new do |s| "examples/cucumber/step_definitions/spot_check_steps.rb", "examples/relaunch_deployment.rb", "examples/right_scale_ec2_instances_api_test.rb", + "git_hooks/post-commit.disabled", + "git_hooks/post-merge.disabled", + "git_hooks/pre-commit", "lib/rest_connection.rb", + "lib/rest_connection/patches.rb", + "lib/rest_connection/rightscale/account.rb", "lib/rest_connection/rightscale/alert_spec.rb", "lib/rest_connection/rightscale/audit_entry.rb", + "lib/rest_connection/rightscale/child_account.rb", + "lib/rest_connection/rightscale/cloud.rb", "lib/rest_connection/rightscale/credential.rb", "lib/rest_connection/rightscale/deployment.rb", "lib/rest_connection/rightscale/ec2_ebs_snapshot.rb", @@ -43,29 +50,58 @@ Gem::Specification.new do |s| "lib/rest_connection/rightscale/ec2_ssh_key_internal.rb", "lib/rest_connection/rightscale/executable.rb", "lib/rest_connection/rightscale/instance.rb", + "lib/rest_connection/rightscale/instance_type.rb", + "lib/rest_connection/rightscale/macro.rb", + "lib/rest_connection/rightscale/mc_datacenter.rb", + "lib/rest_connection/rightscale/mc_deployment.rb", + "lib/rest_connection/rightscale/mc_image.rb", + "lib/rest_connection/rightscale/mc_instance.rb", + "lib/rest_connection/rightscale/mc_instance_type.rb", + "lib/rest_connection/rightscale/mc_multi_cloud_image.rb", + "lib/rest_connection/rightscale/mc_multi_cloud_image_setting.rb", + "lib/rest_connection/rightscale/mc_security_group.rb", "lib/rest_connection/rightscale/mc_server.rb", + "lib/rest_connection/rightscale/mc_server_array.rb", + "lib/rest_connection/rightscale/mc_server_template.rb", + "lib/rest_connection/rightscale/mc_ssh_key.rb", + "lib/rest_connection/rightscale/mc_tag.rb", + "lib/rest_connection/rightscale/mc_volume.rb", + "lib/rest_connection/rightscale/mc_volume_attachment.rb", + "lib/rest_connection/rightscale/mc_volume_snapshot.rb", + "lib/rest_connection/rightscale/mc_volume_type.rb", + "lib/rest_connection/rightscale/monitoring_metric.rb", "lib/rest_connection/rightscale/multi_cloud_image.rb", "lib/rest_connection/rightscale/multi_cloud_image_cloud_setting_internal.rb", "lib/rest_connection/rightscale/multi_cloud_image_internal.rb", + "lib/rest_connection/rightscale/permission.rb", "lib/rest_connection/rightscale/right_script.rb", "lib/rest_connection/rightscale/right_script_internal.rb", "lib/rest_connection/rightscale/rightscale_api_base.rb", "lib/rest_connection/rightscale/rightscale_api_gateway.rb", "lib/rest_connection/rightscale/rightscale_api_internal.rb", + "lib/rest_connection/rightscale/rightscale_api_mc_input.rb", + "lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb", "lib/rest_connection/rightscale/rightscale_api_resources.rb", + "lib/rest_connection/rightscale/rightscale_api_taggable.rb", "lib/rest_connection/rightscale/rs_internal.rb", + "lib/rest_connection/rightscale/s3_bucket.rb", "lib/rest_connection/rightscale/server.rb", + "lib/rest_connection/rightscale/server_interface.rb", "lib/rest_connection/rightscale/server_internal.rb", "lib/rest_connection/rightscale/server_template.rb", "lib/rest_connection/rightscale/server_template_internal.rb", "lib/rest_connection/rightscale/status.rb", "lib/rest_connection/rightscale/tag.rb", + "lib/rest_connection/rightscale/task.rb", + "lib/rest_connection/rightscale/user.rb", "lib/rest_connection/ssh_hax.rb", "rest_connection.gemspec", "spec/ec2_server_array_spec.rb", "spec/ec2_ssh_key_internal_spec.rb", "spec/image_jockey.rb", + "spec/mcserver_spec.rb", "spec/method_missing_spec.rb", + "spec/multi.rb", "spec/right_script_internal.rb", "spec/rs_internal_spec.rb", "spec/server_internal_spec.rb", @@ -74,10 +110,10 @@ Gem::Specification.new do |s| "spec/spec_helper.rb", "spec/tag_spec.rb" ] - s.homepage = %q{http://github.com/jeremyd/rest_connection} + s.homepage = "http://github.com/twrodriguez/rest_connection" s.require_paths = ["lib"] - s.rubygems_version = %q{1.6.2} - s.summary = %q{lib for restful connections to the rightscale api} + s.rubygems_version = "1.7.2" + s.summary = "lib for restful connections to the rightscale api" if s.respond_to? :specification_version then s.specification_version = 3 @@ -86,15 +122,18 @@ Gem::Specification.new do |s| s.add_runtime_dependency(%q, ["= 2.3.10"]) s.add_runtime_dependency(%q, ["= 2.1.4"]) s.add_runtime_dependency(%q, [">= 0"]) + s.add_runtime_dependency(%q, [">= 0"]) else s.add_dependency(%q, ["= 2.3.10"]) s.add_dependency(%q, ["= 2.1.4"]) s.add_dependency(%q, [">= 0"]) + s.add_dependency(%q, [">= 0"]) end else s.add_dependency(%q, ["= 2.3.10"]) s.add_dependency(%q, ["= 2.1.4"]) s.add_dependency(%q, [">= 0"]) + s.add_dependency(%q, [">= 0"]) end end From 849fb9199e25c2a094d6ff0d7dbd7df80463bc5e Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Thu, 10 Nov 2011 17:06:04 -0800 Subject: [PATCH 121/239] Added include_mcis param on ServerTemplate show; ssh raise fix --- lib/rest_connection/rightscale/server_template.rb | 8 ++++++++ lib/rest_connection/ssh_hax.rb | 1 + 2 files changed, 9 insertions(+) diff --git a/lib/rest_connection/rightscale/server_template.rb b/lib/rest_connection/rightscale/server_template.rb index bc3cb4a..208bf45 100644 --- a/lib/rest_connection/rightscale/server_template.rb +++ b/lib/rest_connection/rightscale/server_template.rb @@ -23,6 +23,14 @@ def initialize(params) @params = params end + def reload + ret = connection.get(URI.parse(self.href).path, :include_mcis => true) + @params ? @params.merge!(ret) : @params = ret + @params["multi_cloud_images"].map! { |mci_params| MultiCloudImage.new(mci_params) } + @params["default_multi_cloud_image"] = MultiCloudImage.new(@params["default_multi_cloud_image"]) + @params + end + def executables unless @params["executables"] fetch_executables diff --git a/lib/rest_connection/ssh_hax.rb b/lib/rest_connection/ssh_hax.rb index ce83190..80d6e4f 100644 --- a/lib/rest_connection/ssh_hax.rb +++ b/lib/rest_connection/ssh_hax.rb @@ -179,6 +179,7 @@ def spot_check_command(command, ssh_key=nil, host_dns=self.reachable_ip, do_not_ retry_count += 1 # opening the ssh channel failed -- try again. connection.logger "ERROR during SSH session to #{host_dns}, retrying #{retry_count}: #{e} #{e.backtrace}" sleep 10 + raise e unless retry_count < SSH_RETRY_COUNT end end connection.logger "SSH Run: #{command} on #{host_dns}. Retry was #{retry_count}. Exit status was #{status}. Output below ---\n#{output}\n---" unless do_not_log_result From 12af868ffdb84cc444ebf20b98e2cd7e51f984a4 Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Fri, 11 Nov 2011 13:04:12 -0800 Subject: [PATCH 122/239] Timeout backoff on testing connectivity --- lib/rest_connection/ssh_hax.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/rest_connection/ssh_hax.rb b/lib/rest_connection/ssh_hax.rb index 80d6e4f..2fad123 100644 --- a/lib/rest_connection/ssh_hax.rb +++ b/lib/rest_connection/ssh_hax.rb @@ -154,7 +154,11 @@ def spot_check_command(command, ssh_key=nil, host_dns=self.reachable_ip, do_not_ while (!success && retry_count < SSH_RETRY_COUNT) do begin # Test for ability to connect; Net::SSH.start sometimes hangs under certain server-side sshd configs - test_ssh = `ssh -o \"BatchMode=yes\" -o \"ConnectTimeout 5\" root@#{host_dns} -C \"exit\" 2>&1`.chomp + test_ssh = "" + [5, 15, 60].each { |timeout_max| + test_ssh = `ssh -o \"BatchMode=yes\" -o \"ConnectTimeout #{timeout_max}\" root@#{host_dns} -C \"exit\" 2>&1`.chomp + break if test_ssh =~ /permission denied/i or test_ssh.empty? + } raise test_ssh unless test_ssh =~ /permission denied/i or test_ssh.empty? Net::SSH.start(host_dns, 'root', :keys => ssh_key_config(ssh_key), :user_known_hosts_file => "/dev/null") do |ssh| From add2487b54dc17e5d1c919aeb6658165ad73aed7 Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Wed, 23 Nov 2011 11:31:01 -0800 Subject: [PATCH 123/239] Added new API resources, methods; Added .filters() --- lib/rest_connection.rb | 5 +- .../rightscale/child_account.rb | 4 ++ lib/rest_connection/rightscale/cloud.rb | 4 ++ lib/rest_connection/rightscale/deployment.rb | 19 ++++++- .../rightscale/mc_datacenter.rb | 4 ++ .../rightscale/mc_deployment.rb | 4 ++ lib/rest_connection/rightscale/mc_image.rb | 4 ++ lib/rest_connection/rightscale/mc_instance.rb | 17 +++++++ .../rightscale/mc_instance_type.rb | 4 ++ .../rightscale/mc_multi_cloud_image.rb | 4 ++ .../mc_multi_cloud_image_setting.rb | 4 ++ .../rightscale/mc_security_group.rb | 4 ++ lib/rest_connection/rightscale/mc_server.rb | 4 ++ .../rightscale/mc_server_array.rb | 6 +++ .../rightscale/mc_server_template.rb | 50 +++++++++++++++++++ .../mc_server_template_multi_cloud_image.rb | 48 ++++++++++++++++++ lib/rest_connection/rightscale/mc_ssh_key.rb | 4 ++ lib/rest_connection/rightscale/mc_volume.rb | 4 ++ .../rightscale/mc_volume_attachment.rb | 4 ++ .../rightscale/mc_volume_snapshot.rb | 4 ++ .../rightscale/mc_volume_type.rb | 4 ++ .../rightscale/monitoring_metric.rb | 4 ++ lib/rest_connection/rightscale/permission.rb | 4 ++ .../rightscale/rightscale_api_base.rb | 9 +++- .../rightscale/rightscale_api_gateway.rb | 17 +++++++ .../rightscale/rightscale_api_resources.rb | 2 + lib/rest_connection/rightscale/server.rb | 36 +++++++++++-- lib/rest_connection/rightscale/user.rb | 4 ++ .../rightscale/vpc_dhcp_option.rb | 19 +++++++ 29 files changed, 292 insertions(+), 8 deletions(-) create mode 100644 lib/rest_connection/rightscale/mc_server_template_multi_cloud_image.rb create mode 100644 lib/rest_connection/rightscale/vpc_dhcp_option.rb diff --git a/lib/rest_connection.rb b/lib/rest_connection.rb index 36680c8..3a5e514 100644 --- a/lib/rest_connection.rb +++ b/lib/rest_connection.rb @@ -28,9 +28,10 @@ module RestConnection {"cloud_id" => 2, "name" => "AWS EU"}, {"cloud_id" => 3, "name" => "AWS US-West"}, {"cloud_id" => 4, "name" => "AWS AP-Singapore"}, - {"cloud_id" => 5, "name" => "AWS AP-Tokyo"}] + {"cloud_id" => 5, "name" => "AWS AP-Tokyo"}, + {"cloud_id" => 6, "name" => "AWS US-Oregon"}] - # Check for API 0.1 Access + # Check for API 0.1 Access def self.api0_1? unless class_variable_defined?("@@api0_1") begin diff --git a/lib/rest_connection/rightscale/child_account.rb b/lib/rest_connection/rightscale/child_account.rb index 84e4396..3976cae 100644 --- a/lib/rest_connection/rightscale/child_account.rb +++ b/lib/rest_connection/rightscale/child_account.rb @@ -24,4 +24,8 @@ class ChildAccount include RightScale::Api::Gateway extend RightScale::Api::GatewayExtend + + def self.filters + [:name] + end end diff --git a/lib/rest_connection/rightscale/cloud.rb b/lib/rest_connection/rightscale/cloud.rb index c648362..67de748 100644 --- a/lib/rest_connection/rightscale/cloud.rb +++ b/lib/rest_connection/rightscale/cloud.rb @@ -20,6 +20,10 @@ class Cloud include RightScale::Api::Gateway extend RightScale::Api::GatewayExtend + def self.filters + [:description, :name] + end + def cloud_id self.href.split("/").last end diff --git a/lib/rest_connection/rightscale/deployment.rb b/lib/rest_connection/rightscale/deployment.rb index 5daf0bd..7f7cf26 100644 --- a/lib/rest_connection/rightscale/deployment.rb +++ b/lib/rest_connection/rightscale/deployment.rb @@ -19,6 +19,10 @@ class Deployment include RightScale::Api::Taggable extend RightScale::Api::TaggableExtend + def self.filters + [:description, :nickname] + end + def reload uri = URI.parse(self.href) @params ? @params.merge!(connection.get(uri.path)) : @params = connection.get(uri.path) @@ -45,7 +49,10 @@ def set_input(name, value) def servers_no_reload connection.logger("WARNING: No Servers in the Deployment!") if @params['servers'].empty? - @params['servers'].map { |s| ServerInterface.new(self.cloud_id, s, self.rs_id) } + unless @params['servers'].reduce(true) { |bool,s| bool && s.is_a?(ServerInterface) } + @params['servers'].map! { |s| ServerInterface.new(self.cloud_id, s, self.rs_id) } + end + @params['servers'] end def servers @@ -71,4 +78,14 @@ def destroy(wait_for_servers = nil) end connection.delete(deploy_href.path) end + + def start_all + deploy_href = URI.parse(self.href) + connection.post(deploy_href.path + "/start_all") + end + + def stop_all + deploy_href = URI.parse(self.href) + connection.post(deploy_href.path + "/stop_all") + end end diff --git a/lib/rest_connection/rightscale/mc_datacenter.rb b/lib/rest_connection/rightscale/mc_datacenter.rb index decd54d..d88392f 100644 --- a/lib/rest_connection/rightscale/mc_datacenter.rb +++ b/lib/rest_connection/rightscale/mc_datacenter.rb @@ -40,6 +40,10 @@ def self.parse_args(cloud_id) "clouds/#{cloud_id}/" end + def self.filters + [:name, :resource_uid] + end + def show inst_href = URI.parse(self.href) @params.merge! connection.get(inst_href.path, 'view' => "full") diff --git a/lib/rest_connection/rightscale/mc_deployment.rb b/lib/rest_connection/rightscale/mc_deployment.rb index e236a41..34c9db8 100644 --- a/lib/rest_connection/rightscale/mc_deployment.rb +++ b/lib/rest_connection/rightscale/mc_deployment.rb @@ -39,6 +39,10 @@ def self.resource_singular_name "deployment" end + def self.filters + [:description, :name] + end + def self.create(opts) location = connection.post(resource_plural_name, opts) newrecord = self.new('href' => location) diff --git a/lib/rest_connection/rightscale/mc_image.rb b/lib/rest_connection/rightscale/mc_image.rb index 440598f..017a727 100644 --- a/lib/rest_connection/rightscale/mc_image.rb +++ b/lib/rest_connection/rightscale/mc_image.rb @@ -36,6 +36,10 @@ def self.resource_singular_name "image" end + def self.filters + [:cpu_architecture, :description, :image_type, :name, :os_platform, :resource_uid, :visibility] + end + def self.parse_args(cloud_id) "clouds/#{cloud_id}/" end diff --git a/lib/rest_connection/rightscale/mc_instance.rb b/lib/rest_connection/rightscale/mc_instance.rb index 2055b64..68851b8 100644 --- a/lib/rest_connection/rightscale/mc_instance.rb +++ b/lib/rest_connection/rightscale/mc_instance.rb @@ -44,6 +44,23 @@ def self.parse_args(cloud_id) "clouds/#{cloud_id}/" end + def self.filters + [ + :datacenter_href, + :deployment_href, + :name, + :os_platform, + :parent_href, + :private_dns_name, + :private_ip_address, + :public_dns_name, + :public_ip_address, + :resource_uid, + :server_template_href, + :state + ] + end + def show inst_href = URI.parse(self.href) @params.merge! connection.get(inst_href.path, 'view' => "full") diff --git a/lib/rest_connection/rightscale/mc_instance_type.rb b/lib/rest_connection/rightscale/mc_instance_type.rb index 2829a39..d3e595c 100644 --- a/lib/rest_connection/rightscale/mc_instance_type.rb +++ b/lib/rest_connection/rightscale/mc_instance_type.rb @@ -40,6 +40,10 @@ def self.parse_args(cloud_id) "clouds/#{cloud_id}/" end + def self.filters + [:cpu_architecture, :description, :name, :resource_uid] + end + def show inst_href = URI.parse(self.href) @params.merge! connection.get(inst_href.path, 'view' => "default") diff --git a/lib/rest_connection/rightscale/mc_multi_cloud_image.rb b/lib/rest_connection/rightscale/mc_multi_cloud_image.rb index 477cdc7..1083f19 100644 --- a/lib/rest_connection/rightscale/mc_multi_cloud_image.rb +++ b/lib/rest_connection/rightscale/mc_multi_cloud_image.rb @@ -43,6 +43,10 @@ def self.parse_args(server_template_id=nil) server_template_id ? "server_templates/#{server_template_id}/" : "" end + def self.filters + [:description, :name, :revision] + end + def supported_cloud_ids @settings.map { |mcics| mcics.cloud_id } end diff --git a/lib/rest_connection/rightscale/mc_multi_cloud_image_setting.rb b/lib/rest_connection/rightscale/mc_multi_cloud_image_setting.rb index e584d7a..0cbd705 100644 --- a/lib/rest_connection/rightscale/mc_multi_cloud_image_setting.rb +++ b/lib/rest_connection/rightscale/mc_multi_cloud_image_setting.rb @@ -40,6 +40,10 @@ def self.parse_args(multi_cloud_image_id) "multi_cloud_images/#{multi_cloud_image_id}/" end + def self.filters + [:cloud_href, :multi_cloud_image_href] + end + def cloud_id self.cloud.split(/\//).last.to_i end diff --git a/lib/rest_connection/rightscale/mc_security_group.rb b/lib/rest_connection/rightscale/mc_security_group.rb index acbee31..74b56fd 100644 --- a/lib/rest_connection/rightscale/mc_security_group.rb +++ b/lib/rest_connection/rightscale/mc_security_group.rb @@ -39,4 +39,8 @@ def self.resource_singular_name def self.parse_args(cloud_id) "clouds/#{cloud_id}/" end + + def self.filters + [:name, :resource_uid] + end end diff --git a/lib/rest_connection/rightscale/mc_server.rb b/lib/rest_connection/rightscale/mc_server.rb index 7647cc3..bf4d0dc 100644 --- a/lib/rest_connection/rightscale/mc_server.rb +++ b/lib/rest_connection/rightscale/mc_server.rb @@ -43,6 +43,10 @@ def self.parse_args(deployment_id=nil) deployment_id ? "deployments/#{deployment_id}/" : "" end + def self.filters + [:deployment_href, :name] + end + def launch if actions.include?("launch") t = URI.parse(self.href) diff --git a/lib/rest_connection/rightscale/mc_server_array.rb b/lib/rest_connection/rightscale/mc_server_array.rb index f400d9f..24d3229 100644 --- a/lib/rest_connection/rightscale/mc_server_array.rb +++ b/lib/rest_connection/rightscale/mc_server_array.rb @@ -41,4 +41,10 @@ def self.resource_singular_name def self.parse_args(deployment_id=nil) (deployment_id ? "deployments/#{deployment_id}/" : "") end + + def self.filters + [:deployment_href, :name] + end + + # TODO end diff --git a/lib/rest_connection/rightscale/mc_server_template.rb b/lib/rest_connection/rightscale/mc_server_template.rb index f5bd66f..6ec9bbf 100644 --- a/lib/rest_connection/rightscale/mc_server_template.rb +++ b/lib/rest_connection/rightscale/mc_server_template.rb @@ -39,9 +39,14 @@ def self.resource_singular_name "server_template" end + def self.filters + [:description, :multi_cloud_image_href, :name, :revision] + end + def get_mcis_and_settings @params["multi_cloud_images"] = McMultiCloudImage.find_all(self.rs_id) @params["multi_cloud_images"].each { |mci| mci.get_settings } + @mci_links = McServerTemplateMultiCloudImage.find_with_filter(:server_template_href => self.href) end def multi_cloud_images @@ -50,4 +55,49 @@ def multi_cloud_images end @params["multi_cloud_images"] end + + def add_multi_cloud_image(mci_href) + @mci_links = McServerTemplateMultiCloudImage.find_with_filter(:server_template_href => self.href) + if @mci_links.detect { |mci_link| mci_link.multi_cloud_image == mci_href } + connection.logger("WARNING: MCI #{mci_href} is already attached") + else + ret = McServerTemplateMultiCloudImage.create(:multi_cloud_image_href => mci_href, + :server_template_href => self.href) + get_mcis_and_settings + ret + end + end + + def detach_multi_cloud_image(mci_href) + @mci_links = McServerTemplateMultiCloudImage.find_with_filter(:server_template_href => self.href) + if link = @mci_links.detect { |mci_link| mci_link.multi_cloud_image == mci_href } + ret = link.destroy + get_mcis_and_settings + ret + else + connection.logger("WARNING: MCI #{mci_href} is not attached") + end + end + + def set_default_multi_cloud_image(mci_href) + @mci_links = McServerTemplateMultiCloudImage.find_with_filter(:server_template_href => self.href) + if link = @mci_links.detect { |mci_link| mci_link.multi_cloud_image == mci_href } + ret = link.make_default + get_mcis_and_settings + ret + else + connection.logger("WARNING: MCI #{mci_href} is not attached") + end + end + + def commit(message, commit_head_dependencies, freeze_repositories) + options = {:commit_message => "#{message}", + :commit_head_dependencies => (commit_head_dependencies && true), + :freeze_repositories => (freeze_repositories && true)} + t = URI.parse(self.href) + location = connection.post(t.path + "/commit", options) + newrecord = McServerTemplate.new('links' => [ {'rel' => 'self', 'href' => location } ]) + newrecord.reload + newrecord + end end diff --git a/lib/rest_connection/rightscale/mc_server_template_multi_cloud_image.rb b/lib/rest_connection/rightscale/mc_server_template_multi_cloud_image.rb new file mode 100644 index 0000000..3927f4c --- /dev/null +++ b/lib/rest_connection/rightscale/mc_server_template_multi_cloud_image.rb @@ -0,0 +1,48 @@ +# This file is part of RestConnection +# +# RestConnection is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# RestConnection is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with RestConnection. If not, see . + +# +# You must have Beta v1.5 API access to use these internal API calls. +# + +class McServerTemplateMultiCloudImage + include RightScale::Api::Gateway + extend RightScale::Api::GatewayExtend + + def resource_plural_name + "server_template_multi_cloud_images" + end + + def resource_singular_name + "server_template_multi_cloud_image" + end + + def self.resource_plural_name + "server_template_multi_cloud_images" + end + + def self.resource_singular_name + "server_template_multi_cloud_image" + end + + def self.filters + [:is_default, :multi_cloud_image_href, :server_template_href] + end + + def make_default + my_href = URI.parse(self.href) + connection.post(my_href + "/make_default") + end +end diff --git a/lib/rest_connection/rightscale/mc_ssh_key.rb b/lib/rest_connection/rightscale/mc_ssh_key.rb index b7791df..a6b6f01 100644 --- a/lib/rest_connection/rightscale/mc_ssh_key.rb +++ b/lib/rest_connection/rightscale/mc_ssh_key.rb @@ -40,6 +40,10 @@ def self.parse_args(cloud_id) "clouds/#{cloud_id}/" end + def self.filters + [:resource_uid] + end + def self.create(opts) create_opts = { self.resource_singular_name.to_sym => opts } location = connection.post("clouds/#{opts['cloud_id']}/#{self.resource_plural_name}", create_opts) diff --git a/lib/rest_connection/rightscale/mc_volume.rb b/lib/rest_connection/rightscale/mc_volume.rb index 055e540..9e6dcca 100644 --- a/lib/rest_connection/rightscale/mc_volume.rb +++ b/lib/rest_connection/rightscale/mc_volume.rb @@ -42,6 +42,10 @@ def self.parse_args(cloud_id) "clouds/#{cloud_id}/" end + def self.filters + [:datacenter_href, :description, :name, :parent_volume_snapshot_href, :resource_uid] + end + def show inst_href = URI.parse(self.href) @params.merge! connection.get(inst_href.path, 'view' => 'extended') diff --git a/lib/rest_connection/rightscale/mc_volume_attachment.rb b/lib/rest_connection/rightscale/mc_volume_attachment.rb index 8be0284..75fe929 100644 --- a/lib/rest_connection/rightscale/mc_volume_attachment.rb +++ b/lib/rest_connection/rightscale/mc_volume_attachment.rb @@ -41,6 +41,10 @@ def self.parse_args(cloud_id, instance_id=nil) return "clouds/#{cloud_id}/volumes/#{instance_id}/" if instance_id end + def self.filters + [:instance_href, :resource_uid, :volume_href] + end + def show inst_href = URI.parse(self.href) @params.merge! connection.get(inst_href.path) diff --git a/lib/rest_connection/rightscale/mc_volume_snapshot.rb b/lib/rest_connection/rightscale/mc_volume_snapshot.rb index fd3298e..70ca300 100644 --- a/lib/rest_connection/rightscale/mc_volume_snapshot.rb +++ b/lib/rest_connection/rightscale/mc_volume_snapshot.rb @@ -43,6 +43,10 @@ def self.parse_args(cloud_id, volume_id=nil) return "clouds/#{cloud_id}/volumes/#{volume_id}/" if volume_id end + def self.filters + [:description, :name, :parent_volume_href, :resource_uid] + end + def show inst_href = URI.parse(self.href) @params.merge! connection.get(inst_href.path) diff --git a/lib/rest_connection/rightscale/mc_volume_type.rb b/lib/rest_connection/rightscale/mc_volume_type.rb index a077d3a..bffd285 100644 --- a/lib/rest_connection/rightscale/mc_volume_type.rb +++ b/lib/rest_connection/rightscale/mc_volume_type.rb @@ -40,6 +40,10 @@ def self.parse_args(cloud_id) "clouds/#{cloud_id}/" end + def self.filters + [:name, :resource_uid] + end + def show inst_href = URI.parse(self.href) @params.merge! connection.get(inst_href.path) diff --git a/lib/rest_connection/rightscale/monitoring_metric.rb b/lib/rest_connection/rightscale/monitoring_metric.rb index 8dfe498..d598468 100644 --- a/lib/rest_connection/rightscale/monitoring_metric.rb +++ b/lib/rest_connection/rightscale/monitoring_metric.rb @@ -24,6 +24,10 @@ def self.parse_args(cloud_id, instance_id) "clouds/#{cloud_id}/instances/#{instance_id}/" end + def self.filters + [:plugin, :view] + end + def data(start_time = "-60", end_time = "0") params = {'start' => start_time.to_s, 'end' => end_time.to_s} monitor = connection.get(URI.parse(self.href).path + "/data", params) diff --git a/lib/rest_connection/rightscale/permission.rb b/lib/rest_connection/rightscale/permission.rb index 7a8d66b..ea55779 100644 --- a/lib/rest_connection/rightscale/permission.rb +++ b/lib/rest_connection/rightscale/permission.rb @@ -24,4 +24,8 @@ class Permission include RightScale::Api::Gateway extend RightScale::Api::GatewayExtend + + def self.filters + [:user_href] + end end diff --git a/lib/rest_connection/rightscale/rightscale_api_base.rb b/lib/rest_connection/rightscale/rightscale_api_base.rb index 99dde51..b01d996 100644 --- a/lib/rest_connection/rightscale/rightscale_api_base.rb +++ b/lib/rest_connection/rightscale/rightscale_api_base.rb @@ -109,8 +109,11 @@ def find_by_nickname_speed(nickname) def find_with_filter(filter = {}) filter_params = [] filter.each { |key,val| + unless self.filters.include?(key.to_sym) + raise ArgumentError.new("#{key} is not a valid filter for resource #{self.resource_singular_name}") + end filter_params << "#{key}=#{val}" - } + } a = Array.new connection.get(self.resource_plural_name, :filter => filter_params).each do |object| a << self.new(object) @@ -118,6 +121,10 @@ def find_with_filter(filter = {}) return a end + def filters() + [] + end + def [](*args) ret = [] args.each { |arg| diff --git a/lib/rest_connection/rightscale/rightscale_api_gateway.rb b/lib/rest_connection/rightscale/rightscale_api_gateway.rb index 01fae17..a36a033 100644 --- a/lib/rest_connection/rightscale/rightscale_api_gateway.rb +++ b/lib/rest_connection/rightscale/rightscale_api_gateway.rb @@ -180,6 +180,16 @@ def find_by(attrib, *args, &block) end end + def find(*args) + if args.length > 1 + id = args.pop + url = "#{parse_args(*args)}#{self.resource_plural_name}/#{id}" + return self.new(connection.get(url)) + else + return super(*args) + end + end + def find_all(*args) # self.find_with_filter(*args, {}) a = Array.new @@ -195,6 +205,9 @@ def find_with_filter(*args) filter = {} filter = args.pop if args.last.is_a?(Hash) filter.each { |key,val| + unless self.filters.include?(key.to_sym) + raise ArgumentError.new("#{key} is not a valid filter for resource #{self.resource_singular_name}") + end filter_params << "#{key}==#{val}" } a = Array.new @@ -221,6 +234,10 @@ def parse_args() nil end + def filters() + [] + end + def create(opts) location = connection.post(self.resource_plural_name, self.resource_singular_name.to_sym => opts) newrecord = self.new('links' => [ {'rel' => 'self', 'href' => location } ]) diff --git a/lib/rest_connection/rightscale/rightscale_api_resources.rb b/lib/rest_connection/rightscale/rightscale_api_resources.rb index 67d02f1..90f99bc 100644 --- a/lib/rest_connection/rightscale/rightscale_api_resources.rb +++ b/lib/rest_connection/rightscale/rightscale_api_resources.rb @@ -28,6 +28,7 @@ require 'rest_connection/rightscale/right_script' require 'rest_connection/rightscale/instance' require 'rest_connection/rightscale/ec2_security_group' +require 'rest_connection/rightscale/vpc_dhcp_option' require 'rest_connection/rightscale/ec2_ssh_key' require 'rest_connection/rightscale/multi_cloud_image' require 'rest_connection/rightscale/tag' @@ -49,6 +50,7 @@ require 'rest_connection/rightscale/monitoring_metric' require 'rest_connection/rightscale/mc_multi_cloud_image_setting' require 'rest_connection/rightscale/mc_multi_cloud_image' +require 'rest_connection/rightscale/mc_server_template_multi_cloud_image' require 'rest_connection/rightscale/mc_server_template' require 'rest_connection/rightscale/ec2_ssh_key_internal' require 'rest_connection/rightscale/server_template_internal' diff --git a/lib/rest_connection/rightscale/server.rb b/lib/rest_connection/rightscale/server.rb index 663528b..efa8fdd 100644 --- a/lib/rest_connection/rightscale/server.rb +++ b/lib/rest_connection/rightscale/server.rb @@ -22,6 +22,18 @@ class Server include RightScale::Api::Taggable extend RightScale::Api::TaggableExtend + def self.filters + [ + :aws_id, + :created_at, + :deployment_href, + :ip_address, + :nickname, + :private_ip_address, + :updated_at + ] + end + def self.create(opts) create_options = Hash.new create_options[self.resource_singular_name.to_sym] = opts @@ -144,13 +156,25 @@ def force_stop # Uses ServerInternal api to start and stop EBS based instances def start_ebs - @server_internal = ServerInternal.new(:href => self.href) - @server_internal.start +# @server_internal = ServerInternal.new(:href => self.href) +# @server_internal.start + if self.state == "stopped" + t = URI.parse(self.href) + return connection.post(t.path + '/start_ebs') + else + connection.logger("WARNING: was in #{self.state} so skiping start_ebs call") + end end def stop_ebs - @server_internal = ServerInternal.new(:href => self.href) - @server_internal.stop +# @server_internal = ServerInternal.new(:href => self.href) +# @server_internal.stop + if self.current_instance_href + t = URI.parse(self.href) + connection.post(t.path + '/stop_ebs') + else + connection.logger("WARNING: was in #{self.state} and had a current_instance_href so skiping stop_ebs call") + end end # Works on v4 and v5 images. @@ -260,6 +284,10 @@ def reboot(wait_for_state = false) end end + def alert_specs + # TODO + end + def relaunch self.stop self.wait_for_state("stopped") diff --git a/lib/rest_connection/rightscale/user.rb b/lib/rest_connection/rightscale/user.rb index 0d9710b..90369f7 100644 --- a/lib/rest_connection/rightscale/user.rb +++ b/lib/rest_connection/rightscale/user.rb @@ -24,4 +24,8 @@ class User include RightScale::Api::Gateway extend RightScale::Api::GatewayExtend + + def self.filters + [:email, :first_name, :last_name] + end end diff --git a/lib/rest_connection/rightscale/vpc_dhcp_option.rb b/lib/rest_connection/rightscale/vpc_dhcp_option.rb new file mode 100644 index 0000000..6cf12c8 --- /dev/null +++ b/lib/rest_connection/rightscale/vpc_dhcp_option.rb @@ -0,0 +1,19 @@ +# This file is part of RestConnection +# +# RestConnection is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# RestConnection is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with RestConnection. If not, see . + +class VpcDhcpOption + include RightScale::Api::Base + extend RightScale::Api::BaseExtend +end From 336d0767e857ffcb81212891b9484aa5bb0857f6 Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Fri, 16 Dec 2011 18:30:49 -0800 Subject: [PATCH 124/239] Update for new API resource and new AWS region --- lib/rest_connection.rb | 7 +++- .../rightscale/cloud_account.rb | 37 +++++++++++++++++++ .../rightscale/rightscale_api_resources.rb | 1 + lib/rest_connection/rightscale/server.rb | 1 + 4 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 lib/rest_connection/rightscale/cloud_account.rb diff --git a/lib/rest_connection.rb b/lib/rest_connection.rb index 3a5e514..c777286 100644 --- a/lib/rest_connection.rb +++ b/lib/rest_connection.rb @@ -24,12 +24,15 @@ require 'highline/import' module RestConnection - AWS_CLOUDS = [{"cloud_id" => 1, "name" => "AWS US-East"}, + AWS_CLOUDS = [ + {"cloud_id" => 1, "name" => "AWS US-East"}, {"cloud_id" => 2, "name" => "AWS EU"}, {"cloud_id" => 3, "name" => "AWS US-West"}, {"cloud_id" => 4, "name" => "AWS AP-Singapore"}, {"cloud_id" => 5, "name" => "AWS AP-Tokyo"}, - {"cloud_id" => 6, "name" => "AWS US-Oregon"}] + {"cloud_id" => 6, "name" => "AWS US-Oregon"}, + {"cloud_id" => 7, "name" => "AWS SA-Sao Paulo"}, + ] # Check for API 0.1 Access def self.api0_1? diff --git a/lib/rest_connection/rightscale/cloud_account.rb b/lib/rest_connection/rightscale/cloud_account.rb new file mode 100644 index 0000000..67ca0eb --- /dev/null +++ b/lib/rest_connection/rightscale/cloud_account.rb @@ -0,0 +1,37 @@ +# This file is part of RestConnection +# +# RestConnection is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# RestConnection is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with RestConnection. If not, see . + +# +# You must have Beta v1.5 API access to use these internal API calls. +# +class CloudAccount + include RightScale::Api::Gateway + extend RightScale::Api::GatewayExtend + + def cloud_id + self.cloud.split("/").last + end + + def create(opts) + location = connection.post(self.resource_plural_name, self.resource_singular_name.to_sym => opts) + if location =~ /aws/ + return "AWS Cloud Added successfully" + else + newrecord = self.new('links' => [ {'rel' => 'self', 'href' => location } ]) + newrecord.reload + return newrecord + end + end +end diff --git a/lib/rest_connection/rightscale/rightscale_api_resources.rb b/lib/rest_connection/rightscale/rightscale_api_resources.rb index 90f99bc..781bae9 100644 --- a/lib/rest_connection/rightscale/rightscale_api_resources.rb +++ b/lib/rest_connection/rightscale/rightscale_api_resources.rb @@ -21,6 +21,7 @@ require 'rest_connection/rightscale/rightscale_api_mc_taggable' require 'rest_connection/rightscale/rightscale_api_mc_input' require 'rest_connection/rightscale/executable' +require 'rest_connection/rightscale/cloud_account' require 'rest_connection/rightscale/server' require 'rest_connection/rightscale/deployment' require 'rest_connection/rightscale/status' diff --git a/lib/rest_connection/rightscale/server.rb b/lib/rest_connection/rightscale/server.rb index efa8fdd..3841e23 100644 --- a/lib/rest_connection/rightscale/server.rb +++ b/lib/rest_connection/rightscale/server.rb @@ -85,6 +85,7 @@ def wait_for_state(st,timeout=1200) catch_early_terminated = 60 / step while(timeout > 0) return true if state =~ /#{st}/ + return true if state =~ /terminated|stopped/ && st =~ /terminated|stopped/ raise "FATAL error, this server is stranded and needs to be #{st}: #{nickname}, see audit: #{self.audit_link}" if state.include?('stranded') && !st.include?('stranded') raise "FATAL error, this server went to error state and needs to be #{st}: #{nickname}, see audit: #{self.audit_link}" if state.include?('error') && st !~ /error|terminated|stopped/ connection.logger("waiting for server #{nickname} to go #{st}, state is #{state}") From 33c01d5f4091612a0c13c75d9840096932819735 Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Fri, 16 Dec 2011 18:32:33 -0800 Subject: [PATCH 125/239] Version bump to 0.1.1 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 6c6aa7c..6da28dd 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.1.0 \ No newline at end of file +0.1.1 \ No newline at end of file From 0598601b1002e164d48a69f641c6b7b87c5193f5 Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Sat, 17 Dec 2011 14:33:44 -0800 Subject: [PATCH 126/239] [API 1.5] Added undef's for mixin methods that aren't supported --- lib/rest_connection/rightscale/account.rb | 2 ++ .../rightscale/child_account.rb | 2 ++ lib/rest_connection/rightscale/cloud.rb | 2 ++ .../rightscale/cloud_account.rb | 2 ++ .../rightscale/instance_type.rb | 2 ++ .../rightscale/mc_datacenter.rb | 2 ++ lib/rest_connection/rightscale/mc_image.rb | 2 ++ lib/rest_connection/rightscale/mc_instance.rb | 2 ++ .../rightscale/mc_instance_type.rb | 2 ++ .../rightscale/mc_multi_cloud_image.rb | 2 ++ .../mc_multi_cloud_image_setting.rb | 2 ++ .../rightscale/mc_security_group.rb | 2 ++ .../mc_server_template_multi_cloud_image.rb | 2 ++ lib/rest_connection/rightscale/mc_ssh_key.rb | 2 ++ lib/rest_connection/rightscale/mc_tag.rb | 2 ++ lib/rest_connection/rightscale/mc_volume.rb | 2 ++ .../rightscale/mc_volume_attachment.rb | 2 ++ .../rightscale/mc_volume_snapshot.rb | 2 ++ .../rightscale/mc_volume_type.rb | 2 ++ .../rightscale/monitoring_metric.rb | 2 ++ lib/rest_connection/rightscale/permission.rb | 2 ++ .../rightscale/rightscale_api_base.rb | 4 ++-- .../rightscale/rightscale_api_gateway.rb | 19 +++++++++++++++++++ lib/rest_connection/rightscale/task.rb | 2 ++ lib/rest_connection/rightscale/user.rb | 2 ++ 25 files changed, 67 insertions(+), 2 deletions(-) diff --git a/lib/rest_connection/rightscale/account.rb b/lib/rest_connection/rightscale/account.rb index 9cc1878..39dfc7e 100644 --- a/lib/rest_connection/rightscale/account.rb +++ b/lib/rest_connection/rightscale/account.rb @@ -24,4 +24,6 @@ class Account include RightScale::Api::Gateway extend RightScale::Api::GatewayExtend + + deny_methods :index, :create, :destroy, :update end diff --git a/lib/rest_connection/rightscale/child_account.rb b/lib/rest_connection/rightscale/child_account.rb index 3976cae..dc5b982 100644 --- a/lib/rest_connection/rightscale/child_account.rb +++ b/lib/rest_connection/rightscale/child_account.rb @@ -25,6 +25,8 @@ class ChildAccount include RightScale::Api::Gateway extend RightScale::Api::GatewayExtend + deny_methods :destroy, :update, :show + def self.filters [:name] end diff --git a/lib/rest_connection/rightscale/cloud.rb b/lib/rest_connection/rightscale/cloud.rb index 67de748..98291b0 100644 --- a/lib/rest_connection/rightscale/cloud.rb +++ b/lib/rest_connection/rightscale/cloud.rb @@ -20,6 +20,8 @@ class Cloud include RightScale::Api::Gateway extend RightScale::Api::GatewayExtend + deny_methods :create, :destroy, :update + def self.filters [:description, :name] end diff --git a/lib/rest_connection/rightscale/cloud_account.rb b/lib/rest_connection/rightscale/cloud_account.rb index 67ca0eb..4b24896 100644 --- a/lib/rest_connection/rightscale/cloud_account.rb +++ b/lib/rest_connection/rightscale/cloud_account.rb @@ -20,6 +20,8 @@ class CloudAccount include RightScale::Api::Gateway extend RightScale::Api::GatewayExtend + deny_methods :update + def cloud_id self.cloud.split("/").last end diff --git a/lib/rest_connection/rightscale/instance_type.rb b/lib/rest_connection/rightscale/instance_type.rb index 9a99e05..c31e213 100644 --- a/lib/rest_connection/rightscale/instance_type.rb +++ b/lib/rest_connection/rightscale/instance_type.rb @@ -20,6 +20,8 @@ class InstanceType include RightScale::Api::Gateway extend RightScale::Api::GatewayExtend + deny_methods :create, :destroy, :update + def self.parse_args(cloud_id) "clouds/#{cloud_id}/" end diff --git a/lib/rest_connection/rightscale/mc_datacenter.rb b/lib/rest_connection/rightscale/mc_datacenter.rb index d88392f..14ea7b3 100644 --- a/lib/rest_connection/rightscale/mc_datacenter.rb +++ b/lib/rest_connection/rightscale/mc_datacenter.rb @@ -20,6 +20,8 @@ class McDatacenter include RightScale::Api::Gateway extend RightScale::Api::GatewayExtend + deny_methods :create, :destroy, :update + def resource_plural_name "datacenters" end diff --git a/lib/rest_connection/rightscale/mc_image.rb b/lib/rest_connection/rightscale/mc_image.rb index 017a727..ef98bd2 100644 --- a/lib/rest_connection/rightscale/mc_image.rb +++ b/lib/rest_connection/rightscale/mc_image.rb @@ -20,6 +20,8 @@ class McImage include RightScale::Api::Gateway extend RightScale::Api::GatewayExtend + deny_methods :create, :destroy, :update + def resource_plural_name "images" end diff --git a/lib/rest_connection/rightscale/mc_instance.rb b/lib/rest_connection/rightscale/mc_instance.rb index 68851b8..51693b7 100644 --- a/lib/rest_connection/rightscale/mc_instance.rb +++ b/lib/rest_connection/rightscale/mc_instance.rb @@ -24,6 +24,8 @@ class McInstance include RightScale::Api::McInput attr_accessor :monitoring_metrics + deny_methods :create, :destroy + def resource_plural_name "instances" end diff --git a/lib/rest_connection/rightscale/mc_instance_type.rb b/lib/rest_connection/rightscale/mc_instance_type.rb index d3e595c..b55f166 100644 --- a/lib/rest_connection/rightscale/mc_instance_type.rb +++ b/lib/rest_connection/rightscale/mc_instance_type.rb @@ -20,6 +20,8 @@ class McInstanceType include RightScale::Api::Gateway extend RightScale::Api::GatewayExtend + deny_methods :create, :destroy, :update + def resource_plural_name "instance_types" end diff --git a/lib/rest_connection/rightscale/mc_multi_cloud_image.rb b/lib/rest_connection/rightscale/mc_multi_cloud_image.rb index 1083f19..83685ce 100644 --- a/lib/rest_connection/rightscale/mc_multi_cloud_image.rb +++ b/lib/rest_connection/rightscale/mc_multi_cloud_image.rb @@ -23,6 +23,8 @@ class McMultiCloudImage extend RightScale::Api::McTaggableExtend attr_reader :settings + deny_methods :create, :destroy, :update + def resource_plural_name "multi_cloud_images" end diff --git a/lib/rest_connection/rightscale/mc_multi_cloud_image_setting.rb b/lib/rest_connection/rightscale/mc_multi_cloud_image_setting.rb index 0cbd705..f93b5ec 100644 --- a/lib/rest_connection/rightscale/mc_multi_cloud_image_setting.rb +++ b/lib/rest_connection/rightscale/mc_multi_cloud_image_setting.rb @@ -20,6 +20,8 @@ class McMultiCloudImageSetting include RightScale::Api::Gateway extend RightScale::Api::GatewayExtend + deny_methods :create, :destroy, :update + def resource_plural_name "settings" end diff --git a/lib/rest_connection/rightscale/mc_security_group.rb b/lib/rest_connection/rightscale/mc_security_group.rb index 74b56fd..c840795 100644 --- a/lib/rest_connection/rightscale/mc_security_group.rb +++ b/lib/rest_connection/rightscale/mc_security_group.rb @@ -20,6 +20,8 @@ class McSecurityGroup include RightScale::Api::Gateway extend RightScale::Api::GatewayExtend + deny_methods :create, :destroy, :update + def resource_plural_name "security_groups" end diff --git a/lib/rest_connection/rightscale/mc_server_template_multi_cloud_image.rb b/lib/rest_connection/rightscale/mc_server_template_multi_cloud_image.rb index 3927f4c..8c2343e 100644 --- a/lib/rest_connection/rightscale/mc_server_template_multi_cloud_image.rb +++ b/lib/rest_connection/rightscale/mc_server_template_multi_cloud_image.rb @@ -21,6 +21,8 @@ class McServerTemplateMultiCloudImage include RightScale::Api::Gateway extend RightScale::Api::GatewayExtend + deny_methods :update + def resource_plural_name "server_template_multi_cloud_images" end diff --git a/lib/rest_connection/rightscale/mc_ssh_key.rb b/lib/rest_connection/rightscale/mc_ssh_key.rb index a6b6f01..c0664b9 100644 --- a/lib/rest_connection/rightscale/mc_ssh_key.rb +++ b/lib/rest_connection/rightscale/mc_ssh_key.rb @@ -20,6 +20,8 @@ class McSshKey include RightScale::Api::Gateway extend RightScale::Api::GatewayExtend + deny_methods :update + def resource_plural_name "ssh_keys" end diff --git a/lib/rest_connection/rightscale/mc_tag.rb b/lib/rest_connection/rightscale/mc_tag.rb index 3880f27..45a6d4d 100644 --- a/lib/rest_connection/rightscale/mc_tag.rb +++ b/lib/rest_connection/rightscale/mc_tag.rb @@ -20,6 +20,8 @@ class McTag include RightScale::Api::Gateway extend RightScale::Api::GatewayExtend + deny_methods :index, :show, :create, :destroy, :update + def resource_plural_name "tags" end diff --git a/lib/rest_connection/rightscale/mc_volume.rb b/lib/rest_connection/rightscale/mc_volume.rb index 9e6dcca..debe058 100644 --- a/lib/rest_connection/rightscale/mc_volume.rb +++ b/lib/rest_connection/rightscale/mc_volume.rb @@ -22,6 +22,8 @@ class McVolume include RightScale::Api::McTaggable extend RightScale::Api::McTaggableExtend + deny_methods :update + def resource_plural_name "volumes" end diff --git a/lib/rest_connection/rightscale/mc_volume_attachment.rb b/lib/rest_connection/rightscale/mc_volume_attachment.rb index 75fe929..946f3b0 100644 --- a/lib/rest_connection/rightscale/mc_volume_attachment.rb +++ b/lib/rest_connection/rightscale/mc_volume_attachment.rb @@ -20,6 +20,8 @@ class McVolumeAttachment include RightScale::Api::Gateway extend RightScale::Api::GatewayExtend + deny_methods :update + def resource_plural_name "volume_attachments" end diff --git a/lib/rest_connection/rightscale/mc_volume_snapshot.rb b/lib/rest_connection/rightscale/mc_volume_snapshot.rb index 70ca300..d32fd6c 100644 --- a/lib/rest_connection/rightscale/mc_volume_snapshot.rb +++ b/lib/rest_connection/rightscale/mc_volume_snapshot.rb @@ -22,6 +22,8 @@ class McVolumeSnapshot include RightScale::Api::McTaggable extend RightScale::Api::McTaggableExtend + deny_methods :update + def resource_plural_name "volume_snapshots" end diff --git a/lib/rest_connection/rightscale/mc_volume_type.rb b/lib/rest_connection/rightscale/mc_volume_type.rb index bffd285..21c725a 100644 --- a/lib/rest_connection/rightscale/mc_volume_type.rb +++ b/lib/rest_connection/rightscale/mc_volume_type.rb @@ -20,6 +20,8 @@ class McVolumeType include RightScale::Api::Gateway extend RightScale::Api::GatewayExtend + deny_methods :create, :destroy, :update + def resource_plural_name "volume_types" end diff --git a/lib/rest_connection/rightscale/monitoring_metric.rb b/lib/rest_connection/rightscale/monitoring_metric.rb index d598468..8147237 100644 --- a/lib/rest_connection/rightscale/monitoring_metric.rb +++ b/lib/rest_connection/rightscale/monitoring_metric.rb @@ -20,6 +20,8 @@ class MonitoringMetric include RightScale::Api::Gateway extend RightScale::Api::GatewayExtend + deny_methods :create, :destroy, :update + def self.parse_args(cloud_id, instance_id) "clouds/#{cloud_id}/instances/#{instance_id}/" end diff --git a/lib/rest_connection/rightscale/permission.rb b/lib/rest_connection/rightscale/permission.rb index ea55779..feb4b9e 100644 --- a/lib/rest_connection/rightscale/permission.rb +++ b/lib/rest_connection/rightscale/permission.rb @@ -25,6 +25,8 @@ class Permission include RightScale::Api::Gateway extend RightScale::Api::GatewayExtend + deny_methods :update + def self.filters [:user_href] end diff --git a/lib/rest_connection/rightscale/rightscale_api_base.rb b/lib/rest_connection/rightscale/rightscale_api_base.rb index b01d996..4fef35e 100644 --- a/lib/rest_connection/rightscale/rightscale_api_base.rb +++ b/lib/rest_connection/rightscale/rightscale_api_base.rb @@ -59,7 +59,7 @@ def find_by_cloud_id(cloud_id) end def find_by_nickname(nickname) - connection.logger("DEPRICATION WARNING: use of find_by_nickname is depricated, please use find_by(:nickname) { |n| n == '#{nickname}' } ") + connection.logger("DEPRECATION WARNING: use of find_by_nickname is deprecated, please use find_by(:nickname) { |n| n == '#{nickname}' } ") self.find_by(:nickname) { |n| n == nickname } end @@ -89,7 +89,7 @@ def find(href, additional_params={}, &block) end def find_by_id(id) - connection.logger("DEPRICATION WARNING: use of find_by_id is depricated, please use find(id) ") + connection.logger("DEPRECATION WARNING: use of find_by_id is deprecated, please use find(id) ") self.find(id) end diff --git a/lib/rest_connection/rightscale/rightscale_api_gateway.rb b/lib/rest_connection/rightscale/rightscale_api_gateway.rb index a36a033..7bf4dc7 100644 --- a/lib/rest_connection/rightscale/rightscale_api_gateway.rb +++ b/lib/rest_connection/rightscale/rightscale_api_gateway.rb @@ -244,6 +244,25 @@ def create(opts) newrecord.reload newrecord end + + def deny_methods(*symbols) + symbols.map! { |sym| sym.to_sym } + if symbols.delete(:index) + symbols |= [:find_all, :find_by, :find_by_cloud_id, :find_by_nickname, :find_by_nickname_speed, :find_with_filter] + end + if symbols.delete(:show) + symbols |= [:show, :reload, :find, :find_by_id] + end + symbols.each do |sym| + sym = sym.to_sym + eval_str = "undef #{sym.inspect}" + if self.respond_to?(sym) + instance_eval(eval_str) + elsif self.new.respond_to?(sym) + class_eval(eval_str) + end + end + end end end end diff --git a/lib/rest_connection/rightscale/task.rb b/lib/rest_connection/rightscale/task.rb index c5e4e76..ce83c1d 100644 --- a/lib/rest_connection/rightscale/task.rb +++ b/lib/rest_connection/rightscale/task.rb @@ -20,6 +20,8 @@ class Task include RightScale::Api::Gateway extend RightScale::Api::GatewayExtend + deny_methods :index, :create, :destroy, :update + def self.parse_args(cloud_id, instance_id) "clouds/#{cloud_id}/instances/#{instance_id}/live/" end diff --git a/lib/rest_connection/rightscale/user.rb b/lib/rest_connection/rightscale/user.rb index 90369f7..c19cc47 100644 --- a/lib/rest_connection/rightscale/user.rb +++ b/lib/rest_connection/rightscale/user.rb @@ -25,6 +25,8 @@ class User include RightScale::Api::Gateway extend RightScale::Api::GatewayExtend + deny_methods :destroy, :update + def self.filters [:email, :first_name, :last_name] end From c438e7abba099da309897fcbeba61f43586411cd Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Thu, 22 Dec 2011 11:32:10 -0800 Subject: [PATCH 127/239] Fix for timeout propogation in 1.5 Tasks --- lib/rest_connection/rightscale/task.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/rest_connection/rightscale/task.rb b/lib/rest_connection/rightscale/task.rb index ce83c1d..26fc3fa 100644 --- a/lib/rest_connection/rightscale/task.rb +++ b/lib/rest_connection/rightscale/task.rb @@ -43,7 +43,7 @@ def wait_for_state(state, timeout=900) raise "FATAL: Timeout waiting for Executable to complete. State was #{self.summary}" if timeout <= 0 end - def wait_for_completed(legacy=nil) - wait_for_state("completed") + def wait_for_completed(timeout=900) + wait_for_state("completed", timeout) end end From 4cbf375a62917d786f0ef4401b8d5eac94090f12 Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Wed, 25 Jan 2012 21:49:56 -0800 Subject: [PATCH 128/239] [API 1.0] [API 1.5] [Core] Big Release [API 1.0] - New Resources: AlertSpecSubject, ServerEc2EbsVolume, SqsQueue - Added undef's for mixin methods that aren't supported - Uses correct login URL & cookies [API 1.5] - New Resources: Session, SecurityGroupRule - Updated McSecurityGroup resource to support new APIs - load() function to leverage the "links" field [Core] - Auto-refresh of cookies - Auto-retry on Timeout::Error and EBADF - Dedicated HTTPStatusError classes (one per status code) --- README.rdoc | 2 +- Rakefile | 5 +- git_hooks/post-commit | 43 +++++ git_hooks/pre-commit | 112 ++++++++++-- lib/rest_connection.rb | 172 +++++++++++++++--- lib/rest_connection/rightscale/alert_spec.rb | 6 +- .../rightscale/alert_spec_subject.rb | 21 +++ lib/rest_connection/rightscale/audit_entry.rb | 2 + .../rightscale/ec2_ebs_volume.rb | 6 +- .../rightscale/ec2_elastic_ip.rb | 2 + .../rightscale/ec2_security_group.rb | 24 +++ lib/rest_connection/rightscale/ec2_ssh_key.rb | 2 + lib/rest_connection/rightscale/executable.rb | 2 + .../rightscale/instance_type.rb | 4 + .../rightscale/mc_security_group.rb | 62 ++++++- .../rightscale/multi_cloud_image.rb | 2 + .../rightscale/right_script.rb | 3 + .../rightscale/rightscale_api_base.rb | 51 +++++- .../rightscale/rightscale_api_gateway.rb | 112 ++++++------ .../rightscale/rightscale_api_resources.rb | 5 + lib/rest_connection/rightscale/s3_bucket.rb | 3 +- .../rightscale/security_group_rule.rb | 31 ++++ .../rightscale/server_ec2_ebs_volume.rb | 40 ++++ lib/rest_connection/rightscale/session.rb | 61 +++++++ lib/rest_connection/rightscale/sqs_queue.rb | 22 +++ lib/rest_connection/rightscale/tag.rb | 2 + 26 files changed, 695 insertions(+), 102 deletions(-) create mode 100755 git_hooks/post-commit create mode 100644 lib/rest_connection/rightscale/alert_spec_subject.rb create mode 100644 lib/rest_connection/rightscale/security_group_rule.rb create mode 100644 lib/rest_connection/rightscale/server_ec2_ebs_volume.rb create mode 100644 lib/rest_connection/rightscale/session.rb create mode 100644 lib/rest_connection/rightscale/sqs_queue.rb diff --git a/README.rdoc b/README.rdoc index acd2e85..ff32098 100644 --- a/README.rdoc +++ b/README.rdoc @@ -19,7 +19,7 @@ Copy the example from GEMHOME/rest_connection/examples/rest_api_config.yaml.samp "gem install gemedit" "gem edit rest_connection" -== Usage: some IRB samples +== Usage: some IRB samples for the RightScale API module $ irb ruby> require 'rubygems'; require 'rest_connection' diff --git a/Rakefile b/Rakefile index 17fe29b..434cc24 100644 --- a/Rakefile +++ b/Rakefile @@ -2,8 +2,8 @@ require 'rubygems' require 'jeweler' Jeweler::Tasks.new do |gemspec| gemspec.name = "rest_connection" - gemspec.summary = "lib for restful connections to the rightscale api" - gemspec.description = "provides rest_connection" + gemspec.summary = "Modular RESTful API library" + gemspec.description = "Current implemented modules: RightScale API" gemspec.email = ["jeremy@rubyonlinux.org", "tw.rodriguez@gmail.com"] gemspec.homepage = "http://github.com/twrodriguez/rest_connection" gemspec.authors = ["Jeremy Deininger", "Timothy Rodriguez"] @@ -13,4 +13,3 @@ Jeweler::Tasks.new do |gemspec| gemspec.add_dependency('highline') end Jeweler::GemcutterTasks.new - diff --git a/git_hooks/post-commit b/git_hooks/post-commit new file mode 100755 index 0000000..e742ab1 --- /dev/null +++ b/git_hooks/post-commit @@ -0,0 +1,43 @@ +#!/usr/bin/env ruby +puts < /dev/null`; fail=$? + ruby -c "$FILE" 1> /dev/null; fail=$? + if [[ "$fail" -ne 0 ]]; then echo "Syntax Error found in '$FILE'"; fi else - `ruby -c $FILE 1> /dev/null` + ruby -c "$FILE" 1> /dev/null + if [[ "$?" -ne 0 ]]; then echo "Syntax Error found in '$FILE'"; fi + fi + fi + + # If a file is json, check for syntax errors + if [[ "$FILE" =~ .*\.json$ ]]; then + if [[ "$fail" -eq 0 || -z "$fail" ]]; then + ruby -e "require 'rubygems'; require 'json'; JSON::parse(IO.read('$FILE'))" 1> /dev/null; fail=$? + if [[ "$fail" -ne 0 ]]; then echo "Syntax Error found in '$FILE'"; fi + else + ruby -e "require 'rubygems'; require 'json'; JSON::parse(IO.read('$FILE'))" 1> /dev/null + if [[ "$?" -ne 0 ]]; then echo "Syntax Error found in '$FILE'"; fi + fi + fi + + # If a file is yaml, check for syntax errors + if [[ "$FILE" =~ .*\.yaml$ ]]; then + if [[ "$fail" -eq 0 || -z "$fail" ]]; then + ruby -e "require 'rubygems'; require 'yaml'; YAML::load(IO.read('$FILE'))" 1> /dev/null; fail=$? + if [[ "$fail" -ne 0 ]]; then echo "Syntax Error found in '$FILE'"; fi + else + ruby -e "require 'rubygems'; require 'yaml'; YAML::load(IO.read('$FILE'))" 1> /dev/null + if [[ "$?" -ne 0 ]]; then echo "Syntax Error found in '$FILE'"; fi fi fi fi done +echo "Syntax check complete." # Built-in git checks git diff-index --check HEAD -- if [[ "$fail" -ne 0 && -n "$fail" ]]; then echo "Syntax Errors Found. Aborting commit" + lod_message + exit 1 +fi + +# Check for warnings +fail=0 +for FILE in `git diff-index --name-only HEAD --` ; do + if test -e $FILE; then + # If a file is ruby, check for syntax errors + if [[ -n `find $FILE -regex ".*\.rb$"` ]]; then + warnings=`ruby -c "$FILE" 2>&1 | grep -i warn` + if [[ -n "$warnings" ]]; then fail=1; fi + fi + fi +done + +if [[ "$fail" -ne 0 && -n "$fail" ]]; then + echo "Syntax Warnings Found. Aborting commit" + lod_message exit 1 fi for FILE in $whitespace; do echo "Whitespace problem fixed. Please re-add '$FILE' to your commit" done -if [[ -n "$whitespace" ]]; then exit 1; fi +if [[ -n "$whitespace" ]]; then lod_message; exit 1; fi # Check that project metadata files exist -for FILE in "Rakefile" "README.rdoc" "VERSION" ".gitignore" "rest_connection.gemspec"; do +for FILE in "README.rdoc" "VERSION" ".gitignore" "Rakefile"; do if test ! -e $FILE; then echo "$FILE not present. Aborting commit" exit 1 @@ -44,10 +124,14 @@ done username=`git config --get user.name` useremail=`git config --get user.email` emaildomain=`echo $useremail | grep -o "[^@]*$"` -if [[ "$username" == "" ]]; then +if [[ "$username" == "Put Your Name Here" || "$username" == "" ]]; then echo "Please set your git user.name by running 'git config user.name '" + lod_message exit 1 -elif [[ "$useremail" == "" ]] || ! host "$emaildomain" &> /dev/null; then +elif [[ "$useremail" == "setyouremail@rightscale.com" || "$useremail" == "" ]] || ! host "$emaildomain" &> /dev/null; then echo "Please set your git user.email by running 'git config user.email '" + lod_message exit 1 fi + +exit 0 diff --git a/lib/rest_connection.rb b/lib/rest_connection.rb index c777286..becebeb 100644 --- a/lib/rest_connection.rb +++ b/lib/rest_connection.rb @@ -132,17 +132,48 @@ def rest_connect(&block) http.verify_mode = OpenSSL::SSL::VERIFY_NONE end headers = @settings[:common_headers] - headers.merge!("Cookie" => @cookie) if @cookie http.start do |http| - req = yield(uri, headers) - unless @cookie - req.basic_auth(@settings[:user], @settings[:pass]) if @settings[:user] + @max_retries = 3 + ret = nil + begin + headers.delete("Cookie") + headers.merge!("Cookie" => @cookie) if @cookie + req = yield(uri, headers) + logger("#{req.method}: #{req.path}") + logger("\trequest body: #{req.body}") if req.body and req.body !~ /password/ + req.basic_auth(@settings[:user], @settings[:pass]) if @settings[:user] unless @cookie + + response, body = http.request(req) + ret = handle_response(response) + rescue Exception => e + raise unless error_handler(e) + retry + end + ret + end + end + + def error_handler(e) + case e + when EOFError, Timeout::Error + if @max_retries >= 0 + logger("Caught #{e}. Retrying...") + @max_retries -= 1 + return true + end + when RestConnection::Errors::Forbidden + if @max_retries >= 0 + if e.response.body =~ /(session|cookie).*(invalid|expired)/i + logger("Caught '#{e.response.body}'. Refreshing cookie...") + refresh_cookie if respond_to?(:refresh_cookie) + else + return false + end + @max_retries -= 1 + return true end - logger("#{req.method}: #{req.path}") - logger("\trequest body: #{req.body}") if req.body and req.body !~ /password/ - response, body = http.request(req) - handle_response(response) end + return false end # connection.get("/root/login", :test_header => "x", :test_header2 => "y") @@ -151,9 +182,9 @@ def rest_connect(&block) # additional_parameters = Hash or String of parameters to pass to HTTP::Get def get(href, additional_parameters = "") rest_connect do |base_uri,headers| - href = "#{base_uri}/#{href}" unless begins_with_slash(href) + new_href = (href =~ /^\// ? href : "#{base_uri}/#{href}") params = requestify(additional_parameters) || "" - new_path = URI.escape(href + @settings[:extension] + "?") + params + new_path = URI.escape(new_href + @settings[:extension] + "?") + params Net::HTTP::Get.new(new_path, headers) end end @@ -165,8 +196,8 @@ def get(href, additional_parameters = "") # additional_parameters = Hash or String of parameters to pass to HTTP::Post def post(href, additional_parameters = {}) rest_connect do |base_uri, headers| - href = "#{base_uri}/#{href}" unless begins_with_slash(href) - res = Net::HTTP::Post.new(href , headers) + new_href = (href =~ /^\// ? href : "#{base_uri}/#{href}") + res = Net::HTTP::Post.new(new_href , headers) unless additional_parameters.empty? res.set_content_type('application/json') res.body = additional_parameters.to_json @@ -183,8 +214,8 @@ def post(href, additional_parameters = {}) # additional_parameters = Hash or String of parameters to pass to HTTP::Put def put(href, additional_parameters = {}) rest_connect do |base_uri, headers| - href = "#{base_uri}/#{href}" unless begins_with_slash(href) - new_path = URI.escape(href) + new_href = (href =~ /^\// ? href : "#{base_uri}/#{href}") + new_path = URI.escape(new_href) req = Net::HTTP::Put.new(new_path, headers) req.set_content_type('application/json') req.body = additional_parameters.to_json @@ -199,8 +230,8 @@ def put(href, additional_parameters = {}) # additional_parameters = Hash or String of parameters to pass to HTTP::Delete def delete(href, additional_parameters = {}) rest_connect do |base_uri, headers| - href = "#{base_uri}/#{href}" unless begins_with_slash(href) - new_path = URI.escape(href) + new_href = (href =~ /^\// ? href : "#{base_uri}/#{href}") + new_path = URI.escape(new_href) req = Net::HTTP::Delete.new(href, headers) req.set_content_type('application/json') req.body = additional_parameters.to_json @@ -226,14 +257,10 @@ def handle_response(res) return res end else - raise "invalid response HTTP code: #{res.code.to_i}, #{res.code}, #{res.body}" + raise RestConnection::Errors.status_error(res) end end - def begins_with_slash(href) - href =~ /^\// - end - def logger(message) init_message = "Initializing Logging using " if @@logger.nil? @@ -250,7 +277,7 @@ def logger(message) if @settings.nil? @@logger.info(message) else - @@logger.info("[API v#{@settings[:common_headers]['X_API_VERSION']} ]" + message) + @@logger.info("[API v#{@settings[:common_headers]['X_API_VERSION']}] " + message) end end @@ -272,6 +299,107 @@ def requestify(parameters, prefix=nil) "#{prefix}=#{CGI.escape(parameters.to_s)}" end end + end + + module Errors + # HTTPStatusErrors, borrowed lovingly from the excon gem <3 + class HTTPStatusError < StandardError + attr_reader :request, :response + + def initialize(msg, response = nil, request = nil) + super(msg) + @request = request + @response = response + end + end + class Continue < HTTPStatusError; end # 100 + class SwitchingProtocols < HTTPStatusError; end # 101 + class OK < HTTPStatusError; end # 200 + class Created < HTTPStatusError; end # 201 + class Accepted < HTTPStatusError; end # 202 + class NonAuthoritativeInformation < HTTPStatusError; end # 203 + class NoContent < HTTPStatusError; end # 204 + class ResetContent < HTTPStatusError; end # 205 + class PartialContent < HTTPStatusError; end # 206 + class MultipleChoices < HTTPStatusError; end # 300 + class MovedPermanently < HTTPStatusError; end # 301 + class Found < HTTPStatusError; end # 302 + class SeeOther < HTTPStatusError; end # 303 + class NotModified < HTTPStatusError; end # 304 + class UseProxy < HTTPStatusError; end # 305 + class TemporaryRedirect < HTTPStatusError; end # 307 + class BadRequest < HTTPStatusError; end # 400 + class Unauthorized < HTTPStatusError; end # 401 + class PaymentRequired < HTTPStatusError; end # 402 + class Forbidden < HTTPStatusError; end # 403 + class NotFound < HTTPStatusError; end # 404 + class MethodNotAllowed < HTTPStatusError; end # 405 + class NotAcceptable < HTTPStatusError; end # 406 + class ProxyAuthenticationRequired < HTTPStatusError; end # 407 + class RequestTimeout < HTTPStatusError; end # 408 + class Conflict < HTTPStatusError; end # 409 + class Gone < HTTPStatusError; end # 410 + class LengthRequired < HTTPStatusError; end # 411 + class PreconditionFailed < HTTPStatusError; end # 412 + class RequestEntityTooLarge < HTTPStatusError; end # 413 + class RequestURITooLong < HTTPStatusError; end # 414 + class UnsupportedMediaType < HTTPStatusError; end # 415 + class RequestedRangeNotSatisfiable < HTTPStatusError; end # 416 + class ExpectationFailed < HTTPStatusError; end # 417 + class UnprocessableEntity < HTTPStatusError; end # 422 + class InternalServerError < HTTPStatusError; end # 500 + class NotImplemented < HTTPStatusError; end # 501 + class BadGateway < HTTPStatusError; end # 502 + class ServiceUnavailable < HTTPStatusError; end # 503 + class GatewayTimeout < HTTPStatusError; end # 504 + + # Messages for nicer exceptions, from rfc2616 + def self.status_error(response) + @errors ||= { + 100 => [RestConnection::Errors::Continue, 'Continue'], + 101 => [RestConnection::Errors::SwitchingProtocols, 'Switching Protocols'], + 200 => [RestConnection::Errors::OK, 'OK'], + 201 => [RestConnection::Errors::Created, 'Created'], + 202 => [RestConnection::Errors::Accepted, 'Accepted'], + 203 => [RestConnection::Errors::NonAuthoritativeInformation, 'Non-Authoritative Information'], + 204 => [RestConnection::Errors::NoContent, 'No Content'], + 205 => [RestConnection::Errors::ResetContent, 'Reset Content'], + 206 => [RestConnection::Errors::PartialContent, 'Partial Content'], + 300 => [RestConnection::Errors::MultipleChoices, 'Multiple Choices'], + 301 => [RestConnection::Errors::MovedPermanently, 'Moved Permanently'], + 302 => [RestConnection::Errors::Found, 'Found'], + 303 => [RestConnection::Errors::SeeOther, 'See Other'], + 304 => [RestConnection::Errors::NotModified, 'Not Modified'], + 305 => [RestConnection::Errors::UseProxy, 'Use Proxy'], + 307 => [RestConnection::Errors::TemporaryRedirect, 'Temporary Redirect'], + 400 => [RestConnection::Errors::BadRequest, 'Bad Request'], + 401 => [RestConnection::Errors::Unauthorized, 'Unauthorized'], + 402 => [RestConnection::Errors::PaymentRequired, 'Payment Required'], + 403 => [RestConnection::Errors::Forbidden, 'Forbidden'], + 404 => [RestConnection::Errors::NotFound, 'Not Found'], + 405 => [RestConnection::Errors::MethodNotAllowed, 'Method Not Allowed'], + 406 => [RestConnection::Errors::NotAcceptable, 'Not Acceptable'], + 407 => [RestConnection::Errors::ProxyAuthenticationRequired, 'Proxy Authentication Required'], + 408 => [RestConnection::Errors::RequestTimeout, 'Request Timeout'], + 409 => [RestConnection::Errors::Conflict, 'Conflict'], + 410 => [RestConnection::Errors::Gone, 'Gone'], + 411 => [RestConnection::Errors::LengthRequired, 'Length Required'], + 412 => [RestConnection::Errors::PreconditionFailed, 'Precondition Failed'], + 413 => [RestConnection::Errors::RequestEntityTooLarge, 'Request Entity Too Large'], + 414 => [RestConnection::Errors::RequestURITooLong, 'Request-URI Too Long'], + 415 => [RestConnection::Errors::UnsupportedMediaType, 'Unsupported Media Type'], + 416 => [RestConnection::Errors::RequestedRangeNotSatisfiable, 'Request Range Not Satisfiable'], + 417 => [RestConnection::Errors::ExpectationFailed, 'Expectation Failed'], + 422 => [RestConnection::Errors::UnprocessableEntity, 'Unprocessable Entity'], + 500 => [RestConnection::Errors::InternalServerError, 'InternalServerError'], + 501 => [RestConnection::Errors::NotImplemented, 'Not Implemented'], + 502 => [RestConnection::Errors::BadGateway, 'Bad Gateway'], + 503 => [RestConnection::Errors::ServiceUnavailable, 'Service Unavailable'], + 504 => [RestConnection::Errors::GatewayTimeout, 'Gateway Timeout'] + } + error, message = @errors[response.code.to_i] || [RestConnection::Errors::HTTPStatusError, 'Unknown'] + error.new("Invalid response HTTP code: #{response.code.to_i}: #{response.body}", response) + end end end diff --git a/lib/rest_connection/rightscale/alert_spec.rb b/lib/rest_connection/rightscale/alert_spec.rb index e6ff403..1e185e2 100644 --- a/lib/rest_connection/rightscale/alert_spec.rb +++ b/lib/rest_connection/rightscale/alert_spec.rb @@ -17,11 +17,7 @@ class AlertSpec include RightScale::Api::Base extend RightScale::Api::BaseExtend - - def attach(params) - connection.post('alert_spec_subjects.js' , :alert_spec_subject => params) + AlertSpecSubject.create(params) end - - end diff --git a/lib/rest_connection/rightscale/alert_spec_subject.rb b/lib/rest_connection/rightscale/alert_spec_subject.rb new file mode 100644 index 0000000..aa2fe82 --- /dev/null +++ b/lib/rest_connection/rightscale/alert_spec_subject.rb @@ -0,0 +1,21 @@ +# This file is part of RestConnection +# +# RestConnection is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# RestConnection is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with RestConnection. If not, see . +# +class AlertSpecSubject + include RightScale::Api::Base + extend RightScale::Api::BaseExtend + + deny_methods :index, :destroy, :update, :show +end diff --git a/lib/rest_connection/rightscale/audit_entry.rb b/lib/rest_connection/rightscale/audit_entry.rb index 9a2a8bb..c647ea4 100644 --- a/lib/rest_connection/rightscale/audit_entry.rb +++ b/lib/rest_connection/rightscale/audit_entry.rb @@ -28,6 +28,8 @@ class AuditEntry include RightScale::Api::Base extend RightScale::Api::BaseExtend + deny_methods :index, :create, :destroy, :update + def wait_for_state(state, timeout=900) while(timeout > 0) reload diff --git a/lib/rest_connection/rightscale/ec2_ebs_volume.rb b/lib/rest_connection/rightscale/ec2_ebs_volume.rb index d2b437e..ff0c272 100644 --- a/lib/rest_connection/rightscale/ec2_ebs_volume.rb +++ b/lib/rest_connection/rightscale/ec2_ebs_volume.rb @@ -21,6 +21,10 @@ class Ec2EbsVolume extend RightScale::Api::TaggableExtend def attach(params) - connection.post('component_ec2_ebs_volumes.js' , :component_ec2_ebs_volume => params) + @link = ServerEc2EbsVolume.create(params) + end + + def detach + @link.destroy if @link end end diff --git a/lib/rest_connection/rightscale/ec2_elastic_ip.rb b/lib/rest_connection/rightscale/ec2_elastic_ip.rb index baf044a..b5a8ac7 100644 --- a/lib/rest_connection/rightscale/ec2_elastic_ip.rb +++ b/lib/rest_connection/rightscale/ec2_elastic_ip.rb @@ -17,4 +17,6 @@ class Ec2ElasticIp include RightScale::Api::Base extend RightScale::Api::BaseExtend + + deny_methods :update end diff --git a/lib/rest_connection/rightscale/ec2_security_group.rb b/lib/rest_connection/rightscale/ec2_security_group.rb index 921d6e6..7212971 100644 --- a/lib/rest_connection/rightscale/ec2_security_group.rb +++ b/lib/rest_connection/rightscale/ec2_security_group.rb @@ -16,4 +16,28 @@ class Ec2SecurityGroup include RightScale::Api::Base extend RightScale::Api::BaseExtend + + # NOTE - Create, Destroy, and Update require "security_manager" permissions + # NOTE - Can't remove rules, can only add + def add_rule(opts={}) + opts.each { |k,v| opts["#{k}".to_sym] = v } + update_types = [ + :name => [:owner, :group], + :cidr_ips => [:cidr_ip, :protocol, :from_port, :to_port], + :group => [:owner, :group, :protocol, :from_port, :to_port], + ] + type = (opts[:protocol] ? (opts[:cidr_ip] ? :cidr_ips : :group) : :name) + unless update_types[type].reduce(true) { |b,field| b && opts[field] } + arg_expectation = update_types.values.pretty_inspect + raise ArgumentError.new("add_rule requires one of these groupings: #{arg_expectation}") + end + + params = {} + update_types[type].each { |field| params[field] = opts[field] } + + uri = URI.parse(self.href) + connection.put(uri.path, params) + + self.reload + end end diff --git a/lib/rest_connection/rightscale/ec2_ssh_key.rb b/lib/rest_connection/rightscale/ec2_ssh_key.rb index 8964024..20bb4b0 100644 --- a/lib/rest_connection/rightscale/ec2_ssh_key.rb +++ b/lib/rest_connection/rightscale/ec2_ssh_key.rb @@ -17,6 +17,8 @@ class Ec2SshKey include RightScale::Api::Base extend RightScale::Api::BaseExtend + deny_methods :index, :update + def self.create(opts) create_opts = { self.resource_singular_name.to_sym => opts } create_opts['cloud_id'] = opts['cloud_id'] if opts['cloud_id'] diff --git a/lib/rest_connection/rightscale/executable.rb b/lib/rest_connection/rightscale/executable.rb index 23ffc6c..4df7a84 100644 --- a/lib/rest_connection/rightscale/executable.rb +++ b/lib/rest_connection/rightscale/executable.rb @@ -2,6 +2,8 @@ class Executable include RightScale::Api::Base extend RightScale::Api::BaseExtend + deny_methods :index, :create, :destroy, :update + # executable can be EITHER a right_script or recipe # executable example params format: # can have recipes AND right_scripts diff --git a/lib/rest_connection/rightscale/instance_type.rb b/lib/rest_connection/rightscale/instance_type.rb index c31e213..610d61f 100644 --- a/lib/rest_connection/rightscale/instance_type.rb +++ b/lib/rest_connection/rightscale/instance_type.rb @@ -26,6 +26,10 @@ def self.parse_args(cloud_id) "clouds/#{cloud_id}/" end + def self.filters + [:cpu_architecture, :description, :name, :resource_uid] + end + def show inst_href = URI.parse(self.href) @params.merge! connection.get(inst_href.path, 'view' => "default") diff --git a/lib/rest_connection/rightscale/mc_security_group.rb b/lib/rest_connection/rightscale/mc_security_group.rb index c840795..be01125 100644 --- a/lib/rest_connection/rightscale/mc_security_group.rb +++ b/lib/rest_connection/rightscale/mc_security_group.rb @@ -20,7 +20,7 @@ class McSecurityGroup include RightScale::Api::Gateway extend RightScale::Api::GatewayExtend - deny_methods :create, :destroy, :update + deny_methods :update def resource_plural_name "security_groups" @@ -45,4 +45,64 @@ def self.parse_args(cloud_id) def self.filters [:name, :resource_uid] end + + # NOTE: Create & Destroy require "security_manager" permissions + def self.create(cloud_id, opts={}) + url = "#{parse_args(cloud_id)}#{self.resource_plural_name}" + location = connection.post(url, self.resource_singular_name.to_sym => opts) + newrecord = self.new('links' => [ {'rel' => 'self', 'href' => location } ]) + + rules = opts[:rules] || opts["rules"] + [rules].flatten.each { |rule_hash| newrecord.add_rule(rule_hash) } if rules + + newrecord.reload + newrecord + end + + def rules + self.load(SecurityGroupRule) + end + + def add_rule(opts={}) + opts.each { |k,v| opts["#{k}".to_sym] = v } + fields = [ + {"1.0" => :owner, "1.5" => :group_owner}, # optional + {"1.0" => :group, "1.5" => :group_name}, # optional + {"1.0" => :cidr_ip, "1.5" => :cidr_ips}, # optional + {"1.0" => :protocol, "1.5" => :protocol}, # "tcp" || "udp" || "icmp" + {"1.0" => :from_port, "1.5" => :start_port}, # optional + {"1.0" => :to_port, "1.5" => :end_port}, # optional + { "1.5" => :source_type}, # "cidr_ips" || "group" + { "1.5" => :icmp_code}, # optional + { "1.5" => :icmp_type}, # optional + { "1.5" => :security_group_href}, # optional + ] + unless opts[:protocol] + raise ArgumentError.new("add_rule requires the 'protocol' option") + end + params = { + :source_type => ((opts[:cidr_ip] || opts[:cidr_ips]) ? "cidr_ips" : "group"), + :security_group_href => self.href, + :protocol_details => {} + } + + fields.each { |ver| + next unless val = opts[ver["1.0"]] || opts[ver["1.5"]] + if ver["1.5"].to_s =~ /port|icmp/ + params[:protocol_details][ver["1.5"]] = val + else + params[ver["1.5"]] = val + end + } + + SecurityGroupRule.create(params) + end + + def remove_rules_by_filters(filters={}) + rules_to_delete = rules + filters.each do |filter,regex| + @rules.reject! { |rule| rule[filter] =~ Regexp.new(regex) } + end + @rules.each { |rule| rule.destroy } + end end diff --git a/lib/rest_connection/rightscale/multi_cloud_image.rb b/lib/rest_connection/rightscale/multi_cloud_image.rb index afba896..ff8a597 100644 --- a/lib/rest_connection/rightscale/multi_cloud_image.rb +++ b/lib/rest_connection/rightscale/multi_cloud_image.rb @@ -17,6 +17,8 @@ class MultiCloudImage include RightScale::Api::Base extend RightScale::Api::BaseExtend + deny_methods :create, :destroy, :update + def supported_cloud_ids @params["multi_cloud_image_cloud_settings"].map { |mcics| mcics.cloud_id } end diff --git a/lib/rest_connection/rightscale/right_script.rb b/lib/rest_connection/rightscale/right_script.rb index a4c1193..920cd2e 100644 --- a/lib/rest_connection/rightscale/right_script.rb +++ b/lib/rest_connection/rightscale/right_script.rb @@ -17,6 +17,9 @@ class RightScript include RightScale::Api::Base extend RightScale::Api::BaseExtend + + deny_methods :create, :destroy, :update + def self.from_yaml(yaml) scripts = [] x = YAML.load(yaml) diff --git a/lib/rest_connection/rightscale/rightscale_api_base.rb b/lib/rest_connection/rightscale/rightscale_api_base.rb index 4fef35e..7337a19 100644 --- a/lib/rest_connection/rightscale/rightscale_api_base.rb +++ b/lib/rest_connection/rightscale/rightscale_api_base.rb @@ -17,6 +17,19 @@ module RightScale module Api + BASE_COOKIE_REFRESH = proc do + def refresh_cookie + # login + @cookie = nil + resp = get("login") + unless resp.code == "302" || resp.code == "204" + raise "ERROR: Login failed. #{resp.message}. Code:#{resp.code}" + end + @cookie = resp.response['set-cookie'] + true + end + end + module BaseExtend def connection() @@connection ||= RestConnection::Connection.new @@ -24,6 +37,12 @@ def connection() settings[:common_headers]["X_API_VERSION"] = "1.0" settings[:api_href] = settings[:api_url] settings[:extension] = ".js" + + unless @@connection.respond_to?(:refresh_cookie) + @@connection.instance_exec(&(RightScale::Api::BASE_COOKIE_REFRESH)) + end + + @@connection.refresh_cookie unless @@connection.cookie @@connection end @@ -100,12 +119,12 @@ def create(opts) newrecord end -# filter is only implemented on some api endpoints + # filter is only implemented on some api endpoints def find_by_nickname_speed(nickname) self.find_with_filter('nickname' => nickname) end -# filter is only implemented on some api endpoints + # filter is only implemented on some api endpoints def find_with_filter(filter = {}) filter_params = [] filter.each { |key,val| @@ -160,6 +179,28 @@ def [](*args) } return (args.empty? ? find_all : ret.flatten.uniq) end + + def deny_methods(*symbols) + symbols.map! { |sym| sym.to_sym } + if symbols.delete(:index) + symbols |= [:find_all, :find_by, :find_by_cloud_id, :find_by_nickname, :find_by_nickname_speed, :find_with_filter] + end + if symbols.delete(:show) + symbols |= [:show, :reload, :find, :find_by_id] + end + if symbols.delete(:update) + symbols |= [:save, :update] + end + symbols.each do |sym| + sym = sym.to_sym + eval_str = "undef #{sym.inspect}" + if self.respond_to?(sym) + instance_eval(eval_str) + elsif self.new.respond_to?(sym) + class_eval(eval_str) + end + end + end end module Base @@ -175,6 +216,12 @@ def connection() settings[:common_headers]["X_API_VERSION"] = "1.0" settings[:api_href] = settings[:api_url] settings[:extension] = ".js" + + unless @@connection.respond_to?(:refresh_cookie) + @@connection.instance_exec(&(RightScale::Api::BASE_COOKIE_REFRESH)) + end + + @@connection.refresh_cookie unless @@connection.cookie @@connection end diff --git a/lib/rest_connection/rightscale/rightscale_api_gateway.rb b/lib/rest_connection/rightscale/rightscale_api_gateway.rb index 7bf4dc7..dfbbeb9 100644 --- a/lib/rest_connection/rightscale/rightscale_api_gateway.rb +++ b/lib/rest_connection/rightscale/rightscale_api_gateway.rb @@ -1,5 +1,29 @@ module RightScale module Api + GATEWAY_COOKIE_REFRESH = proc do + def refresh_cookie + # login + ignored, account = @settings[:api_url].split(/\/acct\//) if @settings[:api_url].include?("acct") + params = { + "email" => @settings[:user], + "password" => @settings[:pass], + "account_href" => "/api/accounts/#{account}" + } + @cookie = nil + resp = post("session", params) + unless resp.code == "302" || resp.code == "204" + raise "ERROR: Login failed. #{resp.message}. Code:#{resp.code}" + end + # TODO: handle 302 redirects + @cookie = resp.response['set-cookie'] + + # test session + resp = get("session") + raise "ERROR: Invalid session. #{resp["message"]}." unless resp.is_a?(Hash) + true + end + end + module Gateway include RightScale::Api::Base @@ -17,17 +41,12 @@ def connection settings[:common_headers]["X_API_VERSION"] = "1.5" settings[:api_href], account = settings[:api_url].split(/\/acct\//) if settings[:api_url].include?("acct") settings[:extension] = ".json" - unless @@gateway_connection.cookie - # login - params = { "email" => settings[:user], "password" => settings[:pass], "account_href" => "/api/accounts/#{account}" } - resp = @@gateway_connection.post("session", params) - raise "ERROR: Login failed. #{resp.message}. Code:#{resp.code}" unless resp.code == "302" || resp.code == "204" - @@gateway_connection.cookie = resp.response['set-cookie'] - # test session - resp = @@gateway_connection.get("session") - raise "ERROR: Invalid session. #{resp["message"]}." unless resp.is_a?(Hash) + unless @@gateway_connection.respond_to?(:refresh_cookie) + @@gateway_connection.instance_exec(&(RightScale::Api::GATEWAY_COOKIE_REFRESH)) end + + @@gateway_connection.refresh_cookie unless @@gateway_connection.cookie @@gateway_connection end @@ -130,23 +149,30 @@ def []=(name,val) end def load(resource) - if resource.is_a?(Class) - param_string = resource.resource_singular_name - class_name = resource + mod = RightScale::Api::GatewayExtend + @@gateway_resources ||= Object.constants.map do |const| + klass = Object.const_get(const) + (mod === klass ? klass : nil) + end.compact + pp @@gateway_resources + if mod === resource + klass = resource elsif resource.is_a?(String) or resource.is_a?(Symbol) - param_string = resource - begin - class_name = Kernel.const_get(resource.singularize.camelize) - rescue - class_name = Kernel.const_get("Mc#{resource.singularize.camelize}") + klass = @@gateway_resources.detect do |const| + [const.resource_singular_name, const.resource_plural_name].include?(resource.to_s) end + elsif Class === resource + raise TypeError.new("#{resource} doesn't extend #{mod}") + else + raise TypeError.new("can't convert #{resource.class} into supported Class") end - if self[param_string].nil? - return class_name.load_all(self[param_string.pluralize]) - elsif param_string.pluralize == param_string - return class_name.load_all(self[param_string]) + + if self[klass.resource_singular_name] + return klass.load(self[klass.resource_singular_name]) + elsif self[klass.resource_plural_name] + return klass.load_all(self[klass.resource_plural_name]) else - return class_name.load(self[param_string]) + raise NameError.new("no resource_hrefs found for #{klass}") end end end @@ -159,17 +185,12 @@ def connection settings[:common_headers]["X_API_VERSION"] = "1.5" settings[:api_href], account = settings[:api_url].split(/\/acct\//) if settings[:api_url].include?("acct") settings[:extension] = ".json" - unless @@gateway_connection.cookie - # login - params = { "email" => settings[:user], "password" => settings[:pass], "account_href" => "/api/accounts/#{account}" } - resp = @@gateway_connection.post("session", params) - raise "ERROR: Login failed. #{resp.message}. Code:#{resp.code}" unless resp.code == "302" || resp.code == "204" - @@gateway_connection.cookie = resp.response['set-cookie'] - # test session - resp = @@gateway_connection.get("session") - raise "ERROR: Invalid session. #{resp["message"]}." unless resp.is_a?(Hash) + unless @@gateway_connection.respond_to?(:refresh_cookie) + @@gateway_connection.instance_exec(&(RightScale::Api::GATEWAY_COOKIE_REFRESH)) end + + @@gateway_connection.refresh_cookie unless @@gateway_connection.cookie @@gateway_connection end @@ -238,31 +259,18 @@ def filters() [] end - def create(opts) - location = connection.post(self.resource_plural_name, self.resource_singular_name.to_sym => opts) + def create(*args) + if args.last.is_a?(Hash) + opts = args.pop + else + raise ArgumentError.new("create requires the last argument to be a Hash") + end + url = "#{parse_args(*args)}#{self.resource_plural_name}" + location = connection.post(url, self.resource_singular_name.to_sym => opts) newrecord = self.new('links' => [ {'rel' => 'self', 'href' => location } ]) newrecord.reload newrecord end - - def deny_methods(*symbols) - symbols.map! { |sym| sym.to_sym } - if symbols.delete(:index) - symbols |= [:find_all, :find_by, :find_by_cloud_id, :find_by_nickname, :find_by_nickname_speed, :find_with_filter] - end - if symbols.delete(:show) - symbols |= [:show, :reload, :find, :find_by_id] - end - symbols.each do |sym| - sym = sym.to_sym - eval_str = "undef #{sym.inspect}" - if self.respond_to?(sym) - instance_eval(eval_str) - elsif self.new.respond_to?(sym) - class_eval(eval_str) - end - end - end end end end diff --git a/lib/rest_connection/rightscale/rightscale_api_resources.rb b/lib/rest_connection/rightscale/rightscale_api_resources.rb index 781bae9..e4fac0d 100644 --- a/lib/rest_connection/rightscale/rightscale_api_resources.rb +++ b/lib/rest_connection/rightscale/rightscale_api_resources.rb @@ -20,6 +20,9 @@ require 'rest_connection/rightscale/rightscale_api_taggable' require 'rest_connection/rightscale/rightscale_api_mc_taggable' require 'rest_connection/rightscale/rightscale_api_mc_input' +require 'rest_connection/rightscale/alert_spec_subject' +require 'rest_connection/rightscale/server_ec2_ebs_volume' +require 'rest_connection/rightscale/sqs_queue' require 'rest_connection/rightscale/executable' require 'rest_connection/rightscale/cloud_account' require 'rest_connection/rightscale/server' @@ -49,6 +52,7 @@ require 'rest_connection/rightscale/server_interface' require 'rest_connection/rightscale/mc_instance' require 'rest_connection/rightscale/monitoring_metric' +require 'rest_connection/rightscale/session' require 'rest_connection/rightscale/mc_multi_cloud_image_setting' require 'rest_connection/rightscale/mc_multi_cloud_image' require 'rest_connection/rightscale/mc_server_template_multi_cloud_image' @@ -60,6 +64,7 @@ require 'rest_connection/rightscale/multi_cloud_image_internal' require 'rest_connection/rightscale/ec2_server_array' require 'rest_connection/rightscale/mc_server_array' +require 'rest_connection/rightscale/security_group_rule' require 'rest_connection/rightscale/mc_security_group' require 'rest_connection/rightscale/mc_deployment' require 'rest_connection/rightscale/mc_datacenter' diff --git a/lib/rest_connection/rightscale/s3_bucket.rb b/lib/rest_connection/rightscale/s3_bucket.rb index 3f2cb52..e9c5234 100644 --- a/lib/rest_connection/rightscale/s3_bucket.rb +++ b/lib/rest_connection/rightscale/s3_bucket.rb @@ -17,6 +17,8 @@ class S3Bucket include RightScale::Api::Base extend RightScale::Api::BaseExtend + deny_methods :update + def self.resource_singular_name "s3_bucket" end @@ -32,5 +34,4 @@ def resource_singular_name def resource_plural_name "s3_buckets" end - end diff --git a/lib/rest_connection/rightscale/security_group_rule.rb b/lib/rest_connection/rightscale/security_group_rule.rb new file mode 100644 index 0000000..a42e2af --- /dev/null +++ b/lib/rest_connection/rightscale/security_group_rule.rb @@ -0,0 +1,31 @@ +# This file is part of RestConnection +# +# RestConnection is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# RestConnection is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with RestConnection. If not, see . + +# +# You must have Beta v1.5 API access to use these internal API calls. +# +class SecurityGroupRule + include RightScale::Api::Gateway + extend RightScale::Api::GatewayExtend + + deny_methods :update + + def self.parse_args(cloud_id=nil, security_group_id=nil) + if cloud_id.nil? ^ security_group_id.nil? + raise ArgumentError.new("#{self} requires either 0 arguments, or 2 arguments") + end + "clouds/#{cloud_id}/security_groups/#{security_group_id}/" + end +end diff --git a/lib/rest_connection/rightscale/server_ec2_ebs_volume.rb b/lib/rest_connection/rightscale/server_ec2_ebs_volume.rb new file mode 100644 index 0000000..6a53e2a --- /dev/null +++ b/lib/rest_connection/rightscale/server_ec2_ebs_volume.rb @@ -0,0 +1,40 @@ +# This file is part of RestConnection +# +# RestConnection is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# RestConnection is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with RestConnection. If not, see . +# + +class ServerEc2EbsVolume + include RightScale::Api::Base + extend RightScale::Api::BaseExtend + include RightScale::Api::Taggable + extend RightScale::Api::TaggableExtend + + deny_methods :index, :update + + def resource_plural_name + "component_ec2_ebs_volumes" + end + + def resource_singular_name + "component_ec2_ebs_volume" + end + + def self.resource_plural_name + "component_ec2_ebs_volumes" + end + + def self.resource_singular_name + "component_ec2_ebs_volume" + end +end diff --git a/lib/rest_connection/rightscale/session.rb b/lib/rest_connection/rightscale/session.rb new file mode 100644 index 0000000..1d9b576 --- /dev/null +++ b/lib/rest_connection/rightscale/session.rb @@ -0,0 +1,61 @@ +# This file is part of RestConnection +# +# RestConnection is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# RestConnection is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with RestConnection. If not, see . + +# +# You must have Beta v1.5 API access to use these internal API calls. +# +class Session + include RightScale::Api::Gateway + extend RightScale::Api::GatewayExtend + + deny_methods :index, :destroy, :update, :show + + def self.index + self.new(connection.get(resource_singular_name)) + end + + def self.create(opts={}) + settings = connection.settings + ignored, account = settings[:api_url].split(/\/acct\//) if settings[:api_url].include?("acct") + params = { + "email" => settings[:user], + "password" => settings[:pass], + "account_href" => "/api/accounts/#{account}" + }.merge(opts) + resp = connection.post(resource_singular_name, params) + connection.cookie = resp.response['set-cookie'] + end + + def self.accounts(opts={}) + settings = connection.settings + params = { + "email" => settings[:user], + "password" => settings[:pass], + }.merge(opts) + a = Array.new + connection.get(resource_singular_name + "/accounts").each do |object| + a << Account.new(object) + end + return a + end + + def self.create_instance_session + # TODO + end + + def self.index_instance_session + # TODO + end +end diff --git a/lib/rest_connection/rightscale/sqs_queue.rb b/lib/rest_connection/rightscale/sqs_queue.rb new file mode 100644 index 0000000..16330aa --- /dev/null +++ b/lib/rest_connection/rightscale/sqs_queue.rb @@ -0,0 +1,22 @@ +# This file is part of RestConnection +# +# RestConnection is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# RestConnection is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with RestConnection. If not, see . +# + +class SqsQueue + include RightScale::Api::Base + extend RightScale::Api::BaseExtend + + deny_methods :update +end diff --git a/lib/rest_connection/rightscale/tag.rb b/lib/rest_connection/rightscale/tag.rb index 0bdbb92..8f7be98 100644 --- a/lib/rest_connection/rightscale/tag.rb +++ b/lib/rest_connection/rightscale/tag.rb @@ -17,6 +17,8 @@ class Tag include RightScale::Api::Base extend RightScale::Api::BaseExtend + deny_methods :index, :create, :destroy, :update, :show + def self.search(resource_name, tags, opts=nil) parameters = { :resource_type => resource_name.to_s, :tags => tags } parameters.merge!(opts) unless opts.nil? From 74576d51fa9baa22aa711a6ce529c011ef3c6fa4 Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Wed, 25 Jan 2012 22:05:00 -0800 Subject: [PATCH 129/239] Version bump to 0.1.2 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 6da28dd..8294c18 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.1.1 \ No newline at end of file +0.1.2 \ No newline at end of file From b28d4b95111dc3e69bbcd91928e91921cf00529b Mon Sep 17 00:00:00 2001 From: Peter Schroeter Date: Sun, 29 Jan 2012 20:57:36 -0800 Subject: [PATCH 130/239] look for per application configs --- lib/rest_connection.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/rest_connection.rb b/lib/rest_connection.rb index becebeb..5374d9e 100644 --- a/lib/rest_connection.rb +++ b/lib/rest_connection.rb @@ -94,12 +94,16 @@ def initialize(config_yaml = File.join(File.expand_path("~"), ".rest_connection" @@user = nil @@pass = nil etc_config = File.join("#{File::SEPARATOR}etc", "rest_connection", "rest_api_config.yaml") - if File.exists?(config_yaml) + app_bin_dir = File.expand_path(File.dirname(caller.last)) + app_yaml = File.join(app_bin_dir,"..","config","rest_api_config.yaml") + if File.exists?(app_yaml) + @settings = YAML::load(IO.read(app_yaml)) + elsif File.exists?(config_yaml) @settings = YAML::load(IO.read(config_yaml)) elsif File.exists?(etc_config) @settings = YAML::load(IO.read(etc_config)) else - logger("\nWARNING: you must setup config file rest_api_config.yaml in #{config_yaml} or #{etc_config}") + logger("\nWARNING: you must setup config file rest_api_config.yaml in #{app_yaml} or #{config_yaml} or #{etc_config}") logger("WARNING: see GEM_HOME/rest_connection/config/rest_api_config.yaml for example config") @settings = {} end From bab56f9a05d906840ebce11e0aedb68c5af6b163 Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Fri, 3 Feb 2012 11:30:45 -0800 Subject: [PATCH 131/239] Bugfix for ssh'ing to servers behind a IP forwarding gateway --- lib/rest_connection/rightscale/mc_server.rb | 14 ++++++++++---- lib/rest_connection/rightscale/server.rb | 13 +++++++++++-- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/lib/rest_connection/rightscale/mc_server.rb b/lib/rest_connection/rightscale/mc_server.rb index bf4d0dc..10db49e 100644 --- a/lib/rest_connection/rightscale/mc_server.rb +++ b/lib/rest_connection/rightscale/mc_server.rb @@ -200,18 +200,24 @@ def wait_for_operational_with_dns(state_wait_timeout=1200) def dns_name self.settings + ret = nil if @current_instance - return @current_instance.public_ip_addresses.first || @current_instance.public_dns_names.first + ret ||= @current_instance.public_ip_addresses.first + ret ||= @current_instance.public_dns_names.first + ret ||= get_tags_by_namespace("server")["current_instance"]["public_ip_0"] end - nil + ret end def private_ip self.settings + ret = nil if @current_instance - return @current_instance.private_ip_addresses.first || @current_instance.private_dns_names.first + ret ||= @current_instance.private_ip_addresses.first + ret ||= @current_instance.private_dns_names.first + ret ||= get_tags_by_namespace("server")["current_instance"]["private_ip_0"] end - nil + ret end def save diff --git a/lib/rest_connection/rightscale/server.rb b/lib/rest_connection/rightscale/server.rb index 3841e23..b77b7e6 100644 --- a/lib/rest_connection/rightscale/server.rb +++ b/lib/rest_connection/rightscale/server.rb @@ -366,17 +366,26 @@ def run_executable_and_wait_for_completed(executable, opts=nil) def dns_name self.settings unless self["dns_name"] + if self.current_instance_href + self["dns_name"] ||= get_tags_by_namespace("server")["current_instance"]["public_ip_0"] + end self["dns_name"] end def private_ip self.settings unless @params["private-ip-address"] + if self.current_instance_href + self["private-ip-address"] ||= get_tags_by_namespace("server")["current_instance"]["private_ip_0"] + end @params["private-ip-address"] end def reachable_ip - return self.dns_name if self.dns_name - return self.private_ip if self.private_ip + if ret = self.dns_name + return ret + elsif ret = self.private_ip + return ret + end nil end From 564b790f7193e3b032528592d1d2accd17b54689 Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Tue, 7 Feb 2012 23:08:32 -0800 Subject: [PATCH 132/239] [API 0.1, API 1.0, API 1.5, Core] Several Improvements [API 0.1] - New Resource: RightScriptAttachmentInternal - New API: RightScriptInternal#create, #attachments - Ability to update Connection settings dynamically (RightScale::Api::update_connection_settings(...)) - Performance Improvements [API 1.0] - Several Performance Improvements - Ability to update Connection settings dynamically (RightScale::Api::update_connection_settings(...)) [API 1.5] - New Resources: McAuditEntry, Backup - Several Performance Improvements - Ability to update Connection settings dynamically (RightScale::Api::update_connection_settings(...)) - Dead Code Cleanup [Core] - Removed RightScale/AWS-specific code from core module - Dead code cleanup & refactor - Ability to specify Connection.new() settings with a hash - Code Stability improvements --- Rakefile | 4 +- lib/rest_connection.rb | 55 +--------- lib/rest_connection/patches.rb | 12 +++ lib/rest_connection/rightscale/backup.rb | 70 ++++++++++++ .../rightscale/mc_audit_entry.rb | 101 ++++++++++++++++++ lib/rest_connection/rightscale/mc_server.rb | 17 --- .../rightscale/multi_cloud_image.rb | 9 +- .../rightscale/multi_cloud_image_internal.rb | 1 - .../right_script_attachment_internal.rb | 50 +++++++++ .../rightscale/right_script_internal.rb | 22 ++++ .../rightscale/rightscale_api_base.rb | 98 +++++++++++++---- .../rightscale/rightscale_api_gateway.rb | 76 +++++++------ .../rightscale/rightscale_api_internal.rb | 20 ++-- .../rightscale/rightscale_api_resources.rb | 3 + lib/rest_connection/rightscale/server.rb | 10 +- 15 files changed, 397 insertions(+), 151 deletions(-) create mode 100644 lib/rest_connection/rightscale/backup.rb create mode 100644 lib/rest_connection/rightscale/mc_audit_entry.rb create mode 100644 lib/rest_connection/rightscale/right_script_attachment_internal.rb diff --git a/Rakefile b/Rakefile index 434cc24..b063df7 100644 --- a/Rakefile +++ b/Rakefile @@ -3,9 +3,9 @@ require 'jeweler' Jeweler::Tasks.new do |gemspec| gemspec.name = "rest_connection" gemspec.summary = "Modular RESTful API library" - gemspec.description = "Current implemented modules: RightScale API" + gemspec.description = "A Modular RESTful API library. Current implemented modules: RightScale API" gemspec.email = ["jeremy@rubyonlinux.org", "tw.rodriguez@gmail.com"] - gemspec.homepage = "http://github.com/twrodriguez/rest_connection" + gemspec.homepage = "http://github.com/rightscale/rest_connection" gemspec.authors = ["Jeremy Deininger", "Timothy Rodriguez"] gemspec.add_dependency('activesupport', "=2.3.10") gemspec.add_dependency('net-ssh', "=2.1.4") diff --git a/lib/rest_connection.rb b/lib/rest_connection.rb index becebeb..edc46eb 100644 --- a/lib/rest_connection.rb +++ b/lib/rest_connection.rb @@ -24,55 +24,6 @@ require 'highline/import' module RestConnection - AWS_CLOUDS = [ - {"cloud_id" => 1, "name" => "AWS US-East"}, - {"cloud_id" => 2, "name" => "AWS EU"}, - {"cloud_id" => 3, "name" => "AWS US-West"}, - {"cloud_id" => 4, "name" => "AWS AP-Singapore"}, - {"cloud_id" => 5, "name" => "AWS AP-Tokyo"}, - {"cloud_id" => 6, "name" => "AWS US-Oregon"}, - {"cloud_id" => 7, "name" => "AWS SA-Sao Paulo"}, - ] - - # Check for API 0.1 Access - def self.api0_1? - unless class_variable_defined?("@@api0_1") - begin - Ec2SshKeyInternal.find_all - @@api0_1 = true - rescue - @@api0_1 = false - end - end - return @@api0_1 - end - - # Check for API 1.0 Access - def self.api1_0? - unless class_variable_defined?("@@api1_0") - begin - Ec2SecurityGroup.find_all - @@api1_0 = true - rescue - @@api1_0 = false - end - end - return @@api1_0 - end - - # Check for API 1.5 Beta Access - def self.api1_5? - unless class_variable_defined?("@@api1_5") - begin - Cloud.find_all - @@api1_5 = true - rescue - @@api1_5 = false - end - end - return @@api1_5 - end - class Connection # Settings is a hash of options for customizing the connection. # settings.merge! { @@ -94,7 +45,9 @@ def initialize(config_yaml = File.join(File.expand_path("~"), ".rest_connection" @@user = nil @@pass = nil etc_config = File.join("#{File::SEPARATOR}etc", "rest_connection", "rest_api_config.yaml") - if File.exists?(config_yaml) + if config_yaml.is_a?(Hash) + @settings = config_yaml + elsif File.exists?(config_yaml) @settings = YAML::load(IO.read(config_yaml)) elsif File.exists?(etc_config) @settings = YAML::load(IO.read(etc_config)) @@ -103,6 +56,8 @@ def initialize(config_yaml = File.join(File.expand_path("~"), ".rest_connection" logger("WARNING: see GEM_HOME/rest_connection/config/rest_api_config.yaml for example config") @settings = {} end + @settings.keys.each { |k| @settings[k.to_sym] = @settings[k] if String === k } + @settings[:extension] = ".js" @settings[:api_href] = @settings[:api_url] unless @settings[:api_href] unless @settings[:user] diff --git a/lib/rest_connection/patches.rb b/lib/rest_connection/patches.rb index 083f148..5a47608 100644 --- a/lib/rest_connection/patches.rb +++ b/lib/rest_connection/patches.rb @@ -13,6 +13,9 @@ class Hash def deep_merge(second) target = dup return target unless second + unless self.class === second + raise TypeError.new("can't convert #{second.class} into #{self.class}") + end second.keys.each do |k| if second[k].is_a? Array and self[k].is_a? Array target[k] = target[k].deep_merge(second[k]) @@ -32,6 +35,9 @@ def deep_merge(second) def deep_merge!(second) return nil unless second + unless self.class === second + raise TypeError.new("can't convert #{second.class} into #{self.class}") + end second.each_pair do |k,v| if self[k].is_a?(Array) and second[k].is_a?(Array) self[k].deep_merge!(second[k]) @@ -50,6 +56,9 @@ class Array def deep_merge(second) target = dup return target unless second + unless self.class === second + raise TypeError.new("can't convert #{second.class} into #{self.class}") + end second.each_index do |k| if second[k].is_a? Array and self[k].is_a? Array target[k] = target[k].deep_merge(second[k]) @@ -65,6 +74,9 @@ def deep_merge(second) def deep_merge!(second) return nil unless second + unless self.class === second + raise TypeError.new("can't convert #{second.class} into #{self.class}") + end second.each_index do |k| if self[k].is_a?(Array) and second[k].is_a?(Array) self[k].deep_merge!(second[k]) diff --git a/lib/rest_connection/rightscale/backup.rb b/lib/rest_connection/rightscale/backup.rb new file mode 100644 index 0000000..8f46588 --- /dev/null +++ b/lib/rest_connection/rightscale/backup.rb @@ -0,0 +1,70 @@ +# This file is part of RestConnection +# +# RestConnection is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# RestConnection is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with RestConnection. If not, see . + +# +# You must have Beta v1.5 API access to use these internal API calls. +# +class Backup + include RightScale::Api::Gateway + extend RightScale::Api::GatewayExtend + + deny_methods :index + + def self.filters + [:cloud_href, :committed, :completed, :from_master, :latest_before] + end + + def self.find_all(lineage) + index(lineage) + end + + def self.find_with_filter(lineage, filter={}) + index(lineage, filter) + end + + def self.index(lineage, filter={}) + filter_params = [] + filter.each { |key,val| + unless self.filters.include?(key.to_sym) + raise ArgumentError.new("#{key} is not a valid filter for resource #{self.resource_singular_name}") + end + filter_params << "#{key}==#{val}" + } + + a = Array.new + url = self.resource_plural_name + hsh = {'lineage' => lineage} + hsh.merge(:filter => filter_params) unless filter_params.empty? + connection.get(url, hsh).each do |object| + a << self.new(object) + end + + return a + end + + def self.cleanup(lineage, keep_last, params={}) + params.merge!('keep_last' => keep_last, 'lineage' => lineage) + connection.post(resource_plural_name + "/cleanup", params) + end + + def restore(instance_href, name=nil, description=nil) + uri = URI.parse(self.href) + params = {'instance_href' => instance_href} + params.deep_merge!({'backup' => {'name' => name}}) if name + params.deep_merge!({'backup' => {'description' => description}}) if description + location = connection.post(uri.path + "/restore", params) + Task.new('href' => location) + end +end diff --git a/lib/rest_connection/rightscale/mc_audit_entry.rb b/lib/rest_connection/rightscale/mc_audit_entry.rb new file mode 100644 index 0000000..ff5691f --- /dev/null +++ b/lib/rest_connection/rightscale/mc_audit_entry.rb @@ -0,0 +1,101 @@ +# This file is part of RestConnection +# +# RestConnection is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# RestConnection is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with RestConnection. If not, see . + +# +# You must have Beta v1.5 API access to use these internal API calls. +# +class McAuditEntry + include RightScale::Api::Gateway + extend RightScale::Api::GatewayExtend + + deny_methods :destroy, :index + + def resource_plural_name + "audit_entries" + end + + def resource_singular_name + "audit_entry" + end + + def self.resource_plural_name + "audit_entries" + end + + def self.resource_singular_name + "audit_entry" + end + + def self.filters + [:auditee_href, :user_email] + end + + def self.find_all(start_date=nil, end_date=nil, limit=1000) + start_date ||= (Time.now.utc - (60*60*24*31)).strftime(RightScale::Api::DATETIME_FMT) + end_date ||= Time.now.utc.strftime(RightScale::Api::DATETIME_FMT) + index(start_date, end_date, limit) + end + + def self.find_with_filter(start_date, end_date, limit, filter) + index(start_date, end_date, limit, filter) + end + + def self.index(start_date, end_date, limit=1000, filter={}) + # Validate index params + ex_fmt = "2011/06/25 00:00:00 +0000" + regex = /^(\d{4})\/(\d{2})\/(\d{2}) (\d{2}):(\d{2}):(\d{2}) ([+-]\d{4})$/ + unless start_date =~ regex + raise ArgumentError.new("start_date doesn't match format. e.g., #{ex_fmt}") + end + unless end_date =~ regex + raise ArgumentError.new("end_date doesn't match format. e.g., #{ex_fmt}") + end + unless (1..1000) === limit.to_i + raise ArgumentError.new("limit is not within the range of 1..1000") + end + filter_params = [] + filter.each { |key,val| + unless self.filters.include?(key.to_sym) + raise ArgumentError.new("#{key} is not a valid filter for resource #{self.resource_singular_name}") + end + filter_params << "#{key}==#{val}" + } + + a = Array.new + url = self.resource_plural_name + if filter_params.empty? + connection.get(url).each do |object| + a << self.new(object) + end + else + connection.get(url, :filter => filter_params).each do |object| + a << self.new(object) + end + end + + return a + end + + def append(detail, offset) + uri = URI.parse(self.href) + connection.post(uri.path + "/append", 'detail' => detail, 'offset' => offset) + end + + def detail + uri = URI.parse(self.href) + res = connection.post(uri.path + "/detail") + return res.body + end +end diff --git a/lib/rest_connection/rightscale/mc_server.rb b/lib/rest_connection/rightscale/mc_server.rb index 10db49e..aed4275 100644 --- a/lib/rest_connection/rightscale/mc_server.rb +++ b/lib/rest_connection/rightscale/mc_server.rb @@ -181,23 +181,6 @@ def cloud_id return cloud_href.split("/").last.to_i end -=begin - def wait_for_operational_with_dns(state_wait_timeout=1200) - timeout = 600 - wait_for_state("operational", state_wait_timeout) - step = 15 - while(timeout > 0) - self.settings - break if self.reachable_ip - connection.logger "waiting for any IP for #{self.nickname}" - sleep step - timeout -= step - end - connection.logger "got IP: #{self.reachable_ip}" - raise "FATAL, this server #{self.audit_link} timed out waiting for an IP" if timeout <= 0 - end -=end - def dns_name self.settings ret = nil diff --git a/lib/rest_connection/rightscale/multi_cloud_image.rb b/lib/rest_connection/rightscale/multi_cloud_image.rb index ff8a597..8118e5a 100644 --- a/lib/rest_connection/rightscale/multi_cloud_image.rb +++ b/lib/rest_connection/rightscale/multi_cloud_image.rb @@ -25,11 +25,14 @@ def supported_cloud_ids # You must have access to multiple APIs for this (0.1, and 1.5) def find_and_flatten_settings() - some_settings = McMultiCloudImage.find(rs_id.to_i).get_settings internal = MultiCloudImageInternal.new("href" => self.href) internal.reload - more_settings = internal.settings - @params["multi_cloud_image_cloud_settings"] = some_settings + more_settings + total_image_count = internal.multi_cloud_image_cloud_settings.size + # The .settings call filters out non-ec2 images + if total_image_count > internal.settings.size + more_settings = McMultiCloudImage.find(rs_id.to_i).get_settings + end + @params["multi_cloud_image_cloud_settings"] = internal.settings + more_settings end end diff --git a/lib/rest_connection/rightscale/multi_cloud_image_internal.rb b/lib/rest_connection/rightscale/multi_cloud_image_internal.rb index 5cc95d9..307acc7 100644 --- a/lib/rest_connection/rightscale/multi_cloud_image_internal.rb +++ b/lib/rest_connection/rightscale/multi_cloud_image_internal.rb @@ -58,7 +58,6 @@ def transform_settings def initialize(params={}) @params = params - transform_settings end def settings diff --git a/lib/rest_connection/rightscale/right_script_attachment_internal.rb b/lib/rest_connection/rightscale/right_script_attachment_internal.rb new file mode 100644 index 0000000..b3485aa --- /dev/null +++ b/lib/rest_connection/rightscale/right_script_attachment_internal.rb @@ -0,0 +1,50 @@ +# This file is part of RestConnection +# +# RestConnection is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# RestConnection is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with RestConnection. If not, see . + +class RightScriptAttachmentInternal + include RightScale::Api::Base + extend RightScale::Api::BaseExtend + include RightScale::Api::Internal + extend RightScale::Api::InternalExtend + + def resource_plural_name + "right_script_attachments" + end + + def resource_singular_name + "right_script_attachment" + end + + def self.resource_plural_name + "right_script_attachments" + end + + def self.resource_singular_name + "right_script_attachment" + end + + def self.get_s3_upload_params(right_script_href) + url = self.resource_plural_name + "/get_s3_upload_params" + connection.get(url, {"right_script_href" => right_script_href}) + end + +=begin + def self.upload(filedata, right_script_href) # TODO + end + + def download # TODO + end +=end +end diff --git a/lib/rest_connection/rightscale/right_script_internal.rb b/lib/rest_connection/rightscale/right_script_internal.rb index 3e49a93..b9d51b5 100644 --- a/lib/rest_connection/rightscale/right_script_internal.rb +++ b/lib/rest_connection/rightscale/right_script_internal.rb @@ -36,6 +36,9 @@ def self.resource_singular_name "right_script" end + # NOTE: only RightScriptInternal.create() allows you to pass the ["script"] param. + # Need to request that .save() allows update to "script" + # commits a rightscript def commit(message) t = URI.parse(self.href) @@ -48,4 +51,23 @@ def clone RightScript.new(:href => connection.post(t.path + "/clone")) end + def fetch_right_script_attachments + t = URI.parse(self.href) + @params["attachments"] = [] + connection.get(t.path + "/right_script_attachments").each { |obj| + obj.merge!("right_script_href" => self.href) + @params["attachments"] << RightScriptAttachmentInternal.new(obj) + } + @params["attachments"] + end + + def attachments + @params["attachments"] ||= fetch_right_script_attachments + end + +=begin + def upload_attachment(file) # TODO + filedata = (File.exists?(file) ? IO.read(file) : file) + end +=end end diff --git a/lib/rest_connection/rightscale/rightscale_api_base.rb b/lib/rest_connection/rightscale/rightscale_api_base.rb index 7337a19..3f47aa6 100644 --- a/lib/rest_connection/rightscale/rightscale_api_base.rb +++ b/lib/rest_connection/rightscale/rightscale_api_base.rb @@ -17,6 +17,17 @@ module RightScale module Api + DATETIME_FMT = "%Y/%m/%d %H:%M:%S +0000" + AWS_CLOUDS = [ + {"cloud_id" => 1, "name" => "AWS US-East"}, + {"cloud_id" => 2, "name" => "AWS EU"}, + {"cloud_id" => 3, "name" => "AWS US-West"}, + {"cloud_id" => 4, "name" => "AWS AP-Singapore"}, + {"cloud_id" => 5, "name" => "AWS AP-Tokyo"}, + {"cloud_id" => 6, "name" => "AWS US-Oregon"}, + {"cloud_id" => 7, "name" => "AWS SA-Sao Paulo"}, + ] + BASE_COOKIE_REFRESH = proc do def refresh_cookie # login @@ -30,9 +41,65 @@ def refresh_cookie end end - module BaseExtend - def connection() - @@connection ||= RestConnection::Connection.new + # Pass no arguments to reset to the default configuration, + # pass a hash to update the settings for all API Versions + def self.update_connection_settings(*settings) + if settings.size > 1 + raise ArgumentError.new("wrong number of arguments (#{settings.size} for 1)") + end + konstants = constants.map { |c| const_get(c) } + konstants.reject! { |c| !(Module === c) } + konstants.reject! { |c| !(c.instance_methods.include?("connection")) } + konstants.each do |c| + c.instance_exec(settings) do |opts| + class_variable_set("@@connection", RestConnection::Connection.new(*opts)) + end + end + true + end + + # Check for API 0.1 Access + def self.api0_1? + unless class_variable_defined?("@@api0_1") + begin + Ec2SshKeyInternal.find_all + @@api0_1 = true + rescue + @@api0_1 = false + end + end + return @@api0_1 + end + + # Check for API 1.0 Access + def self.api1_0? + unless class_variable_defined?("@@api1_0") + begin + Ec2SecurityGroup.find_all + @@api1_0 = true + rescue + @@api1_0 = false + end + end + return @@api1_0 + end + + # Check for API 1.5 Beta Access + def self.api1_5? + unless class_variable_defined?("@@api1_5") + begin + Cloud.find_all + @@api1_5 = true + rescue + @@api1_5 = false + end + end + return @@api1_5 + end + + module BaseConnection + def connection(*opts) + @@connection ||= RestConnection::Connection.new(*opts) settings = @@connection.settings settings[:common_headers]["X_API_VERSION"] = "1.0" settings[:api_href] = settings[:api_url] @@ -45,6 +112,10 @@ def connection() @@connection.refresh_cookie unless @@connection.cookie @@connection end + end + + module BaseExtend + include RightScale::Api::BaseConnection def resource_plural_name self.to_s.underscore.pluralize @@ -56,6 +127,10 @@ def resource_singular_name # matches using result of block match expression # ex: Server.find_by(:nickname) { |n| n =~ /production/ } def find_by(attrib, &block) + attrib = attrib.to_sym + if self.filters.include?(attrib) + connection.logger("#{self} includes the filter '#{attrib}', you might be able to speed up this API call") + end self.find_all.select do |s| yield(s[attrib.to_s]) end @@ -204,27 +279,14 @@ def deny_methods(*symbols) end module Base + include RightScale::Api::BaseConnection + # The params hash of attributes for direct manipulation attr_accessor :params def initialize(params = {}) @params = params end - def connection() - @@connection ||= RestConnection::Connection.new - settings = @@connection.settings - settings[:common_headers]["X_API_VERSION"] = "1.0" - settings[:api_href] = settings[:api_url] - settings[:extension] = ".js" - - unless @@connection.respond_to?(:refresh_cookie) - @@connection.instance_exec(&(RightScale::Api::BASE_COOKIE_REFRESH)) - end - - @@connection.refresh_cookie unless @@connection.cookie - @@connection - end - def resource_plural_name self.class.to_s.underscore.pluralize end diff --git a/lib/rest_connection/rightscale/rightscale_api_gateway.rb b/lib/rest_connection/rightscale/rightscale_api_gateway.rb index dfbbeb9..95ac893 100644 --- a/lib/rest_connection/rightscale/rightscale_api_gateway.rb +++ b/lib/rest_connection/rightscale/rightscale_api_gateway.rb @@ -24,8 +24,26 @@ def refresh_cookie end end + module GatewayConnection + def connection(*opts) + @@gateway_connection ||= RestConnection::Connection.new(*opts) + settings = @@gateway_connection.settings + settings[:common_headers]["X_API_VERSION"] = "1.5" + settings[:api_href], account = settings[:api_url].split(/\/acct\//) if settings[:api_url].include?("acct") + settings[:extension] = ".json" + + unless @@gateway_connection.respond_to?(:refresh_cookie) + @@gateway_connection.instance_exec(&(RightScale::Api::GATEWAY_COOKIE_REFRESH)) + end + + @@gateway_connection.refresh_cookie unless @@gateway_connection.cookie + @@gateway_connection + end + end + module Gateway include RightScale::Api::Base + include RightScale::Api::GatewayConnection def initialize(params = {}) @params = parse_params(params) @@ -35,27 +53,23 @@ def parse_params(params = {}) params end - def connection - @@gateway_connection ||= RestConnection::Connection.new - settings = @@gateway_connection.settings - settings[:common_headers]["X_API_VERSION"] = "1.5" - settings[:api_href], account = settings[:api_url].split(/\/acct\//) if settings[:api_url].include?("acct") - settings[:extension] = ".json" + def nickname + @params["nickname"] || @params["name"] + end - unless @@gateway_connection.respond_to?(:refresh_cookie) - @@gateway_connection.instance_exec(&(RightScale::Api::GATEWAY_COOKIE_REFRESH)) + def rediscover + self.reload if @params['href'] + raise "Cannot find attribute 'nickname' or 'name' in #{self.inspect}. Aborting." unless self.nickname + if self.class.filters.include?(:name) + @params = self.class.find_with_filter(:name => self.nickname).first.params + else + @params = self.class.find_by(:name) { |n| n == self.nickname }.first.params end - - @@gateway_connection.refresh_cookie unless @@gateway_connection.cookie - @@gateway_connection end def hash_of_links ret = {} - unless @params['links']# and not (@params['nickname'] or @params['name']) - @params = Kernel.const_get(self.class.to_s).find_by(:name) { |n| n == self.nickname }.first.params - connection.logger("in hash_of_links: @params = #{@params.inspect}") if ENV['REST_CONNECT_DEBUG'] - end + self.rediscover unless @params['links'] @params['links'].each { |link| ret[link['rel']] = link['href'] } if @params['links'] ret end @@ -63,22 +77,14 @@ def hash_of_links def href return @params['href'] if @params['href'] ret = nil - unless @params['links'] - raise "Cannot find attribute 'nickname' or 'name' in #{self.inspect}. Aborting." unless self.nickname - @params = Kernel.const_get(self.class.to_s).find_by(:name) { |n| n == self.nickname }.first.params - connection.logger("in href: @params = #{@params.inspect}") if ENV['REST_CONNECT_DEBUG'] - end + self.rediscover unless @params['links'] @params['links'].each { |link| ret = link['href'] if link['rel'] == 'self' } ret end def actions ret = [] - unless @params['actions'] - raise "Cannot find attribute 'nickname' or 'name' in #{self.inspect}. Aborting." unless self.nickname - @params = Kernel.const_get(self.class.to_s).find_by(:name) { |n| n == self.nickname }.first.params - connection.logger("in actions: @params = #{@params.inspect}") if ENV['REST_CONNECT_DEBUG'] - end + self.rediscover unless @params['actions'] @params['actions'].each { |action| ret << action['rel'] } ret end @@ -179,23 +185,14 @@ def load(resource) module GatewayExtend include RightScale::Api::BaseExtend - def connection - @@gateway_connection ||= RestConnection::Connection.new - settings = @@gateway_connection.settings - settings[:common_headers]["X_API_VERSION"] = "1.5" - settings[:api_href], account = settings[:api_url].split(/\/acct\//) if settings[:api_url].include?("acct") - settings[:extension] = ".json" - - unless @@gateway_connection.respond_to?(:refresh_cookie) - @@gateway_connection.instance_exec(&(RightScale::Api::GATEWAY_COOKIE_REFRESH)) - end - - @@gateway_connection.refresh_cookie unless @@gateway_connection.cookie - @@gateway_connection - end + include RightScale::Api::GatewayConnection def find_by(attrib, *args, &block) + attrib = attrib.to_sym attrib = :name if attrib == :nickname + if self.filters.include?(attrib) + connection.logger("#{self} includes the filter '#{attrib}', you might be able to speed up this API call") + end self.find_all(*args).select do |s| yield(s[attrib.to_s]) end @@ -212,7 +209,6 @@ def find(*args) end def find_all(*args) -# self.find_with_filter(*args, {}) a = Array.new url = "#{parse_args(*args)}#{self.resource_plural_name}" connection.get(url).each do |object| diff --git a/lib/rest_connection/rightscale/rightscale_api_internal.rb b/lib/rest_connection/rightscale/rightscale_api_internal.rb index 7ff85ea..beeb6f0 100644 --- a/lib/rest_connection/rightscale/rightscale_api_internal.rb +++ b/lib/rest_connection/rightscale/rightscale_api_internal.rb @@ -1,8 +1,8 @@ module RightScale module Api - module Internal - def connection - @@little_brother_connection ||= RestConnection::Connection.new + module InternalConnection + def connection(*opts) + @@little_brother_connection ||= RestConnection::Connection.new(*opts) settings = @@little_brother_connection.settings settings[:common_headers]["X_API_VERSION"] = "0.1" settings[:api_href] = settings[:api_url] @@ -11,16 +11,12 @@ def connection end end + module Internal + include RightScale::Api::InternalConnection + end + module InternalExtend - def connection - @@little_brother_connection ||= RestConnection::Connection.new - settings = @@little_brother_connection.settings - settings[:common_headers]["X_API_VERSION"] = "0.1" - settings[:api_href] = settings[:api_url] - settings[:extension] = ".js" - @@little_brother_connection - end + include RightScale::Api::InternalConnection end end end - diff --git a/lib/rest_connection/rightscale/rightscale_api_resources.rb b/lib/rest_connection/rightscale/rightscale_api_resources.rb index e4fac0d..c487e59 100644 --- a/lib/rest_connection/rightscale/rightscale_api_resources.rb +++ b/lib/rest_connection/rightscale/rightscale_api_resources.rb @@ -38,6 +38,8 @@ require 'rest_connection/rightscale/tag' require 'rest_connection/rightscale/mc_tag' require 'rest_connection/rightscale/task' +require 'rest_connection/rightscale/backup' +require 'rest_connection/rightscale/mc_audit_entry' require 'rest_connection/rightscale/rs_internal' require 'rest_connection/rightscale/audit_entry' require 'rest_connection/rightscale/alert_spec' @@ -59,6 +61,7 @@ require 'rest_connection/rightscale/mc_server_template' require 'rest_connection/rightscale/ec2_ssh_key_internal' require 'rest_connection/rightscale/server_template_internal' +require 'rest_connection/rightscale/right_script_attachment_internal' require 'rest_connection/rightscale/right_script_internal' require 'rest_connection/rightscale/multi_cloud_image_cloud_setting_internal' require 'rest_connection/rightscale/multi_cloud_image_internal' diff --git a/lib/rest_connection/rightscale/server.rb b/lib/rest_connection/rightscale/server.rb index b77b7e6..462a033 100644 --- a/lib/rest_connection/rightscale/server.rb +++ b/lib/rest_connection/rightscale/server.rb @@ -328,16 +328,10 @@ def cloud_id if self.state == "operational" return self["cloud_id"] end - cloud_ids = RestConnection::AWS_CLOUDS.map { |hsh| hsh["cloud_id"] } - - api0_1 = false - begin - api0_1 = true if Ec2SshKeyInternal.find_all - rescue - end + cloud_ids = RightScale::Api::AWS_CLOUDS.map { |hsh| hsh["cloud_id"] } # Try ssh keys - if self.ec2_ssh_key_href and api0_1 + if self.ec2_ssh_key_href and RightScale::Api::api0_1? ref = self.ec2_ssh_key_href cloud_ids.each { |cloud| if Ec2SshKeyInternal.find_by_cloud_id(cloud.to_s).select { |o| o.href == ref }.first From d15c9873052a92f92899e0f7ce04c255644491b8 Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Thu, 9 Feb 2012 21:24:18 -0800 Subject: [PATCH 133/239] Bugfixes --- lib/rest_connection/patches.rb | 8 ++++---- lib/rest_connection/rightscale/multi_cloud_image.rb | 1 + .../rightscale/multi_cloud_image_internal.rb | 1 + 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/rest_connection/patches.rb b/lib/rest_connection/patches.rb index 5a47608..ebe59fd 100644 --- a/lib/rest_connection/patches.rb +++ b/lib/rest_connection/patches.rb @@ -13,7 +13,7 @@ class Hash def deep_merge(second) target = dup return target unless second - unless self.class === second + unless Hash === second raise TypeError.new("can't convert #{second.class} into #{self.class}") end second.keys.each do |k| @@ -35,7 +35,7 @@ def deep_merge(second) def deep_merge!(second) return nil unless second - unless self.class === second + unless Hash === second raise TypeError.new("can't convert #{second.class} into #{self.class}") end second.each_pair do |k,v| @@ -56,7 +56,7 @@ class Array def deep_merge(second) target = dup return target unless second - unless self.class === second + unless Array === second raise TypeError.new("can't convert #{second.class} into #{self.class}") end second.each_index do |k| @@ -74,7 +74,7 @@ def deep_merge(second) def deep_merge!(second) return nil unless second - unless self.class === second + unless Array === second raise TypeError.new("can't convert #{second.class} into #{self.class}") end second.each_index do |k| diff --git a/lib/rest_connection/rightscale/multi_cloud_image.rb b/lib/rest_connection/rightscale/multi_cloud_image.rb index 8118e5a..2124e4f 100644 --- a/lib/rest_connection/rightscale/multi_cloud_image.rb +++ b/lib/rest_connection/rightscale/multi_cloud_image.rb @@ -29,6 +29,7 @@ def find_and_flatten_settings() internal.reload total_image_count = internal.multi_cloud_image_cloud_settings.size # The .settings call filters out non-ec2 images + more_settings = [] if total_image_count > internal.settings.size more_settings = McMultiCloudImage.find(rs_id.to_i).get_settings end diff --git a/lib/rest_connection/rightscale/multi_cloud_image_internal.rb b/lib/rest_connection/rightscale/multi_cloud_image_internal.rb index 307acc7..5cc95d9 100644 --- a/lib/rest_connection/rightscale/multi_cloud_image_internal.rb +++ b/lib/rest_connection/rightscale/multi_cloud_image_internal.rb @@ -58,6 +58,7 @@ def transform_settings def initialize(params={}) @params = params + transform_settings end def settings From 229f31a5d80ecf1883954c5bd25f061cdf3815c7 Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Fri, 10 Feb 2012 03:20:35 -0800 Subject: [PATCH 134/239] Cleaning up bugs & additional code --- Rakefile | 1 + .../rightscale/ec2_server_array.rb | 9 ++++ .../rightscale/ec2_server_array_internal.rb | 43 ++++++++++++++++ lib/rest_connection/rightscale/ec2_ssh_key.rb | 9 ++++ .../rightscale/ec2_ssh_key_internal.rb | 4 +- .../rightscale/multi_cloud_image.rb | 9 ++++ ...ulti_cloud_image_cloud_setting_internal.rb | 2 + .../rightscale/right_script.rb | 8 +++ .../right_script_attachment_internal.rb | 50 +++++++++++++++++-- .../rightscale/right_script_internal.rb | 2 + .../rightscale/rightscale_api_base.rb | 43 +++++++--------- .../rightscale/rightscale_api_resources.rb | 12 +++-- lib/rest_connection/rightscale/server.rb | 11 +++- .../rightscale/server_internal.rb | 3 +- .../rightscale/server_template.rb | 9 +++- .../rightscale/server_template_internal.rb | 2 + 16 files changed, 177 insertions(+), 40 deletions(-) create mode 100644 lib/rest_connection/rightscale/ec2_server_array_internal.rb diff --git a/Rakefile b/Rakefile index b063df7..3639cae 100644 --- a/Rakefile +++ b/Rakefile @@ -11,5 +11,6 @@ Jeweler::Tasks.new do |gemspec| gemspec.add_dependency('net-ssh', "=2.1.4") gemspec.add_dependency('json') gemspec.add_dependency('highline') + gemspec.add_dependency('rest-client') end Jeweler::GemcutterTasks.new diff --git a/lib/rest_connection/rightscale/ec2_server_array.rb b/lib/rest_connection/rightscale/ec2_server_array.rb index 29c3cf7..1715b52 100644 --- a/lib/rest_connection/rightscale/ec2_server_array.rb +++ b/lib/rest_connection/rightscale/ec2_server_array.rb @@ -19,6 +19,15 @@ class Ec2ServerArray include RightScale::Api::Taggable extend RightScale::Api::TaggableExtend + attr_accessor :internal + + def initialize(*args, &block) + super(*args, &block) + if RightScale::Api::api0_1? + @internal = Ec2ServerArrayInternal.new(*args, &block) + end + end + # Example: # right_script = @server_template.executables.first # result = @my_array.run_script_on_all(right_script, [@server_template.href]) diff --git a/lib/rest_connection/rightscale/ec2_server_array_internal.rb b/lib/rest_connection/rightscale/ec2_server_array_internal.rb new file mode 100644 index 0000000..9f893cc --- /dev/null +++ b/lib/rest_connection/rightscale/ec2_server_array_internal.rb @@ -0,0 +1,43 @@ +# This file is part of RestConnection +# +# RestConnection is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# RestConnection is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with RestConnection. If not, see . + +class Ec2ServerArray + include RightScale::Api::Base + extend RightScale::Api::BaseExtend + include RightScale::Api::Taggable + extend RightScale::Api::TaggableExtend + + deny_methods :index, :show, :create, :update, :destroy + + def run_script_on_instances(script, ec2_instance_hrefs=[], opts={}) + uri = URI.parse(self.href) + case script + when Executable then script = script.right_script + when String then script = RightScript.new('href' => script) + end + + params = {:right_script_href => script.href} + unless ec2_instance_hrefs.nil? || ec2_instance_hrefs.empty? + params[:ec2_instance_hrefs] = ec2_instance_hrefs + end + unless opts.nil? || opts.empty? + params[:parameters] = opts + end + params = {:ec2_server_array => params} + connection.post(uri.path + "/run_script_on_instances", params).map do |work_unit| + Status.new('href' => location) + end + end +end diff --git a/lib/rest_connection/rightscale/ec2_ssh_key.rb b/lib/rest_connection/rightscale/ec2_ssh_key.rb index 20bb4b0..4de67f9 100644 --- a/lib/rest_connection/rightscale/ec2_ssh_key.rb +++ b/lib/rest_connection/rightscale/ec2_ssh_key.rb @@ -19,6 +19,8 @@ class Ec2SshKey deny_methods :index, :update + attr_accessor :internal + def self.create(opts) create_opts = { self.resource_singular_name.to_sym => opts } create_opts['cloud_id'] = opts['cloud_id'] if opts['cloud_id'] @@ -27,4 +29,11 @@ def self.create(opts) newrecord.reload newrecord end + + def initialize(*args, &block) + super(*args, &block) + if RightScale::Api::api0_1? + @internal = Ec2SshKeyInternal.new(*args, &block) + end + end end diff --git a/lib/rest_connection/rightscale/ec2_ssh_key_internal.rb b/lib/rest_connection/rightscale/ec2_ssh_key_internal.rb index 3d1106a..c669b7b 100644 --- a/lib/rest_connection/rightscale/ec2_ssh_key_internal.rb +++ b/lib/rest_connection/rightscale/ec2_ssh_key_internal.rb @@ -16,10 +16,11 @@ class Ec2SshKeyInternal include RightScale::Api::Base extend RightScale::Api::BaseExtend - include RightScale::Api::Internal extend RightScale::Api::InternalExtend + deny_methods :show, :create, :update, :destroy + def resource_plural_name "ec2_ssh_keys" end @@ -35,5 +36,4 @@ def self.resource_plural_name def self.resource_singular_name "ec2_ssh_key" end - end diff --git a/lib/rest_connection/rightscale/multi_cloud_image.rb b/lib/rest_connection/rightscale/multi_cloud_image.rb index 2124e4f..619b90c 100644 --- a/lib/rest_connection/rightscale/multi_cloud_image.rb +++ b/lib/rest_connection/rightscale/multi_cloud_image.rb @@ -19,6 +19,8 @@ class MultiCloudImage deny_methods :create, :destroy, :update + attr_accessor :internal + def supported_cloud_ids @params["multi_cloud_image_cloud_settings"].map { |mcics| mcics.cloud_id } end @@ -36,4 +38,11 @@ def find_and_flatten_settings() @params["multi_cloud_image_cloud_settings"] = internal.settings + more_settings end + def initialize(*args, &block) + super(*args, &block) + if RightScale::Api::api0_1? + @internal = MultiCloudImageInternal.new(*args, &block) + end + end + end diff --git a/lib/rest_connection/rightscale/multi_cloud_image_cloud_setting_internal.rb b/lib/rest_connection/rightscale/multi_cloud_image_cloud_setting_internal.rb index 7391a5c..7a661d3 100644 --- a/lib/rest_connection/rightscale/multi_cloud_image_cloud_setting_internal.rb +++ b/lib/rest_connection/rightscale/multi_cloud_image_cloud_setting_internal.rb @@ -19,6 +19,8 @@ class MultiCloudImageCloudSettingInternal include RightScale::Api::Internal extend RightScale::Api::InternalExtend + deny_methods :index, :show, :update + def resource_plural_name "multi_cloud_image_cloud_settings" end diff --git a/lib/rest_connection/rightscale/right_script.rb b/lib/rest_connection/rightscale/right_script.rb index 920cd2e..41efbbe 100644 --- a/lib/rest_connection/rightscale/right_script.rb +++ b/lib/rest_connection/rightscale/right_script.rb @@ -20,6 +20,8 @@ class RightScript deny_methods :create, :destroy, :update + attr_accessor :internal + def self.from_yaml(yaml) scripts = [] x = YAML.load(yaml) @@ -44,4 +46,10 @@ def self.from_instance_info(file = "/var/spool/ec2/rs_cache/info.yml") scripts end + def initialize(*args, &block) + super(*args, &block) + if RightScale::Api::api0_1? + @internal = RightScriptInternal.new(*args, &block) + end + end end diff --git a/lib/rest_connection/rightscale/right_script_attachment_internal.rb b/lib/rest_connection/rightscale/right_script_attachment_internal.rb index b3485aa..507952b 100644 --- a/lib/rest_connection/rightscale/right_script_attachment_internal.rb +++ b/lib/rest_connection/rightscale/right_script_attachment_internal.rb @@ -13,12 +13,17 @@ # You should have received a copy of the GNU General Public License # along with RestConnection. If not, see . +require 'rest-client' +RestClient.log = ENV["REST_CONNECTION_LOG"] || "stdout" + class RightScriptAttachmentInternal include RightScale::Api::Base extend RightScale::Api::BaseExtend include RightScale::Api::Internal extend RightScale::Api::InternalExtend + deny_methods :index, :create, :update + def resource_plural_name "right_script_attachments" end @@ -37,14 +42,51 @@ def self.resource_singular_name def self.get_s3_upload_params(right_script_href) url = self.resource_plural_name + "/get_s3_upload_params" - connection.get(url, {"right_script_href" => right_script_href}) + params = {"right_script_href" => right_script_href} + params = {self.resource_singular_name => params} + connection.get(url, params) end =begin - def self.upload(filedata, right_script_href) # TODO - end + def self.upload(filepath, right_script_href) + hsh = get_s3_upload_params(right_script_href) + params = {} + hsh.keys.each { |k| params[k.gsub(/-/,"_").to_sym] = hsh[k] } + params[:file] = File.new(filepath, 'rb') + req = RestClient::Request.new({ + :method => :post, + :url => hsh["url"], + :payload => params, + :multipart => true, + }) + s = req.payload.to_s + splitter = s.split("\r\n").first + a = s.split(/#{splitter}-?-?\r\n/) + a.push(a.delete(a.detect { |n| n =~ %r{name="file";} })) + new_payload = a.join(splitter + "\r\n") + splitter + "--\r\n" - def download # TODO + uri = URI.parse(hsh["url"]) + net_http = Net::HTTP::Post.new(uri.request_uri) + req.transmit(uri, net_http, new_payload) + # TODO: Precondition Failing + + callback_uri = URI.parse(hsh["success_action_redirect"]) + connection.get(callback_uri.request_uri) end =end + + def download + self.reload unless @params["authenticated_s3_url"] + RestClient.get(@params["authenticated_s3_url"]) + end + + def download_to_file(path=Dir.pwd) + data = self.download + File.open(File.join(path, @params["filename"]), 'w') { |f| f.write(data) } + end + + def reload + uri = URI.parse(self.href || "#{resource_plural_name}/#{@params["id"]}") + @params ? @params.merge!(connection.get(uri.path)) : @params = connection.get(uri.path) + end end diff --git a/lib/rest_connection/rightscale/right_script_internal.rb b/lib/rest_connection/rightscale/right_script_internal.rb index b9d51b5..2924e40 100644 --- a/lib/rest_connection/rightscale/right_script_internal.rb +++ b/lib/rest_connection/rightscale/right_script_internal.rb @@ -20,6 +20,8 @@ class RightScriptInternal include RightScale::Api::Internal extend RightScale::Api::InternalExtend + deny_methods :index, :show + def resource_plural_name "right_scripts" end diff --git a/lib/rest_connection/rightscale/rightscale_api_base.rb b/lib/rest_connection/rightscale/rightscale_api_base.rb index 3f47aa6..858f8ea 100644 --- a/lib/rest_connection/rightscale/rightscale_api_base.rb +++ b/lib/rest_connection/rightscale/rightscale_api_base.rb @@ -55,46 +55,41 @@ def self.update_connection_settings(*settings) class_variable_set("@@connection", RestConnection::Connection.new(*opts)) end end + @@api0_1, @@api1_0, @@api1_5 = nil, nil, nil true end # Check for API 0.1 Access def self.api0_1? - unless class_variable_defined?("@@api0_1") - begin - Ec2SshKeyInternal.find_all - @@api0_1 = true - rescue - @@api0_1 = false - end + if class_variable_defined?("@@api0_1") + return @@api0_1 unless @@api0_1.nil? end - return @@api0_1 + Ec2SshKeyInternal.find_all + @@api0_1 = true + rescue RestConnection::Errors::Forbidden + @@api0_1 = false end # Check for API 1.0 Access def self.api1_0? - unless class_variable_defined?("@@api1_0") - begin - Ec2SecurityGroup.find_all - @@api1_0 = true - rescue - @@api1_0 = false - end + if class_variable_defined?("@@api1_0") + return @@api1_0 unless @@api1_0.nil? end - return @@api1_0 + Ec2SecurityGroup.find_all + @@api1_0 = true + rescue RestConnection::Errors::Forbidden + @@api1_0 = false end # Check for API 1.5 Beta Access def self.api1_5? - unless class_variable_defined?("@@api1_5") - begin - Cloud.find_all - @@api1_5 = true - rescue - @@api1_5 = false - end + if class_variable_defined?("@@api1_5") + return @@api1_5 unless @@api1_5.nil? end - return @@api1_5 + Cloud.find_all + @@api1_5 = true + rescue RestConnection::Errors::Forbidden + @@api1_5 = false end module BaseConnection diff --git a/lib/rest_connection/rightscale/rightscale_api_resources.rb b/lib/rest_connection/rightscale/rightscale_api_resources.rb index c487e59..5d2b145 100644 --- a/lib/rest_connection/rightscale/rightscale_api_resources.rb +++ b/lib/rest_connection/rightscale/rightscale_api_resources.rb @@ -20,21 +20,23 @@ require 'rest_connection/rightscale/rightscale_api_taggable' require 'rest_connection/rightscale/rightscale_api_mc_taggable' require 'rest_connection/rightscale/rightscale_api_mc_input' +require 'rest_connection/ssh_hax' require 'rest_connection/rightscale/alert_spec_subject' require 'rest_connection/rightscale/server_ec2_ebs_volume' require 'rest_connection/rightscale/sqs_queue' require 'rest_connection/rightscale/executable' require 'rest_connection/rightscale/cloud_account' +require 'rest_connection/rightscale/server_internal' require 'rest_connection/rightscale/server' require 'rest_connection/rightscale/deployment' require 'rest_connection/rightscale/status' +require 'rest_connection/rightscale/server_template_internal' require 'rest_connection/rightscale/server_template' -require 'rest_connection/rightscale/right_script' require 'rest_connection/rightscale/instance' require 'rest_connection/rightscale/ec2_security_group' require 'rest_connection/rightscale/vpc_dhcp_option' +require 'rest_connection/rightscale/ec2_ssh_key_internal' require 'rest_connection/rightscale/ec2_ssh_key' -require 'rest_connection/rightscale/multi_cloud_image' require 'rest_connection/rightscale/tag' require 'rest_connection/rightscale/mc_tag' require 'rest_connection/rightscale/task' @@ -49,7 +51,6 @@ require 'rest_connection/rightscale/mc_volume' require 'rest_connection/rightscale/mc_volume_snapshot' require 'rest_connection/rightscale/mc_volume_type' -require 'rest_connection/rightscale/server_internal' require 'rest_connection/rightscale/mc_server' require 'rest_connection/rightscale/server_interface' require 'rest_connection/rightscale/mc_instance' @@ -59,12 +60,13 @@ require 'rest_connection/rightscale/mc_multi_cloud_image' require 'rest_connection/rightscale/mc_server_template_multi_cloud_image' require 'rest_connection/rightscale/mc_server_template' -require 'rest_connection/rightscale/ec2_ssh_key_internal' -require 'rest_connection/rightscale/server_template_internal' require 'rest_connection/rightscale/right_script_attachment_internal' require 'rest_connection/rightscale/right_script_internal' +require 'rest_connection/rightscale/right_script' require 'rest_connection/rightscale/multi_cloud_image_cloud_setting_internal' require 'rest_connection/rightscale/multi_cloud_image_internal' +require 'rest_connection/rightscale/multi_cloud_image' +require 'rest_connection/rightscale/ec2_server_array_internal' require 'rest_connection/rightscale/ec2_server_array' require 'rest_connection/rightscale/mc_server_array' require 'rest_connection/rightscale/security_group_rule' diff --git a/lib/rest_connection/rightscale/server.rb b/lib/rest_connection/rightscale/server.rb index 462a033..7f53464 100644 --- a/lib/rest_connection/rightscale/server.rb +++ b/lib/rest_connection/rightscale/server.rb @@ -13,8 +13,6 @@ # You should have received a copy of the GNU General Public License # along with RestConnection. If not, see . -require 'rest_connection/ssh_hax' - class Server include RightScale::Api::Base extend RightScale::Api::BaseExtend @@ -22,6 +20,8 @@ class Server include RightScale::Api::Taggable extend RightScale::Api::TaggableExtend + attr_accessor :internal + def self.filters [ :aws_id, @@ -47,6 +47,13 @@ def self.create(opts) newrecord end + def initialize(*args, &block) + super(*args, &block) + if RightScale::Api::api0_1? + @internal = ServerInternal.new(*args, &block) + end + end + # The RightScale api returns the server parameters as a hash with "name" and "value". # This must be transformed into a hash in case we want to PUT this back to the API. def transform_parameters(parameters) diff --git a/lib/rest_connection/rightscale/server_internal.rb b/lib/rest_connection/rightscale/server_internal.rb index 9099268..74d723c 100644 --- a/lib/rest_connection/rightscale/server_internal.rb +++ b/lib/rest_connection/rightscale/server_internal.rb @@ -20,10 +20,11 @@ class ServerInternal include RightScale::Api::Base extend RightScale::Api::BaseExtend include SshHax - include RightScale::Api::Internal extend RightScale::Api::InternalExtend + deny_methods :index, :show, :create, :destroy, :update + def resource_plural_name "servers" end diff --git a/lib/rest_connection/rightscale/server_template.rb b/lib/rest_connection/rightscale/server_template.rb index 208bf45..35afc2b 100644 --- a/lib/rest_connection/rightscale/server_template.rb +++ b/lib/rest_connection/rightscale/server_template.rb @@ -19,8 +19,13 @@ class ServerTemplate include RightScale::Api::Taggable extend RightScale::Api::TaggableExtend - def initialize(params) - @params = params + attr_accessor :internal + + def initialize(*args, &block) + super(*args, &block) + if RightScale::Api::api0_1? + @internal = ServerTemplateInternal.new(*args, &block) + end end def reload diff --git a/lib/rest_connection/rightscale/server_template_internal.rb b/lib/rest_connection/rightscale/server_template_internal.rb index a96c688..af7b3bb 100644 --- a/lib/rest_connection/rightscale/server_template_internal.rb +++ b/lib/rest_connection/rightscale/server_template_internal.rb @@ -19,6 +19,8 @@ class ServerTemplateInternal include RightScale::Api::Internal extend RightScale::Api::InternalExtend + deny_methods :index, :create, :show, :update, :destroy + def resource_plural_name "server_templates" end From c1ed5d14f07552a8c6f88d7b0693094f79abb41c Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Fri, 10 Feb 2012 03:22:26 -0800 Subject: [PATCH 135/239] Version bump to 0.1.3 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 8294c18..7693c96 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.1.2 \ No newline at end of file +0.1.3 \ No newline at end of file From 0691d0833603ba2dfa2965736abb7bb4d2a56b45 Mon Sep 17 00:00:00 2001 From: Tim Rodriguez Date: Fri, 10 Feb 2012 03:24:56 -0800 Subject: [PATCH 136/239] Updated README to put RightScale's repo as default --- README.rdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rdoc b/README.rdoc index ff32098..37bce93 100644 --- a/README.rdoc +++ b/README.rdoc @@ -4,7 +4,7 @@ "gem install rest_connection" ==== Installing from source - "git clone http://github.com/twrodriguez/rest_connection.git" + "git clone http://github.com/rightscale/rest_connection.git" "gem install jeweler rspec" "rake check_dependencies" <- Install any gems listed. "rake install" From 3a601d2b058f4eea8f65352848e1292f62201d0e Mon Sep 17 00:00:00 2001 From: Jon Marinello Date: Mon, 27 Feb 2012 21:15:26 +0000 Subject: [PATCH 137/239] Added code to prevent @params from getting stepped on (non-hash) and improved logging messages. --- lib/rest_connection.rb | 2 +- lib/rest_connection/rightscale/rightscale_api_gateway.rb | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/rest_connection.rb b/lib/rest_connection.rb index bffdcc6..567e575 100644 --- a/lib/rest_connection.rb +++ b/lib/rest_connection.rb @@ -205,7 +205,7 @@ def delete(href, additional_parameters = {}) def handle_response(res) if res.code.to_i == 201 or res.code.to_i == 202 return res['Location'] - elsif [200,203,204,302].detect { |d| d == res.code.to_i } + elsif [200,203,204].detect { |d| d == res.code.to_i } if res.body begin return JSON.load(res.body) diff --git a/lib/rest_connection/rightscale/rightscale_api_gateway.rb b/lib/rest_connection/rightscale/rightscale_api_gateway.rb index 95ac893..0670a19 100644 --- a/lib/rest_connection/rightscale/rightscale_api_gateway.rb +++ b/lib/rest_connection/rightscale/rightscale_api_gateway.rb @@ -54,6 +54,7 @@ def parse_params(params = {}) end def nickname + raise TypeError.new("@params isn't a Hash! @params.to_s=#{@params.to_s}") unless @params.is_a?(Hash) @params["nickname"] || @params["name"] end @@ -94,7 +95,7 @@ def save end def method_missing(method_name, *args) - puts "DEBUG: method_missing in #{self.class.to_s}: #{method_name}" if ENV['REST_CONNECT_DEBUG'] + puts "DEBUG: method_missing in #{self.class.to_s}: #{method_name.to_s}" if ENV['REST_CONNECT_DEBUG'] mn = method_name.to_s assignment = mn.gsub!(/=/,"") mn_dash = mn.gsub(/_/,"-") @@ -118,7 +119,8 @@ def method_missing(method_name, *args) return self[mn] else return nil - #raise "called unknown method #{method_name} with #{args.inspect}" + warn "!!!! WARNING - called unknown method #{method_name.to_s}# with #{args.inspect}" + #raise "called unknown method #{method_name.to_s}# with #{args.inspect}" end end From 578104a93dd3b0494f0da6c20de8b5439b920563 Mon Sep 17 00:00:00 2001 From: Jon Marinello Date: Mon, 27 Feb 2012 22:17:29 +0000 Subject: [PATCH 138/239] Updated to push 0.1.4 --- rest_connection.gemspec | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/rest_connection.gemspec b/rest_connection.gemspec index 3d639c9..30eaea6 100644 --- a/rest_connection.gemspec +++ b/rest_connection.gemspec @@ -5,13 +5,13 @@ Gem::Specification.new do |s| s.name = "rest_connection" - s.version = "0.1.0" + s.version = "0.1.4" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["Jeremy Deininger", "Timothy Rodriguez"] - s.date = "2011-11-01" + s.date = "2012-02-27" s.description = "provides rest_connection" - s.email = ["jeremy@rubyonlinux.org", "tw.rodriguez@gmail.com"] + s.email = ["daniel.onorato@rightscale.com"] s.extra_rdoc_files = [ "README.rdoc" ] @@ -110,7 +110,7 @@ Gem::Specification.new do |s| "spec/spec_helper.rb", "spec/tag_spec.rb" ] - s.homepage = "http://github.com/twrodriguez/rest_connection" + s.homepage = "http://github.com/rigthscale/rest_connection" s.require_paths = ["lib"] s.rubygems_version = "1.7.2" s.summary = "lib for restful connections to the rightscale api" From a4ca36fa4b613035cd7203daa6f292b734554414 Mon Sep 17 00:00:00 2001 From: Jon Marinello Date: Mon, 27 Feb 2012 23:19:38 +0000 Subject: [PATCH 139/239] Updated the correct files this time to corretly upload the gem file. --- Rakefile | 2 +- VERSION | 2 +- rest_connection.gemspec | 24 ++++++++++++++++++++---- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/Rakefile b/Rakefile index 3639cae..3f02b4a 100644 --- a/Rakefile +++ b/Rakefile @@ -4,7 +4,7 @@ Jeweler::Tasks.new do |gemspec| gemspec.name = "rest_connection" gemspec.summary = "Modular RESTful API library" gemspec.description = "A Modular RESTful API library. Current implemented modules: RightScale API" - gemspec.email = ["jeremy@rubyonlinux.org", "tw.rodriguez@gmail.com"] + gemspec.email = ["daniel.onorato@rightscale.com"] gemspec.homepage = "http://github.com/rightscale/rest_connection" gemspec.authors = ["Jeremy Deininger", "Timothy Rodriguez"] gemspec.add_dependency('activesupport', "=2.3.10") diff --git a/VERSION b/VERSION index 7693c96..845639e 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.1.3 \ No newline at end of file +0.1.4 diff --git a/rest_connection.gemspec b/rest_connection.gemspec index 30eaea6..17490b1 100644 --- a/rest_connection.gemspec +++ b/rest_connection.gemspec @@ -10,7 +10,7 @@ Gem::Specification.new do |s| s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["Jeremy Deininger", "Timothy Rodriguez"] s.date = "2012-02-27" - s.description = "provides rest_connection" + s.description = "A Modular RESTful API library. Current implemented modules: RightScale API" s.email = ["daniel.onorato@rightscale.com"] s.extra_rdoc_files = [ "README.rdoc" @@ -29,6 +29,7 @@ Gem::Specification.new do |s| "examples/cucumber/step_definitions/spot_check_steps.rb", "examples/relaunch_deployment.rb", "examples/right_scale_ec2_instances_api_test.rb", + "git_hooks/post-commit", "git_hooks/post-commit.disabled", "git_hooks/post-merge.disabled", "git_hooks/pre-commit", @@ -36,9 +37,12 @@ Gem::Specification.new do |s| "lib/rest_connection/patches.rb", "lib/rest_connection/rightscale/account.rb", "lib/rest_connection/rightscale/alert_spec.rb", + "lib/rest_connection/rightscale/alert_spec_subject.rb", "lib/rest_connection/rightscale/audit_entry.rb", + "lib/rest_connection/rightscale/backup.rb", "lib/rest_connection/rightscale/child_account.rb", "lib/rest_connection/rightscale/cloud.rb", + "lib/rest_connection/rightscale/cloud_account.rb", "lib/rest_connection/rightscale/credential.rb", "lib/rest_connection/rightscale/deployment.rb", "lib/rest_connection/rightscale/ec2_ebs_snapshot.rb", @@ -46,12 +50,14 @@ Gem::Specification.new do |s| "lib/rest_connection/rightscale/ec2_elastic_ip.rb", "lib/rest_connection/rightscale/ec2_security_group.rb", "lib/rest_connection/rightscale/ec2_server_array.rb", + "lib/rest_connection/rightscale/ec2_server_array_internal.rb", "lib/rest_connection/rightscale/ec2_ssh_key.rb", "lib/rest_connection/rightscale/ec2_ssh_key_internal.rb", "lib/rest_connection/rightscale/executable.rb", "lib/rest_connection/rightscale/instance.rb", "lib/rest_connection/rightscale/instance_type.rb", "lib/rest_connection/rightscale/macro.rb", + "lib/rest_connection/rightscale/mc_audit_entry.rb", "lib/rest_connection/rightscale/mc_datacenter.rb", "lib/rest_connection/rightscale/mc_deployment.rb", "lib/rest_connection/rightscale/mc_image.rb", @@ -63,6 +69,7 @@ Gem::Specification.new do |s| "lib/rest_connection/rightscale/mc_server.rb", "lib/rest_connection/rightscale/mc_server_array.rb", "lib/rest_connection/rightscale/mc_server_template.rb", + "lib/rest_connection/rightscale/mc_server_template_multi_cloud_image.rb", "lib/rest_connection/rightscale/mc_ssh_key.rb", "lib/rest_connection/rightscale/mc_tag.rb", "lib/rest_connection/rightscale/mc_volume.rb", @@ -75,6 +82,7 @@ Gem::Specification.new do |s| "lib/rest_connection/rightscale/multi_cloud_image_internal.rb", "lib/rest_connection/rightscale/permission.rb", "lib/rest_connection/rightscale/right_script.rb", + "lib/rest_connection/rightscale/right_script_attachment_internal.rb", "lib/rest_connection/rightscale/right_script_internal.rb", "lib/rest_connection/rightscale/rightscale_api_base.rb", "lib/rest_connection/rightscale/rightscale_api_gateway.rb", @@ -85,15 +93,20 @@ Gem::Specification.new do |s| "lib/rest_connection/rightscale/rightscale_api_taggable.rb", "lib/rest_connection/rightscale/rs_internal.rb", "lib/rest_connection/rightscale/s3_bucket.rb", + "lib/rest_connection/rightscale/security_group_rule.rb", "lib/rest_connection/rightscale/server.rb", + "lib/rest_connection/rightscale/server_ec2_ebs_volume.rb", "lib/rest_connection/rightscale/server_interface.rb", "lib/rest_connection/rightscale/server_internal.rb", "lib/rest_connection/rightscale/server_template.rb", "lib/rest_connection/rightscale/server_template_internal.rb", + "lib/rest_connection/rightscale/session.rb", + "lib/rest_connection/rightscale/sqs_queue.rb", "lib/rest_connection/rightscale/status.rb", "lib/rest_connection/rightscale/tag.rb", "lib/rest_connection/rightscale/task.rb", "lib/rest_connection/rightscale/user.rb", + "lib/rest_connection/rightscale/vpc_dhcp_option.rb", "lib/rest_connection/ssh_hax.rb", "rest_connection.gemspec", "spec/ec2_server_array_spec.rb", @@ -110,10 +123,10 @@ Gem::Specification.new do |s| "spec/spec_helper.rb", "spec/tag_spec.rb" ] - s.homepage = "http://github.com/rigthscale/rest_connection" + s.homepage = "http://github.com/rightscale/rest_connection" s.require_paths = ["lib"] - s.rubygems_version = "1.7.2" - s.summary = "lib for restful connections to the rightscale api" + s.rubygems_version = "1.8.17" + s.summary = "Modular RESTful API library" if s.respond_to? :specification_version then s.specification_version = 3 @@ -123,17 +136,20 @@ Gem::Specification.new do |s| s.add_runtime_dependency(%q, ["= 2.1.4"]) s.add_runtime_dependency(%q, [">= 0"]) s.add_runtime_dependency(%q, [">= 0"]) + s.add_runtime_dependency(%q, [">= 0"]) else s.add_dependency(%q, ["= 2.3.10"]) s.add_dependency(%q, ["= 2.1.4"]) s.add_dependency(%q, [">= 0"]) s.add_dependency(%q, [">= 0"]) + s.add_dependency(%q, [">= 0"]) end else s.add_dependency(%q, ["= 2.3.10"]) s.add_dependency(%q, ["= 2.1.4"]) s.add_dependency(%q, [">= 0"]) s.add_dependency(%q, [">= 0"]) + s.add_dependency(%q, [">= 0"]) end end From 20b0bf5d41b12cf063f7400c0263a0d2fd135fa0 Mon Sep 17 00:00:00 2001 From: Jon Marinello Date: Mon, 27 Feb 2012 23:40:01 +0000 Subject: [PATCH 140/239] Bumbed version number to allow us to fix the doc problem up on rubygems. --- VERSION | 2 +- rest_connection.gemspec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/VERSION b/VERSION index 845639e..9faa1b7 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.1.4 +0.1.5 diff --git a/rest_connection.gemspec b/rest_connection.gemspec index 17490b1..6583560 100644 --- a/rest_connection.gemspec +++ b/rest_connection.gemspec @@ -5,7 +5,7 @@ Gem::Specification.new do |s| s.name = "rest_connection" - s.version = "0.1.4" + s.version = "0.1.5" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["Jeremy Deininger", "Timothy Rodriguez"] From 44f3d008ea405da2806d1698b58ea6950a7aeacb Mon Sep 17 00:00:00 2001 From: Christopher Deutsch Date: Fri, 2 Mar 2012 13:30:57 -0800 Subject: [PATCH 141/239] class name of Ec2ServerArrayInternal was erroniously set to Ec2ServerArray --- lib/rest_connection/rightscale/ec2_server_array_internal.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rest_connection/rightscale/ec2_server_array_internal.rb b/lib/rest_connection/rightscale/ec2_server_array_internal.rb index 9f893cc..b04f31b 100644 --- a/lib/rest_connection/rightscale/ec2_server_array_internal.rb +++ b/lib/rest_connection/rightscale/ec2_server_array_internal.rb @@ -13,7 +13,7 @@ # You should have received a copy of the GNU General Public License # along with RestConnection. If not, see . -class Ec2ServerArray +class Ec2ServerArrayInternal include RightScale::Api::Base extend RightScale::Api::BaseExtend include RightScale::Api::Taggable From ecaf4647e2f6a01f1b2d7f231d0df506f7bb26cf Mon Sep 17 00:00:00 2001 From: Jon Marinello Date: Tue, 6 Mar 2012 17:53:45 +0000 Subject: [PATCH 142/239] Added instructions for creating the gem and pusing to rubygems.org. --- README.rdoc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.rdoc b/README.rdoc index 37bce93..6e74eda 100644 --- a/README.rdoc +++ b/README.rdoc @@ -47,3 +47,10 @@ Copy the example from GEMHOME/rest_connection/examples/rest_api_config.yaml.samp puts my_array.instances.map { |i| i['ip-address'] } +=== To cut a new gem and push to rubygems.org + + Edit VERSION and bump the number + rake gemspec + rake install + visit www.rubygems.org + gem push pkg/rest_connection-0.0.0.gem (use your new version number in this command) From 3b14924787e812fbf58f1941c179c17b6aded3c1 Mon Sep 17 00:00:00 2001 From: Jon Marinello Date: Tue, 6 Mar 2012 17:55:10 +0000 Subject: [PATCH 143/239] Christopher Deutsch's rest_connection fix for Ec2ServerArray regression. Bumped version to 0.1.6. --- VERSION | 2 +- rest_connection.gemspec | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/VERSION b/VERSION index 9faa1b7..c946ee6 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.1.5 +0.1.6 diff --git a/rest_connection.gemspec b/rest_connection.gemspec index 6583560..f21d950 100644 --- a/rest_connection.gemspec +++ b/rest_connection.gemspec @@ -5,11 +5,11 @@ Gem::Specification.new do |s| s.name = "rest_connection" - s.version = "0.1.5" + s.version = "0.1.6" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["Jeremy Deininger", "Timothy Rodriguez"] - s.date = "2012-02-27" + s.date = "2012-03-06" s.description = "A Modular RESTful API library. Current implemented modules: RightScale API" s.email = ["daniel.onorato@rightscale.com"] s.extra_rdoc_files = [ From a164c678b99617f32316de481a78330feabecc28 Mon Sep 17 00:00:00 2001 From: Christopher Deutsch Date: Wed, 7 Mar 2012 16:09:22 -0800 Subject: [PATCH 144/239] fix includes/extends required for internal API controllers fix bad variable name --- .../rightscale/ec2_server_array_internal.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/rest_connection/rightscale/ec2_server_array_internal.rb b/lib/rest_connection/rightscale/ec2_server_array_internal.rb index b04f31b..62370a6 100644 --- a/lib/rest_connection/rightscale/ec2_server_array_internal.rb +++ b/lib/rest_connection/rightscale/ec2_server_array_internal.rb @@ -16,9 +16,9 @@ class Ec2ServerArrayInternal include RightScale::Api::Base extend RightScale::Api::BaseExtend - include RightScale::Api::Taggable - extend RightScale::Api::TaggableExtend - + include RightScale::Api::Internal + extend RightScale::Api::InternalExtend + deny_methods :index, :show, :create, :update, :destroy def run_script_on_instances(script, ec2_instance_hrefs=[], opts={}) @@ -28,7 +28,7 @@ def run_script_on_instances(script, ec2_instance_hrefs=[], opts={}) when String then script = RightScript.new('href' => script) end - params = {:right_script_href => script.href} + params = {:right_script_href => script.href, :format => 'js'} unless ec2_instance_hrefs.nil? || ec2_instance_hrefs.empty? params[:ec2_instance_hrefs] = ec2_instance_hrefs end @@ -37,7 +37,7 @@ def run_script_on_instances(script, ec2_instance_hrefs=[], opts={}) end params = {:ec2_server_array => params} connection.post(uri.path + "/run_script_on_instances", params).map do |work_unit| - Status.new('href' => location) + Status.new('href' => work_unit) end end end From 927b7cffdc364d148384d6d587f1579256f6f6d9 Mon Sep 17 00:00:00 2001 From: Christopher Deutsch Date: Wed, 7 Mar 2012 16:10:41 -0800 Subject: [PATCH 145/239] add nokogiri dependency for XML parsing --- lib/rest_connection.rb | 16 +++++++++++++++- rest_connection.gemspec | 1 + 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/rest_connection.rb b/lib/rest_connection.rb index 567e575..1f831d0 100644 --- a/lib/rest_connection.rb +++ b/lib/rest_connection.rb @@ -22,6 +22,7 @@ require 'rest_connection/patches' require 'logger' require 'highline/import' +require 'nokogiri' module RestConnection class Connection @@ -204,8 +205,21 @@ def delete(href, additional_parameters = {}) # decoding and post processing goes here. This is where you may need some customization if you want to handle the response differently (or not at all!). Luckily it's easy to modify based on this handler. def handle_response(res) if res.code.to_i == 201 or res.code.to_i == 202 - return res['Location'] + # + # In most cases, it's safe to return the location + # + if res['Location'] + return res['Location'] + else + # + # Ec2ServerArrayInternal.run_script_on_instances returns XML. + # We need to parse it to retrieve the href's to audit entries. + # + xml_response = Nokogiri::XML(res.body) + return xml_response.xpath('audit-entries/audit-entry/href').map { |href| href.content } + end elsif [200,203,204].detect { |d| d == res.code.to_i } + if res.body begin return JSON.load(res.body) diff --git a/rest_connection.gemspec b/rest_connection.gemspec index f21d950..82cfad1 100644 --- a/rest_connection.gemspec +++ b/rest_connection.gemspec @@ -137,6 +137,7 @@ Gem::Specification.new do |s| s.add_runtime_dependency(%q, [">= 0"]) s.add_runtime_dependency(%q, [">= 0"]) s.add_runtime_dependency(%q, [">= 0"]) + s.add_runtime_dependency(%q, [">= 0"]) else s.add_dependency(%q, ["= 2.3.10"]) s.add_dependency(%q, ["= 2.1.4"]) From af9e8ee6a18eb5ef33bd6349e3fa4330a4bb22f7 Mon Sep 17 00:00:00 2001 From: Christopher Deutsch Date: Thu, 8 Mar 2012 16:54:36 -0800 Subject: [PATCH 146/239] return array of Status objects instead of just one --- lib/rest_connection/rightscale/ec2_server_array_internal.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/rest_connection/rightscale/ec2_server_array_internal.rb b/lib/rest_connection/rightscale/ec2_server_array_internal.rb index 62370a6..b78be5e 100644 --- a/lib/rest_connection/rightscale/ec2_server_array_internal.rb +++ b/lib/rest_connection/rightscale/ec2_server_array_internal.rb @@ -28,7 +28,7 @@ def run_script_on_instances(script, ec2_instance_hrefs=[], opts={}) when String then script = RightScript.new('href' => script) end - params = {:right_script_href => script.href, :format => 'js'} + params = {:right_script_href => script.href } unless ec2_instance_hrefs.nil? || ec2_instance_hrefs.empty? params[:ec2_instance_hrefs] = ec2_instance_hrefs end @@ -36,8 +36,10 @@ def run_script_on_instances(script, ec2_instance_hrefs=[], opts={}) params[:parameters] = opts end params = {:ec2_server_array => params} + status_array=[] connection.post(uri.path + "/run_script_on_instances", params).map do |work_unit| - Status.new('href' => work_unit) + status_array.push Status.new('href' => work_unit) end + return(status_array) end end From 5dd92187e7b0307f2a62099fd4eeb4dc37a4f780 Mon Sep 17 00:00:00 2001 From: Christopher Deutsch Date: Wed, 14 Mar 2012 10:52:22 -0700 Subject: [PATCH 147/239] add nokogiri --- Rakefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Rakefile b/Rakefile index 3f02b4a..ab89be8 100644 --- a/Rakefile +++ b/Rakefile @@ -12,5 +12,6 @@ Jeweler::Tasks.new do |gemspec| gemspec.add_dependency('json') gemspec.add_dependency('highline') gemspec.add_dependency('rest-client') + gemspec.add_dependency('nokogiri') end Jeweler::GemcutterTasks.new From caf047421ee5555ea5a2471a54143b5b7abdb8c9 Mon Sep 17 00:00:00 2001 From: Jon Marinello Date: Wed, 14 Mar 2012 20:24:06 +0000 Subject: [PATCH 148/239] Updated VERSION to 0.1.7 and removed rest_connection.gemspec from git since it is generated by running rake gemspec. --- VERSION | 2 +- rest_connection.gemspec | 156 ---------------------------------------- 2 files changed, 1 insertion(+), 157 deletions(-) delete mode 100644 rest_connection.gemspec diff --git a/VERSION b/VERSION index c946ee6..1180819 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.1.6 +0.1.7 diff --git a/rest_connection.gemspec b/rest_connection.gemspec deleted file mode 100644 index 82cfad1..0000000 --- a/rest_connection.gemspec +++ /dev/null @@ -1,156 +0,0 @@ -# Generated by jeweler -# DO NOT EDIT THIS FILE DIRECTLY -# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec' -# -*- encoding: utf-8 -*- - -Gem::Specification.new do |s| - s.name = "rest_connection" - s.version = "0.1.6" - - s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= - s.authors = ["Jeremy Deininger", "Timothy Rodriguez"] - s.date = "2012-03-06" - s.description = "A Modular RESTful API library. Current implemented modules: RightScale API" - s.email = ["daniel.onorato@rightscale.com"] - s.extra_rdoc_files = [ - "README.rdoc" - ] - s.files = [ - "README.rdoc", - "Rakefile", - "VERSION", - "config/rest_api_config.yaml.sample", - "examples/README.txt", - "examples/console.rb", - "examples/cucumber/2mysql_5.x_v2_beta_from_scratch.feature", - "examples/cucumber/step_definitions/deployment_steps.rb", - "examples/cucumber/step_definitions/mysql_steps.rb", - "examples/cucumber/step_definitions/recipe_steps.rb", - "examples/cucumber/step_definitions/spot_check_steps.rb", - "examples/relaunch_deployment.rb", - "examples/right_scale_ec2_instances_api_test.rb", - "git_hooks/post-commit", - "git_hooks/post-commit.disabled", - "git_hooks/post-merge.disabled", - "git_hooks/pre-commit", - "lib/rest_connection.rb", - "lib/rest_connection/patches.rb", - "lib/rest_connection/rightscale/account.rb", - "lib/rest_connection/rightscale/alert_spec.rb", - "lib/rest_connection/rightscale/alert_spec_subject.rb", - "lib/rest_connection/rightscale/audit_entry.rb", - "lib/rest_connection/rightscale/backup.rb", - "lib/rest_connection/rightscale/child_account.rb", - "lib/rest_connection/rightscale/cloud.rb", - "lib/rest_connection/rightscale/cloud_account.rb", - "lib/rest_connection/rightscale/credential.rb", - "lib/rest_connection/rightscale/deployment.rb", - "lib/rest_connection/rightscale/ec2_ebs_snapshot.rb", - "lib/rest_connection/rightscale/ec2_ebs_volume.rb", - "lib/rest_connection/rightscale/ec2_elastic_ip.rb", - "lib/rest_connection/rightscale/ec2_security_group.rb", - "lib/rest_connection/rightscale/ec2_server_array.rb", - "lib/rest_connection/rightscale/ec2_server_array_internal.rb", - "lib/rest_connection/rightscale/ec2_ssh_key.rb", - "lib/rest_connection/rightscale/ec2_ssh_key_internal.rb", - "lib/rest_connection/rightscale/executable.rb", - "lib/rest_connection/rightscale/instance.rb", - "lib/rest_connection/rightscale/instance_type.rb", - "lib/rest_connection/rightscale/macro.rb", - "lib/rest_connection/rightscale/mc_audit_entry.rb", - "lib/rest_connection/rightscale/mc_datacenter.rb", - "lib/rest_connection/rightscale/mc_deployment.rb", - "lib/rest_connection/rightscale/mc_image.rb", - "lib/rest_connection/rightscale/mc_instance.rb", - "lib/rest_connection/rightscale/mc_instance_type.rb", - "lib/rest_connection/rightscale/mc_multi_cloud_image.rb", - "lib/rest_connection/rightscale/mc_multi_cloud_image_setting.rb", - "lib/rest_connection/rightscale/mc_security_group.rb", - "lib/rest_connection/rightscale/mc_server.rb", - "lib/rest_connection/rightscale/mc_server_array.rb", - "lib/rest_connection/rightscale/mc_server_template.rb", - "lib/rest_connection/rightscale/mc_server_template_multi_cloud_image.rb", - "lib/rest_connection/rightscale/mc_ssh_key.rb", - "lib/rest_connection/rightscale/mc_tag.rb", - "lib/rest_connection/rightscale/mc_volume.rb", - "lib/rest_connection/rightscale/mc_volume_attachment.rb", - "lib/rest_connection/rightscale/mc_volume_snapshot.rb", - "lib/rest_connection/rightscale/mc_volume_type.rb", - "lib/rest_connection/rightscale/monitoring_metric.rb", - "lib/rest_connection/rightscale/multi_cloud_image.rb", - "lib/rest_connection/rightscale/multi_cloud_image_cloud_setting_internal.rb", - "lib/rest_connection/rightscale/multi_cloud_image_internal.rb", - "lib/rest_connection/rightscale/permission.rb", - "lib/rest_connection/rightscale/right_script.rb", - "lib/rest_connection/rightscale/right_script_attachment_internal.rb", - "lib/rest_connection/rightscale/right_script_internal.rb", - "lib/rest_connection/rightscale/rightscale_api_base.rb", - "lib/rest_connection/rightscale/rightscale_api_gateway.rb", - "lib/rest_connection/rightscale/rightscale_api_internal.rb", - "lib/rest_connection/rightscale/rightscale_api_mc_input.rb", - "lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb", - "lib/rest_connection/rightscale/rightscale_api_resources.rb", - "lib/rest_connection/rightscale/rightscale_api_taggable.rb", - "lib/rest_connection/rightscale/rs_internal.rb", - "lib/rest_connection/rightscale/s3_bucket.rb", - "lib/rest_connection/rightscale/security_group_rule.rb", - "lib/rest_connection/rightscale/server.rb", - "lib/rest_connection/rightscale/server_ec2_ebs_volume.rb", - "lib/rest_connection/rightscale/server_interface.rb", - "lib/rest_connection/rightscale/server_internal.rb", - "lib/rest_connection/rightscale/server_template.rb", - "lib/rest_connection/rightscale/server_template_internal.rb", - "lib/rest_connection/rightscale/session.rb", - "lib/rest_connection/rightscale/sqs_queue.rb", - "lib/rest_connection/rightscale/status.rb", - "lib/rest_connection/rightscale/tag.rb", - "lib/rest_connection/rightscale/task.rb", - "lib/rest_connection/rightscale/user.rb", - "lib/rest_connection/rightscale/vpc_dhcp_option.rb", - "lib/rest_connection/ssh_hax.rb", - "rest_connection.gemspec", - "spec/ec2_server_array_spec.rb", - "spec/ec2_ssh_key_internal_spec.rb", - "spec/image_jockey.rb", - "spec/mcserver_spec.rb", - "spec/method_missing_spec.rb", - "spec/multi.rb", - "spec/right_script_internal.rb", - "spec/rs_internal_spec.rb", - "spec/server_internal_spec.rb", - "spec/server_spec.rb", - "spec/server_template_internal.rb", - "spec/spec_helper.rb", - "spec/tag_spec.rb" - ] - s.homepage = "http://github.com/rightscale/rest_connection" - s.require_paths = ["lib"] - s.rubygems_version = "1.8.17" - s.summary = "Modular RESTful API library" - - if s.respond_to? :specification_version then - s.specification_version = 3 - - if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then - s.add_runtime_dependency(%q, ["= 2.3.10"]) - s.add_runtime_dependency(%q, ["= 2.1.4"]) - s.add_runtime_dependency(%q, [">= 0"]) - s.add_runtime_dependency(%q, [">= 0"]) - s.add_runtime_dependency(%q, [">= 0"]) - s.add_runtime_dependency(%q, [">= 0"]) - else - s.add_dependency(%q, ["= 2.3.10"]) - s.add_dependency(%q, ["= 2.1.4"]) - s.add_dependency(%q, [">= 0"]) - s.add_dependency(%q, [">= 0"]) - s.add_dependency(%q, [">= 0"]) - end - else - s.add_dependency(%q, ["= 2.3.10"]) - s.add_dependency(%q, ["= 2.1.4"]) - s.add_dependency(%q, [">= 0"]) - s.add_dependency(%q, [">= 0"]) - s.add_dependency(%q, [">= 0"]) - end -end - From 73a3c4fbcdb09daff699cb08cde7e13012b1100c Mon Sep 17 00:00:00 2001 From: Jon Marinello Date: Fri, 16 Mar 2012 18:08:40 +0000 Subject: [PATCH 149/239] Merged timeouts into master: Squashed commit of the following: commit 968ed7a22ced59a10c49db1c453f69cfd8136c20 Merge: 4e8ecee caf0474 Author: Jon Marinello Date: Wed Mar 14 20:31:52 2012 +0000 Merge branch 'master' of github.com:rightscale/rest_connection into timeouts Conflicts: rest_connection.gemspec commit 4e8ecee5f1ea07f13bfdc510b08018e78af826a6 Author: Jon Marinello Date: Tue Mar 13 09:36:20 2012 -0700 Added MIT license to spec files. commit 6f19058d6e186155eaf7ea56d6ccc2f9d5bd1a94 Author: Jon Marinello Date: Mon Mar 12 17:49:46 2012 -0700 Updated runtests to only run rspec on actual tests. commit 8df5784cf581ec911e79996f1c699754ca82cf6f Author: Jon Marinello Date: Mon Mar 12 17:28:10 2012 -0700 Updated to MIT licence agreement. commit 0229bfe59be67639748b069ddb41cbd3eba525b0 Author: Jon Marinello Date: Mon Mar 12 20:49:28 2012 +0000 Fixed tests so they at least run. commit 673c0633432788c9edd71deb0cc6522c3646199a Author: Jon Marinello Date: Thu Mar 8 23:03:53 2012 +0000 Added additional timeouts logic and more timeout values based on complete collateral testing. --- LICENSE | 22 ++++++++++ VERSION | 2 +- examples/console.rb | 23 ++++++++++ .../step_definitions/deployment_steps.rb | 23 ++++++++++ .../cucumber/step_definitions/mysql_steps.rb | 23 ++++++++++ .../cucumber/step_definitions/recipe_steps.rb | 23 ++++++++++ .../step_definitions/spot_check_steps.rb | 23 ++++++++++ examples/relaunch_deployment.rb | 24 ++++++++++ .../right_scale_ec2_instances_api_test.rb | 23 ++++++++++ lib/rest_connection.rb | 30 ++++++++----- lib/rest_connection/patches.rb | 23 ++++++++++ lib/rest_connection/rightscale/account.rb | 30 ++++++++----- lib/rest_connection/rightscale/alert_spec.rb | 32 +++++++++----- .../rightscale/alert_spec_subject.rb | 32 +++++++++----- lib/rest_connection/rightscale/audit_entry.rb | 33 +++++++++----- lib/rest_connection/rightscale/backup.rb | 30 ++++++++----- .../rightscale/child_account.rb | 30 ++++++++----- lib/rest_connection/rightscale/cloud.rb | 30 ++++++++----- .../rightscale/cloud_account.rb | 30 ++++++++----- lib/rest_connection/rightscale/credential.rb | 31 ++++++++----- lib/rest_connection/rightscale/deployment.rb | 30 ++++++++----- .../rightscale/ec2_ebs_snapshot.rb | 31 ++++++++----- .../rightscale/ec2_ebs_volume.rb | 31 ++++++++----- .../rightscale/ec2_elastic_ip.rb | 31 ++++++++----- .../rightscale/ec2_security_group.rb | 30 ++++++++----- .../rightscale/ec2_server_array.rb | 30 ++++++++----- .../rightscale/ec2_server_array_internal.rb | 30 ++++++++----- lib/rest_connection/rightscale/ec2_ssh_key.rb | 30 ++++++++----- .../rightscale/ec2_ssh_key_internal.rb | 30 ++++++++----- lib/rest_connection/rightscale/executable.rb | 23 ++++++++++ lib/rest_connection/rightscale/instance.rb | 30 ++++++++----- .../rightscale/instance_type.rb | 30 ++++++++----- lib/rest_connection/rightscale/macro.rb | 32 +++++++++----- .../rightscale/mc_audit_entry.rb | 30 ++++++++----- .../rightscale/mc_datacenter.rb | 30 ++++++++----- .../rightscale/mc_deployment.rb | 30 ++++++++----- lib/rest_connection/rightscale/mc_image.rb | 30 ++++++++----- lib/rest_connection/rightscale/mc_instance.rb | 30 ++++++++----- .../rightscale/mc_instance_type.rb | 30 ++++++++----- .../rightscale/mc_multi_cloud_image.rb | 30 ++++++++----- .../mc_multi_cloud_image_setting.rb | 30 ++++++++----- .../rightscale/mc_security_group.rb | 30 ++++++++----- lib/rest_connection/rightscale/mc_server.rb | 36 +++++++++------ .../rightscale/mc_server_array.rb | 30 ++++++++----- .../rightscale/mc_server_template.rb | 30 ++++++++----- .../mc_server_template_multi_cloud_image.rb | 30 ++++++++----- lib/rest_connection/rightscale/mc_ssh_key.rb | 30 ++++++++----- lib/rest_connection/rightscale/mc_tag.rb | 30 ++++++++----- lib/rest_connection/rightscale/mc_volume.rb | 30 ++++++++----- .../rightscale/mc_volume_attachment.rb | 30 ++++++++----- .../rightscale/mc_volume_snapshot.rb | 30 ++++++++----- .../rightscale/mc_volume_type.rb | 30 ++++++++----- .../rightscale/monitoring_metric.rb | 30 ++++++++----- .../rightscale/multi_cloud_image.rb | 30 ++++++++----- ...ulti_cloud_image_cloud_setting_internal.rb | 30 ++++++++----- .../rightscale/multi_cloud_image_internal.rb | 30 ++++++++----- lib/rest_connection/rightscale/permission.rb | 30 ++++++++----- .../rightscale/right_script.rb | 30 ++++++++----- .../right_script_attachment_internal.rb | 30 ++++++++----- .../rightscale/right_script_internal.rb | 30 ++++++++----- .../rightscale/rightscale_api_base.rb | 30 ++++++++----- .../rightscale/rightscale_api_gateway.rb | 23 ++++++++++ .../rightscale/rightscale_api_internal.rb | 23 ++++++++++ .../rightscale/rightscale_api_mc_input.rb | 30 ++++++++----- .../rightscale/rightscale_api_mc_taggable.rb | 30 ++++++++----- .../rightscale/rightscale_api_resources.rb | 31 ++++++++----- .../rightscale/rightscale_api_taggable.rb | 30 ++++++++----- lib/rest_connection/rightscale/rs_internal.rb | 30 ++++++++----- lib/rest_connection/rightscale/s3_bucket.rb | 32 +++++++++----- .../rightscale/security_group_rule.rb | 30 ++++++++----- lib/rest_connection/rightscale/server.rb | 44 ++++++++++++------- .../rightscale/server_ec2_ebs_volume.rb | 31 ++++++++----- .../rightscale/server_interface.rb | 30 ++++++++----- .../rightscale/server_internal.rb | 30 ++++++++----- .../rightscale/server_template.rb | 30 ++++++++----- .../rightscale/server_template_internal.rb | 30 ++++++++----- lib/rest_connection/rightscale/session.rb | 30 ++++++++----- lib/rest_connection/rightscale/sqs_queue.rb | 31 ++++++++----- lib/rest_connection/rightscale/status.rb | 31 ++++++++----- lib/rest_connection/rightscale/tag.rb | 30 ++++++++----- lib/rest_connection/rightscale/task.rb | 30 ++++++++----- lib/rest_connection/rightscale/user.rb | 30 ++++++++----- .../rightscale/vpc_dhcp_option.rb | 30 ++++++++----- lib/rest_connection/ssh_hax.rb | 31 ++++++++----- spec/ec2_server_array_spec.rb | 24 +++++++++- spec/ec2_ssh_key_internal_spec.rb | 24 +++++++++- spec/image_jockey.rb | 24 +++++++++- spec/mcserver_spec.rb | 24 +++++++++- spec/method_missing_spec.rb | 24 +++++++++- spec/multi.rb | 24 +++++++++- spec/right_script_internal.rb | 23 ++++++++++ spec/rs_internal_spec.rb | 24 +++++++++- spec/runtests | 9 ++++ spec/server_internal_spec.rb | 24 +++++++++- spec/server_spec.rb | 24 +++++++++- spec/server_template_internal.rb | 23 ++++++++++ spec/spec_helper.rb | 24 +++++++++- spec/tag_spec.rb | 1 - 98 files changed, 1929 insertions(+), 815 deletions(-) create mode 100644 LICENSE create mode 100755 spec/runtests diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..b5b49b6 --- /dev/null +++ b/LICENSE @@ -0,0 +1,22 @@ +#-- +# Copyright (c) 2010-2012 RightScale Inc +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ \ No newline at end of file diff --git a/VERSION b/VERSION index 1180819..699c6c6 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.1.7 +0.1.8 diff --git a/examples/console.rb b/examples/console.rb index 4d8d9df..2a38cad 100644 --- a/examples/console.rb +++ b/examples/console.rb @@ -1,3 +1,26 @@ +#-- +# Copyright (c) 2010-2012 RightScale Inc +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ + require 'rubygems' require 'rest_connection' require 'ruby-debug' diff --git a/examples/cucumber/step_definitions/deployment_steps.rb b/examples/cucumber/step_definitions/deployment_steps.rb index 069885f..79cee2b 100644 --- a/examples/cucumber/step_definitions/deployment_steps.rb +++ b/examples/cucumber/step_definitions/deployment_steps.rb @@ -1,3 +1,26 @@ +#-- +# Copyright (c) 2010-2012 RightScale Inc +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ + require "rubygems" require "rest_connection" require "net/ssh" diff --git a/examples/cucumber/step_definitions/mysql_steps.rb b/examples/cucumber/step_definitions/mysql_steps.rb index 0ad398c..4867e20 100644 --- a/examples/cucumber/step_definitions/mysql_steps.rb +++ b/examples/cucumber/step_definitions/mysql_steps.rb @@ -1,3 +1,26 @@ +#-- +# Copyright (c) 2010-2012 RightScale Inc +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ + require 'rubygems' require 'sqlite3' diff --git a/examples/cucumber/step_definitions/recipe_steps.rb b/examples/cucumber/step_definitions/recipe_steps.rb index 9b43800..e08ac80 100644 --- a/examples/cucumber/step_definitions/recipe_steps.rb +++ b/examples/cucumber/step_definitions/recipe_steps.rb @@ -1,3 +1,26 @@ +#-- +# Copyright (c) 2010-2012 RightScale Inc +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ + When /^I run a recipe named "([^\"]*)" on server "([^\"]*)"\.$/ do |recipe, server_index| human_index = server_index.to_i - 1 STDOUT.puts "#{recipe} -> root@#{@servers[human_index].dns_name}" diff --git a/examples/cucumber/step_definitions/spot_check_steps.rb b/examples/cucumber/step_definitions/spot_check_steps.rb index 393482b..fda0130 100644 --- a/examples/cucumber/step_definitions/spot_check_steps.rb +++ b/examples/cucumber/step_definitions/spot_check_steps.rb @@ -1,3 +1,26 @@ +#-- +# Copyright (c) 2010-2012 RightScale Inc +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ + Then /^I should run a command "([^\"]*)" on server "([^\"]*)"\.$/ do |command, server_index| human_index = server_index.to_i - 1 @servers[human_index].spot_check(command) { |result| puts result } diff --git a/examples/relaunch_deployment.rb b/examples/relaunch_deployment.rb index 3e9f025..34504e2 100644 --- a/examples/relaunch_deployment.rb +++ b/examples/relaunch_deployment.rb @@ -1,4 +1,28 @@ #!/usr/bin/env ruby + +#-- +# Copyright (c) 2010-2012 RightScale Inc +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ + require 'rubygems' require 'trollop' require 'rest_connection' diff --git a/examples/right_scale_ec2_instances_api_test.rb b/examples/right_scale_ec2_instances_api_test.rb index b0c6354..0e8c55e 100644 --- a/examples/right_scale_ec2_instances_api_test.rb +++ b/examples/right_scale_ec2_instances_api_test.rb @@ -1,3 +1,26 @@ +#-- +# Copyright (c) 2010-2012 RightScale Inc +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ + require 'rubygems' require 'rest_connection' require 'spec' diff --git a/lib/rest_connection.rb b/lib/rest_connection.rb index 1f831d0..42c06dd 100644 --- a/lib/rest_connection.rb +++ b/lib/rest_connection.rb @@ -1,17 +1,25 @@ -# This file is part of RestConnection +#-- +# Copyright (c) 2010-2012 RightScale Inc # -# RestConnection is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: # -# RestConnection is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. # -# You should have received a copy of the GNU General Public License -# along with RestConnection. If not, see . +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ require 'net/https' require 'rubygems' diff --git a/lib/rest_connection/patches.rb b/lib/rest_connection/patches.rb index ebe59fd..d866650 100644 --- a/lib/rest_connection/patches.rb +++ b/lib/rest_connection/patches.rb @@ -1,3 +1,26 @@ +#-- +# Copyright (c) 2010-2012 RightScale Inc +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ + # Hash Patches class Hash diff --git a/lib/rest_connection/rightscale/account.rb b/lib/rest_connection/rightscale/account.rb index 39dfc7e..6e0b766 100644 --- a/lib/rest_connection/rightscale/account.rb +++ b/lib/rest_connection/rightscale/account.rb @@ -1,17 +1,25 @@ -# This file is part of RestConnection +#-- +# Copyright (c) 2010-2012 RightScale Inc # -# RestConnection is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: # -# RestConnection is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. # -# You should have received a copy of the GNU General Public License -# along with RestConnection. If not, see . +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ # # You must have Beta v1.5 API access to use these internal API calls. diff --git a/lib/rest_connection/rightscale/alert_spec.rb b/lib/rest_connection/rightscale/alert_spec.rb index 1e185e2..dabc46a 100644 --- a/lib/rest_connection/rightscale/alert_spec.rb +++ b/lib/rest_connection/rightscale/alert_spec.rb @@ -1,18 +1,26 @@ -# This file is part of RestConnection +#-- +# Copyright (c) 2010-2012 RightScale Inc # -# RestConnection is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: # -# RestConnection is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with RestConnection. If not, see . +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. # +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ + class AlertSpec include RightScale::Api::Base extend RightScale::Api::BaseExtend diff --git a/lib/rest_connection/rightscale/alert_spec_subject.rb b/lib/rest_connection/rightscale/alert_spec_subject.rb index aa2fe82..2f2257e 100644 --- a/lib/rest_connection/rightscale/alert_spec_subject.rb +++ b/lib/rest_connection/rightscale/alert_spec_subject.rb @@ -1,18 +1,26 @@ -# This file is part of RestConnection +#-- +# Copyright (c) 2010-2012 RightScale Inc # -# RestConnection is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: # -# RestConnection is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with RestConnection. If not, see . +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. # +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ + class AlertSpecSubject include RightScale::Api::Base extend RightScale::Api::BaseExtend diff --git a/lib/rest_connection/rightscale/audit_entry.rb b/lib/rest_connection/rightscale/audit_entry.rb index c647ea4..ff3fe20 100644 --- a/lib/rest_connection/rightscale/audit_entry.rb +++ b/lib/rest_connection/rightscale/audit_entry.rb @@ -1,18 +1,27 @@ -# This file is part of RestConnection +#-- +# Copyright (c) 2010-2012 RightScale Inc # -# RestConnection is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: # -# RestConnection is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with RestConnection. If not, see . +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. # +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ + + #class AuditEntry # attr_accessor :status, :output # def initialize(opts) diff --git a/lib/rest_connection/rightscale/backup.rb b/lib/rest_connection/rightscale/backup.rb index 8f46588..21178d8 100644 --- a/lib/rest_connection/rightscale/backup.rb +++ b/lib/rest_connection/rightscale/backup.rb @@ -1,17 +1,25 @@ -# This file is part of RestConnection +#-- +# Copyright (c) 2010-2012 RightScale Inc # -# RestConnection is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: # -# RestConnection is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. # -# You should have received a copy of the GNU General Public License -# along with RestConnection. If not, see . +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ # # You must have Beta v1.5 API access to use these internal API calls. diff --git a/lib/rest_connection/rightscale/child_account.rb b/lib/rest_connection/rightscale/child_account.rb index dc5b982..03dc55f 100644 --- a/lib/rest_connection/rightscale/child_account.rb +++ b/lib/rest_connection/rightscale/child_account.rb @@ -1,17 +1,25 @@ -# This file is part of RestConnection +#-- +# Copyright (c) 2010-2012 RightScale Inc # -# RestConnection is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: # -# RestConnection is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. # -# You should have received a copy of the GNU General Public License -# along with RestConnection. If not, see . +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ # # You must have Beta v1.5 API access to use these internal API calls. diff --git a/lib/rest_connection/rightscale/cloud.rb b/lib/rest_connection/rightscale/cloud.rb index 98291b0..42aa256 100644 --- a/lib/rest_connection/rightscale/cloud.rb +++ b/lib/rest_connection/rightscale/cloud.rb @@ -1,17 +1,25 @@ -# This file is part of RestConnection +#-- +# Copyright (c) 2010-2012 RightScale Inc # -# RestConnection is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: # -# RestConnection is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. # -# You should have received a copy of the GNU General Public License -# along with RestConnection. If not, see . +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ # # You must have Beta v1.5 API access to use these internal API calls. diff --git a/lib/rest_connection/rightscale/cloud_account.rb b/lib/rest_connection/rightscale/cloud_account.rb index 4b24896..8cf79af 100644 --- a/lib/rest_connection/rightscale/cloud_account.rb +++ b/lib/rest_connection/rightscale/cloud_account.rb @@ -1,17 +1,25 @@ -# This file is part of RestConnection +#-- +# Copyright (c) 2010-2012 RightScale Inc # -# RestConnection is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: # -# RestConnection is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. # -# You should have received a copy of the GNU General Public License -# along with RestConnection. If not, see . +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ # # You must have Beta v1.5 API access to use these internal API calls. diff --git a/lib/rest_connection/rightscale/credential.rb b/lib/rest_connection/rightscale/credential.rb index 171f4f4..4feb11f 100644 --- a/lib/rest_connection/rightscale/credential.rb +++ b/lib/rest_connection/rightscale/credential.rb @@ -1,18 +1,25 @@ -# This file is part of RestConnection +#-- +# Copyright (c) 2010-2012 RightScale Inc # -# RestConnection is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: # -# RestConnection is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with RestConnection. If not, see . +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. # +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ class Credential include RightScale::Api::Base diff --git a/lib/rest_connection/rightscale/deployment.rb b/lib/rest_connection/rightscale/deployment.rb index 7f7cf26..9756d7d 100644 --- a/lib/rest_connection/rightscale/deployment.rb +++ b/lib/rest_connection/rightscale/deployment.rb @@ -1,17 +1,25 @@ -# This file is part of RestConnection +#-- +# Copyright (c) 2010-2012 RightScale Inc # -# RestConnection is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: # -# RestConnection is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. # -# You should have received a copy of the GNU General Public License -# along with RestConnection. If not, see . +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ class Deployment include RightScale::Api::Base diff --git a/lib/rest_connection/rightscale/ec2_ebs_snapshot.rb b/lib/rest_connection/rightscale/ec2_ebs_snapshot.rb index 16d5ef0..9abd787 100644 --- a/lib/rest_connection/rightscale/ec2_ebs_snapshot.rb +++ b/lib/rest_connection/rightscale/ec2_ebs_snapshot.rb @@ -1,18 +1,25 @@ -# This file is part of RestConnection +#-- +# Copyright (c) 2010-2012 RightScale Inc # -# RestConnection is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: # -# RestConnection is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with RestConnection. If not, see . +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. # +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ class Ec2EbsSnapshot include RightScale::Api::Base diff --git a/lib/rest_connection/rightscale/ec2_ebs_volume.rb b/lib/rest_connection/rightscale/ec2_ebs_volume.rb index ff0c272..69acca7 100644 --- a/lib/rest_connection/rightscale/ec2_ebs_volume.rb +++ b/lib/rest_connection/rightscale/ec2_ebs_volume.rb @@ -1,18 +1,25 @@ -# This file is part of RestConnection +#-- +# Copyright (c) 2010-2012 RightScale Inc # -# RestConnection is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: # -# RestConnection is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with RestConnection. If not, see . +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. # +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ class Ec2EbsVolume include RightScale::Api::Base diff --git a/lib/rest_connection/rightscale/ec2_elastic_ip.rb b/lib/rest_connection/rightscale/ec2_elastic_ip.rb index b5a8ac7..cc30b8b 100644 --- a/lib/rest_connection/rightscale/ec2_elastic_ip.rb +++ b/lib/rest_connection/rightscale/ec2_elastic_ip.rb @@ -1,18 +1,25 @@ -# This file is part of RestConnection +#-- +# Copyright (c) 2010-2012 RightScale Inc # -# RestConnection is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: # -# RestConnection is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with RestConnection. If not, see . +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. # +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ class Ec2ElasticIp include RightScale::Api::Base diff --git a/lib/rest_connection/rightscale/ec2_security_group.rb b/lib/rest_connection/rightscale/ec2_security_group.rb index 7212971..c1fbf7c 100644 --- a/lib/rest_connection/rightscale/ec2_security_group.rb +++ b/lib/rest_connection/rightscale/ec2_security_group.rb @@ -1,17 +1,25 @@ -# This file is part of RestConnection +#-- +# Copyright (c) 2010-2012 RightScale Inc # -# RestConnection is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: # -# RestConnection is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. # -# You should have received a copy of the GNU General Public License -# along with RestConnection. If not, see . +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ class Ec2SecurityGroup include RightScale::Api::Base diff --git a/lib/rest_connection/rightscale/ec2_server_array.rb b/lib/rest_connection/rightscale/ec2_server_array.rb index 1715b52..c4b69b5 100644 --- a/lib/rest_connection/rightscale/ec2_server_array.rb +++ b/lib/rest_connection/rightscale/ec2_server_array.rb @@ -1,17 +1,25 @@ -# This file is part of RestConnection +#-- +# Copyright (c) 2010-2012 RightScale Inc # -# RestConnection is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: # -# RestConnection is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. # -# You should have received a copy of the GNU General Public License -# along with RestConnection. If not, see . +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ class Ec2ServerArray include RightScale::Api::Base diff --git a/lib/rest_connection/rightscale/ec2_server_array_internal.rb b/lib/rest_connection/rightscale/ec2_server_array_internal.rb index b78be5e..eb2fbbc 100644 --- a/lib/rest_connection/rightscale/ec2_server_array_internal.rb +++ b/lib/rest_connection/rightscale/ec2_server_array_internal.rb @@ -1,17 +1,25 @@ -# This file is part of RestConnection +#-- +# Copyright (c) 2010-2012 RightScale Inc # -# RestConnection is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: # -# RestConnection is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. # -# You should have received a copy of the GNU General Public License -# along with RestConnection. If not, see . +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ class Ec2ServerArrayInternal include RightScale::Api::Base diff --git a/lib/rest_connection/rightscale/ec2_ssh_key.rb b/lib/rest_connection/rightscale/ec2_ssh_key.rb index 4de67f9..1c11066 100644 --- a/lib/rest_connection/rightscale/ec2_ssh_key.rb +++ b/lib/rest_connection/rightscale/ec2_ssh_key.rb @@ -1,17 +1,25 @@ -# This file is part of RestConnection +#-- +# Copyright (c) 2010-2012 RightScale Inc # -# RestConnection is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: # -# RestConnection is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. # -# You should have received a copy of the GNU General Public License -# along with RestConnection. If not, see . +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ class Ec2SshKey include RightScale::Api::Base diff --git a/lib/rest_connection/rightscale/ec2_ssh_key_internal.rb b/lib/rest_connection/rightscale/ec2_ssh_key_internal.rb index c669b7b..de8102e 100644 --- a/lib/rest_connection/rightscale/ec2_ssh_key_internal.rb +++ b/lib/rest_connection/rightscale/ec2_ssh_key_internal.rb @@ -1,17 +1,25 @@ -# This file is part of RestConnection +#-- +# Copyright (c) 2010-2012 RightScale Inc # -# RestConnection is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: # -# RestConnection is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. # -# You should have received a copy of the GNU General Public License -# along with RestConnection. If not, see . +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ class Ec2SshKeyInternal include RightScale::Api::Base diff --git a/lib/rest_connection/rightscale/executable.rb b/lib/rest_connection/rightscale/executable.rb index 4df7a84..29af2e5 100644 --- a/lib/rest_connection/rightscale/executable.rb +++ b/lib/rest_connection/rightscale/executable.rb @@ -1,3 +1,26 @@ +#-- +# Copyright (c) 2010-2012 RightScale Inc +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ + class Executable include RightScale::Api::Base extend RightScale::Api::BaseExtend diff --git a/lib/rest_connection/rightscale/instance.rb b/lib/rest_connection/rightscale/instance.rb index d5ab268..26d190c 100644 --- a/lib/rest_connection/rightscale/instance.rb +++ b/lib/rest_connection/rightscale/instance.rb @@ -1,17 +1,25 @@ -# This file is part of RestConnection +#-- +# Copyright (c) 2010-2012 RightScale Inc # -# RestConnection is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: # -# RestConnection is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. # -# You should have received a copy of the GNU General Public License -# along with RestConnection. If not, see . +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ # This is an instance facing api and can only be used with # an authentication URL normally found in the instance's userdata called diff --git a/lib/rest_connection/rightscale/instance_type.rb b/lib/rest_connection/rightscale/instance_type.rb index 610d61f..e51afd3 100644 --- a/lib/rest_connection/rightscale/instance_type.rb +++ b/lib/rest_connection/rightscale/instance_type.rb @@ -1,17 +1,25 @@ -# This file is part of RestConnection +#-- +# Copyright (c) 2010-2012 RightScale Inc # -# RestConnection is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: # -# RestConnection is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. # -# You should have received a copy of the GNU General Public License -# along with RestConnection. If not, see . +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ # # You must have Beta v1.5 API access to use these internal API calls. diff --git a/lib/rest_connection/rightscale/macro.rb b/lib/rest_connection/rightscale/macro.rb index 843462f..a9d1ead 100644 --- a/lib/rest_connection/rightscale/macro.rb +++ b/lib/rest_connection/rightscale/macro.rb @@ -1,18 +1,26 @@ -# This file is part of RestConnection +#-- +# Copyright (c) 2010-2012 RightScale Inc # -# RestConnection is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: # -# RestConnection is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with RestConnection. If not, see . +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. # +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ + class Macro include RightScale::Api::Base extend RightScale::Api::BaseExtend diff --git a/lib/rest_connection/rightscale/mc_audit_entry.rb b/lib/rest_connection/rightscale/mc_audit_entry.rb index ff5691f..2bfa84d 100644 --- a/lib/rest_connection/rightscale/mc_audit_entry.rb +++ b/lib/rest_connection/rightscale/mc_audit_entry.rb @@ -1,17 +1,25 @@ -# This file is part of RestConnection +#-- +# Copyright (c) 2010-2012 RightScale Inc # -# RestConnection is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: # -# RestConnection is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. # -# You should have received a copy of the GNU General Public License -# along with RestConnection. If not, see . +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ # # You must have Beta v1.5 API access to use these internal API calls. diff --git a/lib/rest_connection/rightscale/mc_datacenter.rb b/lib/rest_connection/rightscale/mc_datacenter.rb index 14ea7b3..87edd6b 100644 --- a/lib/rest_connection/rightscale/mc_datacenter.rb +++ b/lib/rest_connection/rightscale/mc_datacenter.rb @@ -1,17 +1,25 @@ -# This file is part of RestConnection +#-- +# Copyright (c) 2010-2012 RightScale Inc # -# RestConnection is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: # -# RestConnection is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. # -# You should have received a copy of the GNU General Public License -# along with RestConnection. If not, see . +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ # # You must have Beta v1.5 API access to use these internal API calls. diff --git a/lib/rest_connection/rightscale/mc_deployment.rb b/lib/rest_connection/rightscale/mc_deployment.rb index 34c9db8..8d8d3f3 100644 --- a/lib/rest_connection/rightscale/mc_deployment.rb +++ b/lib/rest_connection/rightscale/mc_deployment.rb @@ -1,17 +1,25 @@ -# This file is part of RestConnection +#-- +# Copyright (c) 2010-2012 RightScale Inc # -# RestConnection is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: # -# RestConnection is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. # -# You should have received a copy of the GNU General Public License -# along with RestConnection. If not, see . +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ # # You must have Beta v1.5 API access to use these internal API calls. diff --git a/lib/rest_connection/rightscale/mc_image.rb b/lib/rest_connection/rightscale/mc_image.rb index ef98bd2..a6b109d 100644 --- a/lib/rest_connection/rightscale/mc_image.rb +++ b/lib/rest_connection/rightscale/mc_image.rb @@ -1,17 +1,25 @@ -# This file is part of RestConnection +#-- +# Copyright (c) 2010-2012 RightScale Inc # -# RestConnection is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: # -# RestConnection is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. # -# You should have received a copy of the GNU General Public License -# along with RestConnection. If not, see . +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ # # You must have Beta v1.5 API access to use these internal API calls. diff --git a/lib/rest_connection/rightscale/mc_instance.rb b/lib/rest_connection/rightscale/mc_instance.rb index 51693b7..2b65435 100644 --- a/lib/rest_connection/rightscale/mc_instance.rb +++ b/lib/rest_connection/rightscale/mc_instance.rb @@ -1,17 +1,25 @@ -# This file is part of RestConnection +#-- +# Copyright (c) 2010-2012 RightScale Inc # -# RestConnection is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: # -# RestConnection is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. # -# You should have received a copy of the GNU General Public License -# along with RestConnection. If not, see . +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ # # You must have Beta v1.5 API access to use these internal API calls. diff --git a/lib/rest_connection/rightscale/mc_instance_type.rb b/lib/rest_connection/rightscale/mc_instance_type.rb index b55f166..53d7314 100644 --- a/lib/rest_connection/rightscale/mc_instance_type.rb +++ b/lib/rest_connection/rightscale/mc_instance_type.rb @@ -1,17 +1,25 @@ -# This file is part of RestConnection +#-- +# Copyright (c) 2010-2012 RightScale Inc # -# RestConnection is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: # -# RestConnection is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. # -# You should have received a copy of the GNU General Public License -# along with RestConnection. If not, see . +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ # # You must have Beta v1.5 API access to use these internal API calls. diff --git a/lib/rest_connection/rightscale/mc_multi_cloud_image.rb b/lib/rest_connection/rightscale/mc_multi_cloud_image.rb index 83685ce..39dbb80 100644 --- a/lib/rest_connection/rightscale/mc_multi_cloud_image.rb +++ b/lib/rest_connection/rightscale/mc_multi_cloud_image.rb @@ -1,17 +1,25 @@ -# This file is part of RestConnection +#-- +# Copyright (c) 2010-2012 RightScale Inc # -# RestConnection is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: # -# RestConnection is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. # -# You should have received a copy of the GNU General Public License -# along with RestConnection. If not, see . +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ # # You must have Beta v1.5 API access to use these internal API calls. diff --git a/lib/rest_connection/rightscale/mc_multi_cloud_image_setting.rb b/lib/rest_connection/rightscale/mc_multi_cloud_image_setting.rb index f93b5ec..60b18f7 100644 --- a/lib/rest_connection/rightscale/mc_multi_cloud_image_setting.rb +++ b/lib/rest_connection/rightscale/mc_multi_cloud_image_setting.rb @@ -1,17 +1,25 @@ -# This file is part of RestConnection +#-- +# Copyright (c) 2010-2012 RightScale Inc # -# RestConnection is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: # -# RestConnection is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. # -# You should have received a copy of the GNU General Public License -# along with RestConnection. If not, see . +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ # # You must have Beta v1.5 API access to use these internal API calls. diff --git a/lib/rest_connection/rightscale/mc_security_group.rb b/lib/rest_connection/rightscale/mc_security_group.rb index be01125..25ecf1a 100644 --- a/lib/rest_connection/rightscale/mc_security_group.rb +++ b/lib/rest_connection/rightscale/mc_security_group.rb @@ -1,17 +1,25 @@ -# This file is part of RestConnection +#-- +# Copyright (c) 2010-2012 RightScale Inc # -# RestConnection is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: # -# RestConnection is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. # -# You should have received a copy of the GNU General Public License -# along with RestConnection. If not, see . +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ # # You must have Beta v1.5 API access to use these internal API calls. diff --git a/lib/rest_connection/rightscale/mc_server.rb b/lib/rest_connection/rightscale/mc_server.rb index aed4275..b8246b9 100644 --- a/lib/rest_connection/rightscale/mc_server.rb +++ b/lib/rest_connection/rightscale/mc_server.rb @@ -1,18 +1,25 @@ -# This file is part of RestConnection +#-- +# Copyright (c) 2010-2012 RightScale Inc # -# RestConnection is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: # -# RestConnection is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. # -# You should have received a copy of the GNU General Public License -# along with RestConnection. If not, see . - +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ # # You must have Beta v1.5 API access to use these internal API calls. # @@ -147,9 +154,10 @@ def monitoring ret end - def relaunch + # *timeout <~Integer> optional, how long to wait for the inactive state before declare failure (in seconds). + def relaunch(timeout=1200) self.terminate - self.wait_for_state("inactive") + self.wait_for_state("inactive", timeout) self.launch end diff --git a/lib/rest_connection/rightscale/mc_server_array.rb b/lib/rest_connection/rightscale/mc_server_array.rb index 24d3229..6c55f5b 100644 --- a/lib/rest_connection/rightscale/mc_server_array.rb +++ b/lib/rest_connection/rightscale/mc_server_array.rb @@ -1,17 +1,25 @@ -# This file is part of RestConnection +#-- +# Copyright (c) 2010-2012 RightScale Inc # -# RestConnection is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: # -# RestConnection is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. # -# You should have received a copy of the GNU General Public License -# along with RestConnection. If not, see . +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ # # You must have Beta v1.5 API access to use these internal API calls. diff --git a/lib/rest_connection/rightscale/mc_server_template.rb b/lib/rest_connection/rightscale/mc_server_template.rb index 6ec9bbf..d4c5733 100644 --- a/lib/rest_connection/rightscale/mc_server_template.rb +++ b/lib/rest_connection/rightscale/mc_server_template.rb @@ -1,17 +1,25 @@ -# This file is part of RestConnection +#-- +# Copyright (c) 2010-2012 RightScale Inc # -# RestConnection is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: # -# RestConnection is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. # -# You should have received a copy of the GNU General Public License -# along with RestConnection. If not, see . +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ # # You must have Beta v1.5 API access to use these internal API calls. diff --git a/lib/rest_connection/rightscale/mc_server_template_multi_cloud_image.rb b/lib/rest_connection/rightscale/mc_server_template_multi_cloud_image.rb index 8c2343e..f17a27d 100644 --- a/lib/rest_connection/rightscale/mc_server_template_multi_cloud_image.rb +++ b/lib/rest_connection/rightscale/mc_server_template_multi_cloud_image.rb @@ -1,17 +1,25 @@ -# This file is part of RestConnection +#-- +# Copyright (c) 2010-2012 RightScale Inc # -# RestConnection is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: # -# RestConnection is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. # -# You should have received a copy of the GNU General Public License -# along with RestConnection. If not, see . +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ # # You must have Beta v1.5 API access to use these internal API calls. diff --git a/lib/rest_connection/rightscale/mc_ssh_key.rb b/lib/rest_connection/rightscale/mc_ssh_key.rb index c0664b9..10400a4 100644 --- a/lib/rest_connection/rightscale/mc_ssh_key.rb +++ b/lib/rest_connection/rightscale/mc_ssh_key.rb @@ -1,17 +1,25 @@ -# This file is part of RestConnection +#-- +# Copyright (c) 2010-2012 RightScale Inc # -# RestConnection is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: # -# RestConnection is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. # -# You should have received a copy of the GNU General Public License -# along with RestConnection. If not, see . +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ # # You must have Beta v1.5 API access to use these internal API calls. diff --git a/lib/rest_connection/rightscale/mc_tag.rb b/lib/rest_connection/rightscale/mc_tag.rb index 45a6d4d..f5f5db2 100644 --- a/lib/rest_connection/rightscale/mc_tag.rb +++ b/lib/rest_connection/rightscale/mc_tag.rb @@ -1,17 +1,25 @@ -# This file is part of RestConnection +#-- +# Copyright (c) 2010-2012 RightScale Inc # -# RestConnection is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: # -# RestConnection is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. # -# You should have received a copy of the GNU General Public License -# along with RestConnection. If not, see . +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ # # You must have Beta v1.5 API access to use these internal API calls. diff --git a/lib/rest_connection/rightscale/mc_volume.rb b/lib/rest_connection/rightscale/mc_volume.rb index debe058..eb14948 100644 --- a/lib/rest_connection/rightscale/mc_volume.rb +++ b/lib/rest_connection/rightscale/mc_volume.rb @@ -1,17 +1,25 @@ -# This file is part of RestConnection +#-- +# Copyright (c) 2010-2012 RightScale Inc # -# RestConnection is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: # -# RestConnection is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. # -# You should have received a copy of the GNU General Public License -# along with RestConnection. If not, see . +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ # # You must have Beta v1.5 API access to use these internal API calls. diff --git a/lib/rest_connection/rightscale/mc_volume_attachment.rb b/lib/rest_connection/rightscale/mc_volume_attachment.rb index 946f3b0..449fce4 100644 --- a/lib/rest_connection/rightscale/mc_volume_attachment.rb +++ b/lib/rest_connection/rightscale/mc_volume_attachment.rb @@ -1,17 +1,25 @@ -# This file is part of RestConnection +#-- +# Copyright (c) 2010-2012 RightScale Inc # -# RestConnection is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: # -# RestConnection is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. # -# You should have received a copy of the GNU General Public License -# along with RestConnection. If not, see . +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ # # You must have Beta v1.5 API access to use these internal API calls. diff --git a/lib/rest_connection/rightscale/mc_volume_snapshot.rb b/lib/rest_connection/rightscale/mc_volume_snapshot.rb index d32fd6c..336cf68 100644 --- a/lib/rest_connection/rightscale/mc_volume_snapshot.rb +++ b/lib/rest_connection/rightscale/mc_volume_snapshot.rb @@ -1,17 +1,25 @@ -# This file is part of RestConnection +#-- +# Copyright (c) 2010-2012 RightScale Inc # -# RestConnection is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: # -# RestConnection is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. # -# You should have received a copy of the GNU General Public License -# along with RestConnection. If not, see . +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ # # You must have Beta v1.5 API access to use these internal API calls. diff --git a/lib/rest_connection/rightscale/mc_volume_type.rb b/lib/rest_connection/rightscale/mc_volume_type.rb index 21c725a..fe5fb2e 100644 --- a/lib/rest_connection/rightscale/mc_volume_type.rb +++ b/lib/rest_connection/rightscale/mc_volume_type.rb @@ -1,17 +1,25 @@ -# This file is part of RestConnection +#-- +# Copyright (c) 2010-2012 RightScale Inc # -# RestConnection is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: # -# RestConnection is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. # -# You should have received a copy of the GNU General Public License -# along with RestConnection. If not, see . +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ # # You must have Beta v1.5 API access to use these internal API calls. diff --git a/lib/rest_connection/rightscale/monitoring_metric.rb b/lib/rest_connection/rightscale/monitoring_metric.rb index 8147237..7a3db9d 100644 --- a/lib/rest_connection/rightscale/monitoring_metric.rb +++ b/lib/rest_connection/rightscale/monitoring_metric.rb @@ -1,17 +1,25 @@ -# This file is part of RestConnection +#-- +# Copyright (c) 2010-2012 RightScale Inc # -# RestConnection is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: # -# RestConnection is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. # -# You should have received a copy of the GNU General Public License -# along with RestConnection. If not, see . +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ # # You must have Beta v1.5 API access to use these internal API calls. diff --git a/lib/rest_connection/rightscale/multi_cloud_image.rb b/lib/rest_connection/rightscale/multi_cloud_image.rb index 619b90c..9e777a0 100644 --- a/lib/rest_connection/rightscale/multi_cloud_image.rb +++ b/lib/rest_connection/rightscale/multi_cloud_image.rb @@ -1,17 +1,25 @@ -# This file is part of RestConnection +#-- +# Copyright (c) 2010-2012 RightScale Inc # -# RestConnection is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: # -# RestConnection is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. # -# You should have received a copy of the GNU General Public License -# along with RestConnection. If not, see . +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ class MultiCloudImage include RightScale::Api::Base diff --git a/lib/rest_connection/rightscale/multi_cloud_image_cloud_setting_internal.rb b/lib/rest_connection/rightscale/multi_cloud_image_cloud_setting_internal.rb index 7a661d3..8e6c7aa 100644 --- a/lib/rest_connection/rightscale/multi_cloud_image_cloud_setting_internal.rb +++ b/lib/rest_connection/rightscale/multi_cloud_image_cloud_setting_internal.rb @@ -1,17 +1,25 @@ -# This file is part of RestConnection +#-- +# Copyright (c) 2010-2012 RightScale Inc # -# RestConnection is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: # -# RestConnection is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. # -# You should have received a copy of the GNU General Public License -# along with RestConnection. If not, see . +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ class MultiCloudImageCloudSettingInternal include RightScale::Api::Base diff --git a/lib/rest_connection/rightscale/multi_cloud_image_internal.rb b/lib/rest_connection/rightscale/multi_cloud_image_internal.rb index 5cc95d9..6e675eb 100644 --- a/lib/rest_connection/rightscale/multi_cloud_image_internal.rb +++ b/lib/rest_connection/rightscale/multi_cloud_image_internal.rb @@ -1,17 +1,25 @@ -# This file is part of RestConnection +#-- +# Copyright (c) 2010-2012 RightScale Inc # -# RestConnection is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: # -# RestConnection is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. # -# You should have received a copy of the GNU General Public License -# along with RestConnection. If not, see . +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ class MultiCloudImageInternal include RightScale::Api::Base diff --git a/lib/rest_connection/rightscale/permission.rb b/lib/rest_connection/rightscale/permission.rb index feb4b9e..053416e 100644 --- a/lib/rest_connection/rightscale/permission.rb +++ b/lib/rest_connection/rightscale/permission.rb @@ -1,17 +1,25 @@ -# This file is part of RestConnection +#-- +# Copyright (c) 2010-2012 RightScale Inc # -# RestConnection is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: # -# RestConnection is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. # -# You should have received a copy of the GNU General Public License -# along with RestConnection. If not, see . +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ # # You must have Beta v1.5 API access to use these internal API calls. diff --git a/lib/rest_connection/rightscale/right_script.rb b/lib/rest_connection/rightscale/right_script.rb index 41efbbe..3c3906f 100644 --- a/lib/rest_connection/rightscale/right_script.rb +++ b/lib/rest_connection/rightscale/right_script.rb @@ -1,17 +1,25 @@ -# This file is part of RestConnection +#-- +# Copyright (c) 2010-2012 RightScale Inc # -# RestConnection is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: # -# RestConnection is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. # -# You should have received a copy of the GNU General Public License -# along with RestConnection. If not, see . +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ class RightScript diff --git a/lib/rest_connection/rightscale/right_script_attachment_internal.rb b/lib/rest_connection/rightscale/right_script_attachment_internal.rb index 507952b..0edb0f4 100644 --- a/lib/rest_connection/rightscale/right_script_attachment_internal.rb +++ b/lib/rest_connection/rightscale/right_script_attachment_internal.rb @@ -1,17 +1,25 @@ -# This file is part of RestConnection +#-- +# Copyright (c) 2010-2012 RightScale Inc # -# RestConnection is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: # -# RestConnection is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. # -# You should have received a copy of the GNU General Public License -# along with RestConnection. If not, see . +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ require 'rest-client' RestClient.log = ENV["REST_CONNECTION_LOG"] || "stdout" diff --git a/lib/rest_connection/rightscale/right_script_internal.rb b/lib/rest_connection/rightscale/right_script_internal.rb index 2924e40..b0dcf55 100644 --- a/lib/rest_connection/rightscale/right_script_internal.rb +++ b/lib/rest_connection/rightscale/right_script_internal.rb @@ -1,17 +1,25 @@ -# This file is part of RestConnection +#-- +# Copyright (c) 2010-2012 RightScale Inc # -# RestConnection is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: # -# RestConnection is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. # -# You should have received a copy of the GNU General Public License -# along with RestConnection. If not, see . +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ class RightScriptInternal diff --git a/lib/rest_connection/rightscale/rightscale_api_base.rb b/lib/rest_connection/rightscale/rightscale_api_base.rb index 858f8ea..734e359 100644 --- a/lib/rest_connection/rightscale/rightscale_api_base.rb +++ b/lib/rest_connection/rightscale/rightscale_api_base.rb @@ -1,17 +1,25 @@ -# This file is part of RestConnection +#-- +# Copyright (c) 2010-2012 RightScale Inc # -# RestConnection is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: # -# RestConnection is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. # -# You should have received a copy of the GNU General Public License -# along with RestConnection. If not, see . +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ require 'active_support/inflector' diff --git a/lib/rest_connection/rightscale/rightscale_api_gateway.rb b/lib/rest_connection/rightscale/rightscale_api_gateway.rb index 0670a19..2e3e82d 100644 --- a/lib/rest_connection/rightscale/rightscale_api_gateway.rb +++ b/lib/rest_connection/rightscale/rightscale_api_gateway.rb @@ -1,3 +1,26 @@ +#-- +# Copyright (c) 2010-2012 RightScale Inc +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ + module RightScale module Api GATEWAY_COOKIE_REFRESH = proc do diff --git a/lib/rest_connection/rightscale/rightscale_api_internal.rb b/lib/rest_connection/rightscale/rightscale_api_internal.rb index beeb6f0..08ae90d 100644 --- a/lib/rest_connection/rightscale/rightscale_api_internal.rb +++ b/lib/rest_connection/rightscale/rightscale_api_internal.rb @@ -1,3 +1,26 @@ +#-- +# Copyright (c) 2010-2012 RightScale Inc +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ + module RightScale module Api module InternalConnection diff --git a/lib/rest_connection/rightscale/rightscale_api_mc_input.rb b/lib/rest_connection/rightscale/rightscale_api_mc_input.rb index b92e894..964a459 100644 --- a/lib/rest_connection/rightscale/rightscale_api_mc_input.rb +++ b/lib/rest_connection/rightscale/rightscale_api_mc_input.rb @@ -1,17 +1,25 @@ -# This file is part of RestConnection +#-- +# Copyright (c) 2010-2012 RightScale Inc # -# RestConnection is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: # -# RestConnection is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. # -# You should have received a copy of the GNU General Public License -# along with RestConnection. If not, see . +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ # # You must have Beta v1.5 API access to use these internal API calls. diff --git a/lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb b/lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb index 7df70af..ed87a13 100644 --- a/lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb +++ b/lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb @@ -1,17 +1,25 @@ -# This file is part of RestConnection +#-- +# Copyright (c) 2010-2012 RightScale Inc # -# RestConnection is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: # -# RestConnection is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. # -# You should have received a copy of the GNU General Public License -# along with RestConnection. If not, see . +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ # # You must have Beta v1.5 API access to use these internal API calls. diff --git a/lib/rest_connection/rightscale/rightscale_api_resources.rb b/lib/rest_connection/rightscale/rightscale_api_resources.rb index 5d2b145..a4326eb 100644 --- a/lib/rest_connection/rightscale/rightscale_api_resources.rb +++ b/lib/rest_connection/rightscale/rightscale_api_resources.rb @@ -1,18 +1,25 @@ -# This file is part of RestConnection +#-- +# Copyright (c) 2010-2012 RightScale Inc # -# RestConnection is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: # -# RestConnection is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. # -# You should have received a copy of the GNU General Public License -# along with RestConnection. If not, see . - +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ require 'rest_connection/rightscale/rightscale_api_base' require 'rest_connection/rightscale/rightscale_api_internal' diff --git a/lib/rest_connection/rightscale/rightscale_api_taggable.rb b/lib/rest_connection/rightscale/rightscale_api_taggable.rb index 8e4daf4..97db92a 100644 --- a/lib/rest_connection/rightscale/rightscale_api_taggable.rb +++ b/lib/rest_connection/rightscale/rightscale_api_taggable.rb @@ -1,17 +1,25 @@ -# This file is part of RestConnection +#-- +# Copyright (c) 2010-2012 RightScale Inc # -# RestConnection is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: # -# RestConnection is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. # -# You should have received a copy of the GNU General Public License -# along with RestConnection. If not, see . +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ module RightScale module Api diff --git a/lib/rest_connection/rightscale/rs_internal.rb b/lib/rest_connection/rightscale/rs_internal.rb index 4dc4864..16423db 100644 --- a/lib/rest_connection/rightscale/rs_internal.rb +++ b/lib/rest_connection/rightscale/rs_internal.rb @@ -1,17 +1,25 @@ -# This file is part of RestConnection +#-- +# Copyright (c) 2010-2012 RightScale Inc # -# RestConnection is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: # -# RestConnection is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. # -# You should have received a copy of the GNU General Public License -# along with RestConnection. If not, see . +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ # # You must have special API access to use these internal API calls. diff --git a/lib/rest_connection/rightscale/s3_bucket.rb b/lib/rest_connection/rightscale/s3_bucket.rb index e9c5234..694e1b7 100644 --- a/lib/rest_connection/rightscale/s3_bucket.rb +++ b/lib/rest_connection/rightscale/s3_bucket.rb @@ -1,18 +1,26 @@ -# This file is part of RestConnection +#-- +# Copyright (c) 2010-2012 RightScale Inc # -# RestConnection is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: # -# RestConnection is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with RestConnection. If not, see . +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. # +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ + class S3Bucket include RightScale::Api::Base extend RightScale::Api::BaseExtend diff --git a/lib/rest_connection/rightscale/security_group_rule.rb b/lib/rest_connection/rightscale/security_group_rule.rb index a42e2af..3d0456f 100644 --- a/lib/rest_connection/rightscale/security_group_rule.rb +++ b/lib/rest_connection/rightscale/security_group_rule.rb @@ -1,17 +1,25 @@ -# This file is part of RestConnection +#-- +# Copyright (c) 2010-2012 RightScale Inc # -# RestConnection is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: # -# RestConnection is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. # -# You should have received a copy of the GNU General Public License -# along with RestConnection. If not, see . +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ # # You must have Beta v1.5 API access to use these internal API calls. diff --git a/lib/rest_connection/rightscale/server.rb b/lib/rest_connection/rightscale/server.rb index 7f53464..ff4e56c 100644 --- a/lib/rest_connection/rightscale/server.rb +++ b/lib/rest_connection/rightscale/server.rb @@ -1,17 +1,25 @@ -# This file is part of RestConnection +#-- +# Copyright (c) 2010-2012 RightScale Inc # -# RestConnection is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: # -# RestConnection is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. # -# You should have received a copy of the GNU General Public License -# along with RestConnection. If not, see . +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ class Server include RightScale::Api::Base @@ -282,13 +290,14 @@ def monitoring end # takes Bool argument to wait for state change (insurance that we can detect a reboot happened) - def reboot(wait_for_state = false) + # *timeout <~Integer> optional, how long to wait for the stopped state before declare failure (in seconds). + def reboot(wait_for_state = false, timeout = 60*7) reload old_state = self.state serv_href = URI.parse(self.href) connection.post(serv_href.path + "/reboot") if wait_for_state - wait_for_state_change(old_state) + wait_for_state_change(old_state, timeout) end end @@ -296,14 +305,15 @@ def alert_specs # TODO end - def relaunch + # *timeout <~Integer> optional, how long to wait for the stopped state before declare failure (in seconds). + def relaunch(timeout=1200) self.stop - self.wait_for_state("stopped") + self.wait_for_state("stopped", timeout) self.start end - def wait_for_state_change(old_state = nil) - timeout = 60*7 + # *timeout <~Integer> optional, how long to wait for the stopped state before declare failure (in seconds). + def wait_for_state_change(old_state = nil, timeout = 60*7) timer = 0 while(timer < timeout) reload diff --git a/lib/rest_connection/rightscale/server_ec2_ebs_volume.rb b/lib/rest_connection/rightscale/server_ec2_ebs_volume.rb index 6a53e2a..d2e0b05 100644 --- a/lib/rest_connection/rightscale/server_ec2_ebs_volume.rb +++ b/lib/rest_connection/rightscale/server_ec2_ebs_volume.rb @@ -1,18 +1,25 @@ -# This file is part of RestConnection +#-- +# Copyright (c) 2010-2012 RightScale Inc # -# RestConnection is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: # -# RestConnection is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with RestConnection. If not, see . +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. # +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ class ServerEc2EbsVolume include RightScale::Api::Base diff --git a/lib/rest_connection/rightscale/server_interface.rb b/lib/rest_connection/rightscale/server_interface.rb index 6b0c724..fe0f311 100644 --- a/lib/rest_connection/rightscale/server_interface.rb +++ b/lib/rest_connection/rightscale/server_interface.rb @@ -1,17 +1,25 @@ -# This file is part of RestConnection +#-- +# Copyright (c) 2010-2012 RightScale Inc # -# RestConnection is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: # -# RestConnection is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. # -# You should have received a copy of the GNU General Public License -# along with RestConnection. If not, see . +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ require 'rest_connection/ssh_hax' diff --git a/lib/rest_connection/rightscale/server_internal.rb b/lib/rest_connection/rightscale/server_internal.rb index 74d723c..fcec0ae 100644 --- a/lib/rest_connection/rightscale/server_internal.rb +++ b/lib/rest_connection/rightscale/server_internal.rb @@ -1,17 +1,25 @@ -# This file is part of RestConnection +#-- +# Copyright (c) 2010-2012 RightScale Inc # -# RestConnection is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: # -# RestConnection is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. # -# You should have received a copy of the GNU General Public License -# along with RestConnection. If not, see . +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ # # You must have special API access to use these internal API calls. diff --git a/lib/rest_connection/rightscale/server_template.rb b/lib/rest_connection/rightscale/server_template.rb index 35afc2b..885007c 100644 --- a/lib/rest_connection/rightscale/server_template.rb +++ b/lib/rest_connection/rightscale/server_template.rb @@ -1,17 +1,25 @@ -# This file is part of RestConnection +#-- +# Copyright (c) 2010-2012 RightScale Inc # -# RestConnection is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: # -# RestConnection is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. # -# You should have received a copy of the GNU General Public License -# along with RestConnection. If not, see . +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ class ServerTemplate include RightScale::Api::Base diff --git a/lib/rest_connection/rightscale/server_template_internal.rb b/lib/rest_connection/rightscale/server_template_internal.rb index af7b3bb..89bcbb1 100644 --- a/lib/rest_connection/rightscale/server_template_internal.rb +++ b/lib/rest_connection/rightscale/server_template_internal.rb @@ -1,17 +1,25 @@ -# This file is part of RestConnection +#-- +# Copyright (c) 2010-2012 RightScale Inc # -# RestConnection is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: # -# RestConnection is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. # -# You should have received a copy of the GNU General Public License -# along with RestConnection. If not, see . +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ class ServerTemplateInternal include RightScale::Api::Base diff --git a/lib/rest_connection/rightscale/session.rb b/lib/rest_connection/rightscale/session.rb index 1d9b576..1e69a06 100644 --- a/lib/rest_connection/rightscale/session.rb +++ b/lib/rest_connection/rightscale/session.rb @@ -1,17 +1,25 @@ -# This file is part of RestConnection +#-- +# Copyright (c) 2010-2012 RightScale Inc # -# RestConnection is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: # -# RestConnection is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. # -# You should have received a copy of the GNU General Public License -# along with RestConnection. If not, see . +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ # # You must have Beta v1.5 API access to use these internal API calls. diff --git a/lib/rest_connection/rightscale/sqs_queue.rb b/lib/rest_connection/rightscale/sqs_queue.rb index 16330aa..dfce7cc 100644 --- a/lib/rest_connection/rightscale/sqs_queue.rb +++ b/lib/rest_connection/rightscale/sqs_queue.rb @@ -1,18 +1,25 @@ -# This file is part of RestConnection +#-- +# Copyright (c) 2010-2012 RightScale Inc # -# RestConnection is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: # -# RestConnection is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with RestConnection. If not, see . +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. # +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ class SqsQueue include RightScale::Api::Base diff --git a/lib/rest_connection/rightscale/status.rb b/lib/rest_connection/rightscale/status.rb index 11291ec..9e7f875 100644 --- a/lib/rest_connection/rightscale/status.rb +++ b/lib/rest_connection/rightscale/status.rb @@ -1,17 +1,26 @@ -# This file is part of RestConnection +#-- +# Copyright (c) 2010-2012 RightScale Inc # -# RestConnection is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: # -# RestConnection is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. # -# You should have received a copy of the GNU General Public License -# along with RestConnection. If not, see . +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ + # # For now this is a stub for using with the ssh enabled Server#run_script diff --git a/lib/rest_connection/rightscale/tag.rb b/lib/rest_connection/rightscale/tag.rb index 8f7be98..a8e1d90 100644 --- a/lib/rest_connection/rightscale/tag.rb +++ b/lib/rest_connection/rightscale/tag.rb @@ -1,17 +1,25 @@ -# This file is part of RestConnection +#-- +# Copyright (c) 2010-2012 RightScale Inc # -# RestConnection is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: # -# RestConnection is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. # -# You should have received a copy of the GNU General Public License -# along with RestConnection. If not, see . +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ class Tag include RightScale::Api::Base diff --git a/lib/rest_connection/rightscale/task.rb b/lib/rest_connection/rightscale/task.rb index 26fc3fa..c8a8326 100644 --- a/lib/rest_connection/rightscale/task.rb +++ b/lib/rest_connection/rightscale/task.rb @@ -1,17 +1,25 @@ -# This file is part of RestConnection +#-- +# Copyright (c) 2010-2012 RightScale Inc # -# RestConnection is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: # -# RestConnection is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. # -# You should have received a copy of the GNU General Public License -# along with RestConnection. If not, see . +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ # # You must have Beta v1.5 API access to use these internal API calls. diff --git a/lib/rest_connection/rightscale/user.rb b/lib/rest_connection/rightscale/user.rb index c19cc47..88ecf73 100644 --- a/lib/rest_connection/rightscale/user.rb +++ b/lib/rest_connection/rightscale/user.rb @@ -1,17 +1,25 @@ -# This file is part of RestConnection +#-- +# Copyright (c) 2010-2012 RightScale Inc # -# RestConnection is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: # -# RestConnection is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. # -# You should have received a copy of the GNU General Public License -# along with RestConnection. If not, see . +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ # # You must have Beta v1.5 API access to use these internal API calls. diff --git a/lib/rest_connection/rightscale/vpc_dhcp_option.rb b/lib/rest_connection/rightscale/vpc_dhcp_option.rb index 6cf12c8..9092cfd 100644 --- a/lib/rest_connection/rightscale/vpc_dhcp_option.rb +++ b/lib/rest_connection/rightscale/vpc_dhcp_option.rb @@ -1,17 +1,25 @@ -# This file is part of RestConnection +#-- +# Copyright (c) 2010-2012 RightScale Inc # -# RestConnection is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: # -# RestConnection is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. # -# You should have received a copy of the GNU General Public License -# along with RestConnection. If not, see . +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ class VpcDhcpOption include RightScale::Api::Base diff --git a/lib/rest_connection/ssh_hax.rb b/lib/rest_connection/ssh_hax.rb index 2fad123..a1ab6ce 100644 --- a/lib/rest_connection/ssh_hax.rb +++ b/lib/rest_connection/ssh_hax.rb @@ -1,18 +1,25 @@ -# This file is part of RestConnection +#-- +# Copyright (c) 2010-2012 RightScale Inc # -# RestConnection is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: # -# RestConnection is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. # -# You should have received a copy of the GNU General Public License -# along with RestConnection. If not, see . - +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ require 'net/ssh' diff --git a/spec/ec2_server_array_spec.rb b/spec/ec2_server_array_spec.rb index 76ab310..47728ed 100644 --- a/spec/ec2_server_array_spec.rb +++ b/spec/ec2_server_array_spec.rb @@ -1,6 +1,28 @@ +#-- +# Copyright (c) 2010-2012 RightScale Inc +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ + require 'rubygems' require 'rest_connection' -require 'spec' require 'ruby-debug' describe Ec2ServerArray, "takes over the world with some server arrays" do diff --git a/spec/ec2_ssh_key_internal_spec.rb b/spec/ec2_ssh_key_internal_spec.rb index c28945b..0c4b794 100644 --- a/spec/ec2_ssh_key_internal_spec.rb +++ b/spec/ec2_ssh_key_internal_spec.rb @@ -1,6 +1,28 @@ +#-- +# Copyright (c) 2010-2012 RightScale Inc +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ + require 'rubygems' require 'rest_connection' -require 'spec' require 'ruby-debug' describe Ec2SshKeyInternal, "ec2_ssh_key internal api object exercise" do diff --git a/spec/image_jockey.rb b/spec/image_jockey.rb index 5ba42e8..e9167aa 100644 --- a/spec/image_jockey.rb +++ b/spec/image_jockey.rb @@ -1,6 +1,28 @@ +#-- +# Copyright (c) 2010-2012 RightScale Inc +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ + require 'rubygems' require 'rest_connection' -require 'spec' describe MultiCloudImageInternal, "exercises the mci internal api" do diff --git a/spec/mcserver_spec.rb b/spec/mcserver_spec.rb index 3aa1c10..23e3d60 100644 --- a/spec/mcserver_spec.rb +++ b/spec/mcserver_spec.rb @@ -1,6 +1,28 @@ +#-- +# Copyright (c) 2010-2012 RightScale Inc +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ + require 'rubygems' require 'rest_connection' -require 'spec' require 'ruby-debug' describe McServer, "server api object exercise" do diff --git a/spec/method_missing_spec.rb b/spec/method_missing_spec.rb index 082f038..46ca3cb 100644 --- a/spec/method_missing_spec.rb +++ b/spec/method_missing_spec.rb @@ -1,6 +1,28 @@ +#-- +# Copyright (c) 2010-2012 RightScale Inc +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ + require 'rubygems' require 'rest_connection' -require 'spec' require 'ruby-debug' describe Server, "using a server" do diff --git a/spec/multi.rb b/spec/multi.rb index beb64da..c89c9fd 100644 --- a/spec/multi.rb +++ b/spec/multi.rb @@ -1,6 +1,28 @@ +#-- +# Copyright (c) 2010-2012 RightScale Inc +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ + require 'rubygems' require 'rest_connection' -require 'spec' require 'ruby-debug' describe MultiCloudImage do diff --git a/spec/right_script_internal.rb b/spec/right_script_internal.rb index 329229f..faf7ef3 100644 --- a/spec/right_script_internal.rb +++ b/spec/right_script_internal.rb @@ -1,3 +1,26 @@ +#-- +# Copyright (c) 2010-2012 RightScale Inc +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ + require File.join(File.dirname(__FILE__), 'spec_helper') require 'ruby-debug' diff --git a/spec/rs_internal_spec.rb b/spec/rs_internal_spec.rb index 5d7df65..a07c0e1 100644 --- a/spec/rs_internal_spec.rb +++ b/spec/rs_internal_spec.rb @@ -1,6 +1,28 @@ +#-- +# Copyright (c) 2010-2012 RightScale Inc +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ + require 'rubygems' require 'rest_connection' -require 'spec' require 'ruby-debug' describe RsInternal, "exercises the rs_internal api" do diff --git a/spec/runtests b/spec/runtests new file mode 100755 index 0000000..07040dc --- /dev/null +++ b/spec/runtests @@ -0,0 +1,9 @@ +#!/bin/bash +for file in ./*.rb +do + if [ "${file}" != "./spec_helper.rb" ] + then + echo "**** Running ${file}..." + rspec ${file} + fi +done diff --git a/spec/server_internal_spec.rb b/spec/server_internal_spec.rb index 7a440cc..d725f8f 100644 --- a/spec/server_internal_spec.rb +++ b/spec/server_internal_spec.rb @@ -1,6 +1,28 @@ +#-- +# Copyright (c) 2010-2012 RightScale Inc +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ + require 'rubygems' require 'rest_connection' -require 'spec' require 'ruby-debug' describe ServerInternal, "server internal api object exercise" do diff --git a/spec/server_spec.rb b/spec/server_spec.rb index c61dbd3..766c70b 100644 --- a/spec/server_spec.rb +++ b/spec/server_spec.rb @@ -1,6 +1,28 @@ +#-- +# Copyright (c) 2010-2012 RightScale Inc +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ + require 'rubygems' require 'rest_connection' -require 'spec' require 'ruby-debug' describe Server, "server api object exercise" do diff --git a/spec/server_template_internal.rb b/spec/server_template_internal.rb index bb53398..47ab648 100644 --- a/spec/server_template_internal.rb +++ b/spec/server_template_internal.rb @@ -1,3 +1,26 @@ +#-- +# Copyright (c) 2010-2012 RightScale Inc +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ + require File.join(File.dirname(__FILE__), 'spec_helper') require 'ruby-debug' diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index effc892..d0f308a 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,7 +1,29 @@ +#-- +# Copyright (c) 2010-2012 RightScale Inc +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ + $LOAD_PATH.unshift(File.dirname(__FILE__)) $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) require 'rubygems' require 'rest_connection' -require 'spec' require 'fileutils' require 'logger' diff --git a/spec/tag_spec.rb b/spec/tag_spec.rb index 0f2c295..1216c5d 100644 --- a/spec/tag_spec.rb +++ b/spec/tag_spec.rb @@ -1,6 +1,5 @@ require 'rubygems' require 'rest_connection' -require 'spec' require 'ruby-debug' describe Tag, "tags" do From 8e65ab793d08953d96dc35056b23189567f09888 Mon Sep 17 00:00:00 2001 From: Jon Marinello Date: Mon, 19 Mar 2012 12:47:14 -0700 Subject: [PATCH 150/239] Fixed problem where ssh(ing) into a rightscale server always failed from a non-cloud Virtual Monkey Controller. This was keeping us from running the monkey from desktops like Mac BSD Unix and most likely this fixes the same issue with non-cloud (local) Linux clients as well. --- lib/rest_connection/ssh_hax.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/rest_connection/ssh_hax.rb b/lib/rest_connection/ssh_hax.rb index a1ab6ce..b13dbca 100644 --- a/lib/rest_connection/ssh_hax.rb +++ b/lib/rest_connection/ssh_hax.rb @@ -153,7 +153,7 @@ def spot_check_command?(command, ssh_key=nil, host_dns=self.reachable_ip) # returns hash of exit_status and output from command def spot_check_command(command, ssh_key=nil, host_dns=self.reachable_ip, do_not_log_result=false) raise "FATAL: spot_check_command called on a server with no reachable_ip. You need to run .settings on the server to populate this attribute." unless host_dns - connection.logger "SSHing to #{host_dns} using key(s) #{ssh_key_config(ssh_key)}" + connection.logger "SSHing to #{host_dns} using key(s) #{ssh_key_config(ssh_key).inspect}" status = nil output = "" success = false @@ -163,7 +163,7 @@ def spot_check_command(command, ssh_key=nil, host_dns=self.reachable_ip, do_not_ # Test for ability to connect; Net::SSH.start sometimes hangs under certain server-side sshd configs test_ssh = "" [5, 15, 60].each { |timeout_max| - test_ssh = `ssh -o \"BatchMode=yes\" -o \"ConnectTimeout #{timeout_max}\" root@#{host_dns} -C \"exit\" 2>&1`.chomp + test_ssh = `ssh -o \"BatchMode=yes\" -o \"StrictHostKeyChecking=no\" -o \"ConnectTimeout #{timeout_max}\" root@#{host_dns} -C \"exit\" 2>&1`.chomp break if test_ssh =~ /permission denied/i or test_ssh.empty? } raise test_ssh unless test_ssh =~ /permission denied/i or test_ssh.empty? From 9edc5bea34b17a818407e10d212427b217224d1e Mon Sep 17 00:00:00 2001 From: Jon Marinello Date: Mon, 19 Mar 2012 12:52:20 -0700 Subject: [PATCH 151/239] Bumped version to 0.1.9 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 699c6c6..1a03094 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.1.8 +0.1.9 From e72521415256ae9f70ff0e47b0e63e997c494597 Mon Sep 17 00:00:00 2001 From: Jon Marinello Date: Mon, 19 Mar 2012 19:33:27 -0700 Subject: [PATCH 152/239] Merged pre-commit branch into master. Squashed commit of the following: commit 96897126101cce05532ceb7bf06f0e1331b94fb2 Author: Jon Marinello Date: Mon Mar 19 17:37:22 2012 -0700 Removed testfile.rb. commit 7381fc407e3c119780d3cd14aae243bc7b491ea8 Author: Jon Marinello Date: Tue Mar 20 00:34:45 2012 +0000 Checked that pre-commit script removed trailing spaces. commit c6118d2fe9e574e71f7d94c3a26ed72f39d0d8f3 Author: Jon Marinello Date: Mon Mar 19 17:33:10 2012 -0700 Added file to test pre-commit script. commit 8cbcc1bd1b47e54ec35c649190cef6b6d5ef344d Author: Jon Marinello Date: Mon Mar 19 17:28:18 2012 -0700 Fixed pre-commit script to work in a degraded fashion on the Mac. --- git_hooks/pre-commit | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/git_hooks/pre-commit b/git_hooks/pre-commit index 5a09580..48a8eef 100755 --- a/git_hooks/pre-commit +++ b/git_hooks/pre-commit @@ -31,17 +31,28 @@ MMMN NMM$ MMM MMM EOS } +mac_unix_name=Darwin +uname_returned=`uname -a` +unix_name=${uname_returned:0:${#mac_unix_name}} +if [ "$unix_name" = "$mac_unix_name" ]; then + echo "MAC OS \"$mac_unix_name\" detected so whitespace modification logic suppressed..." +else + echo "non-MAC OS detected..." +fi + whitespace="" echo "Checking for syntax errors..." for FILE in `git diff-index --name-only HEAD --` ; do if test -f $FILE; then - filetype=`file -b $FILE` - if [[ "$filetype" =~ "text" ]]; then - if [[ -n `grep "\\s\\s*$" $FILE` ]]; then whitespace="$whitespace $FILE"; fi - # Remove trailing whitespace - sed -i "s/\\s\\s*$//g" $FILE - # Remove tabs - sed -i "s/\t/ /g" $FILE + if [ "$unix_name" != "$mac_unix_name" ]; then + filetype=`file -b $FILE` + if [[ "$filetype" =~ "text" ]]; then + if [[ -n `grep "\\s\\s*$" $FILE` ]]; then whitespace="$whitespace $FILE"; fi + # Remove trailing whitespace + sed -i "s/\\s\\s*$//g" $FILE + # Remove tabs + sed -i "s/\t/ /g" $FILE + fi fi # If a file is ruby, check for syntax errors using ruby @@ -107,10 +118,12 @@ if [[ "$fail" -ne 0 && -n "$fail" ]]; then exit 1 fi -for FILE in $whitespace; do - echo "Whitespace problem fixed. Please re-add '$FILE' to your commit" -done -if [[ -n "$whitespace" ]]; then lod_message; exit 1; fi +if [ "$unix_name" != "$mac_unix_name" ]; then + for FILE in $whitespace; do + echo "Whitespace problem fixed. Please re-add '$FILE' to your commit" + done + if [[ -n "$whitespace" ]]; then lod_message; exit 1; fi +fi # Check that project metadata files exist for FILE in "README.rdoc" "VERSION" ".gitignore" "Rakefile"; do From e6ac663a5059ee513552d111b93df2eaf1cb71a3 Mon Sep 17 00:00:00 2001 From: Jon Marinello Date: Thu, 22 Mar 2012 07:08:38 -0700 Subject: [PATCH 153/239] Added rest_connection.gemspec ignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 3e57bca..da2d5b1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ *.swp *.swo pkg/* +rest_connection.gemspec From f9a04567e2fd233705bca74c8166472f10f82906 Mon Sep 17 00:00:00 2001 From: Jon Marinello Date: Mon, 26 Mar 2012 08:55:10 -0700 Subject: [PATCH 154/239] Bumped version to 0.1.10 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 1a03094..9767cc9 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.1.9 +0.1.10 From 0e75a22a9ab1faa8c5d9284bae6729c5b0118c7c Mon Sep 17 00:00:00 2001 From: Peter Schroeter Date: Sun, 29 Apr 2012 23:11:15 -0700 Subject: [PATCH 155/239] support for some more CRUD operations for multicloud images --- .../rightscale/mc_multi_cloud_image.rb | 16 ++++++++++++---- .../rightscale/mc_multi_cloud_image_setting.rb | 9 ++++++++- .../rightscale/mc_server_template.rb | 2 +- .../rightscale/multi_cloud_image.rb | 2 +- .../rightscale/rightscale_api_gateway.rb | 7 ++++++- 5 files changed, 28 insertions(+), 8 deletions(-) diff --git a/lib/rest_connection/rightscale/mc_multi_cloud_image.rb b/lib/rest_connection/rightscale/mc_multi_cloud_image.rb index 39dbb80..52f3d75 100644 --- a/lib/rest_connection/rightscale/mc_multi_cloud_image.rb +++ b/lib/rest_connection/rightscale/mc_multi_cloud_image.rb @@ -29,9 +29,8 @@ class McMultiCloudImage extend RightScale::Api::GatewayExtend include RightScale::Api::McTaggable extend RightScale::Api::McTaggableExtend - attr_reader :settings - deny_methods :create, :destroy, :update + deny_methods :update #supported in API, not imp'd in code yet def resource_plural_name "multi_cloud_images" @@ -58,10 +57,17 @@ def self.filters end def supported_cloud_ids - @settings.map { |mcics| mcics.cloud_id } + settings.map { |mcics| mcics.cloud_id } end - def get_settings + def reload + @settings = nil + super + end + + # Note, only returns API 1.5 clouds, API 1.0 omitted + def settings + return @settings if @settings @settings = [] url = URI.parse(self.href) connection.get(url.path + '/settings').each { |s| @@ -69,4 +75,6 @@ def get_settings } @settings end + def get_settings; settings; end + end diff --git a/lib/rest_connection/rightscale/mc_multi_cloud_image_setting.rb b/lib/rest_connection/rightscale/mc_multi_cloud_image_setting.rb index 60b18f7..bdf6158 100644 --- a/lib/rest_connection/rightscale/mc_multi_cloud_image_setting.rb +++ b/lib/rest_connection/rightscale/mc_multi_cloud_image_setting.rb @@ -28,7 +28,7 @@ class McMultiCloudImageSetting include RightScale::Api::Gateway extend RightScale::Api::GatewayExtend - deny_methods :create, :destroy, :update + deny_methods :update #supported in API, not imp'd in code yet def resource_plural_name "settings" @@ -57,4 +57,11 @@ def self.filters def cloud_id self.cloud.split(/\//).last.to_i end + + # API 1.5 MultiCloudImageSetting is posted to url + # /api/multi_cloud_images/:id/settings but the object it posts to the + # API is named :multi_cloud_image_setting => { attrs } + def self.resource_post_name + "multi_cloud_image_setting" + end end diff --git a/lib/rest_connection/rightscale/mc_server_template.rb b/lib/rest_connection/rightscale/mc_server_template.rb index d4c5733..023d396 100644 --- a/lib/rest_connection/rightscale/mc_server_template.rb +++ b/lib/rest_connection/rightscale/mc_server_template.rb @@ -53,7 +53,7 @@ def self.filters def get_mcis_and_settings @params["multi_cloud_images"] = McMultiCloudImage.find_all(self.rs_id) - @params["multi_cloud_images"].each { |mci| mci.get_settings } + @params["multi_cloud_images"].each { |mci| mci.settings } # Eager load @mci_links = McServerTemplateMultiCloudImage.find_with_filter(:server_template_href => self.href) end diff --git a/lib/rest_connection/rightscale/multi_cloud_image.rb b/lib/rest_connection/rightscale/multi_cloud_image.rb index 9e777a0..18eef40 100644 --- a/lib/rest_connection/rightscale/multi_cloud_image.rb +++ b/lib/rest_connection/rightscale/multi_cloud_image.rb @@ -41,7 +41,7 @@ def find_and_flatten_settings() # The .settings call filters out non-ec2 images more_settings = [] if total_image_count > internal.settings.size - more_settings = McMultiCloudImage.find(rs_id.to_i).get_settings + more_settings = McMultiCloudImage.find(rs_id.to_i).settings end @params["multi_cloud_image_cloud_settings"] = internal.settings + more_settings end diff --git a/lib/rest_connection/rightscale/rightscale_api_gateway.rb b/lib/rest_connection/rightscale/rightscale_api_gateway.rb index 2e3e82d..0d0d574 100644 --- a/lib/rest_connection/rightscale/rightscale_api_gateway.rb +++ b/lib/rest_connection/rightscale/rightscale_api_gateway.rb @@ -280,6 +280,11 @@ def filters() [] end + # Hack for McMultiCloudImageSetting class to fix a API quirk + def resource_post_name + self.resource_singular_name + end + def create(*args) if args.last.is_a?(Hash) opts = args.pop @@ -287,7 +292,7 @@ def create(*args) raise ArgumentError.new("create requires the last argument to be a Hash") end url = "#{parse_args(*args)}#{self.resource_plural_name}" - location = connection.post(url, self.resource_singular_name.to_sym => opts) + location = connection.post(url, self.resource_post_name.to_sym => opts) newrecord = self.new('links' => [ {'rel' => 'self', 'href' => location } ]) newrecord.reload newrecord From 0f2122362b77ff8f1c1e454a93d77657bb63c3af Mon Sep 17 00:00:00 2001 From: Jon Marinello Date: Mon, 11 Jun 2012 14:16:42 -0700 Subject: [PATCH 156/239] Added RubyMine. --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index da2d5b1..9d4c1fd 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,6 @@ *.swo pkg/* rest_connection.gemspec + +## RubyMine +.idea \ No newline at end of file From 0db26e6fd4365d67d9704b98c69c0a02cc182cd6 Mon Sep 17 00:00:00 2001 From: Jon Marinello Date: Mon, 11 Jun 2012 15:43:08 -0700 Subject: [PATCH 157/239] New rest_connection api log parser. --- log_api_call_parser | 81 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100755 log_api_call_parser diff --git a/log_api_call_parser b/log_api_call_parser new file mode 100755 index 0000000..6443479 --- /dev/null +++ b/log_api_call_parser @@ -0,0 +1,81 @@ +#!/usr/bin/ruby + +#-- +# Copyright (c) 2012 RightScale, Inc, All Rights Reserved Worldwide. +# +# THIS PROGRAM IS CONFIDENTIAL AND PROPRIETARY TO RIGHTSCALE +# AND CONSTITUTES A VALUABLE TRADE SECRET. Any unauthorized use, +# reproduction, modification, or disclosure of this program is +# strictly prohibited. Any use of this program by an authorized +# licensee is strictly subject to the terms and conditions, +# including confidentiality obligations, set forth in the applicable +# License Agreement between RightScale, Inc. and +# the licensee. +#++ + +######################################################################################################################## +# rest_connection API Call Parser Main program +# +# This program will parse a log produced from any given monkey run and display the: +# - API version +# - Request Type +# - Request +# in tabular format on STDOUT. It will also generate the csv file odf the same information. +######################################################################################################################## + +# Third party requires +require 'rubygems' +require 'trollop' +require 'terminal-table' +require 'tempfile' +require 'csv' + +# +# Parse and validate command line arguments +# +opts = Trollop::options do + banner <<-EOS +Usage: +log_api_call_parser [options] + where [options] are: + EOS + opt :input, "Path to the input file in standard rest_connection logger format", :short => "-i", :type => String, :required => true + opt :csv_file, "Path to the csv output file", :short => "-o", :type => String, :required => true +end + +# Open the input file and read it into an array +input_file = File.open(opts[:input]) +log_file_array = input_file.readlines +input_file.close + +# open the output CSV file +csv_file = File.open(opts[:csv_file], "w") +csv_file_name = csv_file.path() + +# Loop over the array and for each row, parse out the api version, Get/Put and the url +log_file_array.each { |element| + if element[0..2] == "I, " + element = element[50..-1] + #puts element + version = element[5..8] + request_type = element[11..13] + if request_type == "GET" || request_type == "PUT" + request = element[16..-1] + output_string = "#{version},#{request_type},#{request}" + csv_file.puts output_string + end + end +} + +# close the output file +csv_file.close + +# Generate a table version and write that out to STDOUT +csv_array = CSV.read(csv_file_name) +table = Terminal::Table.new +csv_array.collect do |line| + table << line + table << :separator +end +puts table + From 56d9702e7320129b1c401dc2ab3ac0b815058f38 Mon Sep 17 00:00:00 2001 From: Jon Marinello Date: Mon, 11 Jun 2012 16:10:35 -0700 Subject: [PATCH 158/239] Sorted the results by API version and removed duplicates. --- log_api_call_parser | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/log_api_call_parser b/log_api_call_parser index 6443479..4d2dfa0 100755 --- a/log_api_call_parser +++ b/log_api_call_parser @@ -52,7 +52,9 @@ input_file.close csv_file = File.open(opts[:csv_file], "w") csv_file_name = csv_file.path() -# Loop over the array and for each row, parse out the api version, Get/Put and the url +# Loop over the array and for each row, parse out the api version, request type and the request +# and add them to output_array for later sorting and writing. +output_array = [] log_file_array.each { |element| if element[0..2] == "I, " element = element[50..-1] @@ -61,12 +63,20 @@ log_file_array.each { |element| request_type = element[11..13] if request_type == "GET" || request_type == "PUT" request = element[16..-1] - output_string = "#{version},#{request_type},#{request}" - csv_file.puts output_string + output_array.push "#{version},#{request_type},#{request}" end end } +# Sort the output array by API version +output_array.sort! {|a,b| a <=> b} + +# Remove duplicates +output_array.uniq! + +# Write out the CSV file +output_array.each { |element| csv_file.puts element } + # close the output file csv_file.close From 7b5a9a5b28449fb8f69a34f223d4acec8799d54c Mon Sep 17 00:00:00 2001 From: Jon Marinello Date: Mon, 11 Jun 2012 17:16:36 -0700 Subject: [PATCH 159/239] Added computation of the api_start_column in log_api_call_parser as this can vary at least per log. --- log_api_call_parser | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/log_api_call_parser b/log_api_call_parser index 4d2dfa0..561a231 100755 --- a/log_api_call_parser +++ b/log_api_call_parser @@ -48,17 +48,18 @@ input_file = File.open(opts[:input]) log_file_array = input_file.readlines input_file.close -# open the output CSV file -csv_file = File.open(opts[:csv_file], "w") -csv_file_name = csv_file.path() - # Loop over the array and for each row, parse out the api version, request type and the request # and add them to output_array for later sorting and writing. output_array = [] +search_string = "INFO -- :" log_file_array.each { |element| if element[0..2] == "I, " - element = element[50..-1] - #puts element + # Find the API version start column as this can vary at least per log file and maybe even per line + api_version_start_column = element.index(search_string) + api_version_start_column = api_version_start_column + search_string.length + 1 + + # Get the elements + element = element[api_version_start_column..-1] version = element[5..8] request_type = element[11..13] if request_type == "GET" || request_type == "PUT" @@ -75,9 +76,9 @@ output_array.sort! {|a,b| a <=> b} output_array.uniq! # Write out the CSV file +csv_file = File.open(opts[:csv_file], "w") +csv_file_name = csv_file.path() output_array.each { |element| csv_file.puts element } - -# close the output file csv_file.close # Generate a table version and write that out to STDOUT From 5e5204a748bac8378ebec5b95e1b36d08b5fd467 Mon Sep 17 00:00:00 2001 From: Ryan Cragun Date: Tue, 26 Jun 2012 12:29:41 -0700 Subject: [PATCH 160/239] Added lock/unlock methods to Server class --- lib/rest_connection/rightscale/server.rb | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/lib/rest_connection/rightscale/server.rb b/lib/rest_connection/rightscale/server.rb index ff4e56c..987384a 100644 --- a/lib/rest_connection/rightscale/server.rb +++ b/lib/rest_connection/rightscale/server.rb @@ -455,4 +455,25 @@ def clear_tags(namespace = nil) tags = tags.select { |tag| tag.start_with?("#{namespace}:") } if namespace self.remove_tags(*tags) end + + def lock + unless self.settings['locked'] + serv_href = URI.parse(self.href) + res = connection.put(serv_href.path, :server => {:lock => 'true'}) + res.is_a?(Net::HTTPSuccess) ? true : false + else + connection.logger("Server is already locked") + end + end + + def unlock + if self.settings['locked'] + serv_href = URI.parse(self.href) + res = connection.put(serv_href.path, :server => {:lock => 'false'}) + res.is_a?(Net::HTTPSuccess) ? true : false + else + connection.logger("Server is already unlocked") + end + end + end From cd48390cdfa180e024c81e57da24ebce1cd58e9d Mon Sep 17 00:00:00 2001 From: Jon Marinello Date: Tue, 26 Jun 2012 13:03:20 -0700 Subject: [PATCH 161/239] Update usage comment. --- log_api_call_parser | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log_api_call_parser b/log_api_call_parser index 561a231..9a56864 100755 --- a/log_api_call_parser +++ b/log_api_call_parser @@ -16,7 +16,7 @@ ######################################################################################################################## # rest_connection API Call Parser Main program # -# This program will parse a log produced from any given monkey run and display the: +# This program will parse a rest_connection.log produced from any given monkey run and display the: # - API version # - Request Type # - Request From db219dc4d63382da2697fe3c3df88211fb0d7aba Mon Sep 17 00:00:00 2001 From: Jon Marinello Date: Tue, 26 Jun 2012 14:57:30 -0700 Subject: [PATCH 162/239] Updated config instructions comment. --- README.rdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rdoc b/README.rdoc index 6e74eda..d7b9c04 100644 --- a/README.rdoc +++ b/README.rdoc @@ -13,7 +13,7 @@ You must setup ~/.rest_connection/rest_api_config.yaml or /etc/rest_connection/rest_api_config.yaml -Copy the example from GEMHOME/rest_connection/examples/rest_api_config.yaml.sample and fill in your connection info. +Copy the example from GEMHOME/rest_connection/config/rest_api_config.yaml.sample and fill in your connection info. Pro Tip: to find a GEMHOME, use gemedit "gem install gemedit" From 4ed939302ceea26bccb89b5e6325d0432141da24 Mon Sep 17 00:00:00 2001 From: jonmarinellors Date: Tue, 10 Jul 2012 16:57:55 -0700 Subject: [PATCH 163/239] Updated LICENSE file contents. --- LICENSE | 32 ++++++++++---------------------- 1 file changed, 10 insertions(+), 22 deletions(-) diff --git a/LICENSE b/LICENSE index b5b49b6..12aab0a 100644 --- a/LICENSE +++ b/LICENSE @@ -1,22 +1,10 @@ -#-- -# Copyright (c) 2010-2012 RightScale Inc -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -#++ \ No newline at end of file +Copyright (c) 2012 RightScale, Inc, All Rights Reserved Worldwide. + +THIS PROGRAM IS CONFIDENTIAL AND PROPRIETARY TO RIGHTSCALE +AND CONSTITUTES A VALUABLE TRADE SECRET. Any unauthorized use, +reproduction, modification, or disclosure of this program is +strictly prohibited. Any use of this program by an authorized +licensee is strictly subject to the terms and conditions, +including confidentiality obligations, set forth in the applicable +License Agreement between RightScale, Inc. and +the licensee. From 2d4a484a145d6dfb151c9e1d703463284146d7ae Mon Sep 17 00:00:00 2001 From: Jon Marinello Date: Wed, 11 Jul 2012 13:11:13 -0700 Subject: [PATCH 164/239] Implemented Azure rest_connection McServer.launch() hack to return on 422 conflict exception --- config/rest_api_config.yaml.sample | 8 ++++--- lib/rest_connection.rb | 2 ++ lib/rest_connection/rightscale/mc_server.rb | 23 +++++++++++++++++++-- 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/config/rest_api_config.yaml.sample b/config/rest_api_config.yaml.sample index 30f72eb..1f50eb2 100644 --- a/config/rest_api_config.yaml.sample +++ b/config/rest_api_config.yaml.sample @@ -1,10 +1,12 @@ ---- -:ssh_keys: +--- +:ssh_keys: - ~/.ssh/my_server_key - ~/.ssh/my_server_key-eu - ~/.ssh/my_server_key-west :pass: myUltraSecurePasswordz :user: myUserEmail@MyMailDomain.com :api_url: https://my.rightscale.com/api/acct/00000000 -:common_headers: +:common_headers: X_API_VERSION: "1.0" +:azure_hack_on: true +:azure_hack_sleep_seconds: 60 diff --git a/lib/rest_connection.rb b/lib/rest_connection.rb index 42c06dd..7fc16dc 100644 --- a/lib/rest_connection.rb +++ b/lib/rest_connection.rb @@ -81,6 +81,8 @@ def initialize(config_yaml = File.join(File.expand_path("~"), ".rest_connection" @@pass = ask("Password:") { |q| q.echo = false } unless @@pass @settings[:pass] = @@pass end + @settings[:azure_hack_on] ||= true + @settings[:azure_hack_sleep_seconds] ||= 60 end # Main HTTP connection loop. Common settings are set here, then we yield(BASE_URI, OPTIONAL_HEADERS) to other methods for each type of HTTP request: GET, PUT, POST, DELETE diff --git a/lib/rest_connection/rightscale/mc_server.rb b/lib/rest_connection/rightscale/mc_server.rb index b8246b9..108d8e2 100644 --- a/lib/rest_connection/rightscale/mc_server.rb +++ b/lib/rest_connection/rightscale/mc_server.rb @@ -56,8 +56,27 @@ def self.filters def launch if actions.include?("launch") - t = URI.parse(self.href) - connection.post(t.path + '/launch') + begin + t = URI.parse(self.href) + connection.post(t.path + '/launch') + rescue RestConnection::Errors => e + # THIS IS A TEMPORARY HACK TO GET AROUND AZURE SERVER LAUNCH PROBLEMS AND SHOULD BE REMOVED ONCE MICROSOFT + # FIXES THIS BUG ON THEIR END! + + # Retry on 422 conflict exception (ONLY MS AZURE WILL GENERATE THIS EXCEPTION) + if e.message =~ "Invalid response HTTP code: 422: CloudException: ConflictError:" + if @settings[:azure_hack_on] + # sleep for azure_hack_sleep_seconds seconds + sleep(@settings[:azure_hack_sleep_seconds]) + + # retry the launch + t = URI.parse(self.href) + connection.post(t.path + '/launch') + else + raise + end + end + end elsif self.state == "inactive" raise "FATAL: Server is in an unlaunchable state!" else From 7de5e85437728e6aa1f536f5e637bae0e3f0d214 Mon Sep 17 00:00:00 2001 From: Jon Marinello Date: Wed, 11 Jul 2012 13:22:12 -0700 Subject: [PATCH 165/239] Added warning message for Azure launch hack. --- lib/rest_connection/rightscale/mc_server.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/rest_connection/rightscale/mc_server.rb b/lib/rest_connection/rightscale/mc_server.rb index 108d8e2..8ffb7b9 100644 --- a/lib/rest_connection/rightscale/mc_server.rb +++ b/lib/rest_connection/rightscale/mc_server.rb @@ -66,6 +66,8 @@ def launch # Retry on 422 conflict exception (ONLY MS AZURE WILL GENERATE THIS EXCEPTION) if e.message =~ "Invalid response HTTP code: 422: CloudException: ConflictError:" if @settings[:azure_hack_on] + warn "McServer.launch() caught Azure exception: Invalid response HTTP code: 422: CloudException: ConflictError: sleeping for #{@settings[:azure_hack_sleep_seconds]} seconds and then retrying server launch..." + # sleep for azure_hack_sleep_seconds seconds sleep(@settings[:azure_hack_sleep_seconds]) From 59306055300b96a0bb935256f6842a3dd4d723b9 Mon Sep 17 00:00:00 2001 From: Jon Marinello Date: Wed, 11 Jul 2012 14:07:17 -0700 Subject: [PATCH 166/239] Added retry logic to Azure hack and some logging statements. --- config/rest_api_config.yaml.sample | 1 + lib/rest_connection.rb | 1 + lib/rest_connection/rightscale/mc_server.rb | 41 ++++++++++++++++----- 3 files changed, 33 insertions(+), 10 deletions(-) diff --git a/config/rest_api_config.yaml.sample b/config/rest_api_config.yaml.sample index 1f50eb2..aa5ef51 100644 --- a/config/rest_api_config.yaml.sample +++ b/config/rest_api_config.yaml.sample @@ -9,4 +9,5 @@ :common_headers: X_API_VERSION: "1.0" :azure_hack_on: true +:azure_hack_retry_count: 5 :azure_hack_sleep_seconds: 60 diff --git a/lib/rest_connection.rb b/lib/rest_connection.rb index 7fc16dc..74ecb26 100644 --- a/lib/rest_connection.rb +++ b/lib/rest_connection.rb @@ -82,6 +82,7 @@ def initialize(config_yaml = File.join(File.expand_path("~"), ".rest_connection" @settings[:pass] = @@pass end @settings[:azure_hack_on] ||= true + @settings[:azure_hack_retry_count] ||= 5 @settings[:azure_hack_sleep_seconds] ||= 60 end diff --git a/lib/rest_connection/rightscale/mc_server.rb b/lib/rest_connection/rightscale/mc_server.rb index 8ffb7b9..eb3690b 100644 --- a/lib/rest_connection/rightscale/mc_server.rb +++ b/lib/rest_connection/rightscale/mc_server.rb @@ -56,24 +56,45 @@ def self.filters def launch if actions.include?("launch") + t = URI.parse(self.href) begin - t = URI.parse(self.href) + puts "************* In mcserver.launch() attempting launch **********************" connection.post(t.path + '/launch') rescue RestConnection::Errors => e + puts "************* In mcserver.launch() caught exception #{e.inspect} **********************" + puts "************* @settings[:azure_hack_on] = #{@settings[:azure_hack_on]} **********************" + puts "************* @settings[:azure_hack_retry_count] = #{@settings[:azure_hack_retry_count]} **********************" + puts "************* @settings[:azure_hack_sleep_seconds] = #{@settings[:azure_hack_sleep_seconds]} **********************" # THIS IS A TEMPORARY HACK TO GET AROUND AZURE SERVER LAUNCH PROBLEMS AND SHOULD BE REMOVED ONCE MICROSOFT # FIXES THIS BUG ON THEIR END! # Retry on 422 conflict exception (ONLY MS AZURE WILL GENERATE THIS EXCEPTION) - if e.message =~ "Invalid response HTTP code: 422: CloudException: ConflictError:" + target_error_message = "Invalid response HTTP code: 422: CloudException: ConflictError:" + if e.message =~ target_error_message + puts "************* In mcserver.launch() exception matched **********************" if @settings[:azure_hack_on] - warn "McServer.launch() caught Azure exception: Invalid response HTTP code: 422: CloudException: ConflictError: sleeping for #{@settings[:azure_hack_sleep_seconds]} seconds and then retrying server launch..." - - # sleep for azure_hack_sleep_seconds seconds - sleep(@settings[:azure_hack_sleep_seconds]) - - # retry the launch - t = URI.parse(self.href) - connection.post(t.path + '/launch') + azure_hack_retry_count = @settings[:azure_hack_retry_count] + warn "McServer.launch() caught Azure exception: Invalid response HTTP code: 422: CloudException: ConflictError: sleeping for #{@settings[:azure_hack_sleep_seconds]} seconds and then retrying server launch #{} times..." + + loop do + # sleep for azure_hack_sleep_seconds seconds + sleep(@settings[:azure_hack_sleep_seconds]) + + # retry the launch + begin + connection.post(t.path + '/launch') + rescue => e + if e.message =~ target_error_message + azure_hack_retry_count -= 1 + if azure_hack_retry_count > 0 + next + else + raise + end + end + end + break + end else raise end From 888de64107541a3d5449e1ab6d2e34508f9160b9 Mon Sep 17 00:00:00 2001 From: Jon Marinello Date: Wed, 11 Jul 2012 14:20:06 -0700 Subject: [PATCH 167/239] Changed exception rescue on azure hack. --- lib/rest_connection/rightscale/mc_server.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/rest_connection/rightscale/mc_server.rb b/lib/rest_connection/rightscale/mc_server.rb index eb3690b..0b085a9 100644 --- a/lib/rest_connection/rightscale/mc_server.rb +++ b/lib/rest_connection/rightscale/mc_server.rb @@ -60,7 +60,7 @@ def launch begin puts "************* In mcserver.launch() attempting launch **********************" connection.post(t.path + '/launch') - rescue RestConnection::Errors => e + rescue Exception => e puts "************* In mcserver.launch() caught exception #{e.inspect} **********************" puts "************* @settings[:azure_hack_on] = #{@settings[:azure_hack_on]} **********************" puts "************* @settings[:azure_hack_retry_count] = #{@settings[:azure_hack_retry_count]} **********************" @@ -83,8 +83,8 @@ def launch # retry the launch begin connection.post(t.path + '/launch') - rescue => e - if e.message =~ target_error_message + rescue Exception => e2 + if e2.message =~ target_error_message azure_hack_retry_count -= 1 if azure_hack_retry_count > 0 next From 6a7c6838773d95c8b0bc825046e054b6819a3328 Mon Sep 17 00:00:00 2001 From: Jon Marinello Date: Wed, 11 Jul 2012 14:24:34 -0700 Subject: [PATCH 168/239] Improved logging on azure hack. --- lib/rest_connection/rightscale/mc_server.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/rest_connection/rightscale/mc_server.rb b/lib/rest_connection/rightscale/mc_server.rb index 0b085a9..064de73 100644 --- a/lib/rest_connection/rightscale/mc_server.rb +++ b/lib/rest_connection/rightscale/mc_server.rb @@ -74,10 +74,12 @@ def launch puts "************* In mcserver.launch() exception matched **********************" if @settings[:azure_hack_on] azure_hack_retry_count = @settings[:azure_hack_retry_count] - warn "McServer.launch() caught Azure exception: Invalid response HTTP code: 422: CloudException: ConflictError: sleeping for #{@settings[:azure_hack_sleep_seconds]} seconds and then retrying server launch #{} times..." + warn "McServer.launch() caught Azure exception: Invalid response HTTP code: 422: CloudException: ConflictError:" + retry_count = 1 loop do # sleep for azure_hack_sleep_seconds seconds + warn "Sleeping for #{@settings[:azure_hack_sleep_seconds]} seconds and then retrying launch (retry count = #{retry_count})..." sleep(@settings[:azure_hack_sleep_seconds]) # retry the launch @@ -87,6 +89,7 @@ def launch if e2.message =~ target_error_message azure_hack_retry_count -= 1 if azure_hack_retry_count > 0 + retry_count += 1 next else raise From ba8d466e5df694e738a69ade6dc6d3b174f07830 Mon Sep 17 00:00:00 2001 From: Jon Marinello Date: Wed, 11 Jul 2012 14:42:25 -0700 Subject: [PATCH 169/239] Fixed settings references in azure hack. --- lib/rest_connection/rightscale/mc_server.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/rest_connection/rightscale/mc_server.rb b/lib/rest_connection/rightscale/mc_server.rb index 064de73..720dbb5 100644 --- a/lib/rest_connection/rightscale/mc_server.rb +++ b/lib/rest_connection/rightscale/mc_server.rb @@ -62,9 +62,9 @@ def launch connection.post(t.path + '/launch') rescue Exception => e puts "************* In mcserver.launch() caught exception #{e.inspect} **********************" - puts "************* @settings[:azure_hack_on] = #{@settings[:azure_hack_on]} **********************" - puts "************* @settings[:azure_hack_retry_count] = #{@settings[:azure_hack_retry_count]} **********************" - puts "************* @settings[:azure_hack_sleep_seconds] = #{@settings[:azure_hack_sleep_seconds]} **********************" + puts "************* connection.settings[:azure_hack_on] = #{connection.settings[:azure_hack_on]} **********************" + puts "************* connection.settings[:azure_hack_retry_count] = #{connection.settings[:azure_hack_retry_count]} **********************" + puts "************* connection.settings[:azure_hack_sleep_seconds] = #{connection.settings[:azure_hack_sleep_seconds]} **********************" # THIS IS A TEMPORARY HACK TO GET AROUND AZURE SERVER LAUNCH PROBLEMS AND SHOULD BE REMOVED ONCE MICROSOFT # FIXES THIS BUG ON THEIR END! @@ -72,15 +72,15 @@ def launch target_error_message = "Invalid response HTTP code: 422: CloudException: ConflictError:" if e.message =~ target_error_message puts "************* In mcserver.launch() exception matched **********************" - if @settings[:azure_hack_on] - azure_hack_retry_count = @settings[:azure_hack_retry_count] + if connection.settings[:azure_hack_on] + azure_hack_retry_count = connection.settings[:azure_hack_retry_count] warn "McServer.launch() caught Azure exception: Invalid response HTTP code: 422: CloudException: ConflictError:" retry_count = 1 loop do # sleep for azure_hack_sleep_seconds seconds - warn "Sleeping for #{@settings[:azure_hack_sleep_seconds]} seconds and then retrying launch (retry count = #{retry_count})..." - sleep(@settings[:azure_hack_sleep_seconds]) + warn "Sleeping for #{connection.settings[:azure_hack_sleep_seconds]} seconds and then retrying launch (retry count = #{retry_count})..." + sleep(connection.settings[:azure_hack_sleep_seconds]) # retry the launch begin From 25ec13a1e9fcbec1f2a49e438bfb8aea9645e83a Mon Sep 17 00:00:00 2001 From: Jon Marinello Date: Wed, 11 Jul 2012 15:19:26 -0700 Subject: [PATCH 170/239] Fixed regex and some logging changes for Azure hack. --- lib/rest_connection/rightscale/mc_server.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/rest_connection/rightscale/mc_server.rb b/lib/rest_connection/rightscale/mc_server.rb index 720dbb5..994b39c 100644 --- a/lib/rest_connection/rightscale/mc_server.rb +++ b/lib/rest_connection/rightscale/mc_server.rb @@ -70,23 +70,23 @@ def launch # Retry on 422 conflict exception (ONLY MS AZURE WILL GENERATE THIS EXCEPTION) target_error_message = "Invalid response HTTP code: 422: CloudException: ConflictError:" - if e.message =~ target_error_message + if e.message =~ /#{target_error_message}/ puts "************* In mcserver.launch() exception matched **********************" if connection.settings[:azure_hack_on] azure_hack_retry_count = connection.settings[:azure_hack_retry_count] - warn "McServer.launch() caught Azure exception: Invalid response HTTP code: 422: CloudException: ConflictError:" + connection.logger("McServer.launch(): Caught Azure exception: #{target_error_message}") retry_count = 1 loop do # sleep for azure_hack_sleep_seconds seconds - warn "Sleeping for #{connection.settings[:azure_hack_sleep_seconds]} seconds and then retrying launch (retry count = #{retry_count})..." + connection.logger("McServer.launch(): Sleeping for #{connection.settings[:azure_hack_sleep_seconds]} seconds and then retrying (#{retry_count}) launch...") sleep(connection.settings[:azure_hack_sleep_seconds]) # retry the launch begin connection.post(t.path + '/launch') rescue Exception => e2 - if e2.message =~ target_error_message + if e2.message =~ /#{target_error_message}/ azure_hack_retry_count -= 1 if azure_hack_retry_count > 0 retry_count += 1 From e4dd0cfc5589fec130b67a58ee7c0df4e1a06cb8 Mon Sep 17 00:00:00 2001 From: Jon Marinello Date: Wed, 11 Jul 2012 15:54:03 -0700 Subject: [PATCH 171/239] Cleaned up logging messages and added a raise if the retry didn't match the target message for Azure hack. --- lib/rest_connection/rightscale/mc_server.rb | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/lib/rest_connection/rightscale/mc_server.rb b/lib/rest_connection/rightscale/mc_server.rb index 994b39c..ed18d64 100644 --- a/lib/rest_connection/rightscale/mc_server.rb +++ b/lib/rest_connection/rightscale/mc_server.rb @@ -58,28 +58,30 @@ def launch if actions.include?("launch") t = URI.parse(self.href) begin - puts "************* In mcserver.launch() attempting launch **********************" connection.post(t.path + '/launch') rescue Exception => e - puts "************* In mcserver.launch() caught exception #{e.inspect} **********************" - puts "************* connection.settings[:azure_hack_on] = #{connection.settings[:azure_hack_on]} **********************" - puts "************* connection.settings[:azure_hack_retry_count] = #{connection.settings[:azure_hack_retry_count]} **********************" - puts "************* connection.settings[:azure_hack_sleep_seconds] = #{connection.settings[:azure_hack_sleep_seconds]} **********************" + puts "************* McServer.launch(): Caught exception #{e.inspect}" + puts "************* McServer.launch(): connection.settings[:azure_hack_on] = #{connection.settings[:azure_hack_on]}" + puts "************* McServer.launch(): connection.settings[:azure_hack_retry_count] = #{connection.settings[:azure_hack_retry_count]}" + puts "************* McServer.launch(): connection.settings[:azure_hack_sleep_seconds] = #{connection.settings[:azure_hack_sleep_seconds]}" # THIS IS A TEMPORARY HACK TO GET AROUND AZURE SERVER LAUNCH PROBLEMS AND SHOULD BE REMOVED ONCE MICROSOFT # FIXES THIS BUG ON THEIR END! # Retry on 422 conflict exception (ONLY MS AZURE WILL GENERATE THIS EXCEPTION) target_error_message = "Invalid response HTTP code: 422: CloudException: ConflictError:" if e.message =~ /#{target_error_message}/ - puts "************* In mcserver.launch() exception matched **********************" if connection.settings[:azure_hack_on] azure_hack_retry_count = connection.settings[:azure_hack_retry_count] - connection.logger("McServer.launch(): Caught Azure exception: #{target_error_message}") + exception_matched_message = "************* McServer.launch(): Matched Azure exception: \"#{target_error_message}\"" + puts(exception_matched_message) + connection.logger(exception_matched_message) retry_count = 1 loop do # sleep for azure_hack_sleep_seconds seconds - connection.logger("McServer.launch(): Sleeping for #{connection.settings[:azure_hack_sleep_seconds]} seconds and then retrying (#{retry_count}) launch...") + sleep_message = "McServer.launch(): Sleeping for #{connection.settings[:azure_hack_sleep_seconds]} seconds and then retrying (#{retry_count}) launch..." + puts(sleep_message) + connection.logger(sleep_message) sleep(connection.settings[:azure_hack_sleep_seconds]) # retry the launch @@ -94,6 +96,8 @@ def launch else raise end + else + raise end end break From 859fffbdb033779e72403e5006e7a1a10bdbf322 Mon Sep 17 00:00:00 2001 From: Jon Marinello Date: Wed, 11 Jul 2012 16:32:18 -0700 Subject: [PATCH 172/239] Added stars to logged sleep message for Azure hack. --- lib/rest_connection/rightscale/mc_server.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rest_connection/rightscale/mc_server.rb b/lib/rest_connection/rightscale/mc_server.rb index ed18d64..ac581a5 100644 --- a/lib/rest_connection/rightscale/mc_server.rb +++ b/lib/rest_connection/rightscale/mc_server.rb @@ -79,7 +79,7 @@ def launch retry_count = 1 loop do # sleep for azure_hack_sleep_seconds seconds - sleep_message = "McServer.launch(): Sleeping for #{connection.settings[:azure_hack_sleep_seconds]} seconds and then retrying (#{retry_count}) launch..." + sleep_message = "************* McServer.launch(): Sleeping for #{connection.settings[:azure_hack_sleep_seconds]} seconds and then retrying (#{retry_count}) launch..." puts(sleep_message) connection.logger(sleep_message) sleep(connection.settings[:azure_hack_sleep_seconds]) From 348aa82b41e7cce2ab3757c7fd80c625967ca6a7 Mon Sep 17 00:00:00 2001 From: Efrain Date: Fri, 27 Jul 2012 21:44:51 +0000 Subject: [PATCH 173/239] added puts statement for extra logging of api calls. the puts changes are in PUT, POST, and GET --- lib/rest_connection.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/rest_connection.rb b/lib/rest_connection.rb index 74ecb26..ae22318 100644 --- a/lib/rest_connection.rb +++ b/lib/rest_connection.rb @@ -154,6 +154,7 @@ def error_handler(e) def get(href, additional_parameters = "") rest_connect do |base_uri,headers| new_href = (href =~ /^\// ? href : "#{base_uri}/#{href}") + puts("DEBUG: new_href get : #{new_href.inspect}") params = requestify(additional_parameters) || "" new_path = URI.escape(new_href + @settings[:extension] + "?") + params Net::HTTP::Get.new(new_path, headers) @@ -168,6 +169,7 @@ def get(href, additional_parameters = "") def post(href, additional_parameters = {}) rest_connect do |base_uri, headers| new_href = (href =~ /^\// ? href : "#{base_uri}/#{href}") + puts("DEBUG: new_href post : #{new_href.inspect}") res = Net::HTTP::Post.new(new_href , headers) unless additional_parameters.empty? res.set_content_type('application/json') @@ -187,7 +189,9 @@ def put(href, additional_parameters = {}) rest_connect do |base_uri, headers| new_href = (href =~ /^\// ? href : "#{base_uri}/#{href}") new_path = URI.escape(new_href) + puts("DEBUG: new_href put : #{new_href.inspect}") req = Net::HTTP::Put.new(new_path, headers) + puts("DEBUG: req put : #{req.inspect}") req.set_content_type('application/json') req.body = additional_parameters.to_json req From 677fb7837c0a73881582dedc118421a97eaf492e Mon Sep 17 00:00:00 2001 From: Jon Marinello Date: Mon, 30 Jul 2012 13:33:44 -0700 Subject: [PATCH 174/239] Added "504 Gateway Time-out" error special handling to McServer.launch() --- lib/rest_connection/rightscale/mc_server.rb | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/rest_connection/rightscale/mc_server.rb b/lib/rest_connection/rightscale/mc_server.rb index ac581a5..cc61fd2 100644 --- a/lib/rest_connection/rightscale/mc_server.rb +++ b/lib/rest_connection/rightscale/mc_server.rb @@ -68,11 +68,17 @@ def launch # FIXES THIS BUG ON THEIR END! # Retry on 422 conflict exception (ONLY MS AZURE WILL GENERATE THIS EXCEPTION) - target_error_message = "Invalid response HTTP code: 422: CloudException: ConflictError:" - if e.message =~ /#{target_error_message}/ + target_422_conflict_error_message = "Invalid response HTTP code: 422: CloudException: ConflictError:" + target_504_gateway_timeout_error_message = "504 Gateway Time-out" + if e.message =~ /#{target_504_gateway_timeout_error_message}/ + exception_matched_message = "McServer.launch(): Caught #{e.message}, treating as a successful launch..." + puts(exception_matched_message) + connection.logger(exception_matched_message) + true + elsif e.message =~ /#{target_422_conflict_error_message}/ if connection.settings[:azure_hack_on] azure_hack_retry_count = connection.settings[:azure_hack_retry_count] - exception_matched_message = "************* McServer.launch(): Matched Azure exception: \"#{target_error_message}\"" + exception_matched_message = "************* McServer.launch(): Matched Azure exception: \"#{target_422_conflict_error_message}\"" puts(exception_matched_message) connection.logger(exception_matched_message) @@ -88,7 +94,7 @@ def launch begin connection.post(t.path + '/launch') rescue Exception => e2 - if e2.message =~ /#{target_error_message}/ + if e2.message =~ /#{target_422_conflict_error_message}/ azure_hack_retry_count -= 1 if azure_hack_retry_count > 0 retry_count += 1 From 637958b22b89b36399b9dccac7eafa67a3a9ae52 Mon Sep 17 00:00:00 2001 From: Jon Marinello Date: Tue, 28 Aug 2012 11:37:48 -0700 Subject: [PATCH 175/239] Version 0.1.11 - Merged in Azurehack branch. --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 9767cc9..20f4951 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.1.10 +0.1.11 From 42b93ba1baea141c2a3f6187c013b5d4e06ef844 Mon Sep 17 00:00:00 2001 From: Jon Marinello Date: Wed, 12 Sep 2012 09:50:37 -0700 Subject: [PATCH 176/239] Changed all SSH probes to use 'right scale' instead of 'root' (This code was migrated from a very old branch Luke created). --- lib/rest_connection/ssh_hax.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/rest_connection/ssh_hax.rb b/lib/rest_connection/ssh_hax.rb index b13dbca..bcc2f35 100644 --- a/lib/rest_connection/ssh_hax.rb +++ b/lib/rest_connection/ssh_hax.rb @@ -49,7 +49,7 @@ def run_and_tail(run_this, tail_command, expect, ssh_key=nil, host_dns=self.reac result = nil output = "" connection.logger("Running: #{run_this}") - Net::SSH.start(host_dns, 'root', :keys => ssh_key_config(ssh_key), :user_known_hosts_file => "/dev/null") do |ssh| + Net::SSH.start(host_dns, 'rightscale', :keys => ssh_key_config(ssh_key), :user_known_hosts_file => "/dev/null") do |ssh| cmd_channel = ssh.open_channel do |ch1| ch1.on_request('exit-status') do |ch, data| status = data.read_long @@ -137,7 +137,7 @@ def run_recipe_with_ssh(recipe, ssh_key=nil, host_dns=self.reachable_ip) def spot_check(command, ssh_key=nil, host_dns=self.reachable_ip, &block) connection.logger "SSHing to #{host_dns}" - Net::SSH.start(host_dns, 'root', :keys => ssh_key_config(ssh_key)) do |ssh| + Net::SSH.start(host_dns, 'rightscale', :keys => ssh_key_config(ssh_key)) do |ssh| result = ssh.exec!(command) yield result end @@ -163,12 +163,12 @@ def spot_check_command(command, ssh_key=nil, host_dns=self.reachable_ip, do_not_ # Test for ability to connect; Net::SSH.start sometimes hangs under certain server-side sshd configs test_ssh = "" [5, 15, 60].each { |timeout_max| - test_ssh = `ssh -o \"BatchMode=yes\" -o \"StrictHostKeyChecking=no\" -o \"ConnectTimeout #{timeout_max}\" root@#{host_dns} -C \"exit\" 2>&1`.chomp + test_ssh = `ssh -o \"BatchMode=yes\" -o \"StrictHostKeyChecking=no\" -o \"ConnectTimeout #{timeout_max}\" rightscale@#{host_dns} -C \"exit\" 2>&1`.chomp break if test_ssh =~ /permission denied/i or test_ssh.empty? } raise test_ssh unless test_ssh =~ /permission denied/i or test_ssh.empty? - Net::SSH.start(host_dns, 'root', :keys => ssh_key_config(ssh_key), :user_known_hosts_file => "/dev/null") do |ssh| + Net::SSH.start(host_dns, 'rightscale', :keys => ssh_key_config(ssh_key), :user_known_hosts_file => "/dev/null") do |ssh| cmd_channel = ssh.open_channel do |ch1| ch1.on_request('exit-status') do |ch, data| status = data.read_long From d8a3020e021bcecd37a374387740e0c1d3e0f483 Mon Sep 17 00:00:00 2001 From: jonmarinellors Date: Wed, 12 Sep 2012 21:31:53 +0000 Subject: [PATCH 177/239] Added logic to obtain a pseudo-tty which is now required now that we use "sudo". --- lib/rest_connection/ssh_hax.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/rest_connection/ssh_hax.rb b/lib/rest_connection/ssh_hax.rb index bcc2f35..bcd8e0b 100644 --- a/lib/rest_connection/ssh_hax.rb +++ b/lib/rest_connection/ssh_hax.rb @@ -173,6 +173,11 @@ def spot_check_command(command, ssh_key=nil, host_dns=self.reachable_ip, do_not_ ch1.on_request('exit-status') do |ch, data| status = data.read_long end + # Request a pseudo-tty, this is needed if sudo is used + ch1.request_pty do |ch, success| + raise "Could not obtain a pseudo-tty!" if !success + end + # Now execute the command ch1.exec(command) do |ch2, success| unless success status = 1 From c482c7ce60f2522b70ecf3fee86f7d2614ca4c91 Mon Sep 17 00:00:00 2001 From: jonmarinellors Date: Fri, 14 Sep 2012 17:39:46 +0000 Subject: [PATCH 178/239] Bumped version t0 0.1.12. --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 20f4951..0e24a92 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.1.11 +0.1.12 From 50c727188dfca25cd6b713eadd2875ddbb155522 Mon Sep 17 00:00:00 2001 From: jonmarinellors Date: Fri, 14 Sep 2012 17:40:20 +0000 Subject: [PATCH 179/239] Added logging, added whitespace for improved readability and added more RightLink 5.8 Ssh logic. --- lib/rest_connection/ssh_hax.rb | 50 ++++++++++++++++++++++++++-------- 1 file changed, 38 insertions(+), 12 deletions(-) diff --git a/lib/rest_connection/ssh_hax.rb b/lib/rest_connection/ssh_hax.rb index bcd8e0b..b317da1 100644 --- a/lib/rest_connection/ssh_hax.rb +++ b/lib/rest_connection/ssh_hax.rb @@ -44,17 +44,28 @@ def ssh_key_config(item) ssh_keys end + + + # Note that "sudo -i" is prepended to and the 'rightscale' user is used. def run_and_tail(run_this, tail_command, expect, ssh_key=nil, host_dns=self.reachable_ip) + puts "SshHax::Probe method #{__method__}() entered..." status = nil result = nil output = "" - connection.logger("Running: #{run_this}") + + # Run the main program + connection.logger("Running: sudo -i #{run_this}") Net::SSH.start(host_dns, 'rightscale', :keys => ssh_key_config(ssh_key), :user_known_hosts_file => "/dev/null") do |ssh| cmd_channel = ssh.open_channel do |ch1| ch1.on_request('exit-status') do |ch, data| status = data.read_long end - ch1.exec(run_this) do |ch2, success| + # Request a pseudo-tty, this is needed as all calls use sudo to support RightLink 5.8 + ch1.request_pty do |ch, success| + raise "Could not obtain a pseudo-tty!" if !success + end + # Now execute the command with "sudo -i" prepended to it + ch1.exec("sudo -i #{run_this}") do |ch2, success| unless success output = "ERROR: SSH cmd failed to exec" status = 1 @@ -68,8 +79,11 @@ def run_and_tail(run_this, tail_command, expect, ssh_key=nil, host_dns=self.reac end end + + # Now run the tail on it + connection.logger("Now tailing #{run_this} with: sudo -i #{tail_command}") log_channel = ssh.open_channel do |ch2| - ch2.exec tail_command do |ch, success| + ch2.exec "sudo -i #{tail_command}" do |ch, success| raise "could not execute command" unless success # "on_data" is called when the process writes something to stdout ch.on_data do |c, data| @@ -87,7 +101,7 @@ def run_and_tail(run_this, tail_command, expect, ssh_key=nil, host_dns=self.reac ch.on_process do |c| if result ch.close - ssh.exec("killall tail") + ssh.exec("killall -u rightscale tail") end end end @@ -101,8 +115,11 @@ def run_and_tail(run_this, tail_command, expect, ssh_key=nil, host_dns=self.reac return {:status => success, :output => output} end + + # script is an Executable object with minimally nick or id set def run_executable_with_ssh(script, options={}, ssh_key=nil) + puts "SshHax::Probe method #{__method__}() entered..." raise "FATAL: run_executable called on a server with no reachable_ip. You need to run .settings on the server to populate this attribute." unless self.reachable_ip if script.is_a?(Executable) script = script.right_script @@ -122,9 +139,12 @@ def run_executable_with_ssh(script, options={}, ssh_key=nil) AuditEntry.new(run_and_tail(run_this, tail_command, expect)) end + + # recipe can be either a String, or an Executable # host_dns is optional and will default to objects self.reachable_ip def run_recipe_with_ssh(recipe, ssh_key=nil, host_dns=self.reachable_ip) + puts "SshHax::Probe method #{__method__}() entered..." raise "FATAL: run_script called on a server with no reachable_ip. You need to run .settings on the server to populate this attribute." unless self.reachable_ip if recipe.is_a?(Executable) recipe = recipe.recipe @@ -135,23 +155,29 @@ def run_recipe_with_ssh(recipe, ssh_key=nil, host_dns=self.reachable_ip) run_and_tail(run_this, tail_command, expect, ssh_key) end + + def spot_check(command, ssh_key=nil, host_dns=self.reachable_ip, &block) - connection.logger "SSHing to #{host_dns}" - Net::SSH.start(host_dns, 'rightscale', :keys => ssh_key_config(ssh_key)) do |ssh| - result = ssh.exec!(command) - yield result - end + puts "SshHax::Probe method #{__method__}() entered..." + results = spot_check_command(command, ssh_key, host_dns) + yield results[:output] end + + # returns true or false based on command success def spot_check_command?(command, ssh_key=nil, host_dns=self.reachable_ip) + puts "SshHax::Probe method #{__method__}() entered..." results = spot_check_command(command, ssh_key, host_dns) return results[:status] == 0 end + # returns hash of exit_status and output from command + # Note that "sudo -i" is prepended to and the 'rightscale' user is used. def spot_check_command(command, ssh_key=nil, host_dns=self.reachable_ip, do_not_log_result=false) + puts "SshHax::Probe method #{__method__}() entered..." raise "FATAL: spot_check_command called on a server with no reachable_ip. You need to run .settings on the server to populate this attribute." unless host_dns connection.logger "SSHing to #{host_dns} using key(s) #{ssh_key_config(ssh_key).inspect}" status = nil @@ -173,12 +199,12 @@ def spot_check_command(command, ssh_key=nil, host_dns=self.reachable_ip, do_not_ ch1.on_request('exit-status') do |ch, data| status = data.read_long end - # Request a pseudo-tty, this is needed if sudo is used + # Request a pseudo-tty, this is needed as all calls use sudo to support RightLink 5.8 ch1.request_pty do |ch, success| raise "Could not obtain a pseudo-tty!" if !success end - # Now execute the command - ch1.exec(command) do |ch2, success| + # Now execute the command with "sudo -i" prepended to it + ch1.exec("sudo -i #{command}") do |ch2, success| unless success status = 1 end From 09ea9c5dcaf63703a5360193609eb0551c479afd Mon Sep 17 00:00:00 2001 From: jonmarinellors Date: Fri, 14 Sep 2012 21:25:24 +0000 Subject: [PATCH 180/239] Added created of a pseudo tty for the tail command. --- lib/rest_connection/ssh_hax.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/rest_connection/ssh_hax.rb b/lib/rest_connection/ssh_hax.rb index b317da1..1b244f3 100644 --- a/lib/rest_connection/ssh_hax.rb +++ b/lib/rest_connection/ssh_hax.rb @@ -83,6 +83,11 @@ def run_and_tail(run_this, tail_command, expect, ssh_key=nil, host_dns=self.reac # Now run the tail on it connection.logger("Now tailing #{run_this} with: sudo -i #{tail_command}") log_channel = ssh.open_channel do |ch2| + # Request a pseudo-tty, this is needed as all calls use sudo to support RightLink 5.8 + ch2.request_pty do |ch, success| + raise "Could not obtain a pseudo-tty!" if !success + end + # Now execute the tail command with "sudo -i" prepended to it ch2.exec "sudo -i #{tail_command}" do |ch, success| raise "could not execute command" unless success # "on_data" is called when the process writes something to stdout From 19dbe3f34d1d609588888fb5cd4c8da3d520cfae Mon Sep 17 00:00:00 2001 From: jonmarinellors Date: Fri, 14 Sep 2012 22:43:30 +0000 Subject: [PATCH 181/239] Commented out methods not used by the virtual monkey, the rest of rest_connection and the collateral. --- lib/rest_connection/ssh_hax.rb | 147 +++++++++++++++++---------------- 1 file changed, 74 insertions(+), 73 deletions(-) diff --git a/lib/rest_connection/ssh_hax.rb b/lib/rest_connection/ssh_hax.rb index 1b244f3..f61cda6 100644 --- a/lib/rest_connection/ssh_hax.rb +++ b/lib/rest_connection/ssh_hax.rb @@ -46,6 +46,79 @@ def ssh_key_config(item) + def spot_check(command, ssh_key=nil, host_dns=self.reachable_ip, &block) + puts "SshHax::Probe method #{__method__}() entered..." + results = spot_check_command(command, ssh_key, host_dns) + yield results[:output] + end + + + + # returns true or false based on command success + def spot_check_command?(command, ssh_key=nil, host_dns=self.reachable_ip) + puts "SshHax::Probe method #{__method__}() entered..." + results = spot_check_command(command, ssh_key, host_dns) + return results[:status] == 0 + end + + + + # returns hash of exit_status and output from command + # Note that "sudo -i" is prepended to and the 'rightscale' user is used. + def spot_check_command(command, ssh_key=nil, host_dns=self.reachable_ip, do_not_log_result=false) + puts "SshHax::Probe method #{__method__}() entered..." + raise "FATAL: spot_check_command called on a server with no reachable_ip. You need to run .settings on the server to populate this attribute." unless host_dns + connection.logger "SSHing to #{host_dns} using key(s) #{ssh_key_config(ssh_key).inspect}" + status = nil + output = "" + success = false + retry_count = 0 + while (!success && retry_count < SSH_RETRY_COUNT) do + begin + # Test for ability to connect; Net::SSH.start sometimes hangs under certain server-side sshd configs + test_ssh = "" + [5, 15, 60].each { |timeout_max| + test_ssh = `ssh -o \"BatchMode=yes\" -o \"StrictHostKeyChecking=no\" -o \"ConnectTimeout #{timeout_max}\" rightscale@#{host_dns} -C \"exit\" 2>&1`.chomp + break if test_ssh =~ /permission denied/i or test_ssh.empty? + } + raise test_ssh unless test_ssh =~ /permission denied/i or test_ssh.empty? + + Net::SSH.start(host_dns, 'rightscale', :keys => ssh_key_config(ssh_key), :user_known_hosts_file => "/dev/null") do |ssh| + cmd_channel = ssh.open_channel do |ch1| + ch1.on_request('exit-status') do |ch, data| + status = data.read_long + end + # Request a pseudo-tty, this is needed as all calls use sudo to support RightLink 5.8 + ch1.request_pty do |ch, success| + raise "Could not obtain a pseudo-tty!" if !success + end + # Now execute the command with "sudo -i" prepended to it + ch1.exec("sudo -i #{command}") do |ch2, success| + unless success + status = 1 + end + ch2.on_data do |ch, data| + output += data + end + ch2.on_extended_data do |ch, type, data| + output += data + end + end + end + end + rescue Exception => e + retry_count += 1 # opening the ssh channel failed -- try again. + connection.logger "ERROR during SSH session to #{host_dns}, retrying #{retry_count}: #{e} #{e.backtrace}" + sleep 10 + raise e unless retry_count < SSH_RETRY_COUNT + end + end + connection.logger "SSH Run: #{command} on #{host_dns}. Retry was #{retry_count}. Exit status was #{status}. Output below ---\n#{output}\n---" unless do_not_log_result + return {:status => status, :output => output} + end + + +=begin # Note that "sudo -i" is prepended to and the 'rightscale' user is used. def run_and_tail(run_this, tail_command, expect, ssh_key=nil, host_dns=self.reachable_ip) puts "SshHax::Probe method #{__method__}() entered..." @@ -159,78 +232,6 @@ def run_recipe_with_ssh(recipe, ssh_key=nil, host_dns=self.reachable_ip) run_this = "rs_run_recipe -n '#{recipe}'" run_and_tail(run_this, tail_command, expect, ssh_key) end - - - - def spot_check(command, ssh_key=nil, host_dns=self.reachable_ip, &block) - puts "SshHax::Probe method #{__method__}() entered..." - results = spot_check_command(command, ssh_key, host_dns) - yield results[:output] - end - - - - # returns true or false based on command success - def spot_check_command?(command, ssh_key=nil, host_dns=self.reachable_ip) - puts "SshHax::Probe method #{__method__}() entered..." - results = spot_check_command(command, ssh_key, host_dns) - return results[:status] == 0 - end - - - - # returns hash of exit_status and output from command - # Note that "sudo -i" is prepended to and the 'rightscale' user is used. - def spot_check_command(command, ssh_key=nil, host_dns=self.reachable_ip, do_not_log_result=false) - puts "SshHax::Probe method #{__method__}() entered..." - raise "FATAL: spot_check_command called on a server with no reachable_ip. You need to run .settings on the server to populate this attribute." unless host_dns - connection.logger "SSHing to #{host_dns} using key(s) #{ssh_key_config(ssh_key).inspect}" - status = nil - output = "" - success = false - retry_count = 0 - while (!success && retry_count < SSH_RETRY_COUNT) do - begin - # Test for ability to connect; Net::SSH.start sometimes hangs under certain server-side sshd configs - test_ssh = "" - [5, 15, 60].each { |timeout_max| - test_ssh = `ssh -o \"BatchMode=yes\" -o \"StrictHostKeyChecking=no\" -o \"ConnectTimeout #{timeout_max}\" rightscale@#{host_dns} -C \"exit\" 2>&1`.chomp - break if test_ssh =~ /permission denied/i or test_ssh.empty? - } - raise test_ssh unless test_ssh =~ /permission denied/i or test_ssh.empty? - - Net::SSH.start(host_dns, 'rightscale', :keys => ssh_key_config(ssh_key), :user_known_hosts_file => "/dev/null") do |ssh| - cmd_channel = ssh.open_channel do |ch1| - ch1.on_request('exit-status') do |ch, data| - status = data.read_long - end - # Request a pseudo-tty, this is needed as all calls use sudo to support RightLink 5.8 - ch1.request_pty do |ch, success| - raise "Could not obtain a pseudo-tty!" if !success - end - # Now execute the command with "sudo -i" prepended to it - ch1.exec("sudo -i #{command}") do |ch2, success| - unless success - status = 1 - end - ch2.on_data do |ch, data| - output += data - end - ch2.on_extended_data do |ch, type, data| - output += data - end - end - end - end - rescue Exception => e - retry_count += 1 # opening the ssh channel failed -- try again. - connection.logger "ERROR during SSH session to #{host_dns}, retrying #{retry_count}: #{e} #{e.backtrace}" - sleep 10 - raise e unless retry_count < SSH_RETRY_COUNT - end - end - connection.logger "SSH Run: #{command} on #{host_dns}. Retry was #{retry_count}. Exit status was #{status}. Output below ---\n#{output}\n---" unless do_not_log_result - return {:status => status, :output => output} - end +=end end From 914a00584eee28b0fcc067255da2f3972fedd8ca Mon Sep 17 00:00:00 2001 From: Jon Marinello Date: Mon, 17 Sep 2012 10:18:08 -0700 Subject: [PATCH 182/239] Removed obsolete and unused code. --- lib/rest_connection/ssh_hax.rb | 117 --------------------------------- 1 file changed, 117 deletions(-) diff --git a/lib/rest_connection/ssh_hax.rb b/lib/rest_connection/ssh_hax.rb index f61cda6..fa28bad 100644 --- a/lib/rest_connection/ssh_hax.rb +++ b/lib/rest_connection/ssh_hax.rb @@ -117,121 +117,4 @@ def spot_check_command(command, ssh_key=nil, host_dns=self.reachable_ip, do_not_ return {:status => status, :output => output} end - -=begin - # Note that "sudo -i" is prepended to and the 'rightscale' user is used. - def run_and_tail(run_this, tail_command, expect, ssh_key=nil, host_dns=self.reachable_ip) - puts "SshHax::Probe method #{__method__}() entered..." - status = nil - result = nil - output = "" - - # Run the main program - connection.logger("Running: sudo -i #{run_this}") - Net::SSH.start(host_dns, 'rightscale', :keys => ssh_key_config(ssh_key), :user_known_hosts_file => "/dev/null") do |ssh| - cmd_channel = ssh.open_channel do |ch1| - ch1.on_request('exit-status') do |ch, data| - status = data.read_long - end - # Request a pseudo-tty, this is needed as all calls use sudo to support RightLink 5.8 - ch1.request_pty do |ch, success| - raise "Could not obtain a pseudo-tty!" if !success - end - # Now execute the command with "sudo -i" prepended to it - ch1.exec("sudo -i #{run_this}") do |ch2, success| - unless success - output = "ERROR: SSH cmd failed to exec" - status = 1 - end - ch2.on_data do |ch, data| - output += data - end - ch2.on_extended_data do |ch, type, data| - output += data - end - - end - end - - # Now run the tail on it - connection.logger("Now tailing #{run_this} with: sudo -i #{tail_command}") - log_channel = ssh.open_channel do |ch2| - # Request a pseudo-tty, this is needed as all calls use sudo to support RightLink 5.8 - ch2.request_pty do |ch, success| - raise "Could not obtain a pseudo-tty!" if !success - end - # Now execute the tail command with "sudo -i" prepended to it - ch2.exec "sudo -i #{tail_command}" do |ch, success| - raise "could not execute command" unless success - # "on_data" is called when the process writes something to stdout - ch.on_data do |c, data| - output += data - if data =~ expect - result = $1 - end - end - # "on_extended_data" is called when the process writes something to stderr - ch.on_extended_data do |c, type, data| - #STDERR.print data - end - ch.on_close do - end - ch.on_process do |c| - if result - ch.close - ssh.exec("killall -u rightscale tail") - end - end - end - end - cmd_channel.wait - log_channel.wait - end - connection.logger output - success = result.include?('completed') - connection.logger "Converge failed. See server audit: #{self.audit_link}" unless success - return {:status => success, :output => output} - end - - - - # script is an Executable object with minimally nick or id set - def run_executable_with_ssh(script, options={}, ssh_key=nil) - puts "SshHax::Probe method #{__method__}() entered..." - raise "FATAL: run_executable called on a server with no reachable_ip. You need to run .settings on the server to populate this attribute." unless self.reachable_ip - if script.is_a?(Executable) - script = script.right_script - end - - raise "FATAL: unrecognized format for script. Must be an Executable or RightScript with href or name attributes" unless (script.is_a?(RightScript)) && (script.href || script.name) - if script.href - run_this = "rs_run_right_script -i #{script.href.split(/\//).last}" - elsif script.name - run_this = "rs_run_right_script -n #{script.name}" - end - tail_command ="tail -f -n1 /var/log/messages" - expect = /RightLink.*RS> ([completed|failed]+:)/ - options.each do |key, value| - run_this += " -p #{key}=#{value}" - end - AuditEntry.new(run_and_tail(run_this, tail_command, expect)) - end - - - - # recipe can be either a String, or an Executable - # host_dns is optional and will default to objects self.reachable_ip - def run_recipe_with_ssh(recipe, ssh_key=nil, host_dns=self.reachable_ip) - puts "SshHax::Probe method #{__method__}() entered..." - raise "FATAL: run_script called on a server with no reachable_ip. You need to run .settings on the server to populate this attribute." unless self.reachable_ip - if recipe.is_a?(Executable) - recipe = recipe.recipe - end - tail_command ="tail -f -n1 /var/log/messages" - expect = /RightLink.*RS> ([completed|failed]+: < #{recipe} >)/ - run_this = "rs_run_recipe -n '#{recipe}'" - run_and_tail(run_this, tail_command, expect, ssh_key) - end -=end - end From b23041d087fc8273ce8e87fb019f128cd1b8e55d Mon Sep 17 00:00:00 2001 From: jonmarinellors Date: Tue, 9 Oct 2012 16:58:57 +0000 Subject: [PATCH 183/239] Added probe exit log statement. --- lib/rest_connection/ssh_hax.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/rest_connection/ssh_hax.rb b/lib/rest_connection/ssh_hax.rb index fa28bad..0cd9856 100644 --- a/lib/rest_connection/ssh_hax.rb +++ b/lib/rest_connection/ssh_hax.rb @@ -114,6 +114,7 @@ def spot_check_command(command, ssh_key=nil, host_dns=self.reachable_ip, do_not_ end end connection.logger "SSH Run: #{command} on #{host_dns}. Retry was #{retry_count}. Exit status was #{status}. Output below ---\n#{output}\n---" unless do_not_log_result + puts "SshHax::Probe method #{__method__}() exiting..." return {:status => status, :output => output} end From c83942c4a3acf5b46cab50b6bd2498d0dbd3a5c5 Mon Sep 17 00:00:00 2001 From: jonmarinellors Date: Tue, 9 Oct 2012 22:48:45 +0000 Subject: [PATCH 184/239] Changed command string handling to use single quoted strings and concatenation to avoid string interpretation by Ruby. --- lib/rest_connection/ssh_hax.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/rest_connection/ssh_hax.rb b/lib/rest_connection/ssh_hax.rb index 0cd9856..4cd04bb 100644 --- a/lib/rest_connection/ssh_hax.rb +++ b/lib/rest_connection/ssh_hax.rb @@ -92,8 +92,12 @@ def spot_check_command(command, ssh_key=nil, host_dns=self.reachable_ip, do_not_ ch1.request_pty do |ch, success| raise "Could not obtain a pseudo-tty!" if !success end - # Now execute the command with "sudo -i" prepended to it - ch1.exec("sudo -i #{command}") do |ch2, success| + # Now execute the command with "sudo -i --" prepended to it. + # NOTE: The -- option indicates that sudo should stop processing command line arguments + # NOTE: The use of single quotes is required to keep Ruby from interpretting the command string passed in and messing up regex's + sudo_command = 'sudo -i -- ' + command + puts 'SshHax::Probe executing ' + sudo_command + '...' + ch1.exec(sudo_command) do |ch2, success| unless success status = 1 end From 6d4e4419bb09138c2daf4b87f99456d07b8d3802 Mon Sep 17 00:00:00 2001 From: Daniel Trinh Date: Tue, 9 Oct 2012 16:22:50 -0700 Subject: [PATCH 185/239] replacing api 0.1 basic auth to use /login cookie instead --- .../rightscale/rightscale_api_internal.rb | 9 ++++++++- lib/rest_connection/rightscale/rs_internal.rb | 16 ++++------------ 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/lib/rest_connection/rightscale/rightscale_api_internal.rb b/lib/rest_connection/rightscale/rightscale_api_internal.rb index 08ae90d..46673ab 100644 --- a/lib/rest_connection/rightscale/rightscale_api_internal.rb +++ b/lib/rest_connection/rightscale/rightscale_api_internal.rb @@ -27,9 +27,16 @@ module InternalConnection def connection(*opts) @@little_brother_connection ||= RestConnection::Connection.new(*opts) settings = @@little_brother_connection.settings - settings[:common_headers]["X_API_VERSION"] = "0.1" + + # authenticate with 1.0 first and set cookie for future requests + # using the @@l.b.c connection object + settings[:common_headers]["X_API_VERSION"] = "1.0" settings[:api_href] = settings[:api_url] + login_response = @@little_brother_connection.get("login") + @@little_brother_connection.cookie = login_response['set-cookie'] + settings[:extension] = ".js" + settings[:common_headers]["X_API_VERSION"] = "0.1" @@little_brother_connection end end diff --git a/lib/rest_connection/rightscale/rs_internal.rb b/lib/rest_connection/rightscale/rs_internal.rb index 16423db..d874cfc 100644 --- a/lib/rest_connection/rightscale/rs_internal.rb +++ b/lib/rest_connection/rightscale/rs_internal.rb @@ -27,23 +27,15 @@ class RsInternal include RightScale::Api::Base extend RightScale::Api::BaseExtend + extend ::RightScale::Api::InternalConnection def connection - @@little_brother_connection ||= RestConnection::Connection.new - settings = @@little_brother_connection.settings - settings[:common_headers]["X_API_VERSION"] = "0.1" - settings[:api_href] = settings[:api_url] - settings[:extension] = ".js" - @@little_brother_connection + self.connection end def self.connection - @@little_brother_connection ||= RestConnection::Connection.new - settings = @@little_brother_connection.settings - settings[:common_headers]["X_API_VERSION"] = "0.1" - settings[:api_href] = settings[:api_url] - settings[:extension] = ".js" - @@little_brother_connection + # call connection defined in InternalConnection module + super end def self.get_server_template_multi_cloud_images(server_template_href) From d074c26da9c66811c5969605a58b504d2d0e4ca8 Mon Sep 17 00:00:00 2001 From: Daniel Trinh Date: Tue, 9 Oct 2012 17:33:40 -0700 Subject: [PATCH 186/239] modified code to follow similar patterns in other .connection methods --- .../rightscale/rightscale_api_internal.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/rest_connection/rightscale/rightscale_api_internal.rb b/lib/rest_connection/rightscale/rightscale_api_internal.rb index 46673ab..ef725cc 100644 --- a/lib/rest_connection/rightscale/rightscale_api_internal.rb +++ b/lib/rest_connection/rightscale/rightscale_api_internal.rb @@ -27,15 +27,15 @@ module InternalConnection def connection(*opts) @@little_brother_connection ||= RestConnection::Connection.new(*opts) settings = @@little_brother_connection.settings - - # authenticate with 1.0 first and set cookie for future requests - # using the @@l.b.c connection object settings[:common_headers]["X_API_VERSION"] = "1.0" settings[:api_href] = settings[:api_url] - login_response = @@little_brother_connection.get("login") - @@little_brother_connection.cookie = login_response['set-cookie'] - settings[:extension] = ".js" + + unless @@little_brother_connection.respond_to?(:refresh_cookie) + @@little_brother_connection.instance_exec(&(RightScale::Api::BASE_COOKIE_REFRESH)) + end + + @@little_brother_connection.refresh_cookie unless @@little_brother_connection.cookie settings[:common_headers]["X_API_VERSION"] = "0.1" @@little_brother_connection end From 629fe4680ac7d04872d64bedb7895b11e6d9564c Mon Sep 17 00:00:00 2001 From: Jon Marinello Date: Wed, 7 Nov 2012 14:29:22 -0800 Subject: [PATCH 187/239] Removed unwanted functionality in git hooks. --- git_hooks/post-commit | 43 -------------------- git_hooks/post-commit.disabled | 4 -- git_hooks/post-merge.disabled | 4 -- git_hooks/pre-commit | 71 ---------------------------------- 4 files changed, 122 deletions(-) delete mode 100755 git_hooks/post-commit delete mode 100755 git_hooks/post-commit.disabled delete mode 100755 git_hooks/post-merge.disabled diff --git a/git_hooks/post-commit b/git_hooks/post-commit deleted file mode 100755 index e742ab1..0000000 --- a/git_hooks/post-commit +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/env ruby -puts <'" - lod_message exit 1 elif [[ "$useremail" == "setyouremail@rightscale.com" || "$useremail" == "" ]] || ! host "$emaildomain" &> /dev/null; then echo "Please set your git user.email by running 'git config user.email '" - lod_message exit 1 fi From 9af197b43a4cae5bc0415f9eaa026c62be270dc8 Mon Sep 17 00:00:00 2001 From: jonmarinellors Date: Sun, 11 Nov 2012 10:37:30 -0800 Subject: [PATCH 188/239] DEBUG API href statements are not controlled via the rest_connection yaml file. --- VERSION | 2 +- config/rest_api_config.yaml.sample | 1 + lib/rest_connection.rb | 9 +++++---- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/VERSION b/VERSION index 20f4951..0e24a92 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.1.11 +0.1.12 diff --git a/config/rest_api_config.yaml.sample b/config/rest_api_config.yaml.sample index aa5ef51..79d17cf 100644 --- a/config/rest_api_config.yaml.sample +++ b/config/rest_api_config.yaml.sample @@ -11,3 +11,4 @@ :azure_hack_on: true :azure_hack_retry_count: 5 :azure_hack_sleep_seconds: 60 +:api_logging: false diff --git a/lib/rest_connection.rb b/lib/rest_connection.rb index ae22318..4d2d653 100644 --- a/lib/rest_connection.rb +++ b/lib/rest_connection.rb @@ -84,6 +84,7 @@ def initialize(config_yaml = File.join(File.expand_path("~"), ".rest_connection" @settings[:azure_hack_on] ||= true @settings[:azure_hack_retry_count] ||= 5 @settings[:azure_hack_sleep_seconds] ||= 60 + @settings[:api_logging] ||= false end # Main HTTP connection loop. Common settings are set here, then we yield(BASE_URI, OPTIONAL_HEADERS) to other methods for each type of HTTP request: GET, PUT, POST, DELETE @@ -154,7 +155,7 @@ def error_handler(e) def get(href, additional_parameters = "") rest_connect do |base_uri,headers| new_href = (href =~ /^\// ? href : "#{base_uri}/#{href}") - puts("DEBUG: new_href get : #{new_href.inspect}") + puts("DEBUG: new_href get : #{new_href.inspect}") if @settings[:api_logging] params = requestify(additional_parameters) || "" new_path = URI.escape(new_href + @settings[:extension] + "?") + params Net::HTTP::Get.new(new_path, headers) @@ -169,7 +170,7 @@ def get(href, additional_parameters = "") def post(href, additional_parameters = {}) rest_connect do |base_uri, headers| new_href = (href =~ /^\// ? href : "#{base_uri}/#{href}") - puts("DEBUG: new_href post : #{new_href.inspect}") + puts("DEBUG: new_href post : #{new_href.inspect}") if @settings[:api_logging] res = Net::HTTP::Post.new(new_href , headers) unless additional_parameters.empty? res.set_content_type('application/json') @@ -189,9 +190,9 @@ def put(href, additional_parameters = {}) rest_connect do |base_uri, headers| new_href = (href =~ /^\// ? href : "#{base_uri}/#{href}") new_path = URI.escape(new_href) - puts("DEBUG: new_href put : #{new_href.inspect}") + puts("DEBUG: new_href put : #{new_href.inspect}") if @settings[:api_logging] req = Net::HTTP::Put.new(new_path, headers) - puts("DEBUG: req put : #{req.inspect}") + puts("DEBUG: req put : #{req.inspect}") if @settings[:api_logging] req.set_content_type('application/json') req.body = additional_parameters.to_json req From 66000a78b0e797337de5fccdab8d0076debe8225 Mon Sep 17 00:00:00 2001 From: Efrain Date: Tue, 13 Nov 2012 01:04:55 +0000 Subject: [PATCH 189/239] Added "AWS AP-Sydney" cloud. --- lib/rest_connection/rightscale/rightscale_api_base.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/rest_connection/rightscale/rightscale_api_base.rb b/lib/rest_connection/rightscale/rightscale_api_base.rb index 734e359..3e634c2 100644 --- a/lib/rest_connection/rightscale/rightscale_api_base.rb +++ b/lib/rest_connection/rightscale/rightscale_api_base.rb @@ -34,6 +34,7 @@ module Api {"cloud_id" => 5, "name" => "AWS AP-Tokyo"}, {"cloud_id" => 6, "name" => "AWS US-Oregon"}, {"cloud_id" => 7, "name" => "AWS SA-Sao Paulo"}, + {"cloud_id" => 8, "name" => "AWS AP-Sydney"}, ] BASE_COOKIE_REFRESH = proc do From d2d2bffe0d7c48e5fb4063c481bc5daec54eeb1a Mon Sep 17 00:00:00 2001 From: Efrain Date: Tue, 13 Nov 2012 01:07:10 +0000 Subject: [PATCH 190/239] Bumped version to 0.1.13 supporting "AWS AP-Sydney" cloud.. --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 0e24a92..7ac4e5e 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.1.12 +0.1.13 From dd744c9ab2878be807b3ae9760a6151e63c6dda9 Mon Sep 17 00:00:00 2001 From: Magne Land Date: Tue, 13 Nov 2012 10:58:17 -0800 Subject: [PATCH 191/239] Bump version number to 1.0.0 This marks the transition of code ownership to the Yellow Team. --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 7ac4e5e..3eefcb9 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.1.13 +1.0.0 From da06350ceea7adfde48295f39e0fb8939d65fa8b Mon Sep 17 00:00:00 2001 From: Jon Marinello Date: Tue, 20 Nov 2012 10:03:00 -0800 Subject: [PATCH 192/239] Version 1.0.1 - Cleaned up and added new timeout behavior to wait_for_operational_with_dns(). --- VERSION | 2 +- lib/rest_connection/rightscale/server.rb | 32 ++++++++++++++++-------- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/VERSION b/VERSION index 3eefcb9..7dea76e 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.0.0 +1.0.1 diff --git a/lib/rest_connection/rightscale/server.rb b/lib/rest_connection/rightscale/server.rb index 987384a..159b57e 100644 --- a/lib/rest_connection/rightscale/server.rb +++ b/lib/rest_connection/rightscale/server.rb @@ -118,19 +118,29 @@ def wait_for_state(st,timeout=1200) end # waits until the server is operational and dns_name is available - def wait_for_operational_with_dns(state_wait_timeout=1200) - timeout = 600 - wait_for_state("operational", state_wait_timeout) - step = 15 - while(timeout > 0) + def wait_for_operational_with_dns(operational_timeout_in_seconds = 1200, dns_timeout_in_seconds = operational_timeout_in_seconds / 2) + # First, wait for the server to go operational + wait_for_state("operational", operational_timeout_in_seconds) + + # Log that we are switching to waiting for dns + connection.logger "#{self.nickname} is operational, now checking for dns name..." + + # Now poll for valid dns + dns_timeout = dns_timeout_in_seconds + dns_step = 15 + while(dns_timeout > 0) self.settings - break if self.reachable_ip - connection.logger "waiting for IP for #{self.nickname}" - sleep step - timeout -= step + if self.reachable_ip + # Go a dns name so log that and return (note that "reachable_ip" is really a dns name) + connection.logger "Got dns: #{self.reachable_ip}." + return + end + connection.logger "Waiting #{dns_step} seconds before checking for dns name on #{self.nickname}..." + sleep dns_step + dns_timeout -= dns_step end - connection.logger "got IP: #{self.reachable_ip}" - raise "FATAL, this server #{self.audit_link} timed out waiting for IP" if timeout <= 0 + + raise "FATAL, server #{self.nickname}, #{self.audit_link} timed out waiting for dns name, waited for #{dns_timeout_in_seconds}." end def audit_link From 09974ba0af7526def3589c7bafadb70bc842cc63 Mon Sep 17 00:00:00 2001 From: Jon Marinello Date: Tue, 20 Nov 2012 10:56:14 -0800 Subject: [PATCH 193/239] Updated comments and log messages to reflect differences on AWS vs. Generic clouds. --- lib/rest_connection/rightscale/server.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/rest_connection/rightscale/server.rb b/lib/rest_connection/rightscale/server.rb index 159b57e..22d70df 100644 --- a/lib/rest_connection/rightscale/server.rb +++ b/lib/rest_connection/rightscale/server.rb @@ -123,7 +123,7 @@ def wait_for_operational_with_dns(operational_timeout_in_seconds = 1200, dns_tim wait_for_state("operational", operational_timeout_in_seconds) # Log that we are switching to waiting for dns - connection.logger "#{self.nickname} is operational, now checking for dns name..." + connection.logger "#{self.nickname} is operational, now checking for dns name/ip address..." # Now poll for valid dns dns_timeout = dns_timeout_in_seconds @@ -131,16 +131,16 @@ def wait_for_operational_with_dns(operational_timeout_in_seconds = 1200, dns_tim while(dns_timeout > 0) self.settings if self.reachable_ip - # Go a dns name so log that and return (note that "reachable_ip" is really a dns name) + # Got a dns name/ip address so log that and return (note that "reachable_ip" returns a dns name on AWS and an ip address on generic clouds) connection.logger "Got dns: #{self.reachable_ip}." return end - connection.logger "Waiting #{dns_step} seconds before checking for dns name on #{self.nickname}..." + connection.logger "Waiting #{dns_step} seconds before checking for dns name/ip address on #{self.nickname}..." sleep dns_step dns_timeout -= dns_step end - raise "FATAL, server #{self.nickname}, #{self.audit_link} timed out waiting for dns name, waited for #{dns_timeout_in_seconds}." + raise "FATAL, server #{self.nickname}, #{self.audit_link} timed out waiting for dns name/ip address, waited for #{dns_timeout_in_seconds}." end def audit_link From 2933eb228c4142a18bbf8da7c14547841e7e3110 Mon Sep 17 00:00:00 2001 From: Jon Marinello Date: Tue, 20 Nov 2012 10:59:32 -0800 Subject: [PATCH 194/239] Updated a log message missed in last commit. --- lib/rest_connection/rightscale/server.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rest_connection/rightscale/server.rb b/lib/rest_connection/rightscale/server.rb index 22d70df..eb909a7 100644 --- a/lib/rest_connection/rightscale/server.rb +++ b/lib/rest_connection/rightscale/server.rb @@ -132,7 +132,7 @@ def wait_for_operational_with_dns(operational_timeout_in_seconds = 1200, dns_tim self.settings if self.reachable_ip # Got a dns name/ip address so log that and return (note that "reachable_ip" returns a dns name on AWS and an ip address on generic clouds) - connection.logger "Got dns: #{self.reachable_ip}." + connection.logger "Got dns name/ip address: #{self.reachable_ip}." return end connection.logger "Waiting #{dns_step} seconds before checking for dns name/ip address on #{self.nickname}..." From 42979f43be449f6a6e96c0a8964bb51b41bfa1c4 Mon Sep 17 00:00:00 2001 From: Magne Land Date: Thu, 22 Nov 2012 12:54:23 -0800 Subject: [PATCH 195/239] Add rconf and Gemfile, update Rakefile and version Add rconf file. Note this uses ree. Update Rakefile to use gemspec, not Jeweler. Add Gemfile that loads gemspec. Add generated Gemfile.lock. Refactor version file. Update version to 1.0.2. --- Gemfile | 3 +++ Gemfile.lock | 43 ++++++++++++++++++++++++++++++++++ Rakefile | 32 ++++++++++++------------- VERSION | 1 - lib/rest_connection/version.rb | 4 ++++ rest_connection.rconf | 10 ++++++++ 6 files changed, 76 insertions(+), 17 deletions(-) create mode 100644 Gemfile create mode 100644 Gemfile.lock delete mode 100644 VERSION create mode 100644 lib/rest_connection/version.rb create mode 100644 rest_connection.rconf diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..8926307 --- /dev/null +++ b/Gemfile @@ -0,0 +1,3 @@ +source 'http://rubygems.org' + +gemspec \ No newline at end of file diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..13fc79c --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,43 @@ +PATH + remote: . + specs: + rest_connection (1.0.2) + activesupport (= 2.3.10) + highline + json + net-ssh (= 2.1.4) + nokogiri + rest-client + +GEM + remote: http://rubygems.org/ + specs: + activesupport (2.3.10) + columnize (0.3.6) + highline (1.6.15) + json (1.7.5) + linecache (0.46) + rbx-require-relative (> 0.0.4) + mime-types (1.19) + net-ssh (2.1.4) + nokogiri (1.5.5) + rake (0.8.7) + rbx-require-relative (0.0.9) + rest-client (1.6.7) + mime-types (>= 1.16) + rspec (1.3.0) + ruby-debug (0.10.4) + columnize (>= 0.1) + ruby-debug-base (~> 0.10.4.0) + ruby-debug-base (0.10.4) + linecache (>= 0.3) + +PLATFORMS + ruby + +DEPENDENCIES + bundler + rake (= 0.8.7) + rest_connection! + rspec (= 1.3.0) + ruby-debug diff --git a/Rakefile b/Rakefile index ab89be8..2caad53 100644 --- a/Rakefile +++ b/Rakefile @@ -1,17 +1,17 @@ -require 'rubygems' -require 'jeweler' -Jeweler::Tasks.new do |gemspec| - gemspec.name = "rest_connection" - gemspec.summary = "Modular RESTful API library" - gemspec.description = "A Modular RESTful API library. Current implemented modules: RightScale API" - gemspec.email = ["daniel.onorato@rightscale.com"] - gemspec.homepage = "http://github.com/rightscale/rest_connection" - gemspec.authors = ["Jeremy Deininger", "Timothy Rodriguez"] - gemspec.add_dependency('activesupport', "=2.3.10") - gemspec.add_dependency('net-ssh', "=2.1.4") - gemspec.add_dependency('json') - gemspec.add_dependency('highline') - gemspec.add_dependency('rest-client') - gemspec.add_dependency('nokogiri') +require File.expand_path('../lib/rest_connection', __FILE__) +require 'rake' +require 'spec/rake/spectask' + +task :build do + system "gem build rest_connection.gemspec" +end + +task :release => :build do + system "gem push rest_connection-#{RestConnection::VERSION}.gem" +end + +Spec::Rake::SpecTask.new('spec') do |t| + t.spec_files = Dir.glob('spec/*_spec.rb') + t.spec_opts << '--format nested' + t.spec_opts << '--colour' end -Jeweler::GemcutterTasks.new diff --git a/VERSION b/VERSION deleted file mode 100644 index 7dea76e..0000000 --- a/VERSION +++ /dev/null @@ -1 +0,0 @@ -1.0.1 diff --git a/lib/rest_connection/version.rb b/lib/rest_connection/version.rb new file mode 100644 index 0000000..7183e11 --- /dev/null +++ b/lib/rest_connection/version.rb @@ -0,0 +1,4 @@ +# This gem is versioned with the usual X.Y.Z notation +module RestConnection + VERSION = '1.0.2' +end diff --git a/rest_connection.rconf b/rest_connection.rconf new file mode 100644 index 0000000..e017417 --- /dev/null +++ b/rest_connection.rconf @@ -0,0 +1,10 @@ +ruby do + version 'ree-1.8.7-2011.02' + rubygems '1.8.17' + gemset 'rest_connection' +end +bundler do + version '1.0.21' + exclusions 'deployment' + bundle_path File.join(ENV["HOME"], '.rightscale_bundle', 'rest_connection') +end From daf95aaf1632dddec30297f0910073f97002560d Mon Sep 17 00:00:00 2001 From: Jon Marinello Date: Tue, 27 Nov 2012 13:31:50 -0800 Subject: [PATCH 196/239] Improved message logging in wait_for_state() to show actual early termination state. --- VERSION | 2 +- lib/rest_connection/rightscale/server.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/VERSION b/VERSION index 7dea76e..6d7de6e 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.0.1 +1.0.2 diff --git a/lib/rest_connection/rightscale/server.rb b/lib/rest_connection/rightscale/server.rb index eb909a7..d0c99e8 100644 --- a/lib/rest_connection/rightscale/server.rb +++ b/lib/rest_connection/rightscale/server.rb @@ -106,7 +106,7 @@ def wait_for_state(st,timeout=1200) connection.logger("waiting for server #{nickname} to go #{st}, state is #{state}") if state =~ /terminated|stopped|inactive|error/ and st !~ /terminated|stopped|inactive|error/ if catch_early_terminated <= 0 - raise "FATAL error, this server terminated when waiting for #{st}: #{nickname}" + raise "FATAL error, this server entered #{state} state waiting for #{st}: #{nickname}" end catch_early_terminated -= 1 end From f279b333f44db78a6226cc807e357d655637abfb Mon Sep 17 00:00:00 2001 From: Magne Land Date: Tue, 27 Nov 2012 14:08:39 -0800 Subject: [PATCH 197/239] Revert to version 1.0.1; version should change in master, not feature branch --- Gemfile.lock | 2 +- lib/rest_connection/version.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 13fc79c..f6fdcc8 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - rest_connection (1.0.2) + rest_connection (1.0.1) activesupport (= 2.3.10) highline json diff --git a/lib/rest_connection/version.rb b/lib/rest_connection/version.rb index 7183e11..44d43a1 100644 --- a/lib/rest_connection/version.rb +++ b/lib/rest_connection/version.rb @@ -1,4 +1,4 @@ # This gem is versioned with the usual X.Y.Z notation module RestConnection - VERSION = '1.0.2' + VERSION = '1.0.1' end From e78113ef8366befa82d4d3c79f000941c412f916 Mon Sep 17 00:00:00 2001 From: Magne Land Date: Tue, 27 Nov 2012 14:47:16 -0800 Subject: [PATCH 198/239] upgrade to the latest versions of ree, rubygems, bundler --- rest_connection.rconf | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rest_connection.rconf b/rest_connection.rconf index e017417..d260025 100644 --- a/rest_connection.rconf +++ b/rest_connection.rconf @@ -1,10 +1,10 @@ ruby do - version 'ree-1.8.7-2011.02' - rubygems '1.8.17' + version 'ree-1.8.7-2012.02' + rubygems '1.8.24' gemset 'rest_connection' end bundler do - version '1.0.21' + version '1.2.2' exclusions 'deployment' bundle_path File.join(ENV["HOME"], '.rightscale_bundle', 'rest_connection') end From 2fe19fc2154f387129e1b2ea088951ba60baa2f8 Mon Sep 17 00:00:00 2001 From: Jon Marinello Date: Tue, 27 Nov 2012 15:02:47 -0800 Subject: [PATCH 199/239] Bumped catch_early_terminated from 60 to 300 to fix problems with rebooting during booting. --- lib/rest_connection/rightscale/server.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rest_connection/rightscale/server.rb b/lib/rest_connection/rightscale/server.rb index d0c99e8..26743b8 100644 --- a/lib/rest_connection/rightscale/server.rb +++ b/lib/rest_connection/rightscale/server.rb @@ -97,7 +97,7 @@ def wait_for_state(st,timeout=1200) reload connection.logger("#{nickname} is #{self.state}") step = 15 - catch_early_terminated = 60 / step + catch_early_terminated = 300 / step while(timeout > 0) return true if state =~ /#{st}/ return true if state =~ /terminated|stopped/ && st =~ /terminated|stopped/ From 3da29f024f624c2dae1dc53934c7231b2470960b Mon Sep 17 00:00:00 2001 From: Magne Land Date: Tue, 27 Nov 2012 15:05:46 -0800 Subject: [PATCH 200/239] add manual gemspec file This file is no longer generated by Jeweler. Preserves any existing dependencies. TODO: figure out how to use rconf's rubygems version --- .gitignore | 1 - rest_connection.gemspec | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 rest_connection.gemspec diff --git a/.gitignore b/.gitignore index 9d4c1fd..84f5240 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,6 @@ *.swp *.swo pkg/* -rest_connection.gemspec ## RubyMine .idea \ No newline at end of file diff --git a/rest_connection.gemspec b/rest_connection.gemspec new file mode 100644 index 0000000..3c72cae --- /dev/null +++ b/rest_connection.gemspec @@ -0,0 +1,32 @@ +require File.expand_path('../lib/rest_connection/version', __FILE__) + +Gem::Specification.new do |s| + s.name = 'rest_connection' + s.version = RestConnection::VERSION + s.platform = Gem::Platform::RUBY + s.date = Time.now.utc.strftime("%Y-%m-%d") + s.require_path = 'lib' + s.authors = [ 'RightScale, Inc.' ] + s.email = [ 'rubygems@rightscale.com' ] + s.homepage = 'https://github.com/rightscale/rest_connection' + s.summary = 'A Modular RESTful API library.' + s.description = %{ +The rest_connection gem simplifies the use of RESTful APIs. +It currently has support for RightScale API 1.0 and 1.5. + } + s.files = `git ls-files`.split(' ') + s.test_files = `git ls-files spec config`.split(' ') + s.rubygems_version = '1.8.24' + + s.add_runtime_dependency 'activesupport', '2.3.10' + s.add_runtime_dependency 'net-ssh', '2.1.4' + s.add_runtime_dependency 'json' + s.add_runtime_dependency 'highline' + s.add_runtime_dependency 'rest-client' + s.add_runtime_dependency 'nokogiri' + + s.add_development_dependency 'rake', '0.8.7' + s.add_development_dependency 'bundler' + s.add_development_dependency 'rspec', '1.3.0' + s.add_development_dependency 'ruby-debug' +end From 8975b4167efd68fc1c8ee54d8ffb5077bf1ce527 Mon Sep 17 00:00:00 2001 From: Magne Land Date: Tue, 27 Nov 2012 15:17:50 -0800 Subject: [PATCH 201/239] update README with new install/publish instructions --- README.rdoc | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/README.rdoc b/README.rdoc index d7b9c04..75497e2 100644 --- a/README.rdoc +++ b/README.rdoc @@ -4,10 +4,11 @@ "gem install rest_connection" ==== Installing from source - "git clone http://github.com/rightscale/rest_connection.git" - "gem install jeweler rspec" - "rake check_dependencies" <- Install any gems listed. - "rake install" + "git clone git@github.com:rightscale/rest_connection.git" + "cd rest_connection" + "gem install rconf" + "rconf" <- follow any further instructions from rconf + "bundle install" == Configuration @@ -47,10 +48,16 @@ Copy the example from GEMHOME/rest_connection/config/rest_api_config.yaml.sample puts my_array.instances.map { |i| i['ip-address'] } -=== To cut a new gem and push to rubygems.org +=== To cut a new gem and push to RubyGems.org - Edit VERSION and bump the number - rake gemspec - rake install - visit www.rubygems.org - gem push pkg/rest_connection-0.0.0.gem (use your new version number in this command) + Edit lib/rest_connection/version.rb and bump the number according to http://semver.org + + "bundle exec gem build rest_connection.gemspec" + "ls *.gem" <- verify that gem was built + "cd /tmp" + "bundle exec gem install /path/to/local/rest_connection-X.Y.Z.gem" <- replace X.Y.Z with your new version number + "bundle exec gem uninstall rest_connection" + "cd -" + "bundle exec gem push rest_connection-X.Y.Z.gem" + + Check it out: https://rubygems.org/gems/rest_connection From c25f65be06b931e365d617bf47de55d61969f5d5 Mon Sep 17 00:00:00 2001 From: Jon Marinello Date: Wed, 28 Nov 2012 04:00:27 -0800 Subject: [PATCH 202/239] Bumped catch_early_terminated from 300 to 600 to fix problems with rebooting during booting (still seeing this on Windows servers). --- lib/rest_connection/rightscale/server.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rest_connection/rightscale/server.rb b/lib/rest_connection/rightscale/server.rb index 26743b8..7e484f6 100644 --- a/lib/rest_connection/rightscale/server.rb +++ b/lib/rest_connection/rightscale/server.rb @@ -97,7 +97,7 @@ def wait_for_state(st,timeout=1200) reload connection.logger("#{nickname} is #{self.state}") step = 15 - catch_early_terminated = 300 / step + catch_early_terminated = 600 / step while(timeout > 0) return true if state =~ /#{st}/ return true if state =~ /terminated|stopped/ && st =~ /terminated|stopped/ From 1e8afc2483ba12ff0571add7d06aa1cbc13acbbd Mon Sep 17 00:00:00 2001 From: Jon Marinello Date: Wed, 28 Nov 2012 04:36:27 -0800 Subject: [PATCH 203/239] Bumped catch_early_terminated from 600 to 1200 to fix problems with rebooting during booting (still seeing this on Windows servers). --- lib/rest_connection/rightscale/server.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rest_connection/rightscale/server.rb b/lib/rest_connection/rightscale/server.rb index 7e484f6..4b3fb63 100644 --- a/lib/rest_connection/rightscale/server.rb +++ b/lib/rest_connection/rightscale/server.rb @@ -97,7 +97,7 @@ def wait_for_state(st,timeout=1200) reload connection.logger("#{nickname} is #{self.state}") step = 15 - catch_early_terminated = 600 / step + catch_early_terminated = 1200 / step while(timeout > 0) return true if state =~ /#{st}/ return true if state =~ /terminated|stopped/ && st =~ /terminated|stopped/ From 66b03f311993fb6468b10784662a2ca88acd6d2e Mon Sep 17 00:00:00 2001 From: Jon Marinello Date: Wed, 28 Nov 2012 13:21:43 -0800 Subject: [PATCH 204/239] Microsoft changed the 422 error message text so adjusted to that, added missing raise for unmatched target exception and added comments. --- lib/rest_connection/rightscale/mc_server.rb | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/rest_connection/rightscale/mc_server.rb b/lib/rest_connection/rightscale/mc_server.rb index cc61fd2..18362a8 100644 --- a/lib/rest_connection/rightscale/mc_server.rb +++ b/lib/rest_connection/rightscale/mc_server.rb @@ -68,7 +68,7 @@ def launch # FIXES THIS BUG ON THEIR END! # Retry on 422 conflict exception (ONLY MS AZURE WILL GENERATE THIS EXCEPTION) - target_422_conflict_error_message = "Invalid response HTTP code: 422: CloudException: ConflictError:" + target_422_conflict_error_message = "Invalid response HTTP code: 422: CloudException: Error code ConflictError:" target_504_gateway_timeout_error_message = "504 Gateway Time-out" if e.message =~ /#{target_504_gateway_timeout_error_message}/ exception_matched_message = "McServer.launch(): Caught #{e.message}, treating as a successful launch..." @@ -98,19 +98,29 @@ def launch azure_hack_retry_count -= 1 if azure_hack_retry_count > 0 retry_count += 1 + + # Try launching again next else + # Azure Hack maximum retries exceeded so rethrow the new 422 conflict exception raise end else + # On this re-launch we got some other exception so rethrow it raise end end + + # Fell through so launch worked and we need to break out of the retry loop break end else + # Azure Hack isn't enabled so rethrow the original exception raise end + else + # Didn't match on any target exception so rethrow the original exception + raise end end elsif self.state == "inactive" From 707c961c58c8cf3f6b172ca94266aac5f104dfa2 Mon Sep 17 00:00:00 2001 From: Jon Marinello Date: Wed, 28 Nov 2012 15:11:57 -0800 Subject: [PATCH 205/239] Moved 504 gateway error handling inside azure_hack logic and changed 422 retry logic to retry on all 422 errors. --- lib/rest_connection/rightscale/mc_server.rb | 50 ++++++++++----------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/lib/rest_connection/rightscale/mc_server.rb b/lib/rest_connection/rightscale/mc_server.rb index 18362a8..9c3ebc8 100644 --- a/lib/rest_connection/rightscale/mc_server.rb +++ b/lib/rest_connection/rightscale/mc_server.rb @@ -60,32 +60,32 @@ def launch begin connection.post(t.path + '/launch') rescue Exception => e - puts "************* McServer.launch(): Caught exception #{e.inspect}" - puts "************* McServer.launch(): connection.settings[:azure_hack_on] = #{connection.settings[:azure_hack_on]}" - puts "************* McServer.launch(): connection.settings[:azure_hack_retry_count] = #{connection.settings[:azure_hack_retry_count]}" - puts "************* McServer.launch(): connection.settings[:azure_hack_sleep_seconds] = #{connection.settings[:azure_hack_sleep_seconds]}" - # THIS IS A TEMPORARY HACK TO GET AROUND AZURE SERVER LAUNCH PROBLEMS AND SHOULD BE REMOVED ONCE MICROSOFT - # FIXES THIS BUG ON THEIR END! - - # Retry on 422 conflict exception (ONLY MS AZURE WILL GENERATE THIS EXCEPTION) - target_422_conflict_error_message = "Invalid response HTTP code: 422: CloudException: Error code ConflictError:" - target_504_gateway_timeout_error_message = "504 Gateway Time-out" - if e.message =~ /#{target_504_gateway_timeout_error_message}/ - exception_matched_message = "McServer.launch(): Caught #{e.message}, treating as a successful launch..." - puts(exception_matched_message) - connection.logger(exception_matched_message) - true - elsif e.message =~ /#{target_422_conflict_error_message}/ - if connection.settings[:azure_hack_on] + if connection.settings[:azure_hack_on] + puts "**** [AZURE_HACK is ON] - McServer.launch() caught exception #{e.inspect}" + puts "**** connection.settings[:azure_hack_retry_count] = #{connection.settings[:azure_hack_retry_count]}" + puts "**** connection.settings[:azure_hack_sleep_seconds] = #{connection.settings[:azure_hack_sleep_seconds]}" + + # 504 Gateway should always be treated as a successful launch + target_504_gateway_timeout_error_message = "504 Gateway Time-out" + + # All 422 exceptions should be retried + target_422_error_message = "Invalid response HTTP code: 422:" + + if e.message =~ /#{target_504_gateway_timeout_error_message}/ + exception_matched_message = "**** McServer.launch(): Caught #{e.message}, treating as a successful launch..." + puts(exception_matched_message) + connection.logger(exception_matched_message) + true + elsif e.message =~ /#{target_422_error_message}/ azure_hack_retry_count = connection.settings[:azure_hack_retry_count] - exception_matched_message = "************* McServer.launch(): Matched Azure exception: \"#{target_422_conflict_error_message}\"" + exception_matched_message = "**** McServer.launch(): Caught #{e.message}, retrying launch..." puts(exception_matched_message) connection.logger(exception_matched_message) retry_count = 1 loop do # sleep for azure_hack_sleep_seconds seconds - sleep_message = "************* McServer.launch(): Sleeping for #{connection.settings[:azure_hack_sleep_seconds]} seconds and then retrying (#{retry_count}) launch..." + sleep_message = "**** McServer.launch(): Sleeping for #{connection.settings[:azure_hack_sleep_seconds]} seconds and then retrying (#{retry_count}) launch..." puts(sleep_message) connection.logger(sleep_message) sleep(connection.settings[:azure_hack_sleep_seconds]) @@ -94,15 +94,15 @@ def launch begin connection.post(t.path + '/launch') rescue Exception => e2 - if e2.message =~ /#{target_422_conflict_error_message}/ + if e2.message =~ /#{target_422_error_message}/ azure_hack_retry_count -= 1 if azure_hack_retry_count > 0 retry_count += 1 - # Try launching again + # Try again on next iteration next else - # Azure Hack maximum retries exceeded so rethrow the new 422 conflict exception + # Azure Hack maximum retries exceeded so rethrow the new 422 exception raise end else @@ -111,15 +111,15 @@ def launch end end - # Fell through so launch worked and we need to break out of the retry loop + # Fell through so launch worked and we need to break out of the retry do loop break end else - # Azure Hack isn't enabled so rethrow the original exception + # Didn't match on any target exception so rethrow the original exception raise end else - # Didn't match on any target exception so rethrow the original exception + # Azure Hack isn't enabled so rethrow the original exception raise end end From aa7362ed816b735b7514753d6583651b40b0f2fe Mon Sep 17 00:00:00 2001 From: Jon Marinello Date: Wed, 28 Nov 2012 16:44:29 -0800 Subject: [PATCH 206/239] Azurehack: Added logging server nickname and logging subsequent exceptions caught on retries. --- lib/rest_connection/rightscale/mc_server.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/rest_connection/rightscale/mc_server.rb b/lib/rest_connection/rightscale/mc_server.rb index 9c3ebc8..0759018 100644 --- a/lib/rest_connection/rightscale/mc_server.rb +++ b/lib/rest_connection/rightscale/mc_server.rb @@ -61,7 +61,7 @@ def launch connection.post(t.path + '/launch') rescue Exception => e if connection.settings[:azure_hack_on] - puts "**** [AZURE_HACK is ON] - McServer.launch() caught exception #{e.inspect}" + puts "**** [AZURE_HACK is ON] - McServer.launch() nickname: #{nickname}, caught exception #{e.message}" puts "**** connection.settings[:azure_hack_retry_count] = #{connection.settings[:azure_hack_retry_count]}" puts "**** connection.settings[:azure_hack_sleep_seconds] = #{connection.settings[:azure_hack_sleep_seconds]}" @@ -94,6 +94,10 @@ def launch begin connection.post(t.path + '/launch') rescue Exception => e2 + exception_caught_message = "**** McServer.launch(): Retry caught #{e2.message}..." + puts(exception_caught_message) + connection.logger(exception_caught_message) + if e2.message =~ /#{target_422_error_message}/ azure_hack_retry_count -= 1 if azure_hack_retry_count > 0 From 27ef9bfd2ad3fd3c559a940cd565721e5d6f521a Mon Sep 17 00:00:00 2001 From: Nels Broberg Date: Thu, 29 Nov 2012 10:52:21 -0800 Subject: [PATCH 207/239] Removes argument expectation logic --- .../rightscale/ec2_security_group.rb | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/lib/rest_connection/rightscale/ec2_security_group.rb b/lib/rest_connection/rightscale/ec2_security_group.rb index c1fbf7c..8490577 100644 --- a/lib/rest_connection/rightscale/ec2_security_group.rb +++ b/lib/rest_connection/rightscale/ec2_security_group.rb @@ -29,20 +29,8 @@ class Ec2SecurityGroup # NOTE - Can't remove rules, can only add def add_rule(opts={}) opts.each { |k,v| opts["#{k}".to_sym] = v } - update_types = [ - :name => [:owner, :group], - :cidr_ips => [:cidr_ip, :protocol, :from_port, :to_port], - :group => [:owner, :group, :protocol, :from_port, :to_port], - ] - type = (opts[:protocol] ? (opts[:cidr_ip] ? :cidr_ips : :group) : :name) - unless update_types[type].reduce(true) { |b,field| b && opts[field] } - arg_expectation = update_types.values.pretty_inspect - raise ArgumentError.new("add_rule requires one of these groupings: #{arg_expectation}") - end - - params = {} - update_types[type].each { |field| params[field] = opts[field] } + params = {'ec2_security_group' => opts} uri = URI.parse(self.href) connection.put(uri.path, params) From 4a1a2e6697158243561d92cd45ac5a27771b5133 Mon Sep 17 00:00:00 2001 From: Nels Broberg Date: Mon, 3 Dec 2012 20:41:44 -0800 Subject: [PATCH 208/239] Added validation logic to sg add_rule method --- .../rightscale/ec2_security_group.rb | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/lib/rest_connection/rightscale/ec2_security_group.rb b/lib/rest_connection/rightscale/ec2_security_group.rb index 8490577..04625e9 100644 --- a/lib/rest_connection/rightscale/ec2_security_group.rb +++ b/lib/rest_connection/rightscale/ec2_security_group.rb @@ -25,15 +25,36 @@ class Ec2SecurityGroup include RightScale::Api::Base extend RightScale::Api::BaseExtend + @@valid_rule_types = [ + [:group, :owner], + [:cidr_ips, :from_port, :protocol, :to_port], + [:from_port, :group, :owner, :protocol, :to_port], + ] + # NOTE - Create, Destroy, and Update require "security_manager" permissions # NOTE - Can't remove rules, can only add def add_rule(opts={}) - opts.each { |k,v| opts["#{k}".to_sym] = v } + rule = {} + opts.each { |k,v| rule["#{k}".to_sym] = v } + + unless validate_rule(rule) + raise ArgumentError.new("add_rule expects one of these valid rule types: #{@@valid_rule_types.to_json}") + end - params = {'ec2_security_group' => opts} + params = {'ec2_security_group' => rule} uri = URI.parse(self.href) connection.put(uri.path, params) self.reload end + + def validate_rule(rule) + @@valid_rule_types.each do |valid_rule_type| + if rule.keys.sort_by {|sym| sym.to_s} == valid_rule_type.sort_by {|sym| sym.to_s} + return true + end + end + + false + end end From b3c3e38f4cb46cbcb6d2f75eb2ecfbd58946df12 Mon Sep 17 00:00:00 2001 From: Nels Broberg Date: Tue, 4 Dec 2012 10:54:16 -0800 Subject: [PATCH 209/239] Use symbol instead of string to indicate its importance --- lib/rest_connection/rightscale/ec2_security_group.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rest_connection/rightscale/ec2_security_group.rb b/lib/rest_connection/rightscale/ec2_security_group.rb index 04625e9..9e9d3e8 100644 --- a/lib/rest_connection/rightscale/ec2_security_group.rb +++ b/lib/rest_connection/rightscale/ec2_security_group.rb @@ -41,7 +41,7 @@ def add_rule(opts={}) raise ArgumentError.new("add_rule expects one of these valid rule types: #{@@valid_rule_types.to_json}") end - params = {'ec2_security_group' => rule} + params = {:ec2_security_group => rule} uri = URI.parse(self.href) connection.put(uri.path, params) From 17eb0a59138fa130f401e260cdad9a451841433b Mon Sep 17 00:00:00 2001 From: Nels Broberg Date: Tue, 4 Dec 2012 11:35:08 -0800 Subject: [PATCH 210/239] Changed from static class variable to constant --- .../rightscale/ec2_security_group.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/rest_connection/rightscale/ec2_security_group.rb b/lib/rest_connection/rightscale/ec2_security_group.rb index 9e9d3e8..85b9e8c 100644 --- a/lib/rest_connection/rightscale/ec2_security_group.rb +++ b/lib/rest_connection/rightscale/ec2_security_group.rb @@ -25,11 +25,11 @@ class Ec2SecurityGroup include RightScale::Api::Base extend RightScale::Api::BaseExtend - @@valid_rule_types = [ - [:group, :owner], - [:cidr_ips, :from_port, :protocol, :to_port], - [:from_port, :group, :owner, :protocol, :to_port], - ] + VALID_RULE_TYPES = [ + [:group, :owner], + [:cidr_ips, :from_port, :protocol, :to_port], + [:from_port, :group, :owner, :protocol, :to_port], + ] # NOTE - Create, Destroy, and Update require "security_manager" permissions # NOTE - Can't remove rules, can only add @@ -38,7 +38,7 @@ def add_rule(opts={}) opts.each { |k,v| rule["#{k}".to_sym] = v } unless validate_rule(rule) - raise ArgumentError.new("add_rule expects one of these valid rule types: #{@@valid_rule_types.to_json}") + raise ArgumentError.new("add_rule expects one of these valid rule types: #{VALID_RULE_TYPES.to_json}") end params = {:ec2_security_group => rule} @@ -49,7 +49,7 @@ def add_rule(opts={}) end def validate_rule(rule) - @@valid_rule_types.each do |valid_rule_type| + VALID_RULE_TYPES.each do |valid_rule_type| if rule.keys.sort_by {|sym| sym.to_s} == valid_rule_type.sort_by {|sym| sym.to_s} return true end From dad4f81bfaf18375cc78db9dfde3411ac68a4f33 Mon Sep 17 00:00:00 2001 From: jonmarinellors Date: Thu, 13 Dec 2012 09:07:07 -0800 Subject: [PATCH 211/239] Put back the code that detected the OS type and correctly set the $stat_flag. --- git_hooks/pre-commit | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/git_hooks/pre-commit b/git_hooks/pre-commit index b56439c..c3e45a1 100755 --- a/git_hooks/pre-commit +++ b/git_hooks/pre-commit @@ -1,5 +1,17 @@ #!/bin/bash +# Setup $stat_flag based on OS type +mac_unix_name=Darwin +uname_returned=`uname -a` +unix_name=${uname_returned:0:${#mac_unix_name}} +if [ "$unix_name" = "$mac_unix_name" ]; then + echo "MAC OS \"$mac_unix_name\" detected..." + stat_flag=-f +else + echo "non-MAC OS detected..." + stat_flag=-c +fi + echo "Checking for syntax errors..." for FILE in `git diff-index --name-only HEAD --` ; do if test -f $FILE; then From 8e5ea39fe7b84d88e00922423ec7cfc6edc19b96 Mon Sep 17 00:00:00 2001 From: Magne Land Date: Thu, 13 Dec 2012 10:29:06 -0800 Subject: [PATCH 212/239] bump up version to 1.0.3 to prepare for gem publish 1.0.2 was already released --- lib/rest_connection/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rest_connection/version.rb b/lib/rest_connection/version.rb index 44d43a1..dbf5ac0 100644 --- a/lib/rest_connection/version.rb +++ b/lib/rest_connection/version.rb @@ -1,4 +1,4 @@ # This gem is versioned with the usual X.Y.Z notation module RestConnection - VERSION = '1.0.1' + VERSION = '1.0.3' end From 31b1000188defd58b535af816a3c2e0999181660 Mon Sep 17 00:00:00 2001 From: Magne Land Date: Fri, 21 Dec 2012 13:41:39 -0800 Subject: [PATCH 213/239] bump up version to 1.0.4 to prepare for gem publish --- lib/rest_connection/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rest_connection/version.rb b/lib/rest_connection/version.rb index dbf5ac0..e094006 100644 --- a/lib/rest_connection/version.rb +++ b/lib/rest_connection/version.rb @@ -1,4 +1,4 @@ # This gem is versioned with the usual X.Y.Z notation module RestConnection - VERSION = '1.0.3' + VERSION = '1.0.4' end From 1e9afe4b9a298055193639de5b1ca1552a5a3197 Mon Sep 17 00:00:00 2001 From: Magne Land Date: Fri, 21 Dec 2012 14:57:52 -0800 Subject: [PATCH 214/239] Relax dependencies for activesupport and net-ssh This remedies Issue #12. Tested manually. --- rest_connection.gemspec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rest_connection.gemspec b/rest_connection.gemspec index 3c72cae..ed81a5b 100644 --- a/rest_connection.gemspec +++ b/rest_connection.gemspec @@ -18,8 +18,8 @@ It currently has support for RightScale API 1.0 and 1.5. s.test_files = `git ls-files spec config`.split(' ') s.rubygems_version = '1.8.24' - s.add_runtime_dependency 'activesupport', '2.3.10' - s.add_runtime_dependency 'net-ssh', '2.1.4' + s.add_runtime_dependency 'activesupport' + s.add_runtime_dependency 'net-ssh' s.add_runtime_dependency 'json' s.add_runtime_dependency 'highline' s.add_runtime_dependency 'rest-client' From 6dfe324dc1938526e81941429d929dec759beda1 Mon Sep 17 00:00:00 2001 From: Magne Land Date: Fri, 21 Dec 2012 14:58:33 -0800 Subject: [PATCH 215/239] Don't store Gemfile.lock for gems --- Gemfile.lock | 43 ------------------------------------------- 1 file changed, 43 deletions(-) delete mode 100644 Gemfile.lock diff --git a/Gemfile.lock b/Gemfile.lock deleted file mode 100644 index f6fdcc8..0000000 --- a/Gemfile.lock +++ /dev/null @@ -1,43 +0,0 @@ -PATH - remote: . - specs: - rest_connection (1.0.1) - activesupport (= 2.3.10) - highline - json - net-ssh (= 2.1.4) - nokogiri - rest-client - -GEM - remote: http://rubygems.org/ - specs: - activesupport (2.3.10) - columnize (0.3.6) - highline (1.6.15) - json (1.7.5) - linecache (0.46) - rbx-require-relative (> 0.0.4) - mime-types (1.19) - net-ssh (2.1.4) - nokogiri (1.5.5) - rake (0.8.7) - rbx-require-relative (0.0.9) - rest-client (1.6.7) - mime-types (>= 1.16) - rspec (1.3.0) - ruby-debug (0.10.4) - columnize (>= 0.1) - ruby-debug-base (~> 0.10.4.0) - ruby-debug-base (0.10.4) - linecache (>= 0.3) - -PLATFORMS - ruby - -DEPENDENCIES - bundler - rake (= 0.8.7) - rest_connection! - rspec (= 1.3.0) - ruby-debug From 8a618a4980571f2b6b688b238312f5a8b49f4dc4 Mon Sep 17 00:00:00 2001 From: Kannan Manickam Date: Fri, 28 Dec 2012 20:55:58 +0000 Subject: [PATCH 216/239] acu69289 - using 'sudo' instead of 'sudo -i --' --- lib/rest_connection/ssh_hax.rb | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/rest_connection/ssh_hax.rb b/lib/rest_connection/ssh_hax.rb index 4cd04bb..1a32cf5 100644 --- a/lib/rest_connection/ssh_hax.rb +++ b/lib/rest_connection/ssh_hax.rb @@ -64,7 +64,7 @@ def spot_check_command?(command, ssh_key=nil, host_dns=self.reachable_ip) # returns hash of exit_status and output from command - # Note that "sudo -i" is prepended to and the 'rightscale' user is used. + # Note that "sudo" is prepended to and the 'rightscale' user is used. def spot_check_command(command, ssh_key=nil, host_dns=self.reachable_ip, do_not_log_result=false) puts "SshHax::Probe method #{__method__}() entered..." raise "FATAL: spot_check_command called on a server with no reachable_ip. You need to run .settings on the server to populate this attribute." unless host_dns @@ -92,10 +92,9 @@ def spot_check_command(command, ssh_key=nil, host_dns=self.reachable_ip, do_not_ ch1.request_pty do |ch, success| raise "Could not obtain a pseudo-tty!" if !success end - # Now execute the command with "sudo -i --" prepended to it. - # NOTE: The -- option indicates that sudo should stop processing command line arguments + # Now execute the command with "sudo" prepended to it. # NOTE: The use of single quotes is required to keep Ruby from interpretting the command string passed in and messing up regex's - sudo_command = 'sudo -i -- ' + command + sudo_command = 'sudo ' + command puts 'SshHax::Probe executing ' + sudo_command + '...' ch1.exec(sudo_command) do |ch2, success| unless success From a05b47357be2466718507f09e62b44cad065f112 Mon Sep 17 00:00:00 2001 From: Magne Land Date: Wed, 2 Jan 2013 17:29:59 -0800 Subject: [PATCH 217/239] bump up version to 1.0.5 to prepare for gem publish --- lib/rest_connection/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rest_connection/version.rb b/lib/rest_connection/version.rb index e094006..689b9cb 100644 --- a/lib/rest_connection/version.rb +++ b/lib/rest_connection/version.rb @@ -1,4 +1,4 @@ # This gem is versioned with the usual X.Y.Z notation module RestConnection - VERSION = '1.0.4' + VERSION = '1.0.5' end From d25c9277946c6c0918ac09450c820431cc5c90ff Mon Sep 17 00:00:00 2001 From: Christopher Deutsch Date: Tue, 5 Feb 2013 16:53:11 -0800 Subject: [PATCH 218/239] acu76268 - fix rest_connection bug preventing chimp from running on generic shards --- lib/rest_connection/rightscale/rightscale_api_base.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/rest_connection/rightscale/rightscale_api_base.rb b/lib/rest_connection/rightscale/rightscale_api_base.rb index 3e634c2..0d5aafc 100644 --- a/lib/rest_connection/rightscale/rightscale_api_base.rb +++ b/lib/rest_connection/rightscale/rightscale_api_base.rb @@ -77,6 +77,8 @@ def self.api0_1? @@api0_1 = true rescue RestConnection::Errors::Forbidden @@api0_1 = false + rescue RestConnection::Errors::UnprocessableEntity + @@api0_1 = false end # Check for API 1.0 Access From 3d9fab1c984f63b4bdaa798e31d689fb0c493ecb Mon Sep 17 00:00:00 2001 From: Christopher Deutsch Date: Tue, 5 Feb 2013 16:55:25 -0800 Subject: [PATCH 219/239] acu76271 - move run_script_on_instances from api 0.1 to 1.0 --- .../rightscale/ec2_server_array.rb | 31 +++++++++++++++++++ .../rightscale/ec2_server_array_internal.rb | 21 ------------- 2 files changed, 31 insertions(+), 21 deletions(-) diff --git a/lib/rest_connection/rightscale/ec2_server_array.rb b/lib/rest_connection/rightscale/ec2_server_array.rb index c4b69b5..f61db54 100644 --- a/lib/rest_connection/rightscale/ec2_server_array.rb +++ b/lib/rest_connection/rightscale/ec2_server_array.rb @@ -50,6 +50,37 @@ def run_script_on_all(script, server_template_hrefs, inputs=nil) connection.post("#{serv_href.path}/run_script_on_all", options) end + # + # Run a script on individual instances in a ServerArray + # + # This was formerly located in Ec2ServerArrayInternal but has + # been moved here to Ec2ServerArray as the call has been ported + # from API 0.1 to API 1.0. + # + # Example: array.run_script_on_instances(right_script, server_href, options_hash) + # + def run_script_on_instances(script, ec2_instance_hrefs=[], opts={}) + uri = URI.parse(self.href) + case script + when Executable then script = script.right_script + when String then script = RightScript.new('href' => script) + end + + params = {:right_script_href => script.href } + unless ec2_instance_hrefs.nil? || ec2_instance_hrefs.empty? + params[:ec2_instance_hrefs] = ec2_instance_hrefs + end + unless opts.nil? || opts.empty? + params[:parameters] = opts + end + params = {:ec2_server_array => params} + status_array=[] + connection.post(uri.path + "/run_script_on_instances", params).map do |work_unit| + status_array.push Status.new('href' => work_unit) + end + return(status_array) + end + def instances serv_href = URI.parse(self.href) connection.get("#{serv_href.path}/instances") diff --git a/lib/rest_connection/rightscale/ec2_server_array_internal.rb b/lib/rest_connection/rightscale/ec2_server_array_internal.rb index eb2fbbc..db995fe 100644 --- a/lib/rest_connection/rightscale/ec2_server_array_internal.rb +++ b/lib/rest_connection/rightscale/ec2_server_array_internal.rb @@ -29,25 +29,4 @@ class Ec2ServerArrayInternal deny_methods :index, :show, :create, :update, :destroy - def run_script_on_instances(script, ec2_instance_hrefs=[], opts={}) - uri = URI.parse(self.href) - case script - when Executable then script = script.right_script - when String then script = RightScript.new('href' => script) - end - - params = {:right_script_href => script.href } - unless ec2_instance_hrefs.nil? || ec2_instance_hrefs.empty? - params[:ec2_instance_hrefs] = ec2_instance_hrefs - end - unless opts.nil? || opts.empty? - params[:parameters] = opts - end - params = {:ec2_server_array => params} - status_array=[] - connection.post(uri.path + "/run_script_on_instances", params).map do |work_unit| - status_array.push Status.new('href' => work_unit) - end - return(status_array) - end end From 0bb29a730c16ebf72021530841005a419ec1f383 Mon Sep 17 00:00:00 2001 From: Christopher Deutsch Date: Mon, 11 Feb 2013 14:02:37 -0800 Subject: [PATCH 220/239] acu76271 - delete unnecessary file --- .../rightscale/ec2_server_array_internal.rb | 32 ------------------- 1 file changed, 32 deletions(-) delete mode 100644 lib/rest_connection/rightscale/ec2_server_array_internal.rb diff --git a/lib/rest_connection/rightscale/ec2_server_array_internal.rb b/lib/rest_connection/rightscale/ec2_server_array_internal.rb deleted file mode 100644 index db995fe..0000000 --- a/lib/rest_connection/rightscale/ec2_server_array_internal.rb +++ /dev/null @@ -1,32 +0,0 @@ -#-- -# Copyright (c) 2010-2012 RightScale Inc -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -#++ - -class Ec2ServerArrayInternal - include RightScale::Api::Base - extend RightScale::Api::BaseExtend - include RightScale::Api::Internal - extend RightScale::Api::InternalExtend - - deny_methods :index, :show, :create, :update, :destroy - -end From 336fd468331c5417db776a50f77891f66d8c64c3 Mon Sep 17 00:00:00 2001 From: Douglas Thrift Date: Mon, 25 Feb 2013 22:59:58 +0000 Subject: [PATCH 221/239] acu78873 - Add -tt to ssh call so there is no warning about not allocating a TTY. --- lib/rest_connection/ssh_hax.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rest_connection/ssh_hax.rb b/lib/rest_connection/ssh_hax.rb index 1a32cf5..e571fe7 100644 --- a/lib/rest_connection/ssh_hax.rb +++ b/lib/rest_connection/ssh_hax.rb @@ -78,7 +78,7 @@ def spot_check_command(command, ssh_key=nil, host_dns=self.reachable_ip, do_not_ # Test for ability to connect; Net::SSH.start sometimes hangs under certain server-side sshd configs test_ssh = "" [5, 15, 60].each { |timeout_max| - test_ssh = `ssh -o \"BatchMode=yes\" -o \"StrictHostKeyChecking=no\" -o \"ConnectTimeout #{timeout_max}\" rightscale@#{host_dns} -C \"exit\" 2>&1`.chomp + test_ssh = `ssh -tt -o \"BatchMode=yes\" -o \"StrictHostKeyChecking=no\" -o \"ConnectTimeout #{timeout_max}\" rightscale@#{host_dns} -C \"exit\" 2>&1`.chomp break if test_ssh =~ /permission denied/i or test_ssh.empty? } raise test_ssh unless test_ssh =~ /permission denied/i or test_ssh.empty? From f95737a05f31dcee3c968fb89843d45c06f318a3 Mon Sep 17 00:00:00 2001 From: Douglas Thrift Date: Tue, 26 Feb 2013 01:30:34 +0000 Subject: [PATCH 222/239] acu78873 - Add -q to ssh call so it doesn't output connection closed message as well. --- lib/rest_connection/ssh_hax.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rest_connection/ssh_hax.rb b/lib/rest_connection/ssh_hax.rb index e571fe7..8d78cf0 100644 --- a/lib/rest_connection/ssh_hax.rb +++ b/lib/rest_connection/ssh_hax.rb @@ -78,7 +78,7 @@ def spot_check_command(command, ssh_key=nil, host_dns=self.reachable_ip, do_not_ # Test for ability to connect; Net::SSH.start sometimes hangs under certain server-side sshd configs test_ssh = "" [5, 15, 60].each { |timeout_max| - test_ssh = `ssh -tt -o \"BatchMode=yes\" -o \"StrictHostKeyChecking=no\" -o \"ConnectTimeout #{timeout_max}\" rightscale@#{host_dns} -C \"exit\" 2>&1`.chomp + test_ssh = `ssh -ttq -o \"BatchMode=yes\" -o \"StrictHostKeyChecking=no\" -o \"ConnectTimeout #{timeout_max}\" rightscale@#{host_dns} -C \"exit\" 2>&1`.chomp break if test_ssh =~ /permission denied/i or test_ssh.empty? } raise test_ssh unless test_ssh =~ /permission denied/i or test_ssh.empty? From d9fb57d39b4ff5adf4914600f0c510f100b8904b Mon Sep 17 00:00:00 2001 From: Christopher Deutsch Date: Thu, 28 Feb 2013 00:50:41 -0800 Subject: [PATCH 223/239] acu80153 - remove require line for deleted ec2_server_array_internal.rb file --- lib/rest_connection/rightscale/rightscale_api_resources.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/rest_connection/rightscale/rightscale_api_resources.rb b/lib/rest_connection/rightscale/rightscale_api_resources.rb index a4326eb..5c5e6dd 100644 --- a/lib/rest_connection/rightscale/rightscale_api_resources.rb +++ b/lib/rest_connection/rightscale/rightscale_api_resources.rb @@ -73,7 +73,6 @@ require 'rest_connection/rightscale/multi_cloud_image_cloud_setting_internal' require 'rest_connection/rightscale/multi_cloud_image_internal' require 'rest_connection/rightscale/multi_cloud_image' -require 'rest_connection/rightscale/ec2_server_array_internal' require 'rest_connection/rightscale/ec2_server_array' require 'rest_connection/rightscale/mc_server_array' require 'rest_connection/rightscale/security_group_rule' From f3c74680e6027ffb2140681d96694ea28b9d87b2 Mon Sep 17 00:00:00 2001 From: Christopher Deutsch Date: Thu, 28 Feb 2013 00:57:29 -0800 Subject: [PATCH 224/239] acu80153 - fixup for removed internal array class --- lib/rest_connection/rightscale/ec2_server_array.rb | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib/rest_connection/rightscale/ec2_server_array.rb b/lib/rest_connection/rightscale/ec2_server_array.rb index f61db54..4c16675 100644 --- a/lib/rest_connection/rightscale/ec2_server_array.rb +++ b/lib/rest_connection/rightscale/ec2_server_array.rb @@ -31,9 +31,6 @@ class Ec2ServerArray def initialize(*args, &block) super(*args, &block) - if RightScale::Api::api0_1? - @internal = Ec2ServerArrayInternal.new(*args, &block) - end end # Example: From 1f4344c9979786941d3562f8f1aee7ca9bce623b Mon Sep 17 00:00:00 2001 From: Douglas Thrift Date: Thu, 14 Mar 2013 23:22:10 +0000 Subject: [PATCH 225/239] acu83842 - Add support for ignore_lock parameter to McServer and McInstance that is equivalent to that on Server. --- lib/rest_connection/rightscale/mc_instance.rb | 9 ++++++++- lib/rest_connection/rightscale/mc_server.rb | 4 ++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/rest_connection/rightscale/mc_instance.rb b/lib/rest_connection/rightscale/mc_instance.rb index 2b65435..0eba66c 100644 --- a/lib/rest_connection/rightscale/mc_instance.rb +++ b/lib/rest_connection/rightscale/mc_instance.rb @@ -151,7 +151,7 @@ def translate_href(old_href) return href end - def run_executable(executable, opts=nil) + def run_executable(executable, opts=nil, ignore_lock=false) run_options = Hash.new if executable.is_a?(Executable) if executable.recipe? @@ -165,8 +165,15 @@ def run_executable(executable, opts=nil) raise "Invalid class passed to run_executable, needs Executable or RightScript, was:#{executable.class}" end + if not opts.nil? and opts.has_key?(:ignore_lock) + run_options[:ignore_lock] = "true" + opts.delete(:ignore_lock) + opts = nil if opts.empty? + end + inst_href = URI.parse(self.href) run_options[:inputs] = transform_inputs(:to_a, opts) unless opts.nil? + run_options[:ignore_lock] = "true" if ignore_lock location = connection.post(inst_href.path + '/run_executable', run_options) Task.new('href' => location) end diff --git a/lib/rest_connection/rightscale/mc_server.rb b/lib/rest_connection/rightscale/mc_server.rb index 0759018..08b1a26 100644 --- a/lib/rest_connection/rightscale/mc_server.rb +++ b/lib/rest_connection/rightscale/mc_server.rb @@ -161,9 +161,9 @@ def stop #stop_ebs raise "You shouldn't be here." end - def run_executable(executable, opts=nil) + def run_executable(executable, opts=nil, ignore_lock=false) raise "Instance isn't running; Can't run executable" unless @current_instance - @current_instance.run_executable(executable, opts) + @current_instance.run_executable(executable, opts, ignore_lock) end def transform_inputs(sym, parameters) From 7f56dd613c877c1d3fd1309679ff86102471ec4f Mon Sep 17 00:00:00 2001 From: Magne Land Date: Thu, 14 Mar 2013 16:24:12 -0700 Subject: [PATCH 226/239] acu83923 rename read me and add mandatory ownership string also converted from rdoc to markdown (hopefully) --- README.rdoc => README.md | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) rename README.rdoc => README.md (81%) diff --git a/README.rdoc b/README.md similarity index 81% rename from README.rdoc rename to README.md index 75497e2..f159884 100644 --- a/README.rdoc +++ b/README.md @@ -1,16 +1,20 @@ -= rest_connection Quick Start -== Install -==== Installing with rubygems +# rest_connection Quick Start + +Maintained by the RightScale "Yellow_team" + +## Install + +#### Installing with rubygems "gem install rest_connection" -==== Installing from source +#### Installing from source "git clone git@github.com:rightscale/rest_connection.git" "cd rest_connection" "gem install rconf" "rconf" <- follow any further instructions from rconf "bundle install" -== Configuration +## Configuration You must setup ~/.rest_connection/rest_api_config.yaml or /etc/rest_connection/rest_api_config.yaml @@ -20,12 +24,12 @@ Copy the example from GEMHOME/rest_connection/config/rest_api_config.yaml.sample "gem install gemedit" "gem edit rest_connection" -== Usage: some IRB samples for the RightScale API module +## Usage: some IRB samples for the RightScale API module $ irb ruby> require 'rubygems'; require 'rest_connection' -=== Lookup and run a RightScript +### Lookup and run a RightScript first_fe = Server.find(:first) { |s| s.nickname =~ /Front End/ } st = ServerTemplate.find(first_fe.server_template_href) @@ -33,14 +37,14 @@ Copy the example from GEMHOME/rest_connection/config/rest_api_config.yaml.sample state = first_fe.run_executable(connect_script) state.wait_for_completed -=== Stop a Deployment +### Stop a Deployment deployment = Deployment.find(opts[:id]) my_servers = deployment.servers my_servers.each { |s| s.stop } my_servers.each { |s| s.wait_for_state("stopped") } -=== Activate an Ec2ServerArray / Display instances IPs +### Activate an Ec2ServerArray / Display instances IPs my_array = Ec2ServerArray.find(opts[:href]) my_array.active = true @@ -48,7 +52,7 @@ Copy the example from GEMHOME/rest_connection/config/rest_api_config.yaml.sample puts my_array.instances.map { |i| i['ip-address'] } -=== To cut a new gem and push to RubyGems.org +### To cut a new gem and push to RubyGems.org Edit lib/rest_connection/version.rb and bump the number according to http://semver.org From 9ad3c4e91f33c0663045682807f86c1086a2fa96 Mon Sep 17 00:00:00 2001 From: Magne Land Date: Fri, 5 Apr 2013 19:39:17 -0700 Subject: [PATCH 227/239] acu87542 indent code using markdown syntax - 4 spaces --- README.md | 69 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 36 insertions(+), 33 deletions(-) diff --git a/README.md b/README.md index f159884..9f42466 100644 --- a/README.md +++ b/README.md @@ -5,14 +5,16 @@ Maintained by the RightScale "Yellow_team" ## Install #### Installing with rubygems - "gem install rest_connection" + + "gem install rest_connection" #### Installing from source - "git clone git@github.com:rightscale/rest_connection.git" - "cd rest_connection" - "gem install rconf" - "rconf" <- follow any further instructions from rconf - "bundle install" + + "git clone git@github.com:rightscale/rest_connection.git" + "cd rest_connection" + "gem install rconf" + "rconf" <- follow any further instructions from rconf + "bundle install" ## Configuration @@ -20,48 +22,49 @@ You must setup ~/.rest_connection/rest_api_config.yaml or /etc/rest_connection/r Copy the example from GEMHOME/rest_connection/config/rest_api_config.yaml.sample and fill in your connection info. - Pro Tip: to find a GEMHOME, use gemedit - "gem install gemedit" - "gem edit rest_connection" +Pro Tip: to find a GEMHOME, use gemedit + + "gem install gemedit" + "gem edit rest_connection" ## Usage: some IRB samples for the RightScale API module - $ irb - ruby> require 'rubygems'; require 'rest_connection' + $ irb + ruby> require 'rubygems'; require 'rest_connection' ### Lookup and run a RightScript - first_fe = Server.find(:first) { |s| s.nickname =~ /Front End/ } - st = ServerTemplate.find(first_fe.server_template_href) - connect_script = st.executables.detect { |ex| ex.name =~ /LB [app|mongrels]+ to HA proxy connect/i } - state = first_fe.run_executable(connect_script) - state.wait_for_completed + first_fe = Server.find(:first) { |s| s.nickname =~ /Front End/ } + st = ServerTemplate.find(first_fe.server_template_href) + connect_script = st.executables.detect { |ex| ex.name =~ /LB [app|mongrels]+ to HA proxy connect/i } + state = first_fe.run_executable(connect_script) + state.wait_for_completed ### Stop a Deployment - deployment = Deployment.find(opts[:id]) - my_servers = deployment.servers - my_servers.each { |s| s.stop } - my_servers.each { |s| s.wait_for_state("stopped") } + deployment = Deployment.find(opts[:id]) + my_servers = deployment.servers + my_servers.each { |s| s.stop } + my_servers.each { |s| s.wait_for_state("stopped") } ### Activate an Ec2ServerArray / Display instances IPs - my_array = Ec2ServerArray.find(opts[:href]) - my_array.active = true - my_array.save + my_array = Ec2ServerArray.find(opts[:href]) + my_array.active = true + my_array.save - puts my_array.instances.map { |i| i['ip-address'] } + puts my_array.instances.map { |i| i['ip-address'] } ### To cut a new gem and push to RubyGems.org - Edit lib/rest_connection/version.rb and bump the number according to http://semver.org +Edit lib/rest_connection/version.rb and bump the number according to http://semver.org - "bundle exec gem build rest_connection.gemspec" - "ls *.gem" <- verify that gem was built - "cd /tmp" - "bundle exec gem install /path/to/local/rest_connection-X.Y.Z.gem" <- replace X.Y.Z with your new version number - "bundle exec gem uninstall rest_connection" - "cd -" - "bundle exec gem push rest_connection-X.Y.Z.gem" + "bundle exec gem build rest_connection.gemspec" + "ls *.gem" <- verify that gem was built + "cd /tmp" + "bundle exec gem install /path/to/local/rest_connection-X.Y.Z.gem" <- replace X.Y.Z with your new version number + "bundle exec gem uninstall rest_connection" + "cd -" + "bundle exec gem push rest_connection-X.Y.Z.gem" - Check it out: https://rubygems.org/gems/rest_connection +Check it out: https://rubygems.org/gems/rest_connection From 9b2235e099e4ba272943193049ec2949cc7c5651 Mon Sep 17 00:00:00 2001 From: Magne Land Date: Fri, 5 Apr 2013 20:12:10 -0700 Subject: [PATCH 228/239] acu87542 updated README.md with more info --- README.md | 41 ++++++++++++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 9f42466..061b3e3 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,26 @@ -# rest_connection Quick Start +# RightScale REST Connection + +The rest_connection gem is a Ruby library for RightScale's API 1.0 and API 1.5. + +It should be considered deprecated. +If you only use API 1.5, you should use the right_api_client gem instead: https://rubygems.org/gems/right_api_client + +- API 1.0 Documentation: http://support.rightscale.com/12-Guides/03-RightScale_API +- API 1.0 Reference Docs: http://reference.rightscale.com/api1.0 +- API 1.5 Documentation: http://support.rightscale.com/12-Guides/RightScale_API_1.5 +- API 1.5 Reference Docs: http://reference.rightscale.com/api1.5 Maintained by the RightScale "Yellow_team" -## Install +## Installation -#### Installing with rubygems +Ruby 1.8.7 or higher is required. + +### Installing from RubyGems "gem install rest_connection" -#### Installing from source +### Installing from source "git clone git@github.com:rightscale/rest_connection.git" "cd rest_connection" @@ -16,7 +28,11 @@ Maintained by the RightScale "Yellow_team" "rconf" <- follow any further instructions from rconf "bundle install" -## Configuration +## Versioning + +We follow semantic versioning according to http://semver.org + +## Usage Instructions You must setup ~/.rest_connection/rest_api_config.yaml or /etc/rest_connection/rest_api_config.yaml @@ -27,9 +43,9 @@ Pro Tip: to find a GEMHOME, use gemedit "gem install gemedit" "gem edit rest_connection" -## Usage: some IRB samples for the RightScale API module +The following examples assume an interactive ruby session (irb): - $ irb + $ bundle exec irb ruby> require 'rubygems'; require 'rest_connection' ### Lookup and run a RightScript @@ -55,9 +71,16 @@ Pro Tip: to find a GEMHOME, use gemedit puts my_array.instances.map { |i| i['ip-address'] } -### To cut a new gem and push to RubyGems.org +## Troubleshooting + +### Wrong ruby version + +Ruby 1.8.7 or higher is required. + +## Publishing -Edit lib/rest_connection/version.rb and bump the number according to http://semver.org +To cut a new gem and push to RubyGems: +Edit lib/rest_connection/version.rb "bundle exec gem build rest_connection.gemspec" "ls *.gem" <- verify that gem was built From ed11af59a56cbd66edacf1304eb22ac412daa39d Mon Sep 17 00:00:00 2001 From: Magne Land Date: Fri, 5 Apr 2013 21:17:34 -0700 Subject: [PATCH 229/239] acu87542 Shortened a common comment. This commit also identifies the set of API 1.5 classes and modules. Note that the mc_ prefix is prevalent but not consistent. --- lib/rest_connection/rightscale/account.rb | 2 +- lib/rest_connection/rightscale/backup.rb | 2 +- lib/rest_connection/rightscale/child_account.rb | 2 +- lib/rest_connection/rightscale/cloud.rb | 2 +- lib/rest_connection/rightscale/cloud_account.rb | 2 +- lib/rest_connection/rightscale/instance_type.rb | 2 +- lib/rest_connection/rightscale/mc_audit_entry.rb | 2 +- lib/rest_connection/rightscale/mc_datacenter.rb | 2 +- lib/rest_connection/rightscale/mc_deployment.rb | 2 +- lib/rest_connection/rightscale/mc_image.rb | 2 +- lib/rest_connection/rightscale/mc_instance.rb | 2 +- lib/rest_connection/rightscale/mc_instance_type.rb | 2 +- lib/rest_connection/rightscale/mc_multi_cloud_image.rb | 2 +- lib/rest_connection/rightscale/mc_multi_cloud_image_setting.rb | 2 +- lib/rest_connection/rightscale/mc_security_group.rb | 2 +- lib/rest_connection/rightscale/mc_server.rb | 2 +- lib/rest_connection/rightscale/mc_server_array.rb | 2 +- lib/rest_connection/rightscale/mc_server_template.rb | 2 +- .../rightscale/mc_server_template_multi_cloud_image.rb | 2 +- lib/rest_connection/rightscale/mc_ssh_key.rb | 2 +- lib/rest_connection/rightscale/mc_tag.rb | 2 +- lib/rest_connection/rightscale/mc_volume.rb | 2 +- lib/rest_connection/rightscale/mc_volume_attachment.rb | 2 +- lib/rest_connection/rightscale/mc_volume_snapshot.rb | 2 +- lib/rest_connection/rightscale/mc_volume_type.rb | 2 +- lib/rest_connection/rightscale/monitoring_metric.rb | 2 +- lib/rest_connection/rightscale/permission.rb | 2 +- lib/rest_connection/rightscale/rightscale_api_mc_input.rb | 2 +- lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb | 2 +- lib/rest_connection/rightscale/security_group_rule.rb | 2 +- lib/rest_connection/rightscale/session.rb | 2 +- lib/rest_connection/rightscale/task.rb | 2 +- lib/rest_connection/rightscale/user.rb | 2 +- 33 files changed, 33 insertions(+), 33 deletions(-) diff --git a/lib/rest_connection/rightscale/account.rb b/lib/rest_connection/rightscale/account.rb index 6e0b766..97984f7 100644 --- a/lib/rest_connection/rightscale/account.rb +++ b/lib/rest_connection/rightscale/account.rb @@ -22,7 +22,7 @@ #++ # -# You must have Beta v1.5 API access to use these internal API calls. +# API 1.5 # # diff --git a/lib/rest_connection/rightscale/backup.rb b/lib/rest_connection/rightscale/backup.rb index 21178d8..5180e68 100644 --- a/lib/rest_connection/rightscale/backup.rb +++ b/lib/rest_connection/rightscale/backup.rb @@ -22,7 +22,7 @@ #++ # -# You must have Beta v1.5 API access to use these internal API calls. +# API 1.5 # class Backup include RightScale::Api::Gateway diff --git a/lib/rest_connection/rightscale/child_account.rb b/lib/rest_connection/rightscale/child_account.rb index 03dc55f..77bb8a0 100644 --- a/lib/rest_connection/rightscale/child_account.rb +++ b/lib/rest_connection/rightscale/child_account.rb @@ -22,7 +22,7 @@ #++ # -# You must have Beta v1.5 API access to use these internal API calls. +# API 1.5 # # diff --git a/lib/rest_connection/rightscale/cloud.rb b/lib/rest_connection/rightscale/cloud.rb index 42aa256..0c46d02 100644 --- a/lib/rest_connection/rightscale/cloud.rb +++ b/lib/rest_connection/rightscale/cloud.rb @@ -22,7 +22,7 @@ #++ # -# You must have Beta v1.5 API access to use these internal API calls. +# API 1.5 # class Cloud include RightScale::Api::Gateway diff --git a/lib/rest_connection/rightscale/cloud_account.rb b/lib/rest_connection/rightscale/cloud_account.rb index 8cf79af..7af08e5 100644 --- a/lib/rest_connection/rightscale/cloud_account.rb +++ b/lib/rest_connection/rightscale/cloud_account.rb @@ -22,7 +22,7 @@ #++ # -# You must have Beta v1.5 API access to use these internal API calls. +# API 1.5 # class CloudAccount include RightScale::Api::Gateway diff --git a/lib/rest_connection/rightscale/instance_type.rb b/lib/rest_connection/rightscale/instance_type.rb index e51afd3..bbfd32d 100644 --- a/lib/rest_connection/rightscale/instance_type.rb +++ b/lib/rest_connection/rightscale/instance_type.rb @@ -22,7 +22,7 @@ #++ # -# You must have Beta v1.5 API access to use these internal API calls. +# API 1.5 # class InstanceType include RightScale::Api::Gateway diff --git a/lib/rest_connection/rightscale/mc_audit_entry.rb b/lib/rest_connection/rightscale/mc_audit_entry.rb index 2bfa84d..72ae833 100644 --- a/lib/rest_connection/rightscale/mc_audit_entry.rb +++ b/lib/rest_connection/rightscale/mc_audit_entry.rb @@ -22,7 +22,7 @@ #++ # -# You must have Beta v1.5 API access to use these internal API calls. +# API 1.5 # class McAuditEntry include RightScale::Api::Gateway diff --git a/lib/rest_connection/rightscale/mc_datacenter.rb b/lib/rest_connection/rightscale/mc_datacenter.rb index 87edd6b..f3d6a87 100644 --- a/lib/rest_connection/rightscale/mc_datacenter.rb +++ b/lib/rest_connection/rightscale/mc_datacenter.rb @@ -22,7 +22,7 @@ #++ # -# You must have Beta v1.5 API access to use these internal API calls. +# API 1.5 # class McDatacenter include RightScale::Api::Gateway diff --git a/lib/rest_connection/rightscale/mc_deployment.rb b/lib/rest_connection/rightscale/mc_deployment.rb index 8d8d3f3..a62e6ed 100644 --- a/lib/rest_connection/rightscale/mc_deployment.rb +++ b/lib/rest_connection/rightscale/mc_deployment.rb @@ -22,7 +22,7 @@ #++ # -# You must have Beta v1.5 API access to use these internal API calls. +# API 1.5 # class McDeployment include RightScale::Api::Gateway diff --git a/lib/rest_connection/rightscale/mc_image.rb b/lib/rest_connection/rightscale/mc_image.rb index a6b109d..0a1c5f5 100644 --- a/lib/rest_connection/rightscale/mc_image.rb +++ b/lib/rest_connection/rightscale/mc_image.rb @@ -22,7 +22,7 @@ #++ # -# You must have Beta v1.5 API access to use these internal API calls. +# API 1.5 # class McImage include RightScale::Api::Gateway diff --git a/lib/rest_connection/rightscale/mc_instance.rb b/lib/rest_connection/rightscale/mc_instance.rb index 0eba66c..7fcb8ba 100644 --- a/lib/rest_connection/rightscale/mc_instance.rb +++ b/lib/rest_connection/rightscale/mc_instance.rb @@ -22,7 +22,7 @@ #++ # -# You must have Beta v1.5 API access to use these internal API calls. +# API 1.5 # class McInstance include RightScale::Api::Gateway diff --git a/lib/rest_connection/rightscale/mc_instance_type.rb b/lib/rest_connection/rightscale/mc_instance_type.rb index 53d7314..25c9450 100644 --- a/lib/rest_connection/rightscale/mc_instance_type.rb +++ b/lib/rest_connection/rightscale/mc_instance_type.rb @@ -22,7 +22,7 @@ #++ # -# You must have Beta v1.5 API access to use these internal API calls. +# API 1.5 # class McInstanceType include RightScale::Api::Gateway diff --git a/lib/rest_connection/rightscale/mc_multi_cloud_image.rb b/lib/rest_connection/rightscale/mc_multi_cloud_image.rb index 52f3d75..a9cface 100644 --- a/lib/rest_connection/rightscale/mc_multi_cloud_image.rb +++ b/lib/rest_connection/rightscale/mc_multi_cloud_image.rb @@ -22,7 +22,7 @@ #++ # -# You must have Beta v1.5 API access to use these internal API calls. +# API 1.5 # class McMultiCloudImage include RightScale::Api::Gateway diff --git a/lib/rest_connection/rightscale/mc_multi_cloud_image_setting.rb b/lib/rest_connection/rightscale/mc_multi_cloud_image_setting.rb index bdf6158..97a10f5 100644 --- a/lib/rest_connection/rightscale/mc_multi_cloud_image_setting.rb +++ b/lib/rest_connection/rightscale/mc_multi_cloud_image_setting.rb @@ -22,7 +22,7 @@ #++ # -# You must have Beta v1.5 API access to use these internal API calls. +# API 1.5 # class McMultiCloudImageSetting include RightScale::Api::Gateway diff --git a/lib/rest_connection/rightscale/mc_security_group.rb b/lib/rest_connection/rightscale/mc_security_group.rb index 25ecf1a..ae668c5 100644 --- a/lib/rest_connection/rightscale/mc_security_group.rb +++ b/lib/rest_connection/rightscale/mc_security_group.rb @@ -22,7 +22,7 @@ #++ # -# You must have Beta v1.5 API access to use these internal API calls. +# API 1.5 # class McSecurityGroup include RightScale::Api::Gateway diff --git a/lib/rest_connection/rightscale/mc_server.rb b/lib/rest_connection/rightscale/mc_server.rb index 08b1a26..d490222 100644 --- a/lib/rest_connection/rightscale/mc_server.rb +++ b/lib/rest_connection/rightscale/mc_server.rb @@ -21,7 +21,7 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #++ # -# You must have Beta v1.5 API access to use these internal API calls. +# API 1.5 # class McServer < Server include RightScale::Api::Gateway diff --git a/lib/rest_connection/rightscale/mc_server_array.rb b/lib/rest_connection/rightscale/mc_server_array.rb index 6c55f5b..018dd45 100644 --- a/lib/rest_connection/rightscale/mc_server_array.rb +++ b/lib/rest_connection/rightscale/mc_server_array.rb @@ -22,7 +22,7 @@ #++ # -# You must have Beta v1.5 API access to use these internal API calls. +# API 1.5 # class McServerArray include RightScale::Api::Gateway diff --git a/lib/rest_connection/rightscale/mc_server_template.rb b/lib/rest_connection/rightscale/mc_server_template.rb index 023d396..49735f8 100644 --- a/lib/rest_connection/rightscale/mc_server_template.rb +++ b/lib/rest_connection/rightscale/mc_server_template.rb @@ -22,7 +22,7 @@ #++ # -# You must have Beta v1.5 API access to use these internal API calls. +# API 1.5 # class McServerTemplate include RightScale::Api::Gateway diff --git a/lib/rest_connection/rightscale/mc_server_template_multi_cloud_image.rb b/lib/rest_connection/rightscale/mc_server_template_multi_cloud_image.rb index f17a27d..29d7c13 100644 --- a/lib/rest_connection/rightscale/mc_server_template_multi_cloud_image.rb +++ b/lib/rest_connection/rightscale/mc_server_template_multi_cloud_image.rb @@ -22,7 +22,7 @@ #++ # -# You must have Beta v1.5 API access to use these internal API calls. +# API 1.5 # class McServerTemplateMultiCloudImage diff --git a/lib/rest_connection/rightscale/mc_ssh_key.rb b/lib/rest_connection/rightscale/mc_ssh_key.rb index 10400a4..fdc9a2f 100644 --- a/lib/rest_connection/rightscale/mc_ssh_key.rb +++ b/lib/rest_connection/rightscale/mc_ssh_key.rb @@ -22,7 +22,7 @@ #++ # -# You must have Beta v1.5 API access to use these internal API calls. +# API 1.5 # class McSshKey include RightScale::Api::Gateway diff --git a/lib/rest_connection/rightscale/mc_tag.rb b/lib/rest_connection/rightscale/mc_tag.rb index f5f5db2..60245d1 100644 --- a/lib/rest_connection/rightscale/mc_tag.rb +++ b/lib/rest_connection/rightscale/mc_tag.rb @@ -22,7 +22,7 @@ #++ # -# You must have Beta v1.5 API access to use these internal API calls. +# API 1.5 # class McTag include RightScale::Api::Gateway diff --git a/lib/rest_connection/rightscale/mc_volume.rb b/lib/rest_connection/rightscale/mc_volume.rb index eb14948..6e6039c 100644 --- a/lib/rest_connection/rightscale/mc_volume.rb +++ b/lib/rest_connection/rightscale/mc_volume.rb @@ -22,7 +22,7 @@ #++ # -# You must have Beta v1.5 API access to use these internal API calls. +# API 1.5 # class McVolume include RightScale::Api::Gateway diff --git a/lib/rest_connection/rightscale/mc_volume_attachment.rb b/lib/rest_connection/rightscale/mc_volume_attachment.rb index 449fce4..adf98ea 100644 --- a/lib/rest_connection/rightscale/mc_volume_attachment.rb +++ b/lib/rest_connection/rightscale/mc_volume_attachment.rb @@ -22,7 +22,7 @@ #++ # -# You must have Beta v1.5 API access to use these internal API calls. +# API 1.5 # class McVolumeAttachment include RightScale::Api::Gateway diff --git a/lib/rest_connection/rightscale/mc_volume_snapshot.rb b/lib/rest_connection/rightscale/mc_volume_snapshot.rb index 336cf68..097b14d 100644 --- a/lib/rest_connection/rightscale/mc_volume_snapshot.rb +++ b/lib/rest_connection/rightscale/mc_volume_snapshot.rb @@ -22,7 +22,7 @@ #++ # -# You must have Beta v1.5 API access to use these internal API calls. +# API 1.5 # class McVolumeSnapshot include RightScale::Api::Gateway diff --git a/lib/rest_connection/rightscale/mc_volume_type.rb b/lib/rest_connection/rightscale/mc_volume_type.rb index fe5fb2e..f6758a7 100644 --- a/lib/rest_connection/rightscale/mc_volume_type.rb +++ b/lib/rest_connection/rightscale/mc_volume_type.rb @@ -22,7 +22,7 @@ #++ # -# You must have Beta v1.5 API access to use these internal API calls. +# API 1.5 # class McVolumeType include RightScale::Api::Gateway diff --git a/lib/rest_connection/rightscale/monitoring_metric.rb b/lib/rest_connection/rightscale/monitoring_metric.rb index 7a3db9d..3d3160e 100644 --- a/lib/rest_connection/rightscale/monitoring_metric.rb +++ b/lib/rest_connection/rightscale/monitoring_metric.rb @@ -22,7 +22,7 @@ #++ # -# You must have Beta v1.5 API access to use these internal API calls. +# API 1.5 # class MonitoringMetric include RightScale::Api::Gateway diff --git a/lib/rest_connection/rightscale/permission.rb b/lib/rest_connection/rightscale/permission.rb index 053416e..d9ef26b 100644 --- a/lib/rest_connection/rightscale/permission.rb +++ b/lib/rest_connection/rightscale/permission.rb @@ -22,7 +22,7 @@ #++ # -# You must have Beta v1.5 API access to use these internal API calls. +# API 1.5 # # diff --git a/lib/rest_connection/rightscale/rightscale_api_mc_input.rb b/lib/rest_connection/rightscale/rightscale_api_mc_input.rb index 964a459..955b249 100644 --- a/lib/rest_connection/rightscale/rightscale_api_mc_input.rb +++ b/lib/rest_connection/rightscale/rightscale_api_mc_input.rb @@ -22,7 +22,7 @@ #++ # -# You must have Beta v1.5 API access to use these internal API calls. +# API 1.5 # module RightScale module Api diff --git a/lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb b/lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb index ed87a13..8d18a65 100644 --- a/lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb +++ b/lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb @@ -22,7 +22,7 @@ #++ # -# You must have Beta v1.5 API access to use these internal API calls. +# API 1.5 # module RightScale module Api diff --git a/lib/rest_connection/rightscale/security_group_rule.rb b/lib/rest_connection/rightscale/security_group_rule.rb index 3d0456f..cd57a0e 100644 --- a/lib/rest_connection/rightscale/security_group_rule.rb +++ b/lib/rest_connection/rightscale/security_group_rule.rb @@ -22,7 +22,7 @@ #++ # -# You must have Beta v1.5 API access to use these internal API calls. +# API 1.5 # class SecurityGroupRule include RightScale::Api::Gateway diff --git a/lib/rest_connection/rightscale/session.rb b/lib/rest_connection/rightscale/session.rb index 1e69a06..779aeeb 100644 --- a/lib/rest_connection/rightscale/session.rb +++ b/lib/rest_connection/rightscale/session.rb @@ -22,7 +22,7 @@ #++ # -# You must have Beta v1.5 API access to use these internal API calls. +# API 1.5 # class Session include RightScale::Api::Gateway diff --git a/lib/rest_connection/rightscale/task.rb b/lib/rest_connection/rightscale/task.rb index c8a8326..ca1ac8d 100644 --- a/lib/rest_connection/rightscale/task.rb +++ b/lib/rest_connection/rightscale/task.rb @@ -22,7 +22,7 @@ #++ # -# You must have Beta v1.5 API access to use these internal API calls. +# API 1.5 # class Task include RightScale::Api::Gateway diff --git a/lib/rest_connection/rightscale/user.rb b/lib/rest_connection/rightscale/user.rb index 88ecf73..12265f3 100644 --- a/lib/rest_connection/rightscale/user.rb +++ b/lib/rest_connection/rightscale/user.rb @@ -22,7 +22,7 @@ #++ # -# You must have Beta v1.5 API access to use these internal API calls. +# API 1.5 # # From 7e9f389f86488b80dade10d9e85b44edc03ce4eb Mon Sep 17 00:00:00 2001 From: Magne Land Date: Fri, 5 Apr 2013 21:18:56 -0700 Subject: [PATCH 230/239] acu87542 Shortened another comment. This commit also identifies the set of API 0.1 classes. --- lib/rest_connection/rightscale/rs_internal.rb | 2 +- lib/rest_connection/rightscale/server_internal.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/rest_connection/rightscale/rs_internal.rb b/lib/rest_connection/rightscale/rs_internal.rb index d874cfc..50088b5 100644 --- a/lib/rest_connection/rightscale/rs_internal.rb +++ b/lib/rest_connection/rightscale/rs_internal.rb @@ -22,7 +22,7 @@ #++ # -# You must have special API access to use these internal API calls. +# API 0.1 # class RsInternal include RightScale::Api::Base diff --git a/lib/rest_connection/rightscale/server_internal.rb b/lib/rest_connection/rightscale/server_internal.rb index fcec0ae..b86b431 100644 --- a/lib/rest_connection/rightscale/server_internal.rb +++ b/lib/rest_connection/rightscale/server_internal.rb @@ -22,7 +22,7 @@ #++ # -# You must have special API access to use these internal API calls. +# API 0.1 # class ServerInternal include RightScale::Api::Base From cd0c66c3fb5e29868646031178bfba2c5a84b7cb Mon Sep 17 00:00:00 2001 From: Magne Land Date: Fri, 5 Apr 2013 21:34:09 -0700 Subject: [PATCH 231/239] acu87542 add comment for more API 0.1 classes --- lib/rest_connection/rightscale/ec2_ssh_key_internal.rb | 3 +++ .../rightscale/multi_cloud_image_cloud_setting_internal.rb | 3 +++ lib/rest_connection/rightscale/multi_cloud_image_internal.rb | 3 +++ lib/rest_connection/rightscale/right_script_internal.rb | 4 +++- lib/rest_connection/rightscale/server_template_internal.rb | 3 +++ 5 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/rest_connection/rightscale/ec2_ssh_key_internal.rb b/lib/rest_connection/rightscale/ec2_ssh_key_internal.rb index de8102e..d490bad 100644 --- a/lib/rest_connection/rightscale/ec2_ssh_key_internal.rb +++ b/lib/rest_connection/rightscale/ec2_ssh_key_internal.rb @@ -21,6 +21,9 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #++ +# +# API 0.1 +# class Ec2SshKeyInternal include RightScale::Api::Base extend RightScale::Api::BaseExtend diff --git a/lib/rest_connection/rightscale/multi_cloud_image_cloud_setting_internal.rb b/lib/rest_connection/rightscale/multi_cloud_image_cloud_setting_internal.rb index 8e6c7aa..c7a49e5 100644 --- a/lib/rest_connection/rightscale/multi_cloud_image_cloud_setting_internal.rb +++ b/lib/rest_connection/rightscale/multi_cloud_image_cloud_setting_internal.rb @@ -21,6 +21,9 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #++ +# +# API 0.1 +# class MultiCloudImageCloudSettingInternal include RightScale::Api::Base extend RightScale::Api::BaseExtend diff --git a/lib/rest_connection/rightscale/multi_cloud_image_internal.rb b/lib/rest_connection/rightscale/multi_cloud_image_internal.rb index 6e675eb..989c0db 100644 --- a/lib/rest_connection/rightscale/multi_cloud_image_internal.rb +++ b/lib/rest_connection/rightscale/multi_cloud_image_internal.rb @@ -21,6 +21,9 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #++ +# +# API 0.1 +# class MultiCloudImageInternal include RightScale::Api::Base extend RightScale::Api::BaseExtend diff --git a/lib/rest_connection/rightscale/right_script_internal.rb b/lib/rest_connection/rightscale/right_script_internal.rb index b0dcf55..2998e8d 100644 --- a/lib/rest_connection/rightscale/right_script_internal.rb +++ b/lib/rest_connection/rightscale/right_script_internal.rb @@ -21,7 +21,9 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #++ - +# +# API 0.1 +# class RightScriptInternal include RightScale::Api::Base extend RightScale::Api::BaseExtend diff --git a/lib/rest_connection/rightscale/server_template_internal.rb b/lib/rest_connection/rightscale/server_template_internal.rb index 89bcbb1..015ba11 100644 --- a/lib/rest_connection/rightscale/server_template_internal.rb +++ b/lib/rest_connection/rightscale/server_template_internal.rb @@ -21,6 +21,9 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #++ +# +# API 0.1 +# class ServerTemplateInternal include RightScale::Api::Base extend RightScale::Api::BaseExtend From 4950e1ae79f79ae8bd4bfc4cb455a8796de58687 Mon Sep 17 00:00:00 2001 From: Magne Land Date: Fri, 5 Apr 2013 21:34:45 -0700 Subject: [PATCH 232/239] acu87542 add comments for API 1.0 classes --- lib/rest_connection/rightscale/alert_spec.rb | 3 +++ lib/rest_connection/rightscale/alert_spec_subject.rb | 3 +++ lib/rest_connection/rightscale/audit_entry.rb | 3 +++ lib/rest_connection/rightscale/credential.rb | 3 +++ lib/rest_connection/rightscale/deployment.rb | 3 +++ lib/rest_connection/rightscale/ec2_ebs_snapshot.rb | 3 +++ lib/rest_connection/rightscale/ec2_ebs_volume.rb | 3 +++ lib/rest_connection/rightscale/ec2_elastic_ip.rb | 3 +++ lib/rest_connection/rightscale/ec2_security_group.rb | 3 +++ lib/rest_connection/rightscale/ec2_server_array.rb | 3 +++ lib/rest_connection/rightscale/ec2_ssh_key.rb | 3 +++ lib/rest_connection/rightscale/executable.rb | 3 +++ lib/rest_connection/rightscale/instance.rb | 4 ++++ lib/rest_connection/rightscale/macro.rb | 3 +++ lib/rest_connection/rightscale/multi_cloud_image.rb | 3 +++ lib/rest_connection/rightscale/right_script.rb | 3 +++ .../rightscale/right_script_attachment_internal.rb | 3 +++ lib/rest_connection/rightscale/s3_bucket.rb | 3 +++ lib/rest_connection/rightscale/server.rb | 3 +++ lib/rest_connection/rightscale/server_ec2_ebs_volume.rb | 3 +++ lib/rest_connection/rightscale/server_template.rb | 3 +++ lib/rest_connection/rightscale/sqs_queue.rb | 3 +++ lib/rest_connection/rightscale/status.rb | 3 +++ lib/rest_connection/rightscale/tag.rb | 3 +++ lib/rest_connection/rightscale/vpc_dhcp_option.rb | 3 +++ 25 files changed, 76 insertions(+) diff --git a/lib/rest_connection/rightscale/alert_spec.rb b/lib/rest_connection/rightscale/alert_spec.rb index dabc46a..84479c5 100644 --- a/lib/rest_connection/rightscale/alert_spec.rb +++ b/lib/rest_connection/rightscale/alert_spec.rb @@ -21,6 +21,9 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #++ +# +# API 1.0 +# class AlertSpec include RightScale::Api::Base extend RightScale::Api::BaseExtend diff --git a/lib/rest_connection/rightscale/alert_spec_subject.rb b/lib/rest_connection/rightscale/alert_spec_subject.rb index 2f2257e..9b3f92b 100644 --- a/lib/rest_connection/rightscale/alert_spec_subject.rb +++ b/lib/rest_connection/rightscale/alert_spec_subject.rb @@ -21,6 +21,9 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #++ +# +# API 1.0 +# class AlertSpecSubject include RightScale::Api::Base extend RightScale::Api::BaseExtend diff --git a/lib/rest_connection/rightscale/audit_entry.rb b/lib/rest_connection/rightscale/audit_entry.rb index ff3fe20..b99a840 100644 --- a/lib/rest_connection/rightscale/audit_entry.rb +++ b/lib/rest_connection/rightscale/audit_entry.rb @@ -33,6 +33,9 @@ # end #end +# +# API 1.0 +# class AuditEntry include RightScale::Api::Base extend RightScale::Api::BaseExtend diff --git a/lib/rest_connection/rightscale/credential.rb b/lib/rest_connection/rightscale/credential.rb index 4feb11f..69c2b68 100644 --- a/lib/rest_connection/rightscale/credential.rb +++ b/lib/rest_connection/rightscale/credential.rb @@ -21,6 +21,9 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #++ +# +# API 1.0 +# class Credential include RightScale::Api::Base extend RightScale::Api::BaseExtend diff --git a/lib/rest_connection/rightscale/deployment.rb b/lib/rest_connection/rightscale/deployment.rb index 9756d7d..f01ef6b 100644 --- a/lib/rest_connection/rightscale/deployment.rb +++ b/lib/rest_connection/rightscale/deployment.rb @@ -21,6 +21,9 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #++ +# +# API 1.0 +# class Deployment include RightScale::Api::Base extend RightScale::Api::BaseExtend diff --git a/lib/rest_connection/rightscale/ec2_ebs_snapshot.rb b/lib/rest_connection/rightscale/ec2_ebs_snapshot.rb index 9abd787..84fa921 100644 --- a/lib/rest_connection/rightscale/ec2_ebs_snapshot.rb +++ b/lib/rest_connection/rightscale/ec2_ebs_snapshot.rb @@ -21,6 +21,9 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #++ +# +# API 1.0 +# class Ec2EbsSnapshot include RightScale::Api::Base extend RightScale::Api::BaseExtend diff --git a/lib/rest_connection/rightscale/ec2_ebs_volume.rb b/lib/rest_connection/rightscale/ec2_ebs_volume.rb index 69acca7..55b2bda 100644 --- a/lib/rest_connection/rightscale/ec2_ebs_volume.rb +++ b/lib/rest_connection/rightscale/ec2_ebs_volume.rb @@ -21,6 +21,9 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #++ +# +# API 1.0 +# class Ec2EbsVolume include RightScale::Api::Base extend RightScale::Api::BaseExtend diff --git a/lib/rest_connection/rightscale/ec2_elastic_ip.rb b/lib/rest_connection/rightscale/ec2_elastic_ip.rb index cc30b8b..4882bdf 100644 --- a/lib/rest_connection/rightscale/ec2_elastic_ip.rb +++ b/lib/rest_connection/rightscale/ec2_elastic_ip.rb @@ -21,6 +21,9 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #++ +# +# API 1.0 +# class Ec2ElasticIp include RightScale::Api::Base extend RightScale::Api::BaseExtend diff --git a/lib/rest_connection/rightscale/ec2_security_group.rb b/lib/rest_connection/rightscale/ec2_security_group.rb index 85b9e8c..76160d7 100644 --- a/lib/rest_connection/rightscale/ec2_security_group.rb +++ b/lib/rest_connection/rightscale/ec2_security_group.rb @@ -21,6 +21,9 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #++ +# +# API 1.0 +# class Ec2SecurityGroup include RightScale::Api::Base extend RightScale::Api::BaseExtend diff --git a/lib/rest_connection/rightscale/ec2_server_array.rb b/lib/rest_connection/rightscale/ec2_server_array.rb index 4c16675..521659f 100644 --- a/lib/rest_connection/rightscale/ec2_server_array.rb +++ b/lib/rest_connection/rightscale/ec2_server_array.rb @@ -21,6 +21,9 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #++ +# +# API 1.0 +# class Ec2ServerArray include RightScale::Api::Base extend RightScale::Api::BaseExtend diff --git a/lib/rest_connection/rightscale/ec2_ssh_key.rb b/lib/rest_connection/rightscale/ec2_ssh_key.rb index 1c11066..87bdce2 100644 --- a/lib/rest_connection/rightscale/ec2_ssh_key.rb +++ b/lib/rest_connection/rightscale/ec2_ssh_key.rb @@ -21,6 +21,9 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #++ +# +# API 1.0 +# class Ec2SshKey include RightScale::Api::Base extend RightScale::Api::BaseExtend diff --git a/lib/rest_connection/rightscale/executable.rb b/lib/rest_connection/rightscale/executable.rb index 29af2e5..73c59fc 100644 --- a/lib/rest_connection/rightscale/executable.rb +++ b/lib/rest_connection/rightscale/executable.rb @@ -21,6 +21,9 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #++ +# +# API 1.0 +# class Executable include RightScale::Api::Base extend RightScale::Api::BaseExtend diff --git a/lib/rest_connection/rightscale/instance.rb b/lib/rest_connection/rightscale/instance.rb index 26d190c..06f1460 100644 --- a/lib/rest_connection/rightscale/instance.rb +++ b/lib/rest_connection/rightscale/instance.rb @@ -21,6 +21,10 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #++ +# +# API 1.0 +# + # This is an instance facing api and can only be used with # an authentication URL normally found in the instance's userdata called # RS_API_URL diff --git a/lib/rest_connection/rightscale/macro.rb b/lib/rest_connection/rightscale/macro.rb index a9d1ead..d5ff222 100644 --- a/lib/rest_connection/rightscale/macro.rb +++ b/lib/rest_connection/rightscale/macro.rb @@ -21,6 +21,9 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #++ +# +# API 1.0 +# class Macro include RightScale::Api::Base extend RightScale::Api::BaseExtend diff --git a/lib/rest_connection/rightscale/multi_cloud_image.rb b/lib/rest_connection/rightscale/multi_cloud_image.rb index 18eef40..d8b5d87 100644 --- a/lib/rest_connection/rightscale/multi_cloud_image.rb +++ b/lib/rest_connection/rightscale/multi_cloud_image.rb @@ -21,6 +21,9 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #++ +# +# API 1.0 +# class MultiCloudImage include RightScale::Api::Base extend RightScale::Api::BaseExtend diff --git a/lib/rest_connection/rightscale/right_script.rb b/lib/rest_connection/rightscale/right_script.rb index 3c3906f..9bc0d05 100644 --- a/lib/rest_connection/rightscale/right_script.rb +++ b/lib/rest_connection/rightscale/right_script.rb @@ -22,6 +22,9 @@ #++ +# +# API 1.0 +# class RightScript include RightScale::Api::Base extend RightScale::Api::BaseExtend diff --git a/lib/rest_connection/rightscale/right_script_attachment_internal.rb b/lib/rest_connection/rightscale/right_script_attachment_internal.rb index 0edb0f4..6f020e3 100644 --- a/lib/rest_connection/rightscale/right_script_attachment_internal.rb +++ b/lib/rest_connection/rightscale/right_script_attachment_internal.rb @@ -24,6 +24,9 @@ require 'rest-client' RestClient.log = ENV["REST_CONNECTION_LOG"] || "stdout" +# +# API 1.0 +# class RightScriptAttachmentInternal include RightScale::Api::Base extend RightScale::Api::BaseExtend diff --git a/lib/rest_connection/rightscale/s3_bucket.rb b/lib/rest_connection/rightscale/s3_bucket.rb index 694e1b7..75b9893 100644 --- a/lib/rest_connection/rightscale/s3_bucket.rb +++ b/lib/rest_connection/rightscale/s3_bucket.rb @@ -21,6 +21,9 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #++ +# +# API 1.0 +# class S3Bucket include RightScale::Api::Base extend RightScale::Api::BaseExtend diff --git a/lib/rest_connection/rightscale/server.rb b/lib/rest_connection/rightscale/server.rb index 4b3fb63..1658ac7 100644 --- a/lib/rest_connection/rightscale/server.rb +++ b/lib/rest_connection/rightscale/server.rb @@ -21,6 +21,9 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #++ +# +# API 1.0 +# class Server include RightScale::Api::Base extend RightScale::Api::BaseExtend diff --git a/lib/rest_connection/rightscale/server_ec2_ebs_volume.rb b/lib/rest_connection/rightscale/server_ec2_ebs_volume.rb index d2e0b05..26fa606 100644 --- a/lib/rest_connection/rightscale/server_ec2_ebs_volume.rb +++ b/lib/rest_connection/rightscale/server_ec2_ebs_volume.rb @@ -21,6 +21,9 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #++ +# +# API 1.0 +# class ServerEc2EbsVolume include RightScale::Api::Base extend RightScale::Api::BaseExtend diff --git a/lib/rest_connection/rightscale/server_template.rb b/lib/rest_connection/rightscale/server_template.rb index 885007c..a575dcf 100644 --- a/lib/rest_connection/rightscale/server_template.rb +++ b/lib/rest_connection/rightscale/server_template.rb @@ -21,6 +21,9 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #++ +# +# API 1.0 +# class ServerTemplate include RightScale::Api::Base extend RightScale::Api::BaseExtend diff --git a/lib/rest_connection/rightscale/sqs_queue.rb b/lib/rest_connection/rightscale/sqs_queue.rb index dfce7cc..2ac238e 100644 --- a/lib/rest_connection/rightscale/sqs_queue.rb +++ b/lib/rest_connection/rightscale/sqs_queue.rb @@ -21,6 +21,9 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #++ +# +# API 1.0 +# class SqsQueue include RightScale::Api::Base extend RightScale::Api::BaseExtend diff --git a/lib/rest_connection/rightscale/status.rb b/lib/rest_connection/rightscale/status.rb index 9e7f875..9a7328e 100644 --- a/lib/rest_connection/rightscale/status.rb +++ b/lib/rest_connection/rightscale/status.rb @@ -26,6 +26,9 @@ #This is the v4 image only work status api. # was used by Server#run_script (depricating..) +# +# API 1.0 +# class Status include RightScale::Api::Base extend RightScale::Api::BaseExtend diff --git a/lib/rest_connection/rightscale/tag.rb b/lib/rest_connection/rightscale/tag.rb index a8e1d90..fc9e27e 100644 --- a/lib/rest_connection/rightscale/tag.rb +++ b/lib/rest_connection/rightscale/tag.rb @@ -21,6 +21,9 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #++ +# +# API 1.0 +# class Tag include RightScale::Api::Base extend RightScale::Api::BaseExtend diff --git a/lib/rest_connection/rightscale/vpc_dhcp_option.rb b/lib/rest_connection/rightscale/vpc_dhcp_option.rb index 9092cfd..20e1bf1 100644 --- a/lib/rest_connection/rightscale/vpc_dhcp_option.rb +++ b/lib/rest_connection/rightscale/vpc_dhcp_option.rb @@ -21,6 +21,9 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #++ +# +# API 1.0 +# class VpcDhcpOption include RightScale::Api::Base extend RightScale::Api::BaseExtend From 9e2820abf4bf6bd719cfedc895a6921dd38bafa2 Mon Sep 17 00:00:00 2001 From: Magne Land Date: Fri, 5 Apr 2013 21:35:40 -0700 Subject: [PATCH 233/239] acu87542 minor tweak to comment Actually all our APIs are stuck in beta anyways. --- lib/rest_connection/rightscale/rightscale_api_base.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rest_connection/rightscale/rightscale_api_base.rb b/lib/rest_connection/rightscale/rightscale_api_base.rb index 0d5aafc..d8a0517 100644 --- a/lib/rest_connection/rightscale/rightscale_api_base.rb +++ b/lib/rest_connection/rightscale/rightscale_api_base.rb @@ -92,7 +92,7 @@ def self.api1_0? @@api1_0 = false end - # Check for API 1.5 Beta Access + # Check for API 1.5 Access def self.api1_5? if class_variable_defined?("@@api1_5") return @@api1_5 unless @@api1_5.nil? From e4753bc409ca5e8fb7e702a2a50a2af95ca010f2 Mon Sep 17 00:00:00 2001 From: Magne Land Date: Fri, 5 Apr 2013 21:58:43 -0700 Subject: [PATCH 234/239] acu87542 added some info about instance facing API 1.0 --- README.md | 26 ++++++++++++++-------- lib/rest_connection/rightscale/instance.rb | 4 +--- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 061b3e3..9a9ef42 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,16 @@ # RightScale REST Connection -The rest_connection gem is a Ruby library for RightScale's API 1.0 and API 1.5. +The rest_connection gem is a Ruby library for RightScale's API 1.0 and API 1.5 on legacy and generic clusters. +Additionally, it has support for RightScale's internal API 0.1 on legacy clusters. -It should be considered deprecated. -If you only use API 1.5, you should use the right_api_client gem instead: https://rubygems.org/gems/right_api_client +This gem also supports RightScale's instance facing API 1.0, which use the instance token to login. +The instance token is found in the instance's user data as 'RS_rn_auth' or alternatively as part of 'RS_api_url'. +The user data is available under the 'Info' tab on the server's page in the RightScale Dashboard. + +This gem should be considered deprecated! + +If you only use API 1.5, you should use the right_api_client gem instead: +https://rubygems.org/gems/right_api_client - API 1.0 Documentation: http://support.rightscale.com/12-Guides/03-RightScale_API - API 1.0 Reference Docs: http://reference.rightscale.com/api1.0 @@ -30,15 +37,15 @@ Ruby 1.8.7 or higher is required. ## Versioning -We follow semantic versioning according to http://semver.org +This gem follows semantic versioning: http://semver.org ## Usage Instructions -You must setup ~/.rest_connection/rest_api_config.yaml or /etc/rest_connection/rest_api_config.yaml +You must setup '~/.rest_connection/rest_api_config.yaml' or '/etc/rest_connection/rest_api_config.yaml' -Copy the example from GEMHOME/rest_connection/config/rest_api_config.yaml.sample and fill in your connection info. +Copy the example from '$GEMHOME/rest_connection/config/rest_api_config.yaml.sample' and fill in your connection info. -Pro Tip: to find a GEMHOME, use gemedit +Pro Tip: to find a $GEMHOME, use gemedit "gem install gemedit" "gem edit rest_connection" @@ -48,7 +55,7 @@ The following examples assume an interactive ruby session (irb): $ bundle exec irb ruby> require 'rubygems'; require 'rest_connection' -### Lookup and run a RightScript +### Look up and run a RightScript first_fe = Server.find(:first) { |s| s.nickname =~ /Front End/ } st = ServerTemplate.find(first_fe.server_template_href) @@ -80,7 +87,8 @@ Ruby 1.8.7 or higher is required. ## Publishing To cut a new gem and push to RubyGems: -Edit lib/rest_connection/version.rb + +Edit lib/rest_connection/version.rb with semantic version number. "bundle exec gem build rest_connection.gemspec" "ls *.gem" <- verify that gem was built diff --git a/lib/rest_connection/rightscale/instance.rb b/lib/rest_connection/rightscale/instance.rb index 06f1460..fd32f77 100644 --- a/lib/rest_connection/rightscale/instance.rb +++ b/lib/rest_connection/rightscale/instance.rb @@ -25,9 +25,7 @@ # API 1.0 # -# This is an instance facing api and can only be used with -# an authentication URL normally found in the instance's userdata called -# RS_API_URL +# Requires instance token for authentication class Instance include RightScale::Api::Base extend RightScale::Api::BaseExtend From d1e8c303a2ca17e8e092084b516dc06b86a3004c Mon Sep 17 00:00:00 2001 From: Magne Land Date: Sat, 6 Apr 2013 11:49:31 -0700 Subject: [PATCH 235/239] acu87542 add even more comments to README.md --- README.md | 43 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 9a9ef42..4aecd4b 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,15 @@ # RightScale REST Connection -The rest_connection gem is a Ruby library for RightScale's API 1.0 and API 1.5 on legacy and generic clusters. -Additionally, it has support for RightScale's internal API 0.1 on legacy clusters. +The rest_connection gem is a Ruby library for RightScale's API 0.1, 1.0 and 1.5. + +Legacy clusters: +- API 0.1 AWS clouds +- API 1.0 AWS clouds +- API 1.5 non-AWS clouds + +Generic clusters: +- API 1.0 AWS clouds +- API 1.5 all clouds This gem also supports RightScale's instance facing API 1.0, which use the instance token to login. The instance token is found in the instance's user data as 'RS_rn_auth' or alternatively as part of 'RS_api_url'. @@ -78,6 +86,37 @@ The following examples assume an interactive ruby session (irb): puts my_array.instances.map { |i| i['ip-address'] } +## Design Decisions + +Currently, all API resources are represented by classes in 'lib/rest_connection/rightscale'. +Various helper modules are also located in this directory. + +### API 0.1 resources + +API 0.1 resources are often named with suffix '_internal'. + +They often pull in common internal code: + + include RightScale::Api::Internal + extend RightScale::Api::InternalExtend + +### API 1.0 resources + +API 1.0 resources are often named with prefix 'ec2_' for Amazon Elastic Compute Cloud. + +They often pull in common internal code: + + include RightScale::Api::Base + extend RightScale::Api::BaseExtend + +### API 1.5 resources + +API 1.5 resources are often named with prefix 'mc_' for MultiCloud. +They often talk to the MultiCloud gateway and therefore pull in some common gateway code: + + include RightScale::Api::Gateway + extend RightScale::Api::GatewayExtend + ## Troubleshooting ### Wrong ruby version From cdf32b2009061af025709f1924bdee0fe2aed8a1 Mon Sep 17 00:00:00 2001 From: Magne Land Date: Sat, 6 Apr 2013 12:37:03 -0700 Subject: [PATCH 236/239] acu87542 add some code comments in utility classes --- lib/rest_connection.rb | 6 ++++ .../rightscale/rightscale_api_base.rb | 34 ++++++++++++++----- .../rightscale/rightscale_api_gateway.rb | 12 +++++++ .../rightscale/rightscale_api_internal.rb | 8 +++++ 4 files changed, 52 insertions(+), 8 deletions(-) diff --git a/lib/rest_connection.rb b/lib/rest_connection.rb index 4d2d653..8dbf58c 100644 --- a/lib/rest_connection.rb +++ b/lib/rest_connection.rb @@ -32,6 +32,10 @@ require 'highline/import' require 'nokogiri' +# +# REST connection config and error definitions. +# + module RestConnection class Connection # Settings is a hash of options for customizing the connection. @@ -250,6 +254,8 @@ def handle_response(res) end end + # Logs a message at info level to stdout or log file + # FIXME: don't lazy initialize def logger(message) init_message = "Initializing Logging using " if @@logger.nil? diff --git a/lib/rest_connection/rightscale/rightscale_api_base.rb b/lib/rest_connection/rightscale/rightscale_api_base.rb index d8a0517..1eece05 100644 --- a/lib/rest_connection/rightscale/rightscale_api_base.rb +++ b/lib/rest_connection/rightscale/rightscale_api_base.rb @@ -23,9 +23,15 @@ require 'active_support/inflector' + module RightScale module Api + + # TODO: move this to McAuditEntry DATETIME_FMT = "%Y/%m/%d %H:%M:%S +0000" + + # Every supported AWS cloud must be hardcoded here. + # FIXME: Once this list exceeds 10 entries, must also update cloud_id logic elsewhere! AWS_CLOUDS = [ {"cloud_id" => 1, "name" => "AWS US-East"}, {"cloud_id" => 2, "name" => "AWS EU"}, @@ -38,6 +44,7 @@ module Api ] BASE_COOKIE_REFRESH = proc do + # Refresh cookie by logging in again def refresh_cookie # login @cookie = nil @@ -51,7 +58,7 @@ def refresh_cookie end # Pass no arguments to reset to the default configuration, - # pass a hash to update the settings for all API Versions + # pass a hash to update the settings for all API versions def self.update_connection_settings(*settings) if settings.size > 1 raise ArgumentError.new("wrong number of arguments (#{settings.size} for 1)") @@ -68,7 +75,12 @@ def self.update_connection_settings(*settings) true end - # Check for API 0.1 Access + # Active API version probing + # TODO: probe passively instead + # TODO: move this logic to a separate file + + # Checks for API 0.1 access + # Requires an account with internal API access on a legacy cluster def self.api0_1? if class_variable_defined?("@@api0_1") return @@api0_1 unless @@api0_1.nil? @@ -81,7 +93,8 @@ def self.api0_1? @@api0_1 = false end - # Check for API 1.0 Access + # Checks for API 1.0 access + # Should always succeed def self.api1_0? if class_variable_defined?("@@api1_0") return @@api1_0 unless @@api1_0.nil? @@ -92,7 +105,8 @@ def self.api1_0? @@api1_0 = false end - # Check for API 1.5 Access + # Check for API 1.5 access + # Should always succeed def self.api1_5? if class_variable_defined?("@@api1_5") return @@api1_5 unless @@api1_5.nil? @@ -104,6 +118,8 @@ def self.api1_5? end module BaseConnection + + # Config for API 1.0 def connection(*opts) @@connection ||= RestConnection::Connection.new(*opts) settings = @@connection.settings @@ -130,6 +146,7 @@ def resource_plural_name def resource_singular_name self.to_s.underscore end + # matches using result of block match expression # ex: Server.find_by(:nickname) { |n| n =~ /production/ } def find_by(attrib, &block) @@ -163,10 +180,11 @@ def find_by_nickname(nickname) self.find_by(:nickname) { |n| n == nickname } end - # the argument can be - # 1) takes href (URI), - # 2) or id (Integer) - # 3) or symbol :all, :first, :last + # Retrieves one or more resources of the same type. + # + # @param [Integer|Symbol|String] href should be one of the following: resource id, :all, :first, :last, resource href + # @param [Hash] additional_params if href is an integer, will be part of retrieve request + # @param [Block] block if href is a symbol, will be used inside select block to refine results def find(href, additional_params={}, &block) if href.is_a?(Integer) return self.new(connection.get(self.resource_plural_name + "/#{href}", additional_params)) diff --git a/lib/rest_connection/rightscale/rightscale_api_gateway.rb b/lib/rest_connection/rightscale/rightscale_api_gateway.rb index 0d0d574..44e94c7 100644 --- a/lib/rest_connection/rightscale/rightscale_api_gateway.rb +++ b/lib/rest_connection/rightscale/rightscale_api_gateway.rb @@ -21,8 +21,16 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #++ +# +# API 1.5 +# + module RightScale module Api + + # + # Refresh cookie by logging in again + # GATEWAY_COOKIE_REFRESH = proc do def refresh_cookie # login @@ -48,6 +56,10 @@ def refresh_cookie end module GatewayConnection + + # + # Config for API 1.5 + # def connection(*opts) @@gateway_connection ||= RestConnection::Connection.new(*opts) settings = @@gateway_connection.settings diff --git a/lib/rest_connection/rightscale/rightscale_api_internal.rb b/lib/rest_connection/rightscale/rightscale_api_internal.rb index ef725cc..6ff8e6a 100644 --- a/lib/rest_connection/rightscale/rightscale_api_internal.rb +++ b/lib/rest_connection/rightscale/rightscale_api_internal.rb @@ -21,9 +21,17 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #++ +# +# API 0.1 +# module RightScale module Api module InternalConnection + + # + # Config for API 0.1 + # Only works for legacy clusters + # def connection(*opts) @@little_brother_connection ||= RestConnection::Connection.new(*opts) settings = @@little_brother_connection.settings From 418db195486790a4875d9e13caa2d46c034e9df6 Mon Sep 17 00:00:00 2001 From: Magne Land Date: Mon, 8 Apr 2013 16:24:10 -0700 Subject: [PATCH 237/239] acu87542 fix typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4aecd4b..86e4a99 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Legacy clusters: - API 1.0 AWS clouds - API 1.5 non-AWS clouds -Generic clusters: +Unified clusters: - API 1.0 AWS clouds - API 1.5 all clouds From 4aa73ea033d1c49ea4fdf48930051df71622a493 Mon Sep 17 00:00:00 2001 From: Magne Land Date: Wed, 10 Apr 2013 17:18:49 -0700 Subject: [PATCH 238/239] acu87542 fix typo --- .../rightscale/right_script_attachment_internal.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rest_connection/rightscale/right_script_attachment_internal.rb b/lib/rest_connection/rightscale/right_script_attachment_internal.rb index 6f020e3..0915d29 100644 --- a/lib/rest_connection/rightscale/right_script_attachment_internal.rb +++ b/lib/rest_connection/rightscale/right_script_attachment_internal.rb @@ -25,7 +25,7 @@ RestClient.log = ENV["REST_CONNECTION_LOG"] || "stdout" # -# API 1.0 +# API 0.1 # class RightScriptAttachmentInternal include RightScale::Api::Base From 12fde4e7baa6d17399c0d49be004b4b773becb6f Mon Sep 17 00:00:00 2001 From: Magne Land Date: Fri, 19 Apr 2013 17:06:43 -0700 Subject: [PATCH 239/239] acu89679 bump up version to 1.0.5 to prepare for gem publish --- lib/rest_connection/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rest_connection/version.rb b/lib/rest_connection/version.rb index 689b9cb..2ec5afb 100644 --- a/lib/rest_connection/version.rb +++ b/lib/rest_connection/version.rb @@ -1,4 +1,4 @@ # This gem is versioned with the usual X.Y.Z notation module RestConnection - VERSION = '1.0.5' + VERSION = '1.0.6' end