rest_connection 0.0.5 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/lib/rest_connection.rb +1 -1
- data/lib/rest_connection/rightscale/audit_entry.rb +3 -1
- data/lib/rest_connection/rightscale/ec2_ssh_key_internal.rb +39 -0
- data/lib/rest_connection/rightscale/multi_cloud_image_cloud_setting_internal.rb +44 -0
- data/lib/rest_connection/rightscale/multi_cloud_image_internal.rb +38 -0
- data/lib/rest_connection/rightscale/rightscale_api_base.rb +7 -4
- data/lib/rest_connection/rightscale/rightscale_api_internal.rb +20 -0
- data/lib/rest_connection/rightscale/rightscale_api_resources.rb +8 -1
- data/lib/rest_connection/rightscale/server.rb +14 -2
- data/lib/rest_connection/rightscale/server_internal.rb +53 -0
- data/lib/rest_connection/rightscale/server_template_internal.rb +58 -0
- data/rest_connection.gemspec +24 -10
- data/spec/ec2_ssh_key_internal_spec.rb +20 -0
- data/spec/image_jockey.rb +33 -0
- data/spec/method_missing_spec.rb +18 -0
- data/spec/server_internal_spec.rb +19 -0
- metadata +35 -10
    
        data/VERSION
    CHANGED
    
    | @@ -1 +1 @@ | |
| 1 | 
            -
            0.0. | 
| 1 | 
            +
            0.0.6
         | 
    
        data/lib/rest_connection.rb
    CHANGED
    
    | @@ -18,7 +18,6 @@ require 'rubygems' | |
| 18 18 | 
             
            require 'json'
         | 
| 19 19 | 
             
            require 'yaml'
         | 
| 20 20 | 
             
            require 'cgi'
         | 
| 21 | 
            -
            require 'rest_connection/rightscale/rightscale_api_base'
         | 
| 22 21 | 
             
            require 'rest_connection/rightscale/rightscale_api_resources'
         | 
| 23 22 | 
             
            require 'logger'
         | 
| 24 23 |  | 
| @@ -152,6 +151,7 @@ module RestConnection | |
| 152 151 | 
             
                      begin
         | 
| 153 152 | 
             
                        return JSON.load(res.body)
         | 
| 154 153 | 
             
                      rescue => e
         | 
| 154 | 
            +
                        logger("WARNING: failed to parse HTTP response body with JSON.load!")
         | 
| 155 155 | 
             
                        return res
         | 
| 156 156 | 
             
                      end
         | 
| 157 157 | 
             
                    else
         | 
| @@ -32,7 +32,9 @@ class AuditEntry | |
| 32 32 | 
             
                while(1)
         | 
| 33 33 | 
             
                  reload
         | 
| 34 34 | 
             
                  connection.logger("state is #{self.state}, waiting for #{state}")
         | 
| 35 | 
            -
                   | 
| 35 | 
            +
                  friendly_url = "https://my.rightscale.com/audit_entries/"
         | 
| 36 | 
            +
                  friendly_url += self.href.split(/\//).last
         | 
| 37 | 
            +
                  raise "FATAL error, #{self.summary}\nSee Audit: API:#{self.href}, WWW:<a href='#{friendly_url}'>#{friendly_url}</a>\n" if self.state == 'failed'
         | 
| 36 38 | 
             
                  sleep 5
         | 
| 37 39 | 
             
                  return true if state == self.state
         | 
| 38 40 | 
             
                end
         | 
| @@ -0,0 +1,39 @@ | |
| 1 | 
            +
            #    This file is part of RestConnection 
         | 
| 2 | 
            +
            #
         | 
| 3 | 
            +
            #    RestConnection is free software: you can redistribute it and/or modify
         | 
| 4 | 
            +
            #    it under the terms of the GNU General Public License as published by
         | 
| 5 | 
            +
            #    the Free Software Foundation, either version 3 of the License, or
         | 
| 6 | 
            +
            #    (at your option) any later version.
         | 
| 7 | 
            +
            #
         | 
| 8 | 
            +
            #    RestConnection is distributed in the hope that it will be useful,
         | 
| 9 | 
            +
            #    but WITHOUT ANY WARRANTY; without even the implied warranty of
         | 
| 10 | 
            +
            #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
         | 
| 11 | 
            +
            #    GNU General Public License for more details.
         | 
| 12 | 
            +
            #
         | 
| 13 | 
            +
            #    You should have received a copy of the GNU General Public License
         | 
| 14 | 
            +
            #    along with RestConnection.  If not, see <http://www.gnu.org/licenses/>.
         | 
| 15 | 
            +
             | 
| 16 | 
            +
            class Ec2SshKeyInternal 
         | 
| 17 | 
            +
              include RightScale::Api::Base
         | 
| 18 | 
            +
              extend RightScale::Api::BaseExtend
         | 
| 19 | 
            +
             | 
| 20 | 
            +
              include RightScale::Api::Internal
         | 
| 21 | 
            +
              extend RightScale::Api::InternalExtend
         | 
| 22 | 
            +
             | 
| 23 | 
            +
              def resource_plural_name
         | 
| 24 | 
            +
                "ec2_ssh_keys"
         | 
| 25 | 
            +
              end
         | 
| 26 | 
            +
             | 
| 27 | 
            +
              def resource_singular_name
         | 
| 28 | 
            +
                "ec2_ssh_key"
         | 
| 29 | 
            +
              end
         | 
| 30 | 
            +
             | 
| 31 | 
            +
              def self.resource_plural_name
         | 
| 32 | 
            +
                "ec2_ssh_keys"
         | 
| 33 | 
            +
              end
         | 
| 34 | 
            +
             | 
| 35 | 
            +
              def self.resource_singular_name
         | 
| 36 | 
            +
                "ec2_ssh_key"
         | 
| 37 | 
            +
              end
         | 
| 38 | 
            +
             | 
| 39 | 
            +
            end
         | 
| @@ -0,0 +1,44 @@ | |
| 1 | 
            +
            #    This file is part of RestConnection 
         | 
| 2 | 
            +
            #
         | 
| 3 | 
            +
            #    RestConnection is free software: you can redistribute it and/or modify
         | 
| 4 | 
            +
            #    it under the terms of the GNU General Public License as published by
         | 
| 5 | 
            +
            #    the Free Software Foundation, either version 3 of the License, or
         | 
| 6 | 
            +
            #    (at your option) any later version.
         | 
| 7 | 
            +
            #
         | 
| 8 | 
            +
            #    RestConnection is distributed in the hope that it will be useful,
         | 
| 9 | 
            +
            #    but WITHOUT ANY WARRANTY; without even the implied warranty of
         | 
| 10 | 
            +
            #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
         | 
| 11 | 
            +
            #    GNU General Public License for more details.
         | 
| 12 | 
            +
            #
         | 
| 13 | 
            +
            #    You should have received a copy of the GNU General Public License
         | 
| 14 | 
            +
            #    along with RestConnection.  If not, see <http://www.gnu.org/licenses/>.
         | 
| 15 | 
            +
             | 
| 16 | 
            +
            class MultiCloudImageCloudSettingInternal
         | 
| 17 | 
            +
              include RightScale::Api::Base
         | 
| 18 | 
            +
              extend RightScale::Api::BaseExtend
         | 
| 19 | 
            +
              include RightScale::Api::Internal
         | 
| 20 | 
            +
              extend RightScale::Api::InternalExtend
         | 
| 21 | 
            +
             | 
| 22 | 
            +
              def resource_plural_name
         | 
| 23 | 
            +
                "multi_cloud_image_cloud_settings"
         | 
| 24 | 
            +
              end
         | 
| 25 | 
            +
             | 
| 26 | 
            +
              def resource_singular_name
         | 
| 27 | 
            +
                "multi_cloud_image_cloud_setting"
         | 
| 28 | 
            +
              end
         | 
| 29 | 
            +
             | 
| 30 | 
            +
              def self.resource_plural_name
         | 
| 31 | 
            +
                "multi_cloud_image_cloud_settings"
         | 
| 32 | 
            +
              end
         | 
| 33 | 
            +
             | 
| 34 | 
            +
              def self.resource_singular_name
         | 
| 35 | 
            +
                "multi_cloud_image_cloud_setting"
         | 
| 36 | 
            +
              end
         | 
| 37 | 
            +
             | 
| 38 | 
            +
              # override create method, with no reload
         | 
| 39 | 
            +
              def self.create(opts)
         | 
| 40 | 
            +
                location = connection.post(self.resource_plural_name, self.resource_singular_name.to_sym => opts)
         | 
| 41 | 
            +
                newrecord = self.new('href' => location)
         | 
| 42 | 
            +
              end
         | 
| 43 | 
            +
             
         | 
| 44 | 
            +
            end
         | 
| @@ -0,0 +1,38 @@ | |
| 1 | 
            +
            #    This file is part of RestConnection 
         | 
| 2 | 
            +
            #
         | 
| 3 | 
            +
            #    RestConnection is free software: you can redistribute it and/or modify
         | 
| 4 | 
            +
            #    it under the terms of the GNU General Public License as published by
         | 
| 5 | 
            +
            #    the Free Software Foundation, either version 3 of the License, or
         | 
| 6 | 
            +
            #    (at your option) any later version.
         | 
| 7 | 
            +
            #
         | 
| 8 | 
            +
            #    RestConnection is distributed in the hope that it will be useful,
         | 
| 9 | 
            +
            #    but WITHOUT ANY WARRANTY; without even the implied warranty of
         | 
| 10 | 
            +
            #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
         | 
| 11 | 
            +
            #    GNU General Public License for more details.
         | 
| 12 | 
            +
            #
         | 
| 13 | 
            +
            #    You should have received a copy of the GNU General Public License
         | 
| 14 | 
            +
            #    along with RestConnection.  If not, see <http://www.gnu.org/licenses/>.
         | 
| 15 | 
            +
             | 
| 16 | 
            +
            class MultiCloudImageInternal
         | 
| 17 | 
            +
              include RightScale::Api::Base
         | 
| 18 | 
            +
              extend RightScale::Api::BaseExtend
         | 
| 19 | 
            +
              include RightScale::Api::Internal
         | 
| 20 | 
            +
              extend RightScale::Api::InternalExtend
         | 
| 21 | 
            +
             | 
| 22 | 
            +
              def resource_plural_name
         | 
| 23 | 
            +
                "multi_cloud_images"
         | 
| 24 | 
            +
              end
         | 
| 25 | 
            +
             | 
| 26 | 
            +
              def resource_singular_name
         | 
| 27 | 
            +
                "multi_cloud_image"
         | 
| 28 | 
            +
              end
         | 
| 29 | 
            +
             | 
| 30 | 
            +
              def self.resource_plural_name
         | 
| 31 | 
            +
                "multi_cloud_images"
         | 
| 32 | 
            +
              end
         | 
| 33 | 
            +
             | 
| 34 | 
            +
              def self.resource_singular_name
         | 
| 35 | 
            +
                "multi_cloud_image"
         | 
| 36 | 
            +
              end
         | 
| 37 | 
            +
             | 
| 38 | 
            +
            end
         | 
| @@ -13,7 +13,7 @@ | |
| 13 13 | 
             
            #    You should have received a copy of the GNU General Public License
         | 
| 14 14 | 
             
            #    along with RestConnection.  If not, see <http://www.gnu.org/licenses/>.
         | 
| 15 15 |  | 
| 16 | 
            -
            require 'active_support'
         | 
| 16 | 
            +
            require 'active_support/inflector'
         | 
| 17 17 |  | 
| 18 18 | 
             
            module RightScale
         | 
| 19 19 | 
             
              module Api
         | 
| @@ -26,7 +26,7 @@ module RightScale | |
| 26 26 | 
             
                    self.to_s.underscore.pluralize
         | 
| 27 27 | 
             
                  end 
         | 
| 28 28 |  | 
| 29 | 
            -
                  def  | 
| 29 | 
            +
                  def resource_singular_name
         | 
| 30 30 | 
             
                    self.to_s.underscore
         | 
| 31 31 | 
             
                  end
         | 
| 32 32 | 
             
                  # matches using result of block match expression
         | 
| @@ -81,7 +81,7 @@ module RightScale | |
| 81 81 | 
             
                  end
         | 
| 82 82 |  | 
| 83 83 | 
             
                  def create(opts)
         | 
| 84 | 
            -
                    location = connection.post(self.resource_plural_name, self. | 
| 84 | 
            +
                    location = connection.post(self.resource_plural_name, self.resource_singular_name.to_sym => opts)
         | 
| 85 85 | 
             
                    newrecord = self.new('href' => location)
         | 
| 86 86 | 
             
                    newrecord.reload
         | 
| 87 87 | 
             
                    newrecord
         | 
| @@ -151,6 +151,9 @@ module RightScale | |
| 151 151 | 
             
                      return @params[mn_dash] 
         | 
| 152 152 | 
             
                    elsif @params[mn.to_sym]
         | 
| 153 153 | 
             
                      return @params[mn.to_sym]
         | 
| 154 | 
            +
                    elsif assignment
         | 
| 155 | 
            +
                      @params[mn] = args[0]
         | 
| 156 | 
            +
                      return @params[mn] 
         | 
| 154 157 | 
             
                    else  
         | 
| 155 158 | 
             
                      return nil
         | 
| 156 159 | 
             
                      #raise "called unknown method #{method_name} with #{args.inspect}"
         | 
| @@ -158,7 +161,7 @@ module RightScale | |
| 158 161 | 
             
                  end
         | 
| 159 162 |  | 
| 160 163 | 
             
                  def [](name)
         | 
| 161 | 
            -
                    try_these = [name, name.gsub(/_/,'-'), name.to_sym]
         | 
| 164 | 
            +
                    try_these = [name, name.to_s.gsub(/_/,'-'), name.to_sym]
         | 
| 162 165 | 
             
                    try_these.each do |t|
         | 
| 163 166 | 
             
                      if @params[t]
         | 
| 164 167 | 
             
                        return @params[name]
         | 
| @@ -0,0 +1,20 @@ | |
| 1 | 
            +
            module RightScale
         | 
| 2 | 
            +
              module Api
         | 
| 3 | 
            +
                module Internal
         | 
| 4 | 
            +
                  def connection
         | 
| 5 | 
            +
                    @@little_brother_connection ||= RestConnection::Connection.new
         | 
| 6 | 
            +
                    @@little_brother_connection.settings[:common_headers] = { 'X-API-VERSION' => '0.1' }
         | 
| 7 | 
            +
                    @@little_brother_connection
         | 
| 8 | 
            +
                  end
         | 
| 9 | 
            +
                end
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                module InternalExtend
         | 
| 12 | 
            +
                  def connection
         | 
| 13 | 
            +
                    @@little_brother_connection ||= RestConnection::Connection.new
         | 
| 14 | 
            +
                    @@little_brother_connection.settings[:common_headers] = { 'X-API-VERSION' => '0.1' }
         | 
| 15 | 
            +
                    @@little_brother_connection
         | 
| 16 | 
            +
                  end
         | 
| 17 | 
            +
                end
         | 
| 18 | 
            +
              end
         | 
| 19 | 
            +
            end
         | 
| 20 | 
            +
             
         | 
| @@ -13,6 +13,9 @@ | |
| 13 13 | 
             
            #    You should have received a copy of the GNU General Public License
         | 
| 14 14 | 
             
            #    along with RestConnection.  If not, see <http://www.gnu.org/licenses/>.
         | 
| 15 15 |  | 
| 16 | 
            +
             | 
| 17 | 
            +
            require 'rest_connection/rightscale/rightscale_api_base'
         | 
| 18 | 
            +
            require 'rest_connection/rightscale/rightscale_api_internal'
         | 
| 16 19 | 
             
            require 'rest_connection/rightscale/executable'
         | 
| 17 20 | 
             
            require 'rest_connection/rightscale/server'
         | 
| 18 21 | 
             
            require 'rest_connection/rightscale/deployment'
         | 
| @@ -28,4 +31,8 @@ require 'rest_connection/rightscale/rs_internal' | |
| 28 31 | 
             
            require 'rest_connection/rightscale/audit_entry'
         | 
| 29 32 | 
             
            require 'rest_connection/rightscale/ec2_ebs_volume'
         | 
| 30 33 | 
             
            require 'rest_connection/rightscale/ec2_ebs_snapshot'
         | 
| 31 | 
            -
             | 
| 34 | 
            +
            require 'rest_connection/rightscale/server_internal'
         | 
| 35 | 
            +
            require 'rest_connection/rightscale/ec2_ssh_key_internal'
         | 
| 36 | 
            +
            require 'rest_connection/rightscale/server_template_internal'
         | 
| 37 | 
            +
            require 'rest_connection/rightscale/multi_cloud_image_internal'
         | 
| 38 | 
            +
            require 'rest_connection/rightscale/multi_cloud_image_cloud_setting_internal'
         | 
| @@ -22,7 +22,7 @@ class Server | |
| 22 22 |  | 
| 23 23 | 
             
              def self.create(opts)
         | 
| 24 24 | 
             
                create_options = Hash.new
         | 
| 25 | 
            -
                create_options[self. | 
| 25 | 
            +
                create_options[self.resource_singular_name.to_sym] = opts
         | 
| 26 26 | 
             
                create_options["cloud_id"] = opts[:cloud_id] if opts[:cloud_id]
         | 
| 27 27 | 
             
                location = connection.post(self.resource_plural_name,create_options)    
         | 
| 28 28 | 
             
                newrecord = self.new('href' => location)
         | 
| @@ -56,7 +56,8 @@ class Server | |
| 56 56 | 
             
              def audit_link
         | 
| 57 57 | 
             
                # proof of concept for now
         | 
| 58 58 | 
             
                server_id = self.href.split(/\//).last
         | 
| 59 | 
            -
                "https://my.rightscale.com/servers/#{server_id}#audit_entries"
         | 
| 59 | 
            +
                audit_href = "https://my.rightscale.com/servers/#{server_id}#audit_entries"
         | 
| 60 | 
            +
                "<a href='#{audit_href}'>#{audit_href}</a>"
         | 
| 60 61 | 
             
              end
         | 
| 61 62 |  | 
| 62 63 | 
             
              def start
         | 
| @@ -77,6 +78,17 @@ class Server | |
| 77 78 | 
             
                end
         | 
| 78 79 | 
             
              end
         | 
| 79 80 |  | 
| 81 | 
            +
            # Uses ServerInternal api to start and stop EBS based instances
         | 
| 82 | 
            +
              def start_ebs
         | 
| 83 | 
            +
                @server_internal = ServerInternal.new(:href => self.href)
         | 
| 84 | 
            +
                @server_internal.start
         | 
| 85 | 
            +
              end
         | 
| 86 | 
            +
             | 
| 87 | 
            +
              def stop_ebs
         | 
| 88 | 
            +
                @server_internal = ServerInternal.new(:href => self.href)
         | 
| 89 | 
            +
                @server_internal.stop
         | 
| 90 | 
            +
              end
         | 
| 91 | 
            +
             | 
| 80 92 | 
             
              # This should be used with v5 images only.
         | 
| 81 93 | 
             
              # executable to run can be an Executable or RightScript object
         | 
| 82 94 | 
             
              def run_executable(executable, opts=nil)
         | 
| @@ -0,0 +1,53 @@ | |
| 1 | 
            +
            #    This file is part of RestConnection 
         | 
| 2 | 
            +
            #
         | 
| 3 | 
            +
            #    RestConnection is free software: you can redistribute it and/or modify
         | 
| 4 | 
            +
            #    it under the terms of the GNU General Public License as published by
         | 
| 5 | 
            +
            #    the Free Software Foundation, either version 3 of the License, or
         | 
| 6 | 
            +
            #    (at your option) any later version.
         | 
| 7 | 
            +
            #
         | 
| 8 | 
            +
            #    RestConnection is distributed in the hope that it will be useful,
         | 
| 9 | 
            +
            #    but WITHOUT ANY WARRANTY; without even the implied warranty of
         | 
| 10 | 
            +
            #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
         | 
| 11 | 
            +
            #    GNU General Public License for more details.
         | 
| 12 | 
            +
            #
         | 
| 13 | 
            +
            #    You should have received a copy of the GNU General Public License
         | 
| 14 | 
            +
            #    along with RestConnection.  If not, see <http://www.gnu.org/licenses/>.
         | 
| 15 | 
            +
             | 
| 16 | 
            +
            #    
         | 
| 17 | 
            +
            # You must have special API access to use these internal API calls.
         | 
| 18 | 
            +
            # 
         | 
| 19 | 
            +
            class ServerInternal
         | 
| 20 | 
            +
              include RightScale::Api::Base
         | 
| 21 | 
            +
              extend RightScale::Api::BaseExtend
         | 
| 22 | 
            +
              include SshHax
         | 
| 23 | 
            +
             | 
| 24 | 
            +
              include RightScale::Api::Internal
         | 
| 25 | 
            +
              extend RightScale::Api::InternalExtend
         | 
| 26 | 
            +
             | 
| 27 | 
            +
              def resource_plural_name
         | 
| 28 | 
            +
                "servers"
         | 
| 29 | 
            +
              end
         | 
| 30 | 
            +
             | 
| 31 | 
            +
              def resource_singular_name
         | 
| 32 | 
            +
                "server"
         | 
| 33 | 
            +
              end
         | 
| 34 | 
            +
             | 
| 35 | 
            +
              def self.resource_plural_name
         | 
| 36 | 
            +
                "servers"
         | 
| 37 | 
            +
              end
         | 
| 38 | 
            +
             | 
| 39 | 
            +
              def self.resource_singular_name
         | 
| 40 | 
            +
                "server"
         | 
| 41 | 
            +
              end
         | 
| 42 | 
            +
             | 
| 43 | 
            +
              def start
         | 
| 44 | 
            +
                t = URI.parse(self.href)
         | 
| 45 | 
            +
                return connection.post(t.path + '/start')
         | 
| 46 | 
            +
              end
         | 
| 47 | 
            +
             | 
| 48 | 
            +
              def stop
         | 
| 49 | 
            +
                t = URI.parse(self.href)
         | 
| 50 | 
            +
                connection.post(t.path + '/stop')
         | 
| 51 | 
            +
              end
         | 
| 52 | 
            +
             | 
| 53 | 
            +
            end
         | 
| @@ -0,0 +1,58 @@ | |
| 1 | 
            +
            #    This file is part of RestConnection 
         | 
| 2 | 
            +
            #
         | 
| 3 | 
            +
            #    RestConnection is free software: you can redistribute it and/or modify
         | 
| 4 | 
            +
            #    it under the terms of the GNU General Public License as published by
         | 
| 5 | 
            +
            #    the Free Software Foundation, either version 3 of the License, or
         | 
| 6 | 
            +
            #    (at your option) any later version.
         | 
| 7 | 
            +
            #
         | 
| 8 | 
            +
            #    RestConnection is distributed in the hope that it will be useful,
         | 
| 9 | 
            +
            #    but WITHOUT ANY WARRANTY; without even the implied warranty of
         | 
| 10 | 
            +
            #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
         | 
| 11 | 
            +
            #    GNU General Public License for more details.
         | 
| 12 | 
            +
            #
         | 
| 13 | 
            +
            #    You should have received a copy of the GNU General Public License
         | 
| 14 | 
            +
            #    along with RestConnection.  If not, see <http://www.gnu.org/licenses/>.
         | 
| 15 | 
            +
             | 
| 16 | 
            +
            class ServerTemplateInternal 
         | 
| 17 | 
            +
              include RightScale::Api::Base
         | 
| 18 | 
            +
              extend RightScale::Api::BaseExtend
         | 
| 19 | 
            +
              include RightScale::Api::Internal
         | 
| 20 | 
            +
              extend RightScale::Api::InternalExtend
         | 
| 21 | 
            +
             | 
| 22 | 
            +
              def resource_plural_name
         | 
| 23 | 
            +
                "server_templates"
         | 
| 24 | 
            +
              end
         | 
| 25 | 
            +
             | 
| 26 | 
            +
              def resource_singular_name
         | 
| 27 | 
            +
                "server_template"
         | 
| 28 | 
            +
              end
         | 
| 29 | 
            +
             | 
| 30 | 
            +
              def self.resource_plural_name
         | 
| 31 | 
            +
                "server_templates"
         | 
| 32 | 
            +
              end
         | 
| 33 | 
            +
             | 
| 34 | 
            +
              def self.resource_singular_name
         | 
| 35 | 
            +
                "server_template"
         | 
| 36 | 
            +
              end
         | 
| 37 | 
            +
             | 
| 38 | 
            +
              def add_multi_cloud_image(mci_href)
         | 
| 39 | 
            +
                t = URI.parse(self.href)
         | 
| 40 | 
            +
                connection.put(t.path + "/add_multi_cloud_image", :multi_cloud_image_href => mci_href)
         | 
| 41 | 
            +
              end
         | 
| 42 | 
            +
              
         | 
| 43 | 
            +
              def delete_multi_cloud_image(mci_href)
         | 
| 44 | 
            +
                t = URI.parse(self.href)
         | 
| 45 | 
            +
                connection.put(t.path + "/delete_multi_cloud_image", :multi_cloud_image_href => mci_href)
         | 
| 46 | 
            +
              end
         | 
| 47 | 
            +
             | 
| 48 | 
            +
              def set_default_multi_cloud_image(mci_href)
         | 
| 49 | 
            +
                t = URI.parse(self.href)
         | 
| 50 | 
            +
                connection.put(t.path + "/set_default_multi_cloud_image", :multi_cloud_image_href => mci_href)
         | 
| 51 | 
            +
              end
         | 
| 52 | 
            +
             | 
| 53 | 
            +
              def multi_cloud_images
         | 
| 54 | 
            +
                t = URI.parse(self.href)
         | 
| 55 | 
            +
                connection.get(t.path + "/multi_cloud_images")
         | 
| 56 | 
            +
              end
         | 
| 57 | 
            +
             | 
| 58 | 
            +
            end
         | 
    
        data/rest_connection.gemspec
    CHANGED
    
    | @@ -5,11 +5,11 @@ | |
| 5 5 |  | 
| 6 6 | 
             
            Gem::Specification.new do |s|
         | 
| 7 7 | 
             
              s.name = %q{rest_connection}
         | 
| 8 | 
            -
              s.version = "0.0. | 
| 8 | 
            +
              s.version = "0.0.6"
         | 
| 9 9 |  | 
| 10 10 | 
             
              s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
         | 
| 11 11 | 
             
              s.authors = ["Jeremy Deininger"]
         | 
| 12 | 
            -
              s.date = %q{2010- | 
| 12 | 
            +
              s.date = %q{2010-05-19}
         | 
| 13 13 | 
             
              s.description = %q{provides rest_connection}
         | 
| 14 14 | 
             
              s.email = %q{jeremy@rubyonlinux.org}
         | 
| 15 15 | 
             
              s.extra_rdoc_files = [
         | 
| @@ -39,47 +39,61 @@ Gem::Specification.new do |s| | |
| 39 39 | 
             
                 "lib/rest_connection/rightscale/ec2_security_group.rb",
         | 
| 40 40 | 
             
                 "lib/rest_connection/rightscale/ec2_server_array.rb",
         | 
| 41 41 | 
             
                 "lib/rest_connection/rightscale/ec2_ssh_key.rb",
         | 
| 42 | 
            +
                 "lib/rest_connection/rightscale/ec2_ssh_key_internal.rb",
         | 
| 42 43 | 
             
                 "lib/rest_connection/rightscale/executable.rb",
         | 
| 43 44 | 
             
                 "lib/rest_connection/rightscale/instance.rb",
         | 
| 44 45 | 
             
                 "lib/rest_connection/rightscale/multi_cloud_image.rb",
         | 
| 46 | 
            +
                 "lib/rest_connection/rightscale/multi_cloud_image_cloud_setting_internal.rb",
         | 
| 47 | 
            +
                 "lib/rest_connection/rightscale/multi_cloud_image_internal.rb",
         | 
| 45 48 | 
             
                 "lib/rest_connection/rightscale/right_script.rb",
         | 
| 46 49 | 
             
                 "lib/rest_connection/rightscale/rightscale_api_base.rb",
         | 
| 50 | 
            +
                 "lib/rest_connection/rightscale/rightscale_api_internal.rb",
         | 
| 47 51 | 
             
                 "lib/rest_connection/rightscale/rightscale_api_resources.rb",
         | 
| 48 52 | 
             
                 "lib/rest_connection/rightscale/rs_internal.rb",
         | 
| 49 53 | 
             
                 "lib/rest_connection/rightscale/server.rb",
         | 
| 54 | 
            +
                 "lib/rest_connection/rightscale/server_internal.rb",
         | 
| 50 55 | 
             
                 "lib/rest_connection/rightscale/server_template.rb",
         | 
| 56 | 
            +
                 "lib/rest_connection/rightscale/server_template_internal.rb",
         | 
| 51 57 | 
             
                 "lib/rest_connection/rightscale/status.rb",
         | 
| 52 58 | 
             
                 "lib/rest_connection/rightscale/tag.rb",
         | 
| 53 59 | 
             
                 "lib/rest_connection/ssh_hax.rb",
         | 
| 54 60 | 
             
                 "rest_connection.gemspec",
         | 
| 61 | 
            +
                 "spec/ec2_ssh_key_internal_spec.rb",
         | 
| 62 | 
            +
                 "spec/image_jockey.rb",
         | 
| 63 | 
            +
                 "spec/method_missing_spec.rb",
         | 
| 55 64 | 
             
                 "spec/rs_internal_spec.rb",
         | 
| 65 | 
            +
                 "spec/server_internal_spec.rb",
         | 
| 56 66 | 
             
                 "spec/server_spec.rb"
         | 
| 57 67 | 
             
              ]
         | 
| 58 68 | 
             
              s.homepage = %q{http://github.com/jeremyd/rest_connection}
         | 
| 59 69 | 
             
              s.rdoc_options = ["--charset=UTF-8"]
         | 
| 60 70 | 
             
              s.require_paths = ["lib"]
         | 
| 61 | 
            -
              s.rubygems_version = %q{1.3. | 
| 71 | 
            +
              s.rubygems_version = %q{1.3.7}
         | 
| 62 72 | 
             
              s.summary = %q{lib for restful connections to the rightscale api}
         | 
| 63 73 | 
             
              s.test_files = [
         | 
| 64 | 
            -
                "spec/ | 
| 74 | 
            +
                "spec/ec2_ssh_key_internal_spec.rb",
         | 
| 75 | 
            +
                 "spec/image_jockey.rb",
         | 
| 76 | 
            +
                 "spec/method_missing_spec.rb",
         | 
| 65 77 | 
             
                 "spec/rs_internal_spec.rb",
         | 
| 66 | 
            -
                 " | 
| 78 | 
            +
                 "spec/server_internal_spec.rb",
         | 
| 79 | 
            +
                 "spec/server_spec.rb",
         | 
| 67 80 | 
             
                 "examples/console.rb",
         | 
| 68 | 
            -
                 "examples/run_php_chef_sequence.rb",
         | 
| 69 | 
            -
                 "examples/set_deployment_template_href.rb",
         | 
| 70 81 | 
             
                 "examples/dev_setup.rb",
         | 
| 71 | 
            -
                 "examples/right_scale_ec2_instances_api_test.rb",
         | 
| 72 82 | 
             
                 "examples/relaunch_deployment.rb",
         | 
| 83 | 
            +
                 "examples/restart_instance_agent.rb",
         | 
| 84 | 
            +
                 "examples/right_scale_ec2_instances_api_test.rb",
         | 
| 85 | 
            +
                 "examples/run_ebs_sequence.rb",
         | 
| 73 86 | 
             
                 "examples/run_ebs_terminate.rb",
         | 
| 74 87 | 
             
                 "examples/run_mysql_chef_sequence.rb",
         | 
| 75 | 
            -
                 "examples/ | 
| 88 | 
            +
                 "examples/run_php_chef_sequence.rb",
         | 
| 89 | 
            +
                 "examples/set_deployment_template_href.rb"
         | 
| 76 90 | 
             
              ]
         | 
| 77 91 |  | 
| 78 92 | 
             
              if s.respond_to? :specification_version then
         | 
| 79 93 | 
             
                current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
         | 
| 80 94 | 
             
                s.specification_version = 3
         | 
| 81 95 |  | 
| 82 | 
            -
                if Gem::Version.new(Gem:: | 
| 96 | 
            +
                if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
         | 
| 83 97 | 
             
                  s.add_runtime_dependency(%q<activesupport>, [">= 0"])
         | 
| 84 98 | 
             
                  s.add_runtime_dependency(%q<net-ssh>, [">= 0"])
         | 
| 85 99 | 
             
                  s.add_runtime_dependency(%q<json>, [">= 0"])
         | 
| @@ -0,0 +1,20 @@ | |
| 1 | 
            +
            require 'rubygems'
         | 
| 2 | 
            +
            require 'rest_connection'
         | 
| 3 | 
            +
            require 'spec'
         | 
| 4 | 
            +
            require 'ruby-debug'
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            describe Ec2SshKeyInternal, "ec2_ssh_key internal api object exercise" do
         | 
| 7 | 
            +
              before(:all) do
         | 
| 8 | 
            +
              end
         | 
| 9 | 
            +
             | 
| 10 | 
            +
              it "should find an index of all ssh keys" do
         | 
| 11 | 
            +
                all_keys = Ec2SshKeyInternal.find(:all)
         | 
| 12 | 
            +
                all_keys.empty?.should == false
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                default_key = Ec2SshKeyInternal.find_by(:aws_key_name) {|n| n=~ /default/}
         | 
| 15 | 
            +
                default_key.first.should_not == nil
         | 
| 16 | 
            +
             | 
| 17 | 
            +
                default_key.first.href.should_not == nil
         | 
| 18 | 
            +
              end
         | 
| 19 | 
            +
             | 
| 20 | 
            +
            end
         | 
| @@ -0,0 +1,33 @@ | |
| 1 | 
            +
            require 'rubygems'
         | 
| 2 | 
            +
            require 'rest_connection'
         | 
| 3 | 
            +
            require 'spec'
         | 
| 4 | 
            +
            require 'ruby-debug'
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            describe MultiCloudImageInternal, "exercises the mci internal api" do
         | 
| 7 | 
            +
             | 
| 8 | 
            +
              it "should do some stuff" do
         | 
| 9 | 
            +
                some_image_href = "https://moo1.rightscale.com/api/acct/0/ec2_images/ami-0859bb61?cloud_id=1"
         | 
| 10 | 
            +
                @mci = MultiCloudImageInternal.create(:name => "123deleteme-test test 1234", :description => "woah")
         | 
| 11 | 
            +
                @mci2 = MultiCloudImageInternal.create(:name => "1234deleteme-test test 12345", :description => "woah")
         | 
| 12 | 
            +
                @new_setting = MultiCloudImageCloudSettingInternal.create(:multi_cloud_image_href => @mci.href, :cloud_id => 1, :ec2_image_href => some_image_href, :aws_instance_type => "m1.small")
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                @new_st = ServerTemplate.create(:multi_cloud_image_href => @mci.href, :nickname => "123deleteme-test test 123456", :description => "1234")
         | 
| 15 | 
            +
             | 
| 16 | 
            +
                @really_new_st = ServerTemplateInternal.new(:href => @new_st.href)
         | 
| 17 | 
            +
                @really_new_st.add_multi_cloud_image(@mci2.href)
         | 
| 18 | 
            +
                @really_new_st.set_default_multi_cloud_image(@mci2.href)
         | 
| 19 | 
            +
                trash = @really_new_st.multi_cloud_images
         | 
| 20 | 
            +
                trash.class.should == Array
         | 
| 21 | 
            +
                trash.first.class.should == Hash
         | 
| 22 | 
            +
                @really_new_st.delete_multi_cloud_image(@mci.href)
         | 
| 23 | 
            +
              end
         | 
| 24 | 
            +
             | 
| 25 | 
            +
              after(:all) do
         | 
| 26 | 
            +
                @new_st.destroy
         | 
| 27 | 
            +
                #@mci.destroy
         | 
| 28 | 
            +
                #@mci2.destroy
         | 
| 29 | 
            +
              end
         | 
| 30 | 
            +
              
         | 
| 31 | 
            +
             | 
| 32 | 
            +
            end
         | 
| 33 | 
            +
             
         | 
| @@ -0,0 +1,18 @@ | |
| 1 | 
            +
            require 'rubygems'
         | 
| 2 | 
            +
            require 'rest_connection'
         | 
| 3 | 
            +
            require 'spec'
         | 
| 4 | 
            +
            require 'ruby-debug'
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            describe Server, "using a server" do
         | 
| 7 | 
            +
              before(:all) do
         | 
| 8 | 
            +
              end
         | 
| 9 | 
            +
             | 
| 10 | 
            +
              it "should use method_missing for assignment" do
         | 
| 11 | 
            +
                @server = Server.find(37842) # hardcoded, you must change to valid server in your account
         | 
| 12 | 
            +
                @server.max_spot_price = "0.01"
         | 
| 13 | 
            +
                @server.pricing = "spot"
         | 
| 14 | 
            +
                @server.save
         | 
| 15 | 
            +
                @server.max_spot_price.should == "0.01"
         | 
| 16 | 
            +
              end
         | 
| 17 | 
            +
             | 
| 18 | 
            +
            end
         | 
| @@ -0,0 +1,19 @@ | |
| 1 | 
            +
            require 'rubygems'
         | 
| 2 | 
            +
            require 'rest_connection'
         | 
| 3 | 
            +
            require 'spec'
         | 
| 4 | 
            +
            require 'ruby-debug'
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            describe ServerInternal, "server internal api object exercise" do
         | 
| 7 | 
            +
              before(:all) do
         | 
| 8 | 
            +
              end
         | 
| 9 | 
            +
             | 
| 10 | 
            +
              it "should find an internal server" do
         | 
| 11 | 
            +
                @server = Server.find(745582)
         | 
| 12 | 
            +
            #    @server.start
         | 
| 13 | 
            +
            #    @server.wait_for_state("operational")
         | 
| 14 | 
            +
                @server.stop_ebs
         | 
| 15 | 
            +
                @server.wait_for_state("stopped")
         | 
| 16 | 
            +
                @server.start_ebs
         | 
| 17 | 
            +
              end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
            end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,12 +1,13 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification 
         | 
| 2 2 | 
             
            name: rest_connection
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version 
         | 
| 4 | 
            +
              hash: 19
         | 
| 4 5 | 
             
              prerelease: false
         | 
| 5 6 | 
             
              segments: 
         | 
| 6 7 | 
             
              - 0
         | 
| 7 8 | 
             
              - 0
         | 
| 8 | 
            -
              -  | 
| 9 | 
            -
              version: 0.0. | 
| 9 | 
            +
              - 6
         | 
| 10 | 
            +
              version: 0.0.6
         | 
| 10 11 | 
             
            platform: ruby
         | 
| 11 12 | 
             
            authors: 
         | 
| 12 13 | 
             
            - Jeremy Deininger
         | 
| @@ -14,16 +15,18 @@ autorequire: | |
| 14 15 | 
             
            bindir: bin
         | 
| 15 16 | 
             
            cert_chain: []
         | 
| 16 17 |  | 
| 17 | 
            -
            date: 2010- | 
| 18 | 
            +
            date: 2010-05-19 00:00:00 -07:00
         | 
| 18 19 | 
             
            default_executable: 
         | 
| 19 20 | 
             
            dependencies: 
         | 
| 20 21 | 
             
            - !ruby/object:Gem::Dependency 
         | 
| 21 22 | 
             
              name: activesupport
         | 
| 22 23 | 
             
              prerelease: false
         | 
| 23 24 | 
             
              requirement: &id001 !ruby/object:Gem::Requirement 
         | 
| 25 | 
            +
                none: false
         | 
| 24 26 | 
             
                requirements: 
         | 
| 25 27 | 
             
                - - ">="
         | 
| 26 28 | 
             
                  - !ruby/object:Gem::Version 
         | 
| 29 | 
            +
                    hash: 3
         | 
| 27 30 | 
             
                    segments: 
         | 
| 28 31 | 
             
                    - 0
         | 
| 29 32 | 
             
                    version: "0"
         | 
| @@ -33,9 +36,11 @@ dependencies: | |
| 33 36 | 
             
              name: net-ssh
         | 
| 34 37 | 
             
              prerelease: false
         | 
| 35 38 | 
             
              requirement: &id002 !ruby/object:Gem::Requirement 
         | 
| 39 | 
            +
                none: false
         | 
| 36 40 | 
             
                requirements: 
         | 
| 37 41 | 
             
                - - ">="
         | 
| 38 42 | 
             
                  - !ruby/object:Gem::Version 
         | 
| 43 | 
            +
                    hash: 3
         | 
| 39 44 | 
             
                    segments: 
         | 
| 40 45 | 
             
                    - 0
         | 
| 41 46 | 
             
                    version: "0"
         | 
| @@ -45,9 +50,11 @@ dependencies: | |
| 45 50 | 
             
              name: json
         | 
| 46 51 | 
             
              prerelease: false
         | 
| 47 52 | 
             
              requirement: &id003 !ruby/object:Gem::Requirement 
         | 
| 53 | 
            +
                none: false
         | 
| 48 54 | 
             
                requirements: 
         | 
| 49 55 | 
             
                - - ">="
         | 
| 50 56 | 
             
                  - !ruby/object:Gem::Version 
         | 
| 57 | 
            +
                    hash: 3
         | 
| 51 58 | 
             
                    segments: 
         | 
| 52 59 | 
             
                    - 0
         | 
| 53 60 | 
             
                    version: "0"
         | 
| @@ -85,20 +92,30 @@ files: | |
| 85 92 | 
             
            - lib/rest_connection/rightscale/ec2_security_group.rb
         | 
| 86 93 | 
             
            - lib/rest_connection/rightscale/ec2_server_array.rb
         | 
| 87 94 | 
             
            - lib/rest_connection/rightscale/ec2_ssh_key.rb
         | 
| 95 | 
            +
            - lib/rest_connection/rightscale/ec2_ssh_key_internal.rb
         | 
| 88 96 | 
             
            - lib/rest_connection/rightscale/executable.rb
         | 
| 89 97 | 
             
            - lib/rest_connection/rightscale/instance.rb
         | 
| 90 98 | 
             
            - lib/rest_connection/rightscale/multi_cloud_image.rb
         | 
| 99 | 
            +
            - lib/rest_connection/rightscale/multi_cloud_image_cloud_setting_internal.rb
         | 
| 100 | 
            +
            - lib/rest_connection/rightscale/multi_cloud_image_internal.rb
         | 
| 91 101 | 
             
            - lib/rest_connection/rightscale/right_script.rb
         | 
| 92 102 | 
             
            - lib/rest_connection/rightscale/rightscale_api_base.rb
         | 
| 103 | 
            +
            - lib/rest_connection/rightscale/rightscale_api_internal.rb
         | 
| 93 104 | 
             
            - lib/rest_connection/rightscale/rightscale_api_resources.rb
         | 
| 94 105 | 
             
            - lib/rest_connection/rightscale/rs_internal.rb
         | 
| 95 106 | 
             
            - lib/rest_connection/rightscale/server.rb
         | 
| 107 | 
            +
            - lib/rest_connection/rightscale/server_internal.rb
         | 
| 96 108 | 
             
            - lib/rest_connection/rightscale/server_template.rb
         | 
| 109 | 
            +
            - lib/rest_connection/rightscale/server_template_internal.rb
         | 
| 97 110 | 
             
            - lib/rest_connection/rightscale/status.rb
         | 
| 98 111 | 
             
            - lib/rest_connection/rightscale/tag.rb
         | 
| 99 112 | 
             
            - lib/rest_connection/ssh_hax.rb
         | 
| 100 113 | 
             
            - rest_connection.gemspec
         | 
| 114 | 
            +
            - spec/ec2_ssh_key_internal_spec.rb
         | 
| 115 | 
            +
            - spec/image_jockey.rb
         | 
| 116 | 
            +
            - spec/method_missing_spec.rb
         | 
| 101 117 | 
             
            - spec/rs_internal_spec.rb
         | 
| 118 | 
            +
            - spec/server_internal_spec.rb
         | 
| 102 119 | 
             
            - spec/server_spec.rb
         | 
| 103 120 | 
             
            has_rdoc: true
         | 
| 104 121 | 
             
            homepage: http://github.com/jeremyd/rest_connection
         | 
| @@ -110,36 +127,44 @@ rdoc_options: | |
| 110 127 | 
             
            require_paths: 
         | 
| 111 128 | 
             
            - lib
         | 
| 112 129 | 
             
            required_ruby_version: !ruby/object:Gem::Requirement 
         | 
| 130 | 
            +
              none: false
         | 
| 113 131 | 
             
              requirements: 
         | 
| 114 132 | 
             
              - - ">="
         | 
| 115 133 | 
             
                - !ruby/object:Gem::Version 
         | 
| 134 | 
            +
                  hash: 3
         | 
| 116 135 | 
             
                  segments: 
         | 
| 117 136 | 
             
                  - 0
         | 
| 118 137 | 
             
                  version: "0"
         | 
| 119 138 | 
             
            required_rubygems_version: !ruby/object:Gem::Requirement 
         | 
| 139 | 
            +
              none: false
         | 
| 120 140 | 
             
              requirements: 
         | 
| 121 141 | 
             
              - - ">="
         | 
| 122 142 | 
             
                - !ruby/object:Gem::Version 
         | 
| 143 | 
            +
                  hash: 3
         | 
| 123 144 | 
             
                  segments: 
         | 
| 124 145 | 
             
                  - 0
         | 
| 125 146 | 
             
                  version: "0"
         | 
| 126 147 | 
             
            requirements: []
         | 
| 127 148 |  | 
| 128 149 | 
             
            rubyforge_project: 
         | 
| 129 | 
            -
            rubygems_version: 1.3. | 
| 150 | 
            +
            rubygems_version: 1.3.7
         | 
| 130 151 | 
             
            signing_key: 
         | 
| 131 152 | 
             
            specification_version: 3
         | 
| 132 153 | 
             
            summary: lib for restful connections to the rightscale api
         | 
| 133 154 | 
             
            test_files: 
         | 
| 134 | 
            -
            - spec/ | 
| 155 | 
            +
            - spec/ec2_ssh_key_internal_spec.rb
         | 
| 156 | 
            +
            - spec/image_jockey.rb
         | 
| 157 | 
            +
            - spec/method_missing_spec.rb
         | 
| 135 158 | 
             
            - spec/rs_internal_spec.rb
         | 
| 136 | 
            -
            -  | 
| 159 | 
            +
            - spec/server_internal_spec.rb
         | 
| 160 | 
            +
            - spec/server_spec.rb
         | 
| 137 161 | 
             
            - examples/console.rb
         | 
| 138 | 
            -
            - examples/run_php_chef_sequence.rb
         | 
| 139 | 
            -
            - examples/set_deployment_template_href.rb
         | 
| 140 162 | 
             
            - examples/dev_setup.rb
         | 
| 141 | 
            -
            - examples/right_scale_ec2_instances_api_test.rb
         | 
| 142 163 | 
             
            - examples/relaunch_deployment.rb
         | 
| 164 | 
            +
            - examples/restart_instance_agent.rb
         | 
| 165 | 
            +
            - examples/right_scale_ec2_instances_api_test.rb
         | 
| 166 | 
            +
            - examples/run_ebs_sequence.rb
         | 
| 143 167 | 
             
            - examples/run_ebs_terminate.rb
         | 
| 144 168 | 
             
            - examples/run_mysql_chef_sequence.rb
         | 
| 145 | 
            -
            - examples/ | 
| 169 | 
            +
            - examples/run_php_chef_sequence.rb
         | 
| 170 | 
            +
            - examples/set_deployment_template_href.rb
         |