vagrant-cloudcenter 0.2.0 → 0.3.0
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.
- checksums.yaml +4 -4
- data/README.md +9 -5
- data/lib/vagrant-cloudcenter/action/deploy.rb +124 -37
- data/lib/vagrant-cloudcenter/action/is_created.rb +94 -16
- data/lib/vagrant-cloudcenter/action/is_stopped.rb +99 -19
- data/lib/vagrant-cloudcenter/action/read_ssh_info.rb +105 -30
- data/lib/vagrant-cloudcenter/action/start_instance.rb +156 -40
- data/lib/vagrant-cloudcenter/action/stop_instance.rb +152 -41
- data/lib/vagrant-cloudcenter/action/terminate_instance.rb +145 -33
- data/lib/vagrant-cloudcenter/command/app.rb +24 -12
- data/lib/vagrant-cloudcenter/command/catalog.rb +31 -19
- data/lib/vagrant-cloudcenter/command/init.rb +7 -1
- data/lib/vagrant-cloudcenter/command/jobs.rb +31 -19
- data/lib/vagrant-cloudcenter/config.rb +18 -8
- data/lib/vagrant-cloudcenter/version.rb +1 -1
- metadata +2 -2
@@ -28,48 +28,123 @@ module VagrantPlugins
|
|
28
28
|
end
|
29
29
|
|
30
30
|
access_key = env[:machine].provider_config.access_key
|
31
|
-
|
31
|
+
host = env[:machine].provider_config.host
|
32
32
|
username = env[:machine].provider_config.username
|
33
33
|
|
34
|
-
|
34
|
+
use_https = env[:machine].provider_config.use_https
|
35
|
+
ssl_ca_file = env[:machine].provider_config.ssl_ca_file
|
36
|
+
|
37
|
+
encoded = URI.encode("https://#{username}:#{access_key}@#{host}/v2/jobs?search=[deploymentEntity.name,fle,#{env[:machine_name]}]");
|
35
38
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
39
|
+
if !use_https
|
40
|
+
response = JSON.parse(RestClient::Request.execute(
|
41
|
+
:method => :get,
|
42
|
+
:url => encoded,
|
43
|
+
:verify_ssl => false,
|
44
|
+
:accept => "json",
|
45
|
+
:headers => {"Content-Type" => "application/json"}
|
46
|
+
));
|
47
|
+
else
|
48
|
+
if ssl_ca_file.to_s.empty?
|
49
|
+
response = JSON.parse(RestClient::Request.execute(
|
50
|
+
:method => :get,
|
51
|
+
:url => encoded,
|
52
|
+
:accept => "json",
|
53
|
+
:headers => {"Content-Type" => "application/json"}
|
54
|
+
));
|
55
|
+
else
|
56
|
+
response = JSON.parse(RestClient::Request.execute(
|
57
|
+
:method => :get,
|
58
|
+
:url => encoded,
|
59
|
+
:ssl_ca_file => ssl_ca_file.to_s,
|
60
|
+
:accept => "json",
|
61
|
+
:headers => {"Content-Type" => "application/json"}
|
62
|
+
));
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
43
66
|
|
44
67
|
jobID = response["jobs"][0]["id"]
|
45
68
|
|
46
69
|
rescue => e
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
70
|
+
if e.to_s == "SSL_connect returned=1 errno=0 state=error: certificate verify failed"
|
71
|
+
puts "\n ERROR: Failed to verify certificate\n\n"
|
72
|
+
exit
|
73
|
+
elsif e.to_s == "hostname \"#{host}\" does not match the server certificate"
|
74
|
+
puts "\n ERROR: Hostname \"#{host}\" does not match the server certificate\n\n"
|
75
|
+
exit
|
76
|
+
elsif e.to_s.include? "No route to host"
|
77
|
+
puts "\n ERROR: No route to host. Check connectivity and try again\n\n"
|
78
|
+
exit
|
79
|
+
elsif e.to_s.== "Timed out connecting to server"
|
80
|
+
puts "\n ERROR: Timed out connecting to server. Check connectivity and try again\n\n"
|
81
|
+
exit
|
82
|
+
elsif e.to_s.== "getaddrinfo: nodename nor servname provided, or not known"
|
83
|
+
puts "\n ERROR: Unable to connect to \"#{host}\" \n\n"
|
84
|
+
exit
|
85
|
+
else
|
86
|
+
error = JSON.parse(e.response)
|
87
|
+
code = error["errors"][0]["code"]
|
88
|
+
|
89
|
+
puts "\n Error code: #{error['errors'][0]['code']}\n"
|
90
|
+
puts "\n #{error['errors'][0]['message']}\n\n"
|
91
|
+
|
92
|
+
exit
|
93
|
+
end
|
54
94
|
end
|
55
95
|
|
56
96
|
begin
|
57
|
-
encoded = URI.encode("https://#{username}:#{access_key}@#{
|
97
|
+
encoded = URI.encode("https://#{username}:#{access_key}@#{host}/v2/jobs/#{jobID}");
|
58
98
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
99
|
+
if !use_https
|
100
|
+
response = JSON.parse(RestClient::Request.execute(
|
101
|
+
:method => :get,
|
102
|
+
:url => encoded,
|
103
|
+
:verify_ssl => false,
|
104
|
+
:accept => "json"
|
105
|
+
));
|
106
|
+
else
|
107
|
+
if ssl_ca_file.to_s.empty?
|
108
|
+
response = JSON.parse(RestClient::Request.execute(
|
109
|
+
:method => :get,
|
110
|
+
:url => encoded,
|
111
|
+
:accept => "json"
|
112
|
+
));
|
113
|
+
else
|
114
|
+
response = JSON.parse(RestClient::Request.execute(
|
115
|
+
:method => :get,
|
116
|
+
:url => encoded,
|
117
|
+
:ssl_ca_file => ssl_ca_file.to_s,
|
118
|
+
:accept => "json"
|
119
|
+
));
|
120
|
+
end
|
121
|
+
end
|
71
122
|
|
72
|
-
|
123
|
+
rescue => e
|
124
|
+
if e.to_s == "SSL_connect returned=1 errno=0 state=error: certificate verify failed"
|
125
|
+
puts "\n ERROR: Failed to verify certificate\n\n"
|
126
|
+
exit
|
127
|
+
elsif e.to_s == "hostname \"#{host}\" does not match the server certificate"
|
128
|
+
puts "\n ERROR: Hostname \"#{host}\" does not match the server certificate\n\n"
|
129
|
+
exit
|
130
|
+
elsif e.to_s.include? "No route to host"
|
131
|
+
puts "\n ERROR: No route to host. Check connectivity and try again\n\n"
|
132
|
+
exit
|
133
|
+
elsif e.to_s.== "Timed out connecting to server"
|
134
|
+
puts "\n ERROR: Timed out connecting to server. Check connectivity and try again\n\n"
|
135
|
+
exit
|
136
|
+
elsif e.to_s.== "getaddrinfo: nodename nor servname provided, or not known"
|
137
|
+
puts "\n ERROR: Unable to connect to \"#{host}\" \n\n"
|
138
|
+
exit
|
139
|
+
else
|
140
|
+
error = JSON.parse(e.response)
|
141
|
+
code = error["errors"][0]["code"]
|
142
|
+
|
143
|
+
puts "\n Error code: #{error['errors'][0]['code']}\n"
|
144
|
+
puts "\n #{error['errors'][0]['message']}\n\n"
|
145
|
+
|
146
|
+
exit
|
147
|
+
end
|
73
148
|
end
|
74
149
|
|
75
150
|
env[:machine_public_ip] = response["accessLink"][7,response.length]
|
@@ -31,62 +31,144 @@ module VagrantPlugins
|
|
31
31
|
end
|
32
32
|
|
33
33
|
access_key = env[:machine].provider_config.access_key
|
34
|
-
|
34
|
+
host = env[:machine].provider_config.host
|
35
35
|
username = env[:machine].provider_config.username
|
36
36
|
|
37
|
+
use_https = env[:machine].provider_config.use_https
|
38
|
+
ssl_ca_file = env[:machine].provider_config.ssl_ca_file
|
39
|
+
|
37
40
|
begin
|
38
|
-
encoded = URI.encode("https://#{username}:#{access_key}@#{
|
41
|
+
encoded = URI.encode("https://#{username}:#{access_key}@#{host}/v2/jobs?search=[deploymentEntity.name,fle,#{env[:machine_name]}]");
|
39
42
|
|
40
43
|
|
41
44
|
|
42
|
-
|
45
|
+
if !use_https
|
46
|
+
response = JSON.parse(RestClient::Request.execute(
|
43
47
|
:method => :get,
|
44
48
|
:url => encoded,
|
45
49
|
:verify_ssl => false,
|
46
50
|
:accept => "json",
|
47
51
|
:headers => {"Content-Type" => "application/json"}
|
48
|
-
|
49
52
|
));
|
53
|
+
else
|
54
|
+
if ssl_ca_file.to_s.empty?
|
55
|
+
response = JSON.parse(RestClient::Request.execute(
|
56
|
+
:method => :get,
|
57
|
+
:url => encoded,
|
58
|
+
:accept => "json",
|
59
|
+
:headers => {"Content-Type" => "application/json"}
|
60
|
+
));
|
61
|
+
else
|
62
|
+
response = JSON.parse(RestClient::Request.execute(
|
63
|
+
:method => :get,
|
64
|
+
:url => encoded,
|
65
|
+
:ssl_ca_file => ssl_ca_file.to_s,
|
66
|
+
:accept => "json",
|
67
|
+
:headers => {"Content-Type" => "application/json"}
|
68
|
+
));
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
|
50
74
|
if !response["jobs"].empty?
|
51
75
|
jobID = response["jobs"][0]["id"]
|
52
76
|
end
|
53
77
|
|
54
78
|
rescue => e
|
55
|
-
|
56
|
-
|
79
|
+
if e.to_s == "SSL_connect returned=1 errno=0 state=error: certificate verify failed"
|
80
|
+
puts "\n ERROR: Failed to verify certificate\n\n"
|
81
|
+
exit
|
82
|
+
elsif e.to_s == "hostname \"#{host}\" does not match the server certificate"
|
83
|
+
puts "\n ERROR: Hostname \"#{host}\" does not match the server certificate\n\n"
|
84
|
+
exit
|
85
|
+
elsif e.to_s.include? "No route to host"
|
86
|
+
puts "\n ERROR: No route to host. Check connectivity and try again\n\n"
|
87
|
+
exit
|
88
|
+
elsif e.to_s.== "Timed out connecting to server"
|
89
|
+
puts "\n ERROR: Timed out connecting to server. Check connectivity and try again\n\n"
|
90
|
+
exit
|
91
|
+
elsif e.to_s.== "getaddrinfo: nodename nor servname provided, or not known"
|
92
|
+
puts "\n ERROR: Unable to connect to \"#{host}\" \n\n"
|
93
|
+
exit
|
94
|
+
else
|
95
|
+
error = JSON.parse(e.response)
|
96
|
+
code = error["errors"][0]["code"]
|
57
97
|
|
58
|
-
|
59
|
-
|
98
|
+
puts "\n Error code: #{error['errors'][0]['code']}\n"
|
99
|
+
puts "\n #{error['errors'][0]['message']}\n\n"
|
60
100
|
|
61
|
-
|
101
|
+
exit
|
102
|
+
end
|
62
103
|
end
|
63
104
|
|
64
105
|
if !jobID.nil?
|
65
106
|
begin
|
66
|
-
encoded = URI.encode("https://#{username}:#{access_key}@#{
|
107
|
+
encoded = URI.encode("https://#{username}:#{access_key}@#{host}/v2/jobs/#{jobID}");
|
67
108
|
|
68
109
|
payload = { "action" => "RESUME" }
|
69
110
|
|
70
111
|
payload = JSON.generate(payload)
|
71
112
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
113
|
+
|
114
|
+
if !use_https
|
115
|
+
response = JSON.parse(RestClient::Request.execute(
|
116
|
+
:method => :put,
|
117
|
+
:url => encoded,
|
118
|
+
:verify_ssl => false,
|
119
|
+
:accept => "json",
|
120
|
+
:payload => payload,
|
121
|
+
:headers => {"Content-Type" => "application/json"}
|
122
|
+
));
|
123
|
+
else
|
124
|
+
if ssl_ca_file.to_s.empty?
|
125
|
+
response = JSON.parse(RestClient::Request.execute(
|
126
|
+
:method => :put,
|
127
|
+
:url => encoded,
|
128
|
+
:accept => "json",
|
129
|
+
:payload => payload,
|
130
|
+
:headers => {"Content-Type" => "application/json"}
|
131
|
+
));
|
132
|
+
else
|
133
|
+
response = JSON.parse(RestClient::Request.execute(
|
134
|
+
:method => :put,
|
135
|
+
:url => encoded,
|
136
|
+
:accept => "json",
|
137
|
+
:payload => payload,
|
138
|
+
:headers => {"Content-Type" => "application/json"},
|
139
|
+
:ssl_ca_file => ssl_ca_file.to_s
|
140
|
+
));
|
141
|
+
end
|
142
|
+
|
143
|
+
end
|
144
|
+
|
80
145
|
|
81
146
|
rescue => e
|
82
147
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
148
|
+
if e.to_s == "SSL_connect returned=1 errno=0 state=error: certificate verify failed"
|
149
|
+
puts "\n ERROR: Failed to verify certificate\n\n"
|
150
|
+
exit
|
151
|
+
elsif e.to_s == "hostname \"#{host}\" does not match the server certificate"
|
152
|
+
puts "\n ERROR: Hostname \"#{host}\" does not match the server certificate\n\n"
|
153
|
+
exit
|
154
|
+
elsif e.to_s.include? "No route to host"
|
155
|
+
puts "\n ERROR: No route to host. Check connectivity and try again\n\n"
|
156
|
+
exit
|
157
|
+
elsif e.to_s.== "Timed out connecting to server"
|
158
|
+
puts "\n ERROR: Timed out connecting to server. Check connectivity and try again\n\n"
|
159
|
+
exit
|
160
|
+
elsif e.to_s.== "getaddrinfo: nodename nor servname provided, or not known"
|
161
|
+
puts "\n ERROR: Unable to connect to \"#{host}\" \n\n"
|
162
|
+
exit
|
163
|
+
else
|
164
|
+
error = JSON.parse(e.response)
|
165
|
+
code = error["errors"][0]["code"]
|
166
|
+
|
167
|
+
puts "\n Error code: #{error['errors'][0]['code']}\n"
|
168
|
+
puts "\n #{error['errors'][0]['message']}\n\n"
|
169
|
+
|
170
|
+
exit
|
171
|
+
end
|
90
172
|
end
|
91
173
|
|
92
174
|
while (countdown > 0 )
|
@@ -94,23 +176,57 @@ module VagrantPlugins
|
|
94
176
|
countdown -= 1
|
95
177
|
|
96
178
|
begin
|
97
|
-
encoded = URI.encode("https://#{username}:#{access_key}@#{
|
179
|
+
encoded = URI.encode("https://#{username}:#{access_key}@#{host}/v2/jobs/#{jobID}");
|
98
180
|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
181
|
+
if !use_https
|
182
|
+
response = JSON.parse(RestClient::Request.execute(
|
183
|
+
:method => :get,
|
184
|
+
:url => encoded,
|
185
|
+
:verify_ssl => false,
|
186
|
+
:accept => "json"
|
187
|
+
));
|
188
|
+
else
|
189
|
+
if ssl_ca_file.to_s.empty?
|
190
|
+
response = JSON.parse(RestClient::Request.execute(
|
191
|
+
:method => :get,
|
192
|
+
:url => encoded,
|
193
|
+
:accept => "json"
|
194
|
+
));
|
195
|
+
else
|
196
|
+
response = JSON.parse(RestClient::Request.execute(
|
197
|
+
:method => :get,
|
198
|
+
:url => encoded,
|
199
|
+
:ssl_ca_file => ssl_ca_file.to_s,
|
200
|
+
:accept => "json"
|
201
|
+
));
|
202
|
+
end
|
203
|
+
end
|
109
204
|
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
205
|
+
rescue => e
|
206
|
+
if e.to_s == "SSL_connect returned=1 errno=0 state=error: certificate verify failed"
|
207
|
+
puts "\n ERROR: Failed to verify certificate\n\n"
|
208
|
+
exit
|
209
|
+
elsif e.to_s == "hostname \"#{host}\" does not match the server certificate"
|
210
|
+
puts "\n ERROR: Hostname \"#{host}\" does not match the server certificate\n\n"
|
211
|
+
exit
|
212
|
+
elsif e.to_s.include? "No route to host"
|
213
|
+
puts "\n ERROR: No route to host. Check connectivity and try again\n\n"
|
214
|
+
exit
|
215
|
+
elsif e.to_s.== "Timed out connecting to server"
|
216
|
+
puts "\n ERROR: Timed out connecting to server. Check connectivity and try again\n\n"
|
217
|
+
exit
|
218
|
+
elsif e.to_s.== "getaddrinfo: nodename nor servname provided, or not known"
|
219
|
+
puts "\n ERROR: Unable to connect to \"#{host}\" \n\n"
|
220
|
+
exit
|
221
|
+
else
|
222
|
+
error = JSON.parse(e.response)
|
223
|
+
code = error["errors"][0]["code"]
|
224
|
+
|
225
|
+
puts "\n Error code: #{error['errors'][0]['code']}\n"
|
226
|
+
puts "\n #{error['errors'][0]['message']}\n\n"
|
227
|
+
|
228
|
+
exit
|
229
|
+
end
|
114
230
|
end
|
115
231
|
|
116
232
|
if response["deploymentEntity"]["attributes"]["status"] == "Deployed"
|
@@ -25,61 +25,138 @@ module VagrantPlugins
|
|
25
25
|
end
|
26
26
|
|
27
27
|
access_key = env[:machine].provider_config.access_key
|
28
|
-
|
28
|
+
host = env[:machine].provider_config.host
|
29
29
|
username = env[:machine].provider_config.username
|
30
30
|
|
31
|
-
|
32
|
-
|
33
|
-
|
31
|
+
use_https = env[:machine].provider_config.use_https
|
32
|
+
ssl_ca_file = env[:machine].provider_config.ssl_ca_file
|
34
33
|
|
34
|
+
begin
|
35
|
+
encoded = URI.encode("https://#{username}:#{access_key}@#{host}/v2/jobs?search=[deploymentEntity.name,fle,#{env[:machine_name]}]");
|
35
36
|
|
37
|
+
if !use_https
|
36
38
|
response = JSON.parse(RestClient::Request.execute(
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
39
|
+
:method => :get,
|
40
|
+
:url => encoded,
|
41
|
+
:verify_ssl => false,
|
42
|
+
:accept => "json",
|
43
|
+
:headers => {"Content-Type" => "application/json"}
|
44
|
+
));
|
45
|
+
else
|
46
|
+
if ssl_ca_file.to_s.empty?
|
47
|
+
response = JSON.parse(RestClient::Request.execute(
|
48
|
+
:method => :get,
|
49
|
+
:url => encoded,
|
50
|
+
:accept => "json",
|
51
|
+
:headers => {"Content-Type" => "application/json"}
|
52
|
+
));
|
53
|
+
else
|
54
|
+
response = JSON.parse(RestClient::Request.execute(
|
55
|
+
:method => :get,
|
56
|
+
:url => encoded,
|
57
|
+
:accept => "json",
|
58
|
+
:headers => {"Content-Type" => "application/json"},
|
59
|
+
:ssl_ca_file => ssl_ca_file.to_s,
|
60
|
+
|
61
|
+
));
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
44
65
|
if !response["jobs"].empty?
|
45
66
|
jobID = response["jobs"][0]["id"]
|
46
67
|
end
|
47
68
|
|
48
69
|
rescue => e
|
49
|
-
|
50
|
-
|
70
|
+
if e.to_s == "SSL_connect returned=1 errno=0 state=error: certificate verify failed"
|
71
|
+
puts "\n ERROR: Failed to verify certificate\n\n"
|
72
|
+
exit
|
73
|
+
elsif e.to_s == "hostname \"#{host}\" does not match the server certificate"
|
74
|
+
puts "\n ERROR: Hostname \"#{host}\" does not match the server certificate\n\n"
|
75
|
+
exit
|
76
|
+
elsif e.to_s.include? "No route to host"
|
77
|
+
puts "\n ERROR: No route to host. Check connectivity and try again\n\n"
|
78
|
+
exit
|
79
|
+
elsif e.to_s.== "Timed out connecting to server"
|
80
|
+
puts "\n ERROR: Timed out connecting to server. Check connectivity and try again\n\n"
|
81
|
+
exit
|
82
|
+
elsif e.to_s.== "getaddrinfo: nodename nor servname provided, or not known"
|
83
|
+
puts "\n ERROR: Unable to connect to \"#{host}\" \n\n"
|
84
|
+
exit
|
85
|
+
else
|
86
|
+
error = JSON.parse(e.response)
|
87
|
+
code = error["errors"][0]["code"]
|
51
88
|
|
52
|
-
|
53
|
-
|
89
|
+
puts "\n Error code: #{error['errors'][0]['code']}\n"
|
90
|
+
puts "\n #{error['errors'][0]['message']}\n\n"
|
54
91
|
|
55
|
-
|
92
|
+
exit
|
93
|
+
end
|
56
94
|
end
|
57
95
|
|
58
96
|
if !jobID.nil?
|
59
97
|
begin
|
60
|
-
encoded = URI.encode("https://#{username}:#{access_key}@#{
|
98
|
+
encoded = URI.encode("https://#{username}:#{access_key}@#{host}/v2/jobs/#{jobID}");
|
61
99
|
|
62
100
|
payload = { "action" => "SUSPEND" }
|
63
101
|
|
64
102
|
payload = JSON.generate(payload)
|
65
103
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
104
|
+
if !use_https
|
105
|
+
response = JSON.parse(RestClient::Request.execute(
|
106
|
+
:method => :put,
|
107
|
+
:url => encoded,
|
108
|
+
:verify_ssl => false,
|
109
|
+
:accept => "json",
|
110
|
+
:payload => payload,
|
111
|
+
:headers => {"Content-Type" => "application/json"}
|
112
|
+
));
|
113
|
+
else
|
114
|
+
if ssl_ca_file.to_s.empty?
|
115
|
+
response = JSON.parse(RestClient::Request.execute(
|
116
|
+
:method => :put,
|
117
|
+
:url => encoded,
|
118
|
+
:accept => "json",
|
119
|
+
:payload => payload,
|
120
|
+
:headers => {"Content-Type" => "application/json"}
|
121
|
+
));
|
122
|
+
else
|
123
|
+
response = JSON.parse(RestClient::Request.execute(
|
124
|
+
:method => :put,
|
125
|
+
:url => encoded,
|
126
|
+
:accept => "json",
|
127
|
+
:payload => payload,
|
128
|
+
:headers => {"Content-Type" => "application/json"},
|
129
|
+
:ssl_ca_file => ssl_ca_file.to_s
|
130
|
+
));
|
131
|
+
end
|
132
|
+
|
133
|
+
end
|
74
134
|
|
75
135
|
rescue => e
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
136
|
+
if e.to_s == "SSL_connect returned=1 errno=0 state=error: certificate verify failed"
|
137
|
+
puts "\n ERROR: Failed to verify certificate\n\n"
|
138
|
+
exit
|
139
|
+
elsif e.to_s == "hostname \"#{host}\" does not match the server certificate"
|
140
|
+
puts "\n ERROR: Hostname \"#{host}\" does not match the server certificate\n\n"
|
141
|
+
exit
|
142
|
+
elsif e.to_s.include? "No route to host"
|
143
|
+
puts "\n ERROR: No route to host. Check connectivity and try again\n\n"
|
144
|
+
exit
|
145
|
+
elsif e.to_s.== "Timed out connecting to server"
|
146
|
+
puts "\n ERROR: Timed out connecting to server. Check connectivity and try again\n\n"
|
147
|
+
exit
|
148
|
+
elsif e.to_s.== "getaddrinfo: nodename nor servname provided, or not known"
|
149
|
+
puts "\n ERROR: Unable to connect to \"#{host}\" \n\n"
|
150
|
+
exit
|
151
|
+
else
|
152
|
+
error = JSON.parse(e.response)
|
153
|
+
code = error["errors"][0]["code"]
|
154
|
+
|
155
|
+
puts "\n Error code: #{error['errors'][0]['code']}\n"
|
156
|
+
puts "\n #{error['errors'][0]['message']}\n\n"
|
157
|
+
|
158
|
+
exit
|
159
|
+
end
|
83
160
|
end
|
84
161
|
|
85
162
|
while (countdown > 0 )
|
@@ -87,24 +164,58 @@ module VagrantPlugins
|
|
87
164
|
countdown -= 1
|
88
165
|
|
89
166
|
begin
|
90
|
-
encoded = URI.encode("https://#{username}:#{access_key}@#{
|
167
|
+
encoded = URI.encode("https://#{username}:#{access_key}@#{host}/v2/jobs/#{jobID}");
|
91
168
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
169
|
+
if !use_https
|
170
|
+
response = JSON.parse(RestClient::Request.execute(
|
171
|
+
:method => :get,
|
172
|
+
:url => encoded,
|
173
|
+
:verify_ssl => false,
|
174
|
+
:accept => "json"
|
175
|
+
));
|
176
|
+
else
|
177
|
+
if ssl_ca_file.to_s.empty?
|
178
|
+
response = JSON.parse(RestClient::Request.execute(
|
179
|
+
:method => :get,
|
180
|
+
:url => encoded,
|
181
|
+
:accept => "json"
|
182
|
+
));
|
183
|
+
else
|
184
|
+
response = JSON.parse(RestClient::Request.execute(
|
185
|
+
:method => :get,
|
186
|
+
:url => encoded,
|
187
|
+
:ssl_ca_file => ssl_ca_file.to_s,
|
188
|
+
:accept => "json"
|
189
|
+
));
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
99
193
|
rescue => e
|
194
|
+
if e.to_s == "SSL_connect returned=1 errno=0 state=error: certificate verify failed"
|
195
|
+
puts "\n ERROR: Failed to verify certificate\n\n"
|
196
|
+
exit
|
197
|
+
elsif e.to_s == "hostname \"#{host}\" does not match the server certificate"
|
198
|
+
puts "\n ERROR: Hostname \"#{host}\" does not match the server certificate\n\n"
|
199
|
+
exit
|
200
|
+
elsif e.to_s.include? "No route to host"
|
201
|
+
puts "\n ERROR: No route to host. Check connectivity and try again\n\n"
|
202
|
+
exit
|
203
|
+
elsif e.to_s.== "Timed out connecting to server"
|
204
|
+
puts "\n ERROR: Timed out connecting to server. Check connectivity and try again\n\n"
|
205
|
+
exit
|
206
|
+
elsif e.to_s.== "getaddrinfo: nodename nor servname provided, or not known"
|
207
|
+
puts "\n ERROR: Unable to connect to \"#{host}\" \n\n"
|
208
|
+
exit
|
209
|
+
else
|
100
210
|
error = JSON.parse(e.response)
|
101
211
|
code = error["errors"][0]["code"]
|
102
212
|
|
103
213
|
puts "\n Error code: #{error['errors'][0]['code']}\n"
|
104
214
|
puts "\n #{error['errors'][0]['message']}\n\n"
|
105
|
-
|
215
|
+
|
106
216
|
exit
|
107
217
|
end
|
218
|
+
end
|
108
219
|
|
109
220
|
if response["deploymentEntity"]["attributes"]["status"] == "Suspended"
|
110
221
|
env[:state] = :stopped
|