vcli 0.1.9 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 03962123c9937bf6343ac4cf1d17910a8b47b2b9
4
- data.tar.gz: afac6cb5141e53c1ee125d858a112c53f57b89a3
3
+ metadata.gz: dfb23c6e1274137524a83a6e9097ab5aaac2e809
4
+ data.tar.gz: 3b0f4d9857ad7c7b9747c973449c4c56ff1719f3
5
5
  SHA512:
6
- metadata.gz: 4018828bc466790dc2eaf25d497f407d83862b02968da68afd24b693c9fb5ff7b2228d3fc37ea970c68f7ee9d921f39d603454f53c1bae3ae6bf206ea758f3c1
7
- data.tar.gz: 5535f8704017af2283530f38bb253be866644109b780e6ab0b49abd05b892de21873b599df1f41bbe423b3be8e422c55ec7cbbdcf8cc6275b6397be4d4885fa1
6
+ metadata.gz: 84116c506c2e1d882b0eb47d5b4bcee1f79459a49a1c7045923c9de56ae9c43554c68692306cea13f0465e2abc3697fff78789ad39653e0396acd1d2e33d94ed
7
+ data.tar.gz: 98afbdec6bcb3d1a4ea8710904bd6dbadd20446fc6717c9b984d449b33a5cd09248184295e0a019967e8c1ab27e24292d2bf6a856d47b09837538ce5d689a317
@@ -20,14 +20,41 @@ module Vcli
20
20
  end
21
21
 
22
22
  desc "login", "Login to the Abiquo VDC with stored details"
23
+ method_option :target, :type => :string, :aliases => "-t"
24
+ method_option :user, :type => :string, :aliases => "-u"
25
+ method_option :password, :type => :string, :aliases => "-p"
23
26
  def login()
24
- abq = AbiquoAPI.new(:abiquo_api_url => Vcli::target,
25
- :abiquo_username => Vcli::user,
26
- :abiquo_password => Vcli::password)
27
- abq.user
28
- enterprise=abq.user.link(:enterprise).get
29
- puts "Logged into Abiquo Portal as User - #{abq.user.id} - #{abq.user.name} #{abq.user.surname}"
30
- puts " in Enterprise - #{enterprise.id} - #{abq.enterprise.title}"
27
+ target=options[:target].to_s
28
+ user=options[:user].to_s
29
+ password=options[:password].to_s
30
+ if target.length >0
31
+ Vcli.set_config("target",target)
32
+ end
33
+ if user.length >0
34
+ Vcli.set_config("user",user)
35
+ end
36
+ if password.length >0
37
+ Vcli.set_config("password",password)
38
+ end
39
+ begin
40
+ abq = AbiquoAPI.new(:abiquo_api_url => Vcli::target,
41
+ :abiquo_username => Vcli::user,
42
+ :abiquo_password => Vcli::password)
43
+ abq.user
44
+ enterprise=abq.user.link(:enterprise).get
45
+ puts "Logged into Abiquo Portal as User - #{abq.user.id} - #{abq.user.name} #{abq.user.surname}"
46
+ puts " in Enterprise - #{enterprise.id} - #{abq.enterprise.title}"
47
+ rescue AbiquoAPIClient::Forbidden
48
+ puts "Forbidden HTTP 403 Received"
49
+ rescue AbiquoAPIClient::InvalidCredentials
50
+ puts "Invalid Credentials - HTTP 401 Received"
51
+ rescue AbiquoAPIClient::BadRequest
52
+ puts "Bad Request - HTTP 400 or 406 Received"
53
+ rescue AbiquoAPIClient::NotFound
54
+ puts "Note Found - HTTP 400 Received"
55
+ rescue AbiquoAPIClient::UnsupportedMediaType
56
+ puts "Unsupported Media Type Specified - HTTP 415 Received"
57
+ end
31
58
  end
32
59
 
33
60
  desc "user username password", "Set user details for accessing the Abiquo VDC"
@@ -14,127 +14,349 @@
14
14
  ############################################################################
15
15
  # 20072015 # 0.2 # Added Virtual Machine functionality
16
16
  ############################################################################
17
+ # 24072015 # 0.3 # Added Users within current Enterprise functionality
18
+ ############################################################################
17
19
 
18
20
  module Vcli
19
21
  module CLI
20
22
  class Show < Thor
21
23
  # Data Centers
22
24
  desc "datacenters", "Show all datacenters"
25
+ method_option :limits, :type => :boolean
23
26
  def datacenters( )
24
- abq = AbiquoAPI.new(:abiquo_api_url => Vcli::target, :abiquo_username => Vcli::user, :abiquo_password => Vcli::password)
25
- link=AbiquoAPI::Link.new(:href => 'api/admin/datacenters' , :type => 'application/vnd.abiquo.datacenters+json')
26
- dc=abq.list(link)
27
- dc.each { |l|
28
- puts "#{l.name} \t - #{l.id} \t - #{l.location}"
29
- }
27
+ begin
28
+ abq = AbiquoAPI.new(:abiquo_api_url => Vcli::target,
29
+ :abiquo_username => Vcli::user,
30
+ :abiquo_password => Vcli::password)
31
+ link=AbiquoAPI::Link.new(:href => 'api/admin/datacenters' ,
32
+ :type => 'application/vnd.abiquo.datacenters+json')
33
+ dc=abq.list(link)
34
+ dc.each { |l|
35
+ puts "#{l.name} \t - #{l.id} \t - #{l.location}"
36
+ if options.limits?
37
+ link2=AbiquoAPI::Link.new(:href => 'api/admin/datacenters/' + l.id.to_s + "/action/getlimits",
38
+ :type => 'application/vnd.abiquo.limits+json')
39
+ limits=abq.list(link2)
40
+ puts "#{limits}.inspect"
41
+ end
42
+ }
43
+ rescue AbiquoAPIClient::Forbidden
44
+ puts "Forbidden HTTP 403 Received"
45
+ rescue AbiquoAPIClient::InvalidCredentials
46
+ puts "Invalid Credentials - HTTP 401 Received"
47
+ rescue AbiquoAPIClient::BadRequest
48
+ puts "Bad Request - HTTP 400 or 406 Received"
49
+ rescue AbiquoAPIClient::NotFound
50
+ puts "Note Found - HTTP 400 Received"
51
+ rescue AbiquoAPIClient::UnsupportedMediaType
52
+ puts "Unsupported Media Type Specified - HTTP 415 Received"
53
+ end
30
54
  end
55
+
31
56
  # Virtual Appliances
32
57
  desc "virtualappliances", "Show all virtualappliances"
33
58
  method_option :vdc, :type => :string
34
59
  def virtualappliances( )
35
- abq = AbiquoAPI.new(:abiquo_api_url => Vcli::target, :abiquo_username => Vcli::user, :abiquo_password => Vcli::password)
36
- # Get something on the screen
37
- puts "VDC,Appliance Name,Appliance ID"
38
- # If --vdc parameter passed
39
- vdc=options[:vdc].to_s
40
- if vdc.length != 0
41
- link2=AbiquoAPI::Link.new(:href => 'api/cloud/virtualdatacenters/' + vdc + '/virtualappliances' , :type => 'application/vnd.abiquo.virtualappliances+json')
42
- virtualappliance=abq.list(link2)
43
- virtualappliance.each { |l|
44
- puts "#{vdc},#{l.name},#{l.id}"
45
- }
46
- # If no --vdc parameter passwd
47
- else
48
- # Cycle through all virtualdatacenters
49
- link=AbiquoAPI::Link.new(:href => 'api/cloud/virtualdatacenters',
50
- :type => 'application/vnd.abiquo.virtualdatacenters+json')
51
- virtualdatacenter=abq.list(link)
52
- # Cycle through all virtual appliances in virtual datacenter
53
- virtualdatacenter.each { |l|
54
- link2=AbiquoAPI::Link.new(:href => 'api/cloud/virtualdatacenters/' + l.id.to_s + '/virtualappliances' , :type => 'application/vnd.abiquo.virtualappliances+json')
55
- virtualappliance=abq.list(link2)
56
- virtualappliance.each { |m|
57
- puts "#{l.id},#{m.name},#{m.id}"
60
+ begin
61
+ abq = AbiquoAPI.new(:abiquo_api_url => Vcli::target,
62
+ :abiquo_username => Vcli::user,
63
+ :abiquo_password => Vcli::password)
64
+ # Get something on the screen
65
+ puts "VDC,Appliance Name,Appliance ID"
66
+ # If --vdc parameter passed
67
+ vdc=options[:vdc].to_s
68
+ if vdc.length != 0
69
+ link2=AbiquoAPI::Link.new(:href => 'api/cloud/virtualdatacenters/' + vdc + '/virtualappliances' ,
70
+ :type => 'application/vnd.abiquo.virtualappliances+json')
71
+ virtualappliance=abq.list(link2)
72
+ virtualappliance.each { |l|
73
+ puts "#{vdc},#{l.name},#{l.id}"
58
74
  }
59
- }
75
+ # If no --vdc parameter passwd
76
+ else
77
+ # Cycle through all virtualdatacenters
78
+ link=AbiquoAPI::Link.new(:href => 'api/cloud/virtualdatacenters',
79
+ :type => 'application/vnd.abiquo.virtualdatacenters+json')
80
+ virtualdatacenter=abq.list(link)
81
+ # Cycle through all virtual appliances in virtual datacenter
82
+ virtualdatacenter.each { |l|
83
+ link2=AbiquoAPI::Link.new(:href => 'api/cloud/virtualdatacenters/' + l.id.to_s + '/virtualappliances' ,
84
+ :type => 'application/vnd.abiquo.virtualappliances+json')
85
+ virtualappliance=abq.list(link2)
86
+ virtualappliance.each { |m|
87
+ puts "#{l.id},#{m.name},#{m.id}"
88
+ }
89
+ }
90
+ end
91
+ rescue AbiquoAPIClient::Forbidden
92
+ puts "Forbidden HTTP 403 Received"
93
+ rescue AbiquoAPIClient::InvalidCredentials
94
+ puts "Invalid Credentials - HTTP 401 Received"
95
+ rescue AbiquoAPIClient::BadRequest
96
+ puts "Bad Request - HTTP 400 or 406 Received"
97
+ rescue AbiquoAPIClient::NotFound
98
+ puts "Note Found - HTTP 400 Received"
99
+ rescue AbiquoAPIClient::UnsupportedMediaType
100
+ puts "Unsupported Media Type Specified - HTTP 415 Received"
101
+ end
102
+ end
103
+
104
+ # VLAN
105
+ desc "vlans", "Show all VLANS within your account"
106
+ method_option :vdc, :type => :string
107
+ method_option :ips, :type => :boolean
108
+ def vlans( )
109
+ begin
110
+ abq = AbiquoAPI.new(:abiquo_api_url => Vcli::target,
111
+ :abiquo_username => Vcli::user,
112
+ :abiquo_password => Vcli::password)
113
+ # Get something on the screen
114
+ puts "VLAN ID,VLAN Name,VDC ID,Network,Mask,Gateway"
115
+ # If --vdc parameter passed
116
+ vdc=options[:vdc].to_s
117
+ if vdc.length != 0
118
+ link=AbiquoAPI::Link.new(:href => 'api/cloud/virtualdatacenters/' + vdc + '/privatenetworks' ,
119
+ :type => 'application/vnd.abiquo.vlans+json')
120
+ vlans=abq.list(link)
121
+ vlans.each { |l|
122
+ puts "#{l.id},#{l.name},#{vdc},#{l.address},#{l.mask},#{l.gateway}"
123
+ if options[:ips]
124
+ id=l.id.to_s
125
+ link2=AbiquoAPI::Link.new(:href => 'api/cloud/virtualdatacenters/' + vdc + '/privatenetworks/' + id + '/ips',
126
+ :type => 'application/vnd.abiquo.privateips+json')
127
+ listofips=abq.list(link2)
128
+ listofips.each { |m|
129
+ puts " - #{m.id}, #{m.ip}, #{m.name}"
130
+ }
131
+ end
132
+
133
+ }
134
+ # If no --vdc parameter passwd
135
+ else
136
+ # Cycle through all virtualdatacenters
137
+ link=AbiquoAPI::Link.new(:href => 'api/cloud/virtualdatacenters',
138
+ :type => 'application/vnd.abiquo.virtualdatacenters+json')
139
+ virtualdatacenter=abq.list(link)
140
+ # Cycle through all virtual appliances in virtual datacenter
141
+ virtualdatacenter.each { |l|
142
+ link2=AbiquoAPI::Link.new(:href => 'api/cloud/virtualdatacenters/' + l.id.to_s + '/privatenetworks' ,
143
+ :type => 'application/vnd.abiquo.vlans+json')
144
+ vlans=abq.list(link2)
145
+ vlans.each { |m|
146
+ puts "#{m.id},#{m.name},#{l.id},#{m.address},#{m.mask},#{m.gateway}"
147
+ }
148
+ }
149
+ end
150
+ rescue AbiquoAPIClient::Forbidden
151
+ puts "Forbidden HTTP 403 Received"
152
+ rescue AbiquoAPIClient::InvalidCredentials
153
+ puts "Invalid Credentials - HTTP 401 Received"
154
+ rescue AbiquoAPIClient::BadRequest
155
+ puts "Bad Request - HTTP 400 or 406 Received"
156
+ rescue AbiquoAPIClient::NotFound
157
+ puts "Note Found - HTTP 400 Received"
158
+ rescue AbiquoAPIClient::UnsupportedMediaType
159
+ puts "Unsupported Media Type Specified - HTTP 415 Received"
60
160
  end
61
161
  end
162
+
62
163
  # Users
63
164
  desc "users", "Show all users within your account"
64
165
  def users( )
65
- abq = AbiquoAPI.new(:abiquo_api_url => Vcli::target,
66
- :abiquo_username => Vcli::user,
67
- :abiquo_password => Vcli::password)
68
- abq.user
69
- #enterprise=abq.user.link(:enterprise).get
70
- link2=AbiquoAPI::Link.new(:href => 'api/admin/enterprises/' + enterprise.id.to_s + '/users' , :type => 'application/vnd.abiquo.users+json')
71
- users=abq.list(link2)
72
- puts "UserID,Firstname,Surname,Email"
73
- users.each { |m|
74
- puts "#{m.id},#{m.name},#{m.surname},#{m.email}"
75
- }
166
+ begin
167
+ abq = AbiquoAPI.new(:abiquo_api_url => Vcli::target,
168
+ :abiquo_username => Vcli::user,
169
+ :abiquo_password => Vcli::password)
170
+ abq.user
171
+ ent=abq.user.link(:enterprise).get
172
+ link=AbiquoAPI::Link.new(:href => 'api/admin/enterprises/'+ent.id.to_s + '/users',
173
+ :type => 'application/vnd.abiquo.users+json')
174
+ users=abq.list(link)
175
+ puts "UserID,Firstname,Surname,Email"
176
+ users.each { |m|
177
+ puts "#{m.id},#{m.name},#{m.surname},#{m.email}"
178
+ }
179
+ rescue AbiquoAPIClient::Forbidden
180
+ puts "Forbidden HTTP 403 Received"
181
+ rescue AbiquoAPIClient::InvalidCredentials
182
+ puts "Invalid Credentials - HTTP 401 Received"
183
+ rescue AbiquoAPIClient::BadRequest
184
+ puts "Bad Request - HTTP 400 or 406 Received"
185
+ rescue AbiquoAPIClient::NotFound
186
+ puts "Note Found - HTTP 400 Received"
187
+ rescue AbiquoAPIClient::UnsupportedMediaType
188
+ puts "Unsupported Media Type Specified - HTTP 415 Received"
189
+ end
76
190
  end
191
+
77
192
  # Enterprise
78
193
  desc "enterprise", "Show Enterprise details"
194
+ method_option :ent, :type => :string
79
195
  def enterprise( )
80
- abq = AbiquoAPI.new(:abiquo_api_url => Vcli::target, :abiquo_username => Vcli::user, :abiquo_password => Vcli::password)
81
- link=AbiquoAPI::Link.new(:href => 'api/admin/enterprises',
82
- :type => 'application/vnd.abiquo.enterprises+json')
83
- enterprises=abq.list(link)
84
- enterprises.each { |l|
85
- puts "#{l.id} \t - #{l.name}"
86
- }
87
- end
88
- # Resources
89
- desc "resources", "Show resources usage details"
90
- def resources( )
91
- command = "TBC - showing resources details"
92
- puts command
93
- end
94
- # Resource Limits
95
- #
96
- desc "limits", "Show limit details"
97
- def limits( )
98
- command = "TBC - showing limit details"
99
- puts command
196
+ begin
197
+ abq = AbiquoAPI.new(:abiquo_api_url => Vcli::target,
198
+ :abiquo_username => Vcli::user,
199
+ :abiquo_password => Vcli::password)
200
+ ent=options[:ent].to_s
201
+ if ent.length == 0
202
+ link=AbiquoAPI::Link.new(:href => 'api/admin/enterprises',
203
+ :type => 'application/vnd.abiquo.enterprises+json')
204
+ enterprises=abq.list(link)
205
+ enterprises.each { |l|
206
+ puts "#{l.id} \t - #{l.name}"
207
+ }
208
+ else
209
+ link=AbiquoAPI::Link.new(:href => 'api/admin/enterprises/' + ent + '',
210
+ :type => 'application/vnd.abiquo.enterprise+json',
211
+ :client => abq)
212
+ enterprises=link.get
213
+ puts 'Enterprise ID - ' + enterprises.id.to_s
214
+ puts 'Enterprise Name - ' + enterprises.name
215
+ puts 'CPU Hard Limit - ' + enterprises.cpuCountHardLimit.to_s
216
+ puts 'CPU Soft Limit - ' + enterprises.cpuCountSoftLimit.to_s
217
+ puts 'RAM Hard Limit (MB)- ' + enterprises.ramHardLimitInMb.to_s
218
+ puts 'RAM Soft Limit (MB)- ' + enterprises.ramSoftLimitInMb.to_s
219
+ puts 'Public IP Hard Limit - ' + enterprises.publicIpsHard.to_s
220
+ puts 'Public IP Soft Limit - ' + enterprises.publicIpsSoft.to_s
221
+ puts 'Disk Hard Limit (MB)- ' + enterprises.diskHardLimitInMb.to_s
222
+ puts 'Disk Soft Limit (MB)- ' + enterprises.diskSoftLimitInMb.to_s
223
+ puts 'Repository Hard Limit (MB)- ' + enterprises.repositoryHardInMb.to_s
224
+ puts 'Repository Soft Limit (MB)- ' + enterprises.repositorySoftInMb.to_s
225
+ puts 'Storage Hard Limit (MB)- ' + enterprises.storageHardInMb.to_s
226
+ puts 'Storage Soft Limit (MB)- ' + enterprises.storageSoftInMb.to_s
227
+ puts 'VLANs Hard Limit - ' + enterprises.vlansHard.to_s
228
+ puts 'VLANs Soft Limit - ' + enterprises.vlansSoft.to_s
229
+ end
230
+ rescue AbiquoAPIClient::Forbidden
231
+ puts "Forbidden HTTP 403 Received"
232
+ rescue AbiquoAPIClient::InvalidCredentials
233
+ puts "Invalid Credentials - HTTP 401 Received"
234
+ rescue AbiquoAPIClient::BadRequest
235
+ puts "Bad Request - HTTP 400 or 406 Received"
236
+ rescue AbiquoAPIClient::NotFound
237
+ puts "Note Found - HTTP 400 Received"
238
+ rescue AbiquoAPIClient::UnsupportedMediaType
239
+ puts "Unsupported Media Type Specified - HTTP 415 Received"
240
+ end
100
241
  end
101
- # Virtual Datacenters
102
- desc "virtualdatacenters", "show configured Virtual Data Centers"
103
- def virtualdatacenters( )
242
+
243
+ # Templates
244
+ desc "templates", "Show template details"
245
+ method_option :vdc, :type => :string, :required => true
246
+ def templates( )
104
247
  abq = AbiquoAPI.new(:abiquo_api_url => Vcli::target,
105
248
  :abiquo_username => Vcli::user,
106
249
  :abiquo_password => Vcli::password)
107
- link=AbiquoAPI::Link.new(:href => 'api/cloud/virtualdatacenters',
108
- :type => 'application/vnd.abiquo.virtualdatacenters+json')
109
- vdc=abq.list(link)
110
- vdc.each { |l|
111
- puts "#{l.id} \t - #{l.name}"
250
+ vdc=options[:vdc].to_s
251
+ link=AbiquoAPI::Link.new(:href => 'api/cloud/virtualdatacenters/' + vdc + '/action/templates',
252
+ :type => 'application/vnd.abiquo.virtualmachinetemplates+json',
253
+ :client => abq)
254
+ templates=link.get
255
+ puts "ID, Name, OS Type, CPU Req, RAM Req"
256
+ templates.each {|l|
257
+ puts "#{l.id},#{l.name},#{l.osType},#{l.cpuRequired},#{l.ramRequired}"
112
258
  }
259
+
260
+ end
261
+
262
+ # Virtual Datacenters
263
+ desc "virtualdatacenters", "show configured Virtual Data Centers"
264
+ method_option :limits, :type => :boolean
265
+ method_option :vdc, :type => :string
266
+ def virtualdatacenters( )
267
+ begin
268
+ abq = AbiquoAPI.new(:abiquo_api_url => Vcli::target,
269
+ :abiquo_username => Vcli::user,
270
+ :abiquo_password => Vcli::password)
271
+ vdc=options[:vdc].to_s
272
+ if vdc.length==0
273
+ link=AbiquoAPI::Link.new(:href => 'api/cloud/virtualdatacenters',
274
+ :type => 'application/vnd.abiquo.virtualdatacenters+json',
275
+ :client => abq)
276
+ vdcs=link.get
277
+ vdcs.each { |l|
278
+ puts "#{l.id} \t - #{l.name}"
279
+ }
280
+ else
281
+ link=AbiquoAPI::Link.new(:href => 'api/cloud/virtualdatacenters/' + vdc,
282
+ :type => 'application/vnd.abiquo.virtualdatacenter+json',
283
+ :client => abq)
284
+ l=link.get
285
+ puts "#{l.id} \t - #{l.name}"
286
+ puts " - RAM Soft Limit (MB) - #{l.ramSoftLimitInMb}"
287
+ puts " - RAM Hard Limit (MB) - #{l.ramHardLimitInMb}"
288
+ puts " - CPU Soft Limit - #{l.cpuCountSoftLimit}"
289
+ puts " - CPU Hard Limit - #{l.cpuCountHardLimit}"
290
+ puts " - Disk Soft Limit (MB) - #{l.diskSoftLimitInMb}"
291
+ puts " - Disk Hard Limit (MB) - #{l.diskHardLimitInMb}"
292
+ puts " - Storage Soft Limit (MB) - #{l.storageSoftInMb}"
293
+ puts " - Storage Hard Limit (MB) - #{l.storageHardInMb}"
294
+ puts " - VLANS Soft Limit - #{l.vlansSoft}"
295
+ puts " - VLANS Hard Limit - #{l.vlansHard}"
296
+ puts " - Public IPS Soft Limit - #{l.publicIpsSoft}"
297
+ puts " - Public IPS Hard Limit - #{l.publicIpsHard}"
298
+ end
299
+
300
+ rescue AbiquoAPIClient::Forbidden
301
+ puts "Forbidden HTTP 403 Received"
302
+ rescue AbiquoAPIClient::InvalidCredentials
303
+ puts "Invalid Credentials - HTTP 401 Received"
304
+ rescue AbiquoAPIClient::BadRequest
305
+ puts "Bad Request - HTTP 400 or 406 Received"
306
+ rescue AbiquoAPIClient::NotFound
307
+ puts "Note Found - HTTP 400 Received"
308
+ rescue AbiquoAPIClient::UnsupportedMediaType
309
+ puts "Unsupported Media Type Specified - HTTP 415 Received"
310
+ end
113
311
  end
312
+
114
313
  # Virtual Machines
115
314
  desc "virtualmachines", "show Virtual Machines"
116
315
  method_option :va, :type => :string
117
316
  method_option :vdc, :type => :string
118
317
  def virtualmachines( )
119
- abq = AbiquoAPI.new(:abiquo_api_url => Vcli::target,
120
- :abiquo_username => Vcli::user,
121
- :abiquo_password => Vcli::password)
122
- # If --vdc parameter passed
123
- va=options[:va].to_s
124
- vdc=options[:vdc].to_s
125
- if va.length == 0 && vdc.length == 0
126
- # Cycle through all virtualdatacenters
127
- link=AbiquoAPI::Link.new(:href => 'api/cloud/virtualdatacenters',
128
- :type => 'application/vnd.abiquo.virtualdatacenters+json')
129
- virtualdatacenters=abq.list(link)
130
- # Cycle through all virtual appliances in virtual datacenter
131
- virtualdatacenters.each { |l|
132
- puts "- VDC - #{l.id} "
133
- link2=AbiquoAPI::Link.new(:href => 'api/cloud/virtualdatacenters/' + l.id.to_s + '/virtualappliances' , :type => 'application/vnd.abiquo.virtualappliances+json')
318
+ begin
319
+ abq = AbiquoAPI.new(:abiquo_api_url => Vcli::target,
320
+ :abiquo_username => Vcli::user,
321
+ :abiquo_password => Vcli::password)
322
+ # If --vdc parameter passed
323
+ va=options[:va].to_s
324
+ vdc=options[:vdc].to_s
325
+ if va.length == 0 && vdc.length == 0
326
+ # Cycle through all virtualdatacenters
327
+ link=AbiquoAPI::Link.new(:href => 'api/cloud/virtualdatacenters',
328
+ :type => 'application/vnd.abiquo.virtualdatacenters+json')
329
+ virtualdatacenters=abq.list(link)
330
+ # Cycle through all virtual appliances in virtual datacenter
331
+ virtualdatacenters.each { |l|
332
+ puts "- VDC - #{l.id} "
333
+ link2=AbiquoAPI::Link.new(:href => 'api/cloud/virtualdatacenters/' + l.id.to_s + '/virtualappliances' ,
334
+ :type => 'application/vnd.abiquo.virtualappliances+json')
335
+ virtualappliances=abq.list(link2)
336
+ virtualappliances.each { |m|
337
+ puts " - Virtual Appliance - #{m.name} - VA ID - #{m.id}"
338
+ link3=AbiquoAPI::Link.new(:href => 'api/cloud/virtualdatacenters/' + l.id.to_s + '/virtualappliances/' + m.id.to_s + '/virtualmachines' ,
339
+ :type => 'application/vnd.abiquo.virtualmachines+json')
340
+ virtualmachines=abq.list(link3)
341
+ virtualmachines.each { |n|
342
+ puts " - ID: #{n.id}, UUID: #{n.uuid}"
343
+ puts " - Name: #{n.label}"
344
+ puts " - CPU: #{n.cpu} RAM: #{n.ram} MB"
345
+ disksizeInGB = n.hdInBytes/(1024**3)
346
+ puts " - HD Size: #{disksizeInGB} GB"
347
+ puts " - State: #{n.state}"
348
+ }
349
+ }
350
+ }
351
+ elsif vdc.length != 0 && va.length == 0
352
+ puts "- VDC - #{vdc.to_s} "
353
+ link2=AbiquoAPI::Link.new(:href => 'api/cloud/virtualdatacenters/' + vdc.to_s + '/virtualappliances' ,
354
+ :type => 'application/vnd.abiquo.virtualappliances+json')
134
355
  virtualappliances=abq.list(link2)
135
356
  virtualappliances.each { |m|
136
357
  puts " - Virtual Appliance - #{m.name} - VA ID - #{m.id}"
137
- link3=AbiquoAPI::Link.new(:href => 'api/cloud/virtualdatacenters/' + l.id.to_s + '/virtualappliances/' + m.id.to_s + '/virtualmachines' , :type => 'application/vnd.abiquo.virtualmachines+json')
358
+ link3=AbiquoAPI::Link.new(:href => 'api/cloud/virtualdatacenters/' + vdc.to_s + '/virtualappliances/' + m.id.to_s + '/virtualmachines' ,
359
+ :type => 'application/vnd.abiquo.virtualmachines+json')
138
360
  virtualmachines=abq.list(link3)
139
361
  virtualmachines.each { |n|
140
362
  puts " - ID: #{n.id}, UUID: #{n.uuid}"
@@ -145,14 +367,9 @@ module Vcli
145
367
  puts " - State: #{n.state}"
146
368
  }
147
369
  }
148
- }
149
- elsif vdc.length != 0 && va.length == 0
150
- puts "- VDC - #{vdc.to_s} "
151
- link2=AbiquoAPI::Link.new(:href => 'api/cloud/virtualdatacenters/' + vdc.to_s + '/virtualappliances' , :type => 'application/vnd.abiquo.virtualappliances+json')
152
- virtualappliances=abq.list(link2)
153
- virtualappliances.each { |m|
154
- puts " - Virtual Appliance - #{m.name} - VA ID - #{m.id}"
155
- link3=AbiquoAPI::Link.new(:href => 'api/cloud/virtualdatacenters/' + vdc.to_s + '/virtualappliances/' + m.id.to_s + '/virtualmachines' , :type => 'application/vnd.abiquo.virtualmachines+json')
370
+ elsif vdc.length != 0 && va.length != 0
371
+ link3=AbiquoAPI::Link.new(:href => 'api/cloud/virtualdatacenters/' + vdc.to_s + '/virtualappliances/' + va.to_s + '/virtualmachines' ,
372
+ :type => 'application/vnd.abiquo.virtualmachines+json')
156
373
  virtualmachines=abq.list(link3)
157
374
  virtualmachines.each { |n|
158
375
  puts " - ID: #{n.id}, UUID: #{n.uuid}"
@@ -162,23 +379,22 @@ module Vcli
162
379
  puts " - HD Size: #{disksizeInGB} GB"
163
380
  puts " - State: #{n.state}"
164
381
  }
165
- }
166
- elsif vdc.length != 0 && va.length != 0
167
- link3=AbiquoAPI::Link.new(:href => 'api/cloud/virtualdatacenters/' + vdc.to_s + '/virtualappliances/' + va.to_s + '/virtualmachines' , :type => 'application/vnd.abiquo.virtualmachines+json')
168
- virtualmachines=abq.list(link3)
169
- virtualmachines.each { |n|
170
- puts " - ID: #{n.id}, UUID: #{n.uuid}"
171
- puts " - Name: #{n.label}"
172
- puts " - CPU: #{n.cpu} RAM: #{n.ram} MB"
173
- disksizeInGB = n.hdInBytes/(1024**3)
174
- puts " - HD Size: #{disksizeInGB} GB"
175
- puts " - State: #{n.state}"
176
- }
177
- else
178
- puts "If options are used the alternatives are as follows:"
179
- puts " --VDC xxx --VA xxx"
180
- puts " --VDC xxx"
181
- puts "using --VA without --VDC is not allowed"
382
+ else
383
+ puts "If options are used the alternatives are as follows:"
384
+ puts " --VDC xxx --VA xxx"
385
+ puts " --VDC xxx"
386
+ puts "using --VA without --VDC is not allowed"
387
+ end
388
+ rescue AbiquoAPIClient::Forbidden
389
+ puts "Forbidden HTTP 403 Received"
390
+ rescue AbiquoAPIClient::InvalidCredentials
391
+ puts "Invalid Credentials - HTTP 401 Received"
392
+ rescue AbiquoAPIClient::BadRequest
393
+ puts "Bad Request - HTTP 400 or 406 Received"
394
+ rescue AbiquoAPIClient::NotFound
395
+ puts "Note Found - HTTP 400 Received"
396
+ rescue AbiquoAPIClient::UnsupportedMediaType
397
+ puts "Unsupported Media Type Specified - HTTP 415 Received"
182
398
  end
183
399
  end
184
400
  end
@@ -5,8 +5,10 @@ module Vcli
5
5
  #################################################################
6
6
  # Version # Date # What
7
7
  #################################################################
8
- # 0.19 #20072015# Added virtual machine functionality
8
+ # 0.1.9 #20072015# Added virtual machine functionality
9
+ #################################################################
10
+ # 0.2.0 #20072015# Added virtual machine functionality
9
11
  #################################################################
10
12
 
11
- VERSION = "0.1.9"
13
+ VERSION = "0.2.0"
12
14
  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.1.9
4
+ version: 0.2.0
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-07-20 00:00:00.000000000 Z
11
+ date: 2015-07-27 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
@@ -70,28 +70,28 @@ dependencies:
70
70
  name: thor
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ~>
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ~>
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: httparty
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
@@ -112,14 +112,14 @@ dependencies:
112
112
  name: abiquo-api
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - ~>
115
+ - - "~>"
116
116
  - !ruby/object:Gem::Version
117
117
  version: '0'
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - ~>
122
+ - - "~>"
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  description: "Command Line Interface for the Abiquo API\nStart with 'vcli target https://put.your.portal.api.fqdn.here/api'\nthen
@@ -129,24 +129,24 @@ description: "Command Line Interface for the Abiquo API\nStart with 'vcli target
129
129
  email:
130
130
  - jay@jayfearn.com
131
131
  executables:
132
- - setup
133
132
  - console
133
+ - setup
134
134
  - vcli
135
135
  extensions: []
136
136
  extra_rdoc_files: []
137
137
  files:
138
138
  - Rakefile
139
- - bin/setup
140
139
  - bin/console
140
+ - bin/setup
141
141
  - bin/vcli
142
142
  - lib/vcli.rb
143
- - lib/vcli/version.rb
144
- - lib/vcli/cli/show.rb
145
- - lib/vcli/cli/resource.rb
146
- - lib/vcli/cli/abiquo.rb
147
143
  - lib/vcli/cli.rb
148
- - test/vcli_test.rb
144
+ - lib/vcli/cli/abiquo.rb
145
+ - lib/vcli/cli/resource.rb
146
+ - lib/vcli/cli/show.rb
147
+ - lib/vcli/version.rb
149
148
  - test/test_helper.rb
149
+ - test/vcli_test.rb
150
150
  homepage: http://www.sittingonthe.net
151
151
  licenses:
152
152
  - MIT
@@ -157,17 +157,17 @@ require_paths:
157
157
  - lib
158
158
  required_ruby_version: !ruby/object:Gem::Requirement
159
159
  requirements:
160
- - - '>='
160
+ - - ">="
161
161
  - !ruby/object:Gem::Version
162
162
  version: '0'
163
163
  required_rubygems_version: !ruby/object:Gem::Requirement
164
164
  requirements:
165
- - - '>='
165
+ - - ">="
166
166
  - !ruby/object:Gem::Version
167
167
  version: '0'
168
168
  requirements: []
169
169
  rubyforge_project:
170
- rubygems_version: 2.0.14
170
+ rubygems_version: 2.4.5
171
171
  signing_key:
172
172
  specification_version: 4
173
173
  summary: Command Line Interface for the Abiquo API