rest_connection 1.0.12 → 1.0.13

Sign up to get free protection for your applications and to get access to all the features.
@@ -60,10 +60,35 @@ class Deployment
60
60
 
61
61
  def servers_no_reload
62
62
  connection.logger("WARNING: No Servers in the Deployment!") if @params['servers'].empty?
63
- unless @params['servers'].reduce(true) { |bool,s| bool && s.is_a?(ServerInterface) }
64
- @params['servers'].map! { |s| ServerInterface.new(self.cloud_id, s, self.rs_id) }
63
+
64
+ cloud_id = nil
65
+ @params["tags"].each do |hash|
66
+ if hash["name"] =~ /info:cloud=(\d+)/
67
+ cloud_id = $1
68
+ break
69
+ end
65
70
  end
66
- @params['servers']
71
+
72
+ unless @params['servers'].reduce(true) { |bool,s| bool && s.is_a?(ServerInterface) }
73
+ @params['servers'].map! do |s|
74
+ # Create a temporary, legacy type server for each server in deployment.
75
+ id = s['href'].match(/(\d{6,})$/)[0]
76
+ serv = Server[id.to_i]
77
+
78
+ # Query for settings. AWS servers will return valid details, Generics won't.
79
+ cloud_id = nil
80
+ begin
81
+ settings = serv.first.settings
82
+ cloud_id = settings['cloud_id']
83
+ puts "Cloud id #{cloud_id} found for server #{id.to_s}, assuming AWS server"
84
+ rescue
85
+ puts "Settings not returned from server #{id.to_s}, using API 1.0 call, assuming Generic server"
86
+ end
87
+
88
+ # Now we pass on cloud_id, it will be nil for generic servers, of a valid number for AWS servers
89
+ ServerInterface.new(cloud_id, s, self.rs_id)
90
+ end
91
+ end
67
92
  end
68
93
 
69
94
  def servers
@@ -27,13 +27,15 @@ class ServerInterface
27
27
  attr_reader :multicloud
28
28
 
29
29
  def initialize(cid = nil, params = {}, deployment_id = nil)
30
+
31
+ # If cid is nil, assume generic server, otherwise check value and if cloud
32
+ # id is in range of AWS clouds we can assume it's an AWS server
30
33
  if cid
31
34
  @multicloud = (cid.to_i > 10 ? true : false)
32
- elsif params["href"]
33
- @multicloud = false
34
35
  else
35
36
  @multicloud = true
36
37
  end
38
+
37
39
  if @multicloud
38
40
  if deployment_id
39
41
  name = params["nickname"] || params["name"] || params[:nickname] || params[:name]
@@ -103,7 +105,7 @@ class ServerInterface
103
105
  {"1.0" => [:pricing]},
104
106
  {"1.0" => [:max_spot_price]},
105
107
  { "1.5" => [:inputs]},
106
- { "1.5" => [:mci_href, :multi_cloud_image_href]},
108
+ {"1.0" => [:multi_cloud_image_href], "1.5" => [:mci_href, :multi_cloud_image_href]},
107
109
  { "1.5" => [:datacenter_href]},
108
110
  {"1.0" => [:aki_image_href], "1.5" => [:kernel_image_href]},
109
111
  {"1.0" => [:ari_image_href], "1.5" => [:ramdisk_image_href]}]
@@ -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.12'
3
+ VERSION = '1.0.13'
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: 15
4
+ hash: 13
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 12
10
- version: 1.0.12
9
+ - 13
10
+ version: 1.0.13
11
11
  platform: ruby
12
12
  authors:
13
13
  - RightScale, Inc.
@@ -18,8 +18,6 @@ cert_chain: []
18
18
  date: 2014-04-03 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
- name: net-ssh
22
- prerelease: false
23
21
  requirement: &id001 !ruby/object:Gem::Requirement
24
22
  none: false
25
23
  requirements:
@@ -30,10 +28,10 @@ dependencies:
30
28
  - 0
31
29
  version: "0"
32
30
  type: :runtime
31
+ name: net-ssh
33
32
  version_requirements: *id001
34
- - !ruby/object:Gem::Dependency
35
- name: json
36
33
  prerelease: false
34
+ - !ruby/object:Gem::Dependency
37
35
  requirement: &id002 !ruby/object:Gem::Requirement
38
36
  none: false
39
37
  requirements:
@@ -44,10 +42,10 @@ dependencies:
44
42
  - 0
45
43
  version: "0"
46
44
  type: :runtime
45
+ name: json
47
46
  version_requirements: *id002
48
- - !ruby/object:Gem::Dependency
49
- name: highline
50
47
  prerelease: false
48
+ - !ruby/object:Gem::Dependency
51
49
  requirement: &id003 !ruby/object:Gem::Requirement
52
50
  none: false
53
51
  requirements:
@@ -58,10 +56,10 @@ dependencies:
58
56
  - 0
59
57
  version: "0"
60
58
  type: :runtime
59
+ name: highline
61
60
  version_requirements: *id003
62
- - !ruby/object:Gem::Dependency
63
- name: rest-client
64
61
  prerelease: false
62
+ - !ruby/object:Gem::Dependency
65
63
  requirement: &id004 !ruby/object:Gem::Requirement
66
64
  none: false
67
65
  requirements:
@@ -72,10 +70,10 @@ dependencies:
72
70
  - 0
73
71
  version: "0"
74
72
  type: :runtime
73
+ name: rest-client
75
74
  version_requirements: *id004
76
- - !ruby/object:Gem::Dependency
77
- name: rake
78
75
  prerelease: false
76
+ - !ruby/object:Gem::Dependency
79
77
  requirement: &id005 !ruby/object:Gem::Requirement
80
78
  none: false
81
79
  requirements:
@@ -88,10 +86,10 @@ dependencies:
88
86
  - 7
89
87
  version: 0.8.7
90
88
  type: :development
89
+ name: rake
91
90
  version_requirements: *id005
92
- - !ruby/object:Gem::Dependency
93
- name: bundler
94
91
  prerelease: false
92
+ - !ruby/object:Gem::Dependency
95
93
  requirement: &id006 !ruby/object:Gem::Requirement
96
94
  none: false
97
95
  requirements:
@@ -102,10 +100,10 @@ dependencies:
102
100
  - 0
103
101
  version: "0"
104
102
  type: :development
103
+ name: bundler
105
104
  version_requirements: *id006
106
- - !ruby/object:Gem::Dependency
107
- name: rspec
108
105
  prerelease: false
106
+ - !ruby/object:Gem::Dependency
109
107
  requirement: &id007 !ruby/object:Gem::Requirement
110
108
  none: false
111
109
  requirements:
@@ -118,10 +116,10 @@ dependencies:
118
116
  - 0
119
117
  version: 1.3.0
120
118
  type: :development
119
+ name: rspec
121
120
  version_requirements: *id007
122
- - !ruby/object:Gem::Dependency
123
- name: nokogiri
124
121
  prerelease: false
122
+ - !ruby/object:Gem::Dependency
125
123
  requirement: &id008 !ruby/object:Gem::Requirement
126
124
  none: false
127
125
  requirements:
@@ -134,10 +132,10 @@ dependencies:
134
132
  - 0
135
133
  version: 1.6.0
136
134
  type: :runtime
135
+ name: nokogiri
137
136
  version_requirements: *id008
138
- - !ruby/object:Gem::Dependency
139
- name: activesupport
140
137
  prerelease: false
138
+ - !ruby/object:Gem::Dependency
141
139
  requirement: &id009 !ruby/object:Gem::Requirement
142
140
  none: false
143
141
  requirements:
@@ -150,10 +148,10 @@ dependencies:
150
148
  - 0
151
149
  version: 4.0.0
152
150
  type: :runtime
151
+ name: activesupport
153
152
  version_requirements: *id009
154
- - !ruby/object:Gem::Dependency
155
- name: ruby-debug
156
153
  prerelease: false
154
+ - !ruby/object:Gem::Dependency
157
155
  requirement: &id010 !ruby/object:Gem::Requirement
158
156
  none: false
159
157
  requirements:
@@ -164,7 +162,9 @@ dependencies:
164
162
  - 0
165
163
  version: "0"
166
164
  type: :development
165
+ name: ruby-debug
167
166
  version_requirements: *id010
167
+ prerelease: false
168
168
  description: "\n\
169
169
  This gem is deprecated! Please use right_api_client instead.\n\
170
170
  The rest_connection gem simplifies the use of RESTful APIs.\n\
@@ -334,4 +334,3 @@ test_files:
334
334
  - spec/server_template_internal.rb
335
335
  - spec/spec_helper.rb
336
336
  - spec/tag_spec.rb
337
- has_rdoc: