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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 95ab5e6dc39e8576ac043a790dcf2927b761eb7d
|
4
|
+
data.tar.gz: c37b33459cfdd76967c1d79c4a349c32c6f6502a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5bb65791a1d5364afae378bf739149fdcfd9cbce8d59d54009c3416ca753faca151a6881289f04933d6e27f12b5dd7fd2f3ad5e1b4ab56bec690d36900696c93
|
7
|
+
data.tar.gz: 913da05c6c7a07a71b3d86daeab52451f57798de8056ce2452c82bed4d92956913dd908d38a704b68d89636a74e5ac15d9eec49455b988c602244e4e3b89eeb5
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
This is a Vagrant plugin that adds a Cisco CloudCenter provider to Vagrant. It allows Vagrant to communicate with CloudCenter and have it control and provision machines in a number of public and private clouds.
|
4
4
|
|
5
|
-
This plugin is currently a Proof of Concept and has been developed and tested against Cisco CloudCenter 4.8.0 and Vagrant 1.
|
5
|
+
This plugin is currently a Proof of Concept and has been developed and tested against Cisco CloudCenter 4.8.0 and Vagrant 1.9.5
|
6
6
|
|
7
7
|

|
8
8
|
|
@@ -33,9 +33,13 @@ Created by [gh-md-toc](https://github.com/ekalinin/github-markdown-toc)
|
|
33
33
|
|
34
34
|
## Usage
|
35
35
|
|
36
|
-
After installing the plugin
|
36
|
+
After installing the plugin, add the CloudCenter sample box, and then use `vagrant up --provider=cloudcenter` to launch the instance
|
37
37
|
|
38
38
|
```
|
39
|
+
$ vagrant plugin install vagrant-cloudcenter
|
40
|
+
...
|
41
|
+
$ vagrant box add dummy https://github.com/conmurphy/vagrant-cloudcenter/raw/master/example_box/cloudcenter.box
|
42
|
+
...
|
39
43
|
$ vagrant up --provider=cloudcenter
|
40
44
|
...
|
41
45
|
```
|
@@ -104,12 +108,12 @@ This is a JSON file used by Cisco CloudCenter to deploy a new application into t
|
|
104
108
|
2. Search for the required application in the Applications page
|
105
109
|
3. Select `Deploy`
|
106
110
|
|
107
|
-

|
108
112
|
|
109
113
|
4. Complete the required fields
|
110
114
|
5. Select `Restful JSON`
|
111
115
|
|
112
|
-

|
113
117
|
|
114
118
|
6. Save the JSON output into a new file on your local machine - if sharing a single file amongst multiple people or for multiple projects be sure to change the deployment job name so there is no overlap.
|
115
119
|
7. Use this file in the `cloudcenter.deployment_config` setting
|
@@ -133,7 +137,7 @@ To work on the CloudCenter plugin, clone this repository then run the following
|
|
133
137
|
|
134
138
|
```
|
135
139
|
$ gem build vagrant-cloudcenter.gemspec
|
136
|
-
$ vagrant plugin install ./vagrant-cloudcenter-0.
|
140
|
+
$ vagrant plugin install ./vagrant-cloudcenter-0.2.0.gem
|
137
141
|
```
|
138
142
|
|
139
143
|
To uninstall the plugin run `vagrant plugin uninstall vagrant-cloudcenter`
|
@@ -22,9 +22,11 @@ module VagrantPlugins
|
|
22
22
|
|
23
23
|
# Get the rest API key for authentication
|
24
24
|
access_key = env[:machine].provider_config.access_key
|
25
|
-
|
25
|
+
host = env[:machine].provider_config.host
|
26
26
|
username = env[:machine].provider_config.username
|
27
|
-
|
27
|
+
use_https = env[:machine].provider_config.use_https
|
28
|
+
ssl_ca_file = env[:machine].provider_config.ssl_ca_file
|
29
|
+
|
28
30
|
countdown = 24
|
29
31
|
|
30
32
|
#@logger.info("Deploying VM to Cloudcenter...")
|
@@ -40,40 +42,92 @@ module VagrantPlugins
|
|
40
42
|
tmp = JSON.parse(deployment_config)
|
41
43
|
env[:machine_name] = tmp["name"]
|
42
44
|
|
43
|
-
encoded = URI.encode("https://#{username}:#{access_key}@#{
|
45
|
+
encoded = URI.encode("https://#{username}:#{access_key}@#{host}/v2/jobs");
|
44
46
|
|
45
|
-
|
46
|
-
|
47
|
-
|
47
|
+
if !use_https
|
48
|
+
response = JSON.parse(RestClient::Request.execute(
|
49
|
+
:method => :post,
|
50
|
+
:url => encoded,
|
48
51
|
:verify_ssl => false,
|
49
52
|
:accept => "json",
|
50
53
|
:payload => deployment_config,
|
51
54
|
:headers => {"Content-Type" => "application/json"}
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
+
));
|
56
|
+
else
|
57
|
+
if ssl_ca_file.to_s.empty?
|
58
|
+
response = JSON.parse(RestClient::Request.execute(
|
59
|
+
:method => :post,
|
60
|
+
:url => encoded,
|
61
|
+
:accept => "json",
|
62
|
+
:payload => deployment_config,
|
63
|
+
:headers => {"Content-Type" => "application/json"}
|
64
|
+
));
|
65
|
+
else
|
66
|
+
response = JSON.parse(RestClient::Request.execute(
|
67
|
+
:method => :post,
|
68
|
+
:url => encoded,
|
69
|
+
:ssl_ca_file => ssl_ca_file.to_s,
|
70
|
+
:accept => "json",
|
71
|
+
:payload => deployment_config,
|
72
|
+
:headers => {"Content-Type" => "application/json"}
|
73
|
+
));
|
74
|
+
end
|
75
|
+
end
|
55
76
|
|
56
77
|
jobID = response["id"]
|
57
78
|
|
58
|
-
encoded = URI.encode("https://#{username}:#{access_key}@#{
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
79
|
+
encoded = URI.encode("https://#{username}:#{access_key}@#{host}/v2/jobs/#{jobID}");
|
80
|
+
|
81
|
+
if !use_https
|
82
|
+
response = JSON.parse(RestClient::Request.execute(
|
83
|
+
:method => :get,
|
84
|
+
:url => encoded,
|
85
|
+
:verify_ssl => false,
|
86
|
+
:accept => "json"
|
87
|
+
));
|
88
|
+
else
|
89
|
+
if ssl_ca_file.to_s.empty?
|
90
|
+
response = JSON.parse(RestClient::Request.execute(
|
91
|
+
:method => :get,
|
92
|
+
:url => encoded,
|
93
|
+
:accept => "json"
|
94
|
+
));
|
95
|
+
else
|
96
|
+
response = JSON.parse(RestClient::Request.execute(
|
97
|
+
:method => :get,
|
98
|
+
:url => encoded,
|
99
|
+
:accept => "json",
|
100
|
+
:ssl_ca_file => ssl_ca_file.to_s
|
101
|
+
));
|
102
|
+
end
|
103
|
+
end
|
67
104
|
|
68
105
|
rescue => e
|
69
106
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
107
|
+
if e.to_s == "SSL_connect returned=1 errno=0 state=error: certificate verify failed"
|
108
|
+
puts "\n ERROR: Failed to verify certificate\n\n"
|
109
|
+
exit
|
110
|
+
elsif e.to_s == "hostname \"#{host}\" does not match the server certificate"
|
111
|
+
puts "\n ERROR: Hostname \"#{host}\" does not match the server certificate\n\n"
|
112
|
+
exit
|
113
|
+
elsif e.to_s.include? "No route to host"
|
114
|
+
puts "\n ERROR: No route to host. Check connectivity and try again\n\n"
|
115
|
+
exit
|
116
|
+
elsif e.to_s.== "Timed out connecting to server"
|
117
|
+
puts "\n ERROR: Timed out connecting to server. Check connectivity and try again\n\n"
|
118
|
+
exit
|
119
|
+
elsif e.to_s.== "getaddrinfo: nodename nor servname provided, or not known"
|
120
|
+
puts "\n ERROR: Unable to connect to \"#{host}\" \n\n"
|
121
|
+
exit
|
122
|
+
else
|
123
|
+
error = JSON.parse(e.response)
|
124
|
+
code = error["errors"][0]["code"]
|
125
|
+
|
126
|
+
puts "\n Error code: #{error['errors'][0]['code']}\n"
|
127
|
+
puts "\n #{error['errors'][0]['message']}\n\n"
|
128
|
+
|
129
|
+
exit
|
130
|
+
end
|
77
131
|
|
78
132
|
end
|
79
133
|
|
@@ -92,15 +146,31 @@ module VagrantPlugins
|
|
92
146
|
|
93
147
|
jobID = response["id"]
|
94
148
|
|
95
|
-
encoded = URI.encode("https://#{username}:#{access_key}@#{
|
149
|
+
encoded = URI.encode("https://#{username}:#{access_key}@#{host}/v2/jobs/#{jobID}");
|
96
150
|
|
97
|
-
|
151
|
+
if !use_https
|
152
|
+
response = JSON.parse(RestClient::Request.execute(
|
153
|
+
:method => :get,
|
154
|
+
:url => encoded,
|
155
|
+
:verify_ssl => false,
|
156
|
+
:accept => "json"
|
157
|
+
));
|
158
|
+
else
|
159
|
+
if ssl_ca_file.to_s.empty?
|
160
|
+
response = JSON.parse(RestClient::Request.execute(
|
98
161
|
:method => :get,
|
99
162
|
:url => encoded,
|
100
|
-
:verify_ssl => false,
|
101
163
|
:accept => "json"
|
102
|
-
|
103
|
-
|
164
|
+
));
|
165
|
+
else
|
166
|
+
response = JSON.parse(RestClient::Request.execute(
|
167
|
+
:method => :get,
|
168
|
+
:url => encoded,
|
169
|
+
:accept => "json",
|
170
|
+
:ssl_ca_file => ssl_ca_file.to_s
|
171
|
+
));
|
172
|
+
end
|
173
|
+
end
|
104
174
|
|
105
175
|
status = response["status"]
|
106
176
|
|
@@ -117,13 +187,30 @@ module VagrantPlugins
|
|
117
187
|
end
|
118
188
|
|
119
189
|
rescue => e
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
190
|
+
if e.to_s == "SSL_connect returned=1 errno=0 state=error: certificate verify failed"
|
191
|
+
puts "\n ERROR: Failed to verify certificate\n\n"
|
192
|
+
exit
|
193
|
+
elsif e.to_s == "hostname \"#{host}\" does not match the server certificate"
|
194
|
+
puts "\n ERROR: Hostname \"#{host}\" does not match the server certificate\n\n"
|
195
|
+
exit
|
196
|
+
elsif e.to_s.include? "No route to host"
|
197
|
+
puts "\n ERROR: No route to host. Check connectivity and try again\n\n"
|
198
|
+
exit
|
199
|
+
elsif e.to_s.== "Timed out connecting to server"
|
200
|
+
puts "\n ERROR: Timed out connecting to server. Check connectivity and try again\n\n"
|
201
|
+
exit
|
202
|
+
elsif e.to_s.== "getaddrinfo: nodename nor servname provided, or not known"
|
203
|
+
puts "\n ERROR: Unable to connect to \"#{host}\" \n\n"
|
204
|
+
exit
|
205
|
+
else
|
206
|
+
error = JSON.parse(e.response)
|
207
|
+
code = error["errors"][0]["code"]
|
208
|
+
|
209
|
+
puts "\n Error code: #{error['errors'][0]['code']}\n"
|
210
|
+
puts "\n #{error['errors'][0]['message']}\n\n"
|
211
|
+
|
212
|
+
exit
|
213
|
+
end
|
127
214
|
end
|
128
215
|
|
129
216
|
sleep 20
|
@@ -21,46 +21,123 @@ module VagrantPlugins
|
|
21
21
|
end
|
22
22
|
|
23
23
|
access_key = env[:machine].provider_config.access_key
|
24
|
-
|
24
|
+
host = env[:machine].provider_config.host
|
25
25
|
username = env[:machine].provider_config.username
|
26
26
|
|
27
|
+
use_https = env[:machine].provider_config.use_https
|
28
|
+
ssl_ca_file = env[:machine].provider_config.ssl_ca_file
|
29
|
+
|
27
30
|
begin
|
28
|
-
encoded = URI.encode("https://#{username}:#{access_key}@#{
|
29
|
-
|
30
|
-
|
31
|
+
encoded = URI.encode("https://#{username}:#{access_key}@#{host}/v2/jobs?search=[deploymentEntity.name,fle,#{env[:machine_name]}]");
|
32
|
+
|
33
|
+
if !use_https
|
34
|
+
response = JSON.parse(RestClient::Request.execute(
|
31
35
|
:method => :get,
|
32
36
|
:url => encoded,
|
33
37
|
:verify_ssl => false,
|
34
38
|
:accept => "json",
|
35
39
|
:headers => {"Content-Type" => "application/json"}
|
36
40
|
));
|
41
|
+
else
|
42
|
+
if ssl_ca_file.to_s.empty?
|
43
|
+
response = JSON.parse(RestClient::Request.execute(
|
44
|
+
:method => :get,
|
45
|
+
:url => encoded,
|
46
|
+
:accept => "json",
|
47
|
+
:headers => {"Content-Type" => "application/json"}
|
48
|
+
));
|
49
|
+
else
|
50
|
+
response = JSON.parse(RestClient::Request.execute(
|
51
|
+
:method => :get,
|
52
|
+
:url => encoded,
|
53
|
+
:ssl_ca_file => ssl_ca_file.to_s,
|
54
|
+
:accept => "json",
|
55
|
+
:headers => {"Content-Type" => "application/json"}
|
56
|
+
));
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
|
37
62
|
|
38
63
|
if !response["jobs"].empty?
|
39
64
|
jobID = response["jobs"][0]["id"]
|
40
65
|
end
|
41
66
|
|
42
67
|
rescue => e
|
43
|
-
error = JSON.parse(e.response)
|
44
|
-
code = error["errors"][0]["code"]
|
45
68
|
|
46
|
-
|
47
|
-
|
69
|
+
if e.to_s == "SSL_connect returned=1 errno=0 state=error: certificate verify failed"
|
70
|
+
puts "\n ERROR: Failed to verify certificate\n\n"
|
71
|
+
exit
|
72
|
+
elsif e.to_s == "hostname \"#{host}\" does not match the server certificate"
|
73
|
+
puts "\n ERROR: Hostname \"#{host}\" does not match the server certificate\n\n"
|
74
|
+
exit
|
75
|
+
elsif e.to_s.include? "No route to host"
|
76
|
+
puts "\n ERROR: No route to host. Check connectivity and try again\n\n"
|
77
|
+
exit
|
78
|
+
elsif e.to_s.== "Timed out connecting to server"
|
79
|
+
puts "\n ERROR: Timed out connecting to server. Check connectivity and try again\n\n"
|
80
|
+
exit
|
81
|
+
elsif e.to_s.== "getaddrinfo: nodename nor servname provided, or not known"
|
82
|
+
puts "\n ERROR: Unable to connect to \"#{host}\" \n\n"
|
83
|
+
exit
|
84
|
+
else
|
85
|
+
error = JSON.parse(e.response)
|
86
|
+
code = error["errors"][0]["code"]
|
87
|
+
|
88
|
+
puts "\n Error code: #{error['errors'][0]['code']}\n"
|
89
|
+
puts "\n #{error['errors'][0]['message']}\n\n"
|
48
90
|
|
49
|
-
|
91
|
+
exit
|
92
|
+
end
|
50
93
|
end
|
51
94
|
|
52
95
|
if !jobID.nil?
|
53
96
|
begin
|
54
|
-
encoded = URI.encode("https://#{username}:#{access_key}@#{
|
97
|
+
encoded = URI.encode("https://#{username}:#{access_key}@#{host}/v2/jobs/#{jobID}");
|
55
98
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
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
|
62
122
|
|
63
123
|
rescue => e
|
124
|
+
|
125
|
+
if e.to_s == "SSL_connect returned=1 errno=0 state=error: certificate verify failed"
|
126
|
+
puts "\n ERROR: Failed to verify certificate\n\n"
|
127
|
+
exit
|
128
|
+
elsif e.to_s == "hostname \"#{host}\" does not match the server certificate"
|
129
|
+
puts "\n ERROR: Hostname \"#{host}\" does not match the server certificate\n\n"
|
130
|
+
exit
|
131
|
+
elsif e.to_s.include? "No route to host"
|
132
|
+
puts "\n ERROR: No route to host. Check connectivity and try again\n\n"
|
133
|
+
exit
|
134
|
+
elsif e.to_s.== "Timed out connecting to server"
|
135
|
+
puts "\n ERROR: Timed out connecting to server. Check connectivity and try again\n\n"
|
136
|
+
exit
|
137
|
+
elsif e.to_s.== "getaddrinfo: nodename nor servname provided, or not known"
|
138
|
+
puts "\n ERROR: Unable to connect to \"#{host}\" \n\n"
|
139
|
+
exit
|
140
|
+
else
|
64
141
|
error = JSON.parse(e.response)
|
65
142
|
code = error["errors"][0]["code"]
|
66
143
|
|
@@ -68,6 +145,7 @@ module VagrantPlugins
|
|
68
145
|
puts "\n #{error['errors'][0]['message']}\n\n"
|
69
146
|
|
70
147
|
exit
|
148
|
+
end
|
71
149
|
end
|
72
150
|
|
73
151
|
env[:machine_public_ip] = response["accessLink"][7,response.length]
|
@@ -21,49 +21,128 @@ module VagrantPlugins
|
|
21
21
|
end
|
22
22
|
|
23
23
|
access_key = env[:machine].provider_config.access_key
|
24
|
-
|
24
|
+
host = env[:machine].provider_config.host
|
25
25
|
username = env[:machine].provider_config.username
|
26
26
|
|
27
|
+
use_https = env[:machine].provider_config.use_https
|
28
|
+
ssl_ca_file = env[:machine].provider_config.ssl_ca_file
|
29
|
+
|
27
30
|
begin
|
28
|
-
encoded = URI.encode("https://#{username}:#{access_key}@#{
|
29
|
-
|
31
|
+
encoded = URI.encode("https://#{username}:#{access_key}@#{host}/v2/jobs?search=[deploymentEntity.name,fle,#{env[:machine_name]}]");
|
32
|
+
|
33
|
+
if !use_https
|
34
|
+
response = JSON.parse(RestClient::Request.execute(
|
30
35
|
:method => :get,
|
31
36
|
:url => encoded,
|
32
37
|
:verify_ssl => false,
|
33
38
|
:accept => "json",
|
34
39
|
:headers => {"Content-Type" => "application/json"}
|
35
40
|
));
|
41
|
+
else
|
42
|
+
if ssl_ca_file.to_s.empty?
|
43
|
+
response = JSON.parse(RestClient::Request.execute(
|
44
|
+
:method => :get,
|
45
|
+
:url => encoded,
|
46
|
+
:accept => "json",
|
47
|
+
:headers => {"Content-Type" => "application/json"}
|
48
|
+
));
|
49
|
+
else
|
50
|
+
response = JSON.parse(RestClient::Request.execute(
|
51
|
+
:method => :get,
|
52
|
+
:url => encoded,
|
53
|
+
:ssl_ca_file => ssl_ca_file.to_s,
|
54
|
+
:accept => "json",
|
55
|
+
:headers => {"Content-Type" => "application/json"}
|
56
|
+
));
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
|
36
62
|
if !response["jobs"].empty?
|
37
63
|
jobID = response["jobs"][0]["id"]
|
38
64
|
end
|
39
65
|
|
40
66
|
rescue => e
|
41
|
-
error = JSON.parse(e.response)
|
42
|
-
code = error["errors"][0]["code"]
|
43
67
|
|
44
|
-
if
|
45
|
-
puts "\n
|
46
|
-
|
68
|
+
if e.to_s == "SSL_connect returned=1 errno=0 state=error: certificate verify failed"
|
69
|
+
puts "\n ERROR: Failed to verify certificate\n\n"
|
70
|
+
exit
|
71
|
+
elsif e.to_s == "hostname \"#{host}\" does not match the server certificate"
|
72
|
+
puts "\n ERROR: Hostname \"#{host}\" does not match the server certificate\n\n"
|
73
|
+
exit
|
74
|
+
elsif e.to_s.include? "No route to host"
|
75
|
+
puts "\n ERROR: No route to host. Check connectivity and try again\n\n"
|
76
|
+
exit
|
77
|
+
elsif e.to_s.== "Timed out connecting to server"
|
78
|
+
puts "\n ERROR: Timed out connecting to server. Check connectivity and try again\n\n"
|
79
|
+
exit
|
80
|
+
elsif e.to_s.== "getaddrinfo: nodename nor servname provided, or not known"
|
81
|
+
puts "\n ERROR: Unable to connect to \"#{host}\" \n\n"
|
47
82
|
exit
|
48
83
|
else
|
49
|
-
|
50
|
-
|
51
|
-
end
|
84
|
+
error = JSON.parse(e.response)
|
85
|
+
code = error["errors"][0]["code"]
|
52
86
|
|
53
|
-
|
87
|
+
if code == "DEPLOYMENT_STATUS_NOT_VALID_FOR_OPERATION"
|
88
|
+
puts "\n Error code: #{error['errors'][0]['code']}\n"
|
89
|
+
puts "\n #{error['errors'][0]['message']}\n\n"
|
90
|
+
exit
|
91
|
+
else
|
92
|
+
puts "\n Error code: #{error['errors'][0]['code']}\n"
|
93
|
+
puts "\n #{error['errors'][0]['message']}\n\n"
|
94
|
+
end
|
95
|
+
|
96
|
+
exit
|
97
|
+
end
|
98
|
+
|
54
99
|
end
|
55
100
|
|
56
101
|
if !jobID.nil?
|
57
102
|
begin
|
58
|
-
encoded = URI.encode("https://#{username}:#{access_key}@#{
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
103
|
+
encoded = URI.encode("https://#{username}:#{access_key}@#{host}/v2/jobs/#{jobID}");
|
104
|
+
|
105
|
+
if !use_https
|
106
|
+
response = JSON.parse(RestClient::Request.execute(
|
107
|
+
:method => :get,
|
108
|
+
:url => encoded,
|
109
|
+
:verify_ssl => false,
|
110
|
+
:accept => "json"
|
111
|
+
));
|
112
|
+
else
|
113
|
+
if ssl_ca_file.to_s.empty?
|
114
|
+
response = JSON.parse(RestClient::Request.execute(
|
115
|
+
:method => :get,
|
116
|
+
:url => encoded,
|
117
|
+
:accept => "json"
|
118
|
+
));
|
119
|
+
else
|
120
|
+
response = JSON.parse(RestClient::Request.execute(
|
121
|
+
:method => :get,
|
122
|
+
:url => encoded,
|
123
|
+
:ssl_ca_file => ssl_ca_file.to_s,
|
124
|
+
:accept => "json"
|
125
|
+
));
|
126
|
+
end
|
127
|
+
end
|
65
128
|
|
66
129
|
rescue => e
|
130
|
+
if e.to_s == "SSL_connect returned=1 errno=0 state=error: certificate verify failed"
|
131
|
+
puts "\n ERROR: Failed to verify certificate\n\n"
|
132
|
+
exit
|
133
|
+
elsif e.to_s == "hostname \"#{host}\" does not match the server certificate"
|
134
|
+
puts "\n ERROR: Hostname \"#{host}\" does not match the server certificate\n\n"
|
135
|
+
exit
|
136
|
+
elsif e.to_s.include? "No route to host"
|
137
|
+
puts "\n ERROR: No route to host. Check connectivity and try again\n\n"
|
138
|
+
exit
|
139
|
+
elsif e.to_s.== "Timed out connecting to server"
|
140
|
+
puts "\n ERROR: Timed out connecting to server. Check connectivity and try again\n\n"
|
141
|
+
exit
|
142
|
+
elsif e.to_s.== "getaddrinfo: nodename nor servname provided, or not known"
|
143
|
+
puts "\n ERROR: Unable to connect to \"#{host}\" \n\n"
|
144
|
+
exit
|
145
|
+
else
|
67
146
|
error = JSON.parse(e.response)
|
68
147
|
code = error["errors"][0]["code"]
|
69
148
|
|
@@ -77,6 +156,7 @@ module VagrantPlugins
|
|
77
156
|
end
|
78
157
|
|
79
158
|
exit
|
159
|
+
end
|
80
160
|
end
|
81
161
|
|
82
162
|
if response["deploymentEntity"]["attributes"]["health"] == "Healthy"
|