rest_connection 1.0.8 → 1.0.9

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.
@@ -12,3 +12,4 @@
12
12
  :azure_hack_retry_count: 5
13
13
  :azure_hack_sleep_seconds: 60
14
14
  :api_logging: false
15
+ :legacy_shard: true
@@ -85,10 +85,11 @@ module RestConnection
85
85
  @@pass = ask("Password:") { |q| q.echo = false } unless @@pass
86
86
  @settings[:pass] = @@pass
87
87
  end
88
- @settings[:azure_hack_on] ||= true
88
+ @settings[:azure_hack_on] = true if @settings[:azure_hack_on] == nil
89
89
  @settings[:azure_hack_retry_count] ||= 5
90
90
  @settings[:azure_hack_sleep_seconds] ||= 60
91
91
  @settings[:api_logging] ||= false
92
+ @settings[:legacy_shard] = true if @settings[:legacy_shard] == nil
92
93
  end
93
94
 
94
95
  # 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
@@ -36,17 +36,20 @@ class MultiCloudImage
36
36
  @params["multi_cloud_image_cloud_settings"].map { |mcics| mcics.cloud_id }
37
37
  end
38
38
 
39
- # You must have access to multiple APIs for this (0.1, and 1.5)
40
- def find_and_flatten_settings()
41
- internal = MultiCloudImageInternal.new("href" => self.href)
42
- internal.reload
43
- total_image_count = internal.multi_cloud_image_cloud_settings.size
44
- # The .settings call filters out non-ec2 images
45
- more_settings = []
46
- if total_image_count > internal.settings.size
47
- more_settings = McMultiCloudImage.find(rs_id.to_i).settings
39
+ def find_and_flatten_settings
40
+ if connection.settings[:legacy_shard]
41
+ internal = MultiCloudImageInternal.new("href" => self.href)
42
+ internal.reload
43
+ total_image_count = internal.multi_cloud_image_cloud_settings.size
44
+ # The .settings call filters out non-ec2 images
45
+ more_settings = []
46
+ if total_image_count > internal.settings.size
47
+ more_settings = McMultiCloudImage.find(rs_id.to_i).settings
48
+ end
49
+ @params["multi_cloud_image_cloud_settings"] = internal.settings + more_settings
50
+ else
51
+ @params["multi_cloud_image_cloud_settings"] = McMultiCloudImage.find(rs_id.to_i).settings
48
52
  end
49
- @params["multi_cloud_image_cloud_settings"] = internal.settings + more_settings
50
53
  end
51
54
 
52
55
  def initialize(*args, &block)
@@ -85,12 +85,19 @@ module RightScale
85
85
  if class_variable_defined?("@@api0_1")
86
86
  return @@api0_1 unless @@api0_1.nil?
87
87
  end
88
- Ec2SshKeyInternal.find_all
89
- @@api0_1 = true
90
- rescue RestConnection::Errors::Forbidden
91
- @@api0_1 = false
92
- rescue RestConnection::Errors::UnprocessableEntity
93
- @@api0_1 = false
88
+
89
+ if RestConnection::Connection.new.settings[:legacy_shard]
90
+ begin
91
+ Ec2SshKeyInternal.find_all
92
+ @@api0_1 = true
93
+ rescue RestConnection::Errors::Forbidden
94
+ @@api0_1 = false
95
+ rescue RestConnection::Errors::UnprocessableEntity
96
+ @@api0_1 = false
97
+ end
98
+ else
99
+ @@api0_1 = false
100
+ end
94
101
  end
95
102
 
96
103
  # Checks for API 1.0 access
@@ -88,13 +88,19 @@ class ServerTemplate
88
88
 
89
89
  def fetch_multi_cloud_images
90
90
  @params["multi_cloud_images"] = []
91
- ServerTemplateInternal.new(:href => self.href).multi_cloud_images.each { |mci_params|
92
- @params["multi_cloud_images"] << MultiCloudImageInternal.new(mci_params)
93
- }
94
- mcis = McServerTemplate.find(self.rs_id.to_i).multi_cloud_images
95
- @params["multi_cloud_images"].each_index { |i|
96
- @params["multi_cloud_images"][i]["multi_cloud_image_cloud_settings"] += mcis[i].settings
97
- }
91
+ if connection.settings[:legacy_shard]
92
+ ServerTemplateInternal.new(:href => self.href).multi_cloud_images.each { |mci_params|
93
+ @params["multi_cloud_images"] << MultiCloudImageInternal.new(mci_params)
94
+ }
95
+ mcis = McServerTemplate.find(self.rs_id.to_i).multi_cloud_images
96
+ @params["multi_cloud_images"].each_index { |i|
97
+ @params["multi_cloud_images"][i]["multi_cloud_image_cloud_settings"] += mcis[i].settings
98
+ }
99
+ else
100
+ McServerTemplate.find(self.rs_id.to_i).multi_cloud_images.each { |mci|
101
+ @params["multi_cloud_images"] << McMultiCloudImage.new(mci.params)
102
+ }
103
+ end
98
104
  @params["multi_cloud_images"]
99
105
  end
100
106
 
@@ -34,12 +34,15 @@ module SshHax
34
34
  ssh_keys = item
35
35
  elsif item.is_a?(String)
36
36
  ssh_keys = [item]
37
- elsif k = connection.settings[:ssh_key]
38
- ssh_keys = [k]
39
- elsif kk = connection.settings[:ssh_keys]
40
- ssh_keys = kk
37
+ elsif connection_key = connection.settings[:ssh_key]
38
+ ssh_keys = [connection_key]
39
+ elsif connection_keys = connection.settings[:ssh_keys]
40
+ ssh_keys = connection_keys
41
41
  else
42
- ssh_keys = nil
42
+ # If no key(s) provided, assume a standard monkey configuration which uses '/root/.ssh/api_user_key'.
43
+ api_user_key_ssh_key_file_name = '/root/.ssh/api_user_key'
44
+ raise "FATAL ERROR: #{api_user_key_ssh_key_file_name} does not exist." if !File.exist?(api_user_key_ssh_key_file_name)
45
+ ssh_keys = [api_user_key_ssh_key_file_name]
43
46
  end
44
47
  ssh_keys
45
48
  end
@@ -1,4 +1,4 @@
1
1
  # This gem is versioned with the usual X.Y.Z notation
2
2
  module RestConnection
3
- VERSION = '1.0.8'
3
+ VERSION = '1.0.9'
4
4
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rest_connection
3
3
  version: !ruby/object:Gem::Version
4
- hash: 7
4
+ hash: 5
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 8
10
- version: 1.0.8
9
+ - 9
10
+ version: 1.0.9
11
11
  platform: ruby
12
12
  authors:
13
13
  - RightScale, Inc.
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2013-05-28 00:00:00 Z
18
+ date: 2013-06-05 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  version_requirements: &id001 !ruby/object:Gem::Requirement