rest_connection 1.0.8 → 1.0.9
Sign up to get free protection for your applications and to get access to all the features.
- data/config/rest_api_config.yaml.sample +1 -0
- data/lib/rest_connection.rb +2 -1
- data/lib/rest_connection/rightscale/multi_cloud_image.rb +13 -10
- data/lib/rest_connection/rightscale/rightscale_api_base.rb +13 -6
- data/lib/rest_connection/rightscale/server_template.rb +13 -7
- data/lib/rest_connection/ssh_hax.rb +8 -5
- data/lib/rest_connection/version.rb +1 -1
- metadata +4 -4
data/lib/rest_connection.rb
CHANGED
@@ -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]
|
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
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
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
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
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
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
@params["multi_cloud_images"]
|
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
|
38
|
-
ssh_keys = [
|
39
|
-
elsif
|
40
|
-
ssh_keys =
|
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
|
-
|
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
|
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:
|
4
|
+
hash: 5
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
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
|
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
|