vcli 0.2.5 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/console +0 -0
- data/bin/setup +0 -0
- data/bin/vcli +0 -0
- data/lib/vcli/cli.rb +174 -58
- data/lib/vcli/cli/create.rb +47 -38
- data/lib/vcli/cli/delete.rb +6 -12
- data/lib/vcli/cli/show.rb +8 -23
- data/lib/vcli/version.rb +3 -2
- metadata +19 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 46c3b42fcb446f735257bda7f13025ec65f2b697
|
4
|
+
data.tar.gz: edea7f33a1cf74778c4587253eb63e58d31056e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 72973dbf8cccb3b7d9a5760782feaaeaa28ba7fca09d2e3a6eccd77b9676b3d9fed6aba30bd5753f0441d590523fe8a8e762a7166489162e195cac9ea4d25fae
|
7
|
+
data.tar.gz: f3e513398d4897c1e0fad293133bf5e9469c6df69bdf3f34ac9a91ef617b2e678caadd740891cfed670cd41d6551d758f986eef4319bc2067d3778353042a01d
|
data/bin/console
CHANGED
File without changes
|
data/bin/setup
CHANGED
File without changes
|
data/bin/vcli
CHANGED
File without changes
|
data/lib/vcli/cli.rb
CHANGED
@@ -55,7 +55,7 @@ module Vcli
|
|
55
55
|
rescue AbiquoAPIClient::BadRequest
|
56
56
|
puts "Bad Request - HTTP 400 or 406 Received"
|
57
57
|
rescue AbiquoAPIClient::NotFound
|
58
|
-
puts "
|
58
|
+
puts "Not Found - HTTP 400 Received"
|
59
59
|
rescue AbiquoAPIClient::UnsupportedMediaType
|
60
60
|
puts "Unsupported Media Type Specified - HTTP 415 Received"
|
61
61
|
end
|
@@ -85,25 +85,166 @@ module Vcli
|
|
85
85
|
method_option :va, :type => :string, :required => true
|
86
86
|
method_option :vdc, :type => :string, :required => true
|
87
87
|
def deploy()
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
88
|
+
begin
|
89
|
+
abq = AbiquoAPI.new(:abiquo_api_url => Vcli::target, :abiquo_username => Vcli::user, :abiquo_password => Vcli::password)
|
90
|
+
# If --vm parameter passed
|
91
|
+
vdc=options[:vdc].to_s
|
92
|
+
va=options[:va].to_s
|
93
|
+
vm=options[:vm].to_s
|
94
|
+
if vm.length != 0
|
95
|
+
# if Virtual Machine Specified
|
96
|
+
link=AbiquoAPI::Link.new(:href => 'api/cloud/virtualdatacenters/' + vdc + '/virtualappliances/' + va + '/virtualmachines/' + vm + '/action/deploy',
|
97
|
+
:type => 'application/vnd.abiquo.acceptedrequest+json')
|
98
|
+
reqdata=Hash.new
|
99
|
+
response=abq.post(link,reqdata)
|
100
|
+
puts "Deploying Virtual Machine"
|
101
|
+
puts "Waiting for VM to be deployed"
|
102
|
+
status=response.link(:status).get
|
103
|
+
while status.state == "STARTED" && status.state != "LOCKED" do
|
104
|
+
status=response.link(:status).get
|
105
|
+
print "."
|
106
|
+
sleep 10
|
107
|
+
end
|
108
|
+
else
|
109
|
+
# If no Virtual Machine specified its a Virtual Appliance
|
110
|
+
link=AbiquoAPI::Link.new(:href => 'api/cloud/virtualdatacenters/' + vdc + '/virtualappliances/' + va + '/action/deploy')
|
111
|
+
reqdata=Hash.new
|
112
|
+
response=abq.post(link,reqdata)
|
113
|
+
puts "Deploying Virtual Appliance"
|
114
|
+
puts "Waiting for VA to be Deployed"
|
115
|
+
end
|
116
|
+
|
117
|
+
rescue AbiquoAPIClient::Forbidden
|
118
|
+
puts "Forbidden HTTP 403 Received"
|
119
|
+
rescue AbiquoAPIClient::InvalidCredentials
|
120
|
+
puts "Invalid Credentials - HTTP 401 Received"
|
121
|
+
rescue AbiquoAPIClient::BadRequest => e
|
122
|
+
puts "Bad Request - HTTP 400 or 406 Received"
|
123
|
+
puts e.inspect
|
124
|
+
rescue AbiquoAPIClient::NotFound
|
125
|
+
puts "Not Found - HTTP 400 Received"
|
126
|
+
rescue AbiquoAPIClient::UnsupportedMediaType
|
127
|
+
puts "Unsupported Media Type Specified - HTTP 415 Received"
|
128
|
+
end
|
129
|
+
end
|
102
130
|
|
131
|
+
|
132
|
+
desc "poweroff",
|
133
|
+
"poweroff [required]--vm=<virtualmachine id>
|
134
|
+
[required] --va=<virtualappliance id>
|
135
|
+
[required] --vdc=<vdc id>"
|
136
|
+
method_option :vm, :type => :string, :required =>true
|
137
|
+
method_option :va, :type => :string, :required => true
|
138
|
+
method_option :vdc, :type => :string, :required => true
|
139
|
+
def poweroff()
|
140
|
+
begin
|
141
|
+
abq = AbiquoAPI.new(:abiquo_api_url => Vcli::target, :abiquo_username => Vcli::user, :abiquo_password => Vcli::password)
|
142
|
+
vdc=options[:vdc].to_s
|
143
|
+
va=options[:va].to_s
|
144
|
+
vm=options[:vm].to_s
|
145
|
+
link=AbiquoAPI::Link.new(:href => 'api/cloud/virtualdatacenters/' + vdc + '/virtualappliances/' + va + '/virtualmachines/' + vm + '/state',
|
146
|
+
:type => 'application/vnd.abiquo.virtualmachinestate+json')
|
147
|
+
reqdata=Hash.new
|
148
|
+
reqdata[:state]= "OFF"
|
149
|
+
reqoptions=Hash.new
|
150
|
+
reqoptions[:accept] = 'application/vnd.abiquo.acceptedrequest+json'
|
151
|
+
print "Powering Off VM."
|
152
|
+
tries ||= 3
|
153
|
+
begin
|
154
|
+
response=abq.put(link,reqdata,reqoptions)
|
155
|
+
status=response.link(:status).get
|
156
|
+
while status.state == "STARTED" && status.state != "LOCKED" do
|
157
|
+
status=response.link(:status).get
|
158
|
+
print "."
|
159
|
+
sleep 10
|
160
|
+
end
|
161
|
+
rescue Exception=> e
|
162
|
+
retry unless (tries -= 1).zero?
|
163
|
+
end
|
164
|
+
puts
|
165
|
+
puts "VM Powered Off"
|
166
|
+
rescue AbiquoAPIClient::Forbidden
|
167
|
+
puts "Forbidden HTTP 403 Received"
|
168
|
+
rescue AbiquoAPIClient::InvalidCredentials
|
169
|
+
puts "Invalid Credentials - HTTP 401 Received"
|
170
|
+
rescue AbiquoAPIClient::BadRequest => e
|
171
|
+
puts "Bad Request - HTTP 400 or 406 Received"
|
172
|
+
puts e.inspect
|
173
|
+
rescue AbiquoAPIClient::NotFound
|
174
|
+
puts "Not Found - HTTP 400 Received"
|
175
|
+
rescue AbiquoAPIClient::UnsupportedMediaType
|
176
|
+
puts "Unsupported Media Type Specified - HTTP 415 Received"
|
103
177
|
end
|
104
|
-
response=abq.post(link,"{}")
|
105
178
|
end
|
106
|
-
|
179
|
+
|
180
|
+
desc "poweron",
|
181
|
+
"poweron [required]--vm=<virtualmachine id>
|
182
|
+
[required] --va=<virtualappliance id>
|
183
|
+
[required] --vdc=<vdc id>"
|
184
|
+
method_option :vm, :type => :string, :required =>true
|
185
|
+
method_option :va, :type => :string, :required => true
|
186
|
+
method_option :vdc, :type => :string, :required => true
|
187
|
+
def poweron()
|
188
|
+
begin
|
189
|
+
abq = AbiquoAPI.new(:abiquo_api_url => Vcli::target, :abiquo_username => Vcli::user, :abiquo_password => Vcli::password)
|
190
|
+
vdc=options[:vdc].to_s
|
191
|
+
va=options[:va].to_s
|
192
|
+
vm=options[:vm].to_s
|
193
|
+
link=AbiquoAPI::Link.new(:href => 'api/cloud/virtualdatacenters/' + vdc + '/virtualappliances/' + va + '/virtualmachines/' + vm + '/state',
|
194
|
+
:type => 'application/vnd.abiquo.virtualmachinestate+json')
|
195
|
+
reqdata=Hash.new
|
196
|
+
reqdata[:state]= "ON"
|
197
|
+
reqoptions=Hash.new
|
198
|
+
reqoptions[:accept] = 'application/vnd.abiquo.acceptedrequest+json'
|
199
|
+
abq.put(link,reqdata,reqoptions)
|
200
|
+
puts "VM Powered On"
|
201
|
+
rescue AbiquoAPIClient::Forbidden
|
202
|
+
puts "Forbidden HTTP 403 Received"
|
203
|
+
rescue AbiquoAPIClient::InvalidCredentials
|
204
|
+
puts "Invalid Credentials - HTTP 401 Received"
|
205
|
+
rescue AbiquoAPIClient::BadRequest => e
|
206
|
+
puts "Bad Request - HTTP 400 or 406 Received"
|
207
|
+
puts e.inspect
|
208
|
+
rescue AbiquoAPIClient::NotFound
|
209
|
+
puts "Not Found - HTTP 400 Received"
|
210
|
+
rescue AbiquoAPIClient::UnsupportedMediaType
|
211
|
+
puts "Unsupported Media Type Specified - HTTP 415 Received"
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
215
|
+
desc "reset",
|
216
|
+
"reset [required]--vm=<virtualmachine id>
|
217
|
+
[required] --va=<virtualappliance id>
|
218
|
+
[required] --vdc=<vdc id>"
|
219
|
+
method_option :vm, :type => :string, :required =>true
|
220
|
+
method_option :va, :type => :string, :required => true
|
221
|
+
method_option :vdc, :type => :string, :required => true
|
222
|
+
def reset()
|
223
|
+
begin
|
224
|
+
abq = AbiquoAPI.new(:abiquo_api_url => Vcli::target, :abiquo_username => Vcli::user, :abiquo_password => Vcli::password)
|
225
|
+
# If --vm parameter passed
|
226
|
+
vdc=options[:vdc].to_s
|
227
|
+
va=options[:va].to_s
|
228
|
+
vm=options[:vm].to_s
|
229
|
+
link=AbiquoAPI::Link.new(:href => 'api/cloud/virtualdatacenters/' + vdc + '/virtualappliances/' + va + '/virtualmachines/' + vm + '/action/reset',
|
230
|
+
:type => 'application/vnd.abiquo.acceptedrequest+json')
|
231
|
+
reqdata=Hash.new
|
232
|
+
abq.post(link,reqdata)
|
233
|
+
puts "VM Reset"
|
234
|
+
rescue AbiquoAPIClient::Forbidden
|
235
|
+
puts "Forbidden HTTP 403 Received"
|
236
|
+
rescue AbiquoAPIClient::InvalidCredentials
|
237
|
+
puts "Invalid Credentials - HTTP 401 Received"
|
238
|
+
rescue AbiquoAPIClient::BadRequest => e
|
239
|
+
puts "Bad Request - HTTP 400 or 406 Received"
|
240
|
+
puts e.inspect
|
241
|
+
rescue AbiquoAPIClient::NotFound
|
242
|
+
puts "Not Found - HTTP 400 Received"
|
243
|
+
rescue AbiquoAPIClient::UnsupportedMediaType
|
244
|
+
puts "Unsupported Media Type Specified - HTTP 415 Received"
|
245
|
+
end
|
246
|
+
end
|
247
|
+
|
107
248
|
desc "undeploy",
|
108
249
|
"undeploy [optional] --vm=<virtualmachine id>
|
109
250
|
[required] --va=<virtualappliance id>
|
@@ -114,9 +255,7 @@ module Vcli
|
|
114
255
|
method_option :force, :type => :boolean
|
115
256
|
def undeploy()
|
116
257
|
begin
|
117
|
-
abq = AbiquoAPI.new(:abiquo_api_url => Vcli::target,
|
118
|
-
:abiquo_username => Vcli::user,
|
119
|
-
:abiquo_password => Vcli::password)
|
258
|
+
abq = AbiquoAPI.new(:abiquo_api_url => Vcli::target, :abiquo_username => Vcli::user, :abiquo_password => Vcli::password)
|
120
259
|
# If --vm parameter passed
|
121
260
|
vdc=options[:vdc].to_s
|
122
261
|
va=options[:va].to_s
|
@@ -127,9 +266,8 @@ module Vcli
|
|
127
266
|
if force
|
128
267
|
forcerequest[:forceUndeploy]=true
|
129
268
|
else
|
130
|
-
forcerequest[:forceUndeploy]=false
|
131
|
-
end
|
132
|
-
|
269
|
+
forcerequest[:forceUndeploy]=false
|
270
|
+
end
|
133
271
|
request[:virtualmachinetask]=forcerequest
|
134
272
|
if vm.length != 0
|
135
273
|
# if Virtual Machine Specified
|
@@ -143,41 +281,19 @@ module Vcli
|
|
143
281
|
end
|
144
282
|
reqoptions=Hash.new
|
145
283
|
reqoptions[:accept] = 'application/vnd.abiquo.acceptedrequest+json'
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
end
|
160
|
-
|
161
|
-
desc "poweron",
|
162
|
-
"poweron [optional] --vm=<virtualmachine id>
|
163
|
-
[required] --va=<virtualappliance id>
|
164
|
-
[required] --vdc=<vdc id>"
|
165
|
-
method_option :virtualmachine, :type => :string, :aliases => "-vm"
|
166
|
-
method_option :virtualappliance, :type => :string, :aliases => "-va", :required => true
|
167
|
-
method_option :vdc, :type => :string, :required => true
|
168
|
-
def poweron()
|
169
|
-
#TODO
|
170
|
-
end
|
171
|
-
|
172
|
-
desc "poweroff",
|
173
|
-
"poweroff [optional] --vm=<virtualmachine id>
|
174
|
-
[required] --va=<virtualappliance id>
|
175
|
-
[required] --vdc=<vdc id>"
|
176
|
-
method_option :virtualmachine, :type => :string, :aliases => "-vm"
|
177
|
-
method_option :virtualappliance, :type => :string, :aliases => "-va", :required => true
|
178
|
-
method_option :vdc, :type => :string, :required => true
|
179
|
-
def poweroff()
|
180
|
-
#TODO
|
284
|
+
abq.post(link,request,reqoptions)
|
285
|
+
rescue AbiquoAPIClient::Forbidden
|
286
|
+
puts "Forbidden HTTP 403 Received"
|
287
|
+
rescue AbiquoAPIClient::InvalidCredentials
|
288
|
+
puts "Invalid Credentials - HTTP 401 Received"
|
289
|
+
rescue AbiquoAPIClient::BadRequest => e
|
290
|
+
puts "Bad Request - HTTP 400 or 406 Received"
|
291
|
+
puts e.inspect
|
292
|
+
rescue AbiquoAPIClient::NotFound
|
293
|
+
puts "Not Found - HTTP 400 Received"
|
294
|
+
rescue AbiquoAPIClient::UnsupportedMediaType
|
295
|
+
puts "Unsupported Media Type Specified - HTTP 415 Received"
|
296
|
+
end
|
181
297
|
end
|
182
298
|
end
|
183
299
|
end
|
data/lib/vcli/cli/create.rb
CHANGED
@@ -18,9 +18,7 @@ module Vcli
|
|
18
18
|
desc "create virtualappliance", "create virtualappliance <name> <vdc>"
|
19
19
|
def virtualappliance(name,vdc)
|
20
20
|
begin
|
21
|
-
abq = AbiquoAPI.new(:abiquo_api_url => Vcli::target,
|
22
|
-
:abiquo_username => Vcli::user,
|
23
|
-
:abiquo_password => Vcli::password)
|
21
|
+
abq = AbiquoAPI.new(:abiquo_api_url => Vcli::target, :abiquo_username => Vcli::user, :abiquo_password => Vcli::password)
|
24
22
|
link=AbiquoAPI::Link.new(:href => 'api/cloud/virtualdatacenters/' + vdc + '/virtualappliances' ,
|
25
23
|
:type => 'application/vnd.abiquo.virtualappliance+json')
|
26
24
|
newvirtualappliance={name: name}
|
@@ -42,9 +40,7 @@ module Vcli
|
|
42
40
|
desc "create vlan", "create vlan <name> <address> <mask> <gateway> <vdc id>"
|
43
41
|
def vlan(name, address, mask, gateway, vdc)
|
44
42
|
begin
|
45
|
-
abq = AbiquoAPI.new(:abiquo_api_url => Vcli::target,
|
46
|
-
:abiquo_username => Vcli::user,
|
47
|
-
:abiquo_password => Vcli::password)
|
43
|
+
abq = AbiquoAPI.new(:abiquo_api_url => Vcli::target, :abiquo_username => Vcli::user, :abiquo_password => Vcli::password)
|
48
44
|
link=AbiquoAPI::Link.new(:href => 'api/cloud/virtualdatacenters/' + vdc + '/privatenetworks' ,
|
49
45
|
:type => 'application/vnd.abiquo.vlan+json')
|
50
46
|
# TODO Check the limits before creating new VLAN
|
@@ -70,26 +66,15 @@ module Vcli
|
|
70
66
|
end
|
71
67
|
|
72
68
|
desc "create virtualmachine", "create virtualmachine <name> <template id> <vdc id> <virtualappliance id>"
|
73
|
-
method_option :cpu,
|
74
|
-
|
75
|
-
|
76
|
-
method_option :
|
77
|
-
|
78
|
-
|
79
|
-
method_option :description,
|
80
|
-
:type => :string,
|
81
|
-
:aliases => "-d"
|
82
|
-
method_option :password,
|
83
|
-
:type => :string,
|
84
|
-
:aliases => "-p"
|
69
|
+
method_option :cpu, :type => :string, :aliases => "-t"
|
70
|
+
method_option :ram, :type => :string, :aliases => "-r"
|
71
|
+
method_option :description, :type => :string, :aliases => "-d"
|
72
|
+
method_option :password, :type => :string, :aliases => "-p"
|
73
|
+
method_option :ip, :type => :string, :aliases => "-i"
|
74
|
+
method_option :vlan, :type => :string, :aliases => "-v"
|
85
75
|
def virtualmachine(name, template, vdc, va)
|
86
76
|
begin
|
87
|
-
|
88
|
-
abq = AbiquoAPI.new(:abiquo_api_url => Vcli::target,
|
89
|
-
:abiquo_username => Vcli::user,
|
90
|
-
:abiquo_password => Vcli::password)
|
91
|
-
|
92
|
-
|
77
|
+
abq = AbiquoAPI.new(:abiquo_api_url => Vcli::target, :abiquo_username => Vcli::user, :abiquo_password => Vcli::password)
|
93
78
|
# Link to post
|
94
79
|
link=AbiquoAPI::Link.new(:href => 'api/cloud/virtualdatacenters/' + vdc + '/virtualappliances/' + va + '/virtualmachines' ,
|
95
80
|
:type => 'application/vnd.abiquo.virtualmachine+json')
|
@@ -113,29 +98,54 @@ module Vcli
|
|
113
98
|
}
|
114
99
|
newvirtualmachine[:label]=linkhash[:title]
|
115
100
|
newvirtualmachine[:label]=name
|
116
|
-
#link2hash["0"]=linkhash
|
117
101
|
arrayforlinks=Array.new
|
118
102
|
arrayforlinks[0]=link2hash
|
119
103
|
newvirtualmachine[:links]=arrayforlinks
|
120
104
|
cpu=options[:cpu].to_s
|
121
|
-
if cpu.length >0
|
122
|
-
newvirtualmachine[:cpu]= cpu
|
123
|
-
end
|
124
105
|
ram=options[:ram].to_s
|
125
|
-
if ram.length >0
|
126
|
-
newvirtualmachine[:ram]= ram
|
127
|
-
end
|
128
106
|
description=options[:description].to_s
|
129
|
-
if description.length >0
|
130
|
-
newvirtualmachine[:description]= description
|
131
|
-
end
|
132
107
|
password=options[:password].to_s
|
133
|
-
|
134
|
-
|
135
|
-
|
108
|
+
ip=options[:ip].to_s
|
109
|
+
vlan=options[:vlan].to_s
|
110
|
+
newvirtualmachine[:cpu]= cpu if cpu.length >0
|
111
|
+
newvirtualmachine[:ram]= ram if ram.length >0
|
112
|
+
newvirtualmachine[:description]= description if description.length >0
|
113
|
+
newvirtualmachine[:password]=password if password.length >0
|
136
114
|
newvirtualmachine[:vdrpEnabled]=true
|
115
|
+
# Create VirtualMachine
|
137
116
|
response=abq.post(link,newvirtualmachine)
|
138
117
|
puts "ID for Virtual Machine - #{response.id}"
|
118
|
+
system("vcli deploy --vdc=#{vdc} --va=#{va} --vm=#{response.id}")
|
119
|
+
sleep 20
|
120
|
+
puts
|
121
|
+
system("vcli poweroff --vdc=#{vdc} --va=#{va} --vm=#{response.id}")
|
122
|
+
puts
|
123
|
+
|
124
|
+
# Link to get put modified machine
|
125
|
+
link4=AbiquoAPI::Link.new(:href => 'api/cloud/virtualdatacenters/' + vdc + '/virtualappliances/' + va + '/virtualmachines/' + response.id.to_s ,
|
126
|
+
:type => 'application/vnd.abiquo.virtualmachine+json',
|
127
|
+
:client => abq)
|
128
|
+
# Private IPS in VLAN
|
129
|
+
link5=AbiquoAPI::Link.new(:href => 'api/cloud/virtualdatacenters/' + vdc + '/privatenetworks/' + vlan + '/ips',
|
130
|
+
:type => 'application/vnd.abiquo.privateips+json',
|
131
|
+
:client => abq)
|
132
|
+
listofips=abq.list(link5)
|
133
|
+
listofips.each { |m|
|
134
|
+
if m.ip == ip
|
135
|
+
if !m.has_link?(:virtualmachine)
|
136
|
+
url=m.url
|
137
|
+
break
|
138
|
+
else
|
139
|
+
puts "IP Address already allocated"
|
140
|
+
exit 1
|
141
|
+
end
|
142
|
+
end
|
143
|
+
}
|
144
|
+
reqoptions=Hash.new
|
145
|
+
reqoptions[:accept] = 'application/vnd.abiquo.acceptedrequest+json'
|
146
|
+
virtualmachine2=abq.get(link4)
|
147
|
+
puts virtualmachine2.to_yaml
|
148
|
+
response=abq.put(link4,virtualmachine2,reqoptions)
|
139
149
|
rescue AbiquoAPIClient::Forbidden
|
140
150
|
puts "Forbidden HTTP 403 Received"
|
141
151
|
rescue AbiquoAPIClient::InvalidCredentials
|
@@ -150,7 +160,6 @@ module Vcli
|
|
150
160
|
puts "Error - "+ e.message
|
151
161
|
end
|
152
162
|
end
|
153
|
-
|
154
163
|
end
|
155
164
|
end
|
156
165
|
end
|
data/lib/vcli/cli/delete.rb
CHANGED
@@ -18,12 +18,10 @@ module Vcli
|
|
18
18
|
desc "delete virtualappliance", "delete virtualappliance <virtualappliance id> <vdc id>"
|
19
19
|
def virtualappliance(id,vdc)
|
20
20
|
begin
|
21
|
-
abq = AbiquoAPI.new(:abiquo_api_url => Vcli::target,
|
22
|
-
:abiquo_username => Vcli::user,
|
23
|
-
:abiquo_password => Vcli::password)
|
21
|
+
abq = AbiquoAPI.new(:abiquo_api_url => Vcli::target, :abiquo_username => Vcli::user, :abiquo_password => Vcli::password)
|
24
22
|
link=AbiquoAPI::Link.new(:href => 'api/cloud/virtualdatacenters/' + vdc + '/virtualappliances/' + id ,
|
25
23
|
:type => 'application/vnd.abiquo.virtualappliance+json')
|
26
|
-
|
24
|
+
abq.delete(link)
|
27
25
|
rescue AbiquoAPIClient::Forbidden
|
28
26
|
puts "Forbidden HTTP 403 Received"
|
29
27
|
rescue AbiquoAPIClient::InvalidCredentials
|
@@ -40,12 +38,10 @@ module Vcli
|
|
40
38
|
desc "delete vlan", "delete vlan <vlan id> <vdc id>"
|
41
39
|
def vlan(id,vdc)
|
42
40
|
begin
|
43
|
-
abq = AbiquoAPI.new(:abiquo_api_url => Vcli::target,
|
44
|
-
:abiquo_username => Vcli::user,
|
45
|
-
:abiquo_password => Vcli::password)
|
41
|
+
abq = AbiquoAPI.new(:abiquo_api_url => Vcli::target, :abiquo_username => Vcli::user, :abiquo_password => Vcli::password)
|
46
42
|
link=AbiquoAPI::Link.new(:href => 'api/cloud/virtualdatacenters/' + vdc + '/privatenetworks/' + id ,
|
47
43
|
:type => 'application/vnd.abiquo.vlan+json')
|
48
|
-
|
44
|
+
abq.delete(link)
|
49
45
|
puts "VLAN Deleted"
|
50
46
|
rescue AbiquoAPIClient::Forbidden
|
51
47
|
puts "Forbidden HTTP 403 Received"
|
@@ -65,12 +61,10 @@ module Vcli
|
|
65
61
|
desc "delete virtualmachine", "delete virtualmachine <virtualmachine id> <virtualappliance id> <vdc id>"
|
66
62
|
def virtualmachine(vm, va, vdc)
|
67
63
|
begin
|
68
|
-
abq = AbiquoAPI.new(:abiquo_api_url => Vcli::target,
|
69
|
-
:abiquo_username => Vcli::user,
|
70
|
-
:abiquo_password => Vcli::password)
|
64
|
+
abq = AbiquoAPI.new(:abiquo_api_url => Vcli::target, :abiquo_username => Vcli::user, :abiquo_password => Vcli::password)
|
71
65
|
link=AbiquoAPI::Link.new(:href => 'api/cloud/virtualdatacenters/' + vdc + '/virtualappliances/' + va + '/virtualmachines/' + vm,
|
72
66
|
:type => 'application/vnd.abiquo.virtualmachine+json')
|
73
|
-
|
67
|
+
abq.delete(link)
|
74
68
|
puts "VM Deleted"
|
75
69
|
rescue AbiquoAPIClient::Forbidden
|
76
70
|
puts "Forbidden HTTP 403 Received"
|
data/lib/vcli/cli/show.rb
CHANGED
@@ -52,9 +52,7 @@ module Vcli
|
|
52
52
|
method_option :vdc, :type => :string
|
53
53
|
def virtualappliances( )
|
54
54
|
begin
|
55
|
-
abq = AbiquoAPI.new(:abiquo_api_url => Vcli::target,
|
56
|
-
:abiquo_username => Vcli::user,
|
57
|
-
:abiquo_password => Vcli::password)
|
55
|
+
abq = AbiquoAPI.new(:abiquo_api_url => Vcli::target, :abiquo_username => Vcli::user, :abiquo_password => Vcli::password)
|
58
56
|
# Get something on the screen
|
59
57
|
puts "VDC,Appliance Name,Appliance ID"
|
60
58
|
# If --vdc parameter passed
|
@@ -103,9 +101,7 @@ module Vcli
|
|
103
101
|
method_option :free, :type => :boolean, :default => false
|
104
102
|
def vlans( )
|
105
103
|
begin
|
106
|
-
abq = AbiquoAPI.new(:abiquo_api_url => Vcli::target,
|
107
|
-
:abiquo_username => Vcli::user,
|
108
|
-
:abiquo_password => Vcli::password)
|
104
|
+
abq = AbiquoAPI.new(:abiquo_api_url => Vcli::target, :abiquo_username => Vcli::user, :abiquo_password => Vcli::password)
|
109
105
|
# Get something on the screen
|
110
106
|
puts "VLAN ID,VLAN Name,VDC ID,Network,Mask,Gateway"
|
111
107
|
# If --vdc parameter passed
|
@@ -151,9 +147,8 @@ module Vcli
|
|
151
147
|
end
|
152
148
|
}
|
153
149
|
end
|
154
|
-
|
155
150
|
}
|
156
|
-
# If no --vdc parameter
|
151
|
+
# If no --vdc parameter passed
|
157
152
|
else
|
158
153
|
# Cycle through all virtualdatacenters
|
159
154
|
link=AbiquoAPI::Link.new(:href => 'api/cloud/virtualdatacenters',
|
@@ -186,9 +181,7 @@ module Vcli
|
|
186
181
|
desc "show users", "Show all users within your account"
|
187
182
|
def users( )
|
188
183
|
begin
|
189
|
-
abq = AbiquoAPI.new(:abiquo_api_url => Vcli::target,
|
190
|
-
:abiquo_username => Vcli::user,
|
191
|
-
:abiquo_password => Vcli::password)
|
184
|
+
abq = AbiquoAPI.new(:abiquo_api_url => Vcli::target, :abiquo_username => Vcli::user, :abiquo_password => Vcli::password)
|
192
185
|
abq.user
|
193
186
|
ent=abq.user.link(:enterprise).get
|
194
187
|
link=AbiquoAPI::Link.new(:href => 'api/admin/enterprises/'+ent.id.to_s + '/users',
|
@@ -216,9 +209,7 @@ module Vcli
|
|
216
209
|
method_option :ent, :type => :string
|
217
210
|
def enterprise( )
|
218
211
|
begin
|
219
|
-
abq = AbiquoAPI.new(:abiquo_api_url => Vcli::target,
|
220
|
-
:abiquo_username => Vcli::user,
|
221
|
-
:abiquo_password => Vcli::password)
|
212
|
+
abq = AbiquoAPI.new(:abiquo_api_url => Vcli::target, :abiquo_username => Vcli::user, :abiquo_password => Vcli::password)
|
222
213
|
ent=options[:ent].to_s
|
223
214
|
if ent.length == 0
|
224
215
|
link=AbiquoAPI::Link.new(:href => 'api/admin/enterprises',
|
@@ -266,9 +257,7 @@ module Vcli
|
|
266
257
|
desc "show templates", "show templates --vdc=<vdc id>"
|
267
258
|
method_option :vdc, :type => :string, :required => true
|
268
259
|
def templates( )
|
269
|
-
abq = AbiquoAPI.new(:abiquo_api_url => Vcli::target,
|
270
|
-
:abiquo_username => Vcli::user,
|
271
|
-
:abiquo_password => Vcli::password)
|
260
|
+
abq = AbiquoAPI.new(:abiquo_api_url => Vcli::target, :abiquo_username => Vcli::user, :abiquo_password => Vcli::password)
|
272
261
|
vdc=options[:vdc].to_s
|
273
262
|
link=AbiquoAPI::Link.new(:href => 'api/cloud/virtualdatacenters/' + vdc + '/action/templates',
|
274
263
|
:type => 'application/vnd.abiquo.virtualmachinetemplates+json',
|
@@ -287,9 +276,7 @@ module Vcli
|
|
287
276
|
method_option :vdc, :type => :string
|
288
277
|
def virtualdatacenters( )
|
289
278
|
begin
|
290
|
-
abq = AbiquoAPI.new(:abiquo_api_url => Vcli::target,
|
291
|
-
:abiquo_username => Vcli::user,
|
292
|
-
:abiquo_password => Vcli::password)
|
279
|
+
abq = AbiquoAPI.new(:abiquo_api_url => Vcli::target, :abiquo_username => Vcli::user, :abiquo_password => Vcli::password)
|
293
280
|
vdc=options[:vdc].to_s
|
294
281
|
if vdc.length==0
|
295
282
|
link=AbiquoAPI::Link.new(:href => 'api/cloud/virtualdatacenters',
|
@@ -338,9 +325,7 @@ module Vcli
|
|
338
325
|
method_option :vdc, :type => :string
|
339
326
|
def virtualmachines( )
|
340
327
|
begin
|
341
|
-
abq = AbiquoAPI.new(:abiquo_api_url => Vcli::target,
|
342
|
-
:abiquo_username => Vcli::user,
|
343
|
-
:abiquo_password => Vcli::password)
|
328
|
+
abq = AbiquoAPI.new(:abiquo_api_url => Vcli::target, :abiquo_username => Vcli::user, :abiquo_password => Vcli::password)
|
344
329
|
# If --vdc parameter passed
|
345
330
|
va=options[:va].to_s
|
346
331
|
vdc=options[:vdc].to_s
|
data/lib/vcli/version.rb
CHANGED
@@ -21,8 +21,9 @@ module Vcli
|
|
21
21
|
#################################################################
|
22
22
|
# 0.2.5 #31072015# Added deploy and undeploy for virtualappliance
|
23
23
|
# # # and virtualmachines
|
24
|
+
#################################################################
|
25
|
+
# 0.2.6 #05082015# Added create virtualmachine
|
24
26
|
#################################################################
|
25
27
|
|
26
|
-
|
27
|
-
VERSION = "0.2.5"
|
28
|
+
VERSION = "0.2.6"
|
28
29
|
end
|
metadata
CHANGED
@@ -1,55 +1,55 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vcli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jay Fearn
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-08-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.10'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.10'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ~>
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '10.0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ~>
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '10.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: minitest
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ~>
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '5'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ~>
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '5'
|
55
55
|
- !ruby/object:Gem::Dependency
|
@@ -84,28 +84,28 @@ dependencies:
|
|
84
84
|
name: thor
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - ~>
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '0'
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - ~>
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: httparty
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- -
|
101
|
+
- - ~>
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: '0'
|
104
104
|
type: :runtime
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- -
|
108
|
+
- - ~>
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
111
|
- !ruby/object:Gem::Dependency
|
@@ -126,14 +126,14 @@ dependencies:
|
|
126
126
|
name: abiquo-api
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
|
-
- -
|
129
|
+
- - ~>
|
130
130
|
- !ruby/object:Gem::Version
|
131
131
|
version: '0'
|
132
132
|
type: :runtime
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
|
-
- -
|
136
|
+
- - ~>
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '0'
|
139
139
|
description: "Command Line Interface for the Abiquo API\nStart with 'vcli target https://put.your.portal.api.fqdn.here/api'\nthen
|
@@ -153,13 +153,13 @@ files:
|
|
153
153
|
- bin/console
|
154
154
|
- bin/setup
|
155
155
|
- bin/vcli
|
156
|
-
- lib/vcli.rb
|
157
|
-
- lib/vcli/cli.rb
|
158
156
|
- lib/vcli/cli/create.rb
|
159
157
|
- lib/vcli/cli/delete.rb
|
160
158
|
- lib/vcli/cli/resource.rb
|
161
159
|
- lib/vcli/cli/show.rb
|
160
|
+
- lib/vcli/cli.rb
|
162
161
|
- lib/vcli/version.rb
|
162
|
+
- lib/vcli.rb
|
163
163
|
- test/test_helper.rb
|
164
164
|
- test/vcli_test.rb
|
165
165
|
homepage: http://www.sittingonthe.net
|
@@ -172,17 +172,17 @@ require_paths:
|
|
172
172
|
- lib
|
173
173
|
required_ruby_version: !ruby/object:Gem::Requirement
|
174
174
|
requirements:
|
175
|
-
- -
|
175
|
+
- - '>='
|
176
176
|
- !ruby/object:Gem::Version
|
177
177
|
version: '0'
|
178
178
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
179
179
|
requirements:
|
180
|
-
- -
|
180
|
+
- - '>='
|
181
181
|
- !ruby/object:Gem::Version
|
182
182
|
version: '0'
|
183
183
|
requirements: []
|
184
184
|
rubyforge_project:
|
185
|
-
rubygems_version: 2.
|
185
|
+
rubygems_version: 2.0.14
|
186
186
|
signing_key:
|
187
187
|
specification_version: 4
|
188
188
|
summary: Command Line Interface for the Abiquo API
|