vcautils 0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ MDBhZDI5Y2FjYzczNWM4MDQxNzM1NzYyNTdkMzU4MzI1OWIwYmU3Mw==
5
+ data.tar.gz: !binary |-
6
+ NThkYjYzZmJjYjU3ZDNlOTY4NGViNjk0YzE2ZmY5MDEwYzNjNWNlYg==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ MjUzY2IzYzc3ODhhOTlmNTgzYmYwY2JmMTVhMzJmYzBlNTI3NTBmOGE0OTNk
10
+ NjdhYjQwMjgxNjgzMjQ3NDBlYTE0MzkwOWQzNWI2YWVlOWJiYTM3YjMwYzkx
11
+ NTliODNkMzkzMDc2MjAxZjA1NGZkNmYxMmIwMzYwOTQ0ZGJkYzc=
12
+ data.tar.gz: !binary |-
13
+ Y2RjYzVhMjkyM2M0OWEzOTAyOTJkOWYyMDVhNTJjNTQ5ZTQ1NmFhYzQ5MGNi
14
+ OGY5N2FkYzQ3YzRhZDNlYjI0MzVjMTllYjcxYmE4OWY2MTViYmZlYTkzMWI5
15
+ NmUxMDFmZjhlYWExMWFjMjY3YWQ5YjMxNWFkZjI0YzJkNGE0N2Y=
data/bin/compute ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'compute'
data/bin/vca ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'vca'
data/bin/vchs ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'vchs'
data/lib/compute.rb ADDED
@@ -0,0 +1,403 @@
1
+
2
+
3
+ #################################################################################
4
+ #### Massimo Re Ferre' ####
5
+ #### www.it20.info ####
6
+ #### vcautils, a set of utilities for vCloud Air Consumers ####
7
+ #################################################################################
8
+
9
+
10
+
11
+
12
+ #################################################################################
13
+ #### vcacompute.rb is the front end program that presents a CLI interface ####
14
+ #### It leverages the vcautils library ####
15
+ #################################################################################
16
+
17
+
18
+ #################################################################################
19
+ #### IMPORTANT !! ####
20
+ #### The program reads a file called vcautils.yml in the working directory ####
21
+ #### If the file does not exist the program will abort ####
22
+ #### The file is used to provide the program with connectivity parameters ####
23
+ #################################################################################
24
+
25
+ # This is the format of the vcautils.yml file:
26
+ # :username: email@domain
27
+ # :password: password
28
+ # :serviceroot: https://vca.vmware.com
29
+ # :mode: admin | developer
30
+
31
+ # These are the additional modules/gems required to run the program
32
+
33
+ require 'httparty'
34
+ require 'yaml'
35
+ require 'xml-fu'
36
+ require 'pp'
37
+ require 'json'
38
+ require 'awesome_print' #optional - useful for debugging
39
+
40
+ require 'modules/compute-be'
41
+
42
+
43
+ # We stole this piece of code (silence_warnings) from the Internet.
44
+ # We are using it to silence the warnings of the certificates settings (below)
45
+
46
+
47
+ def silence_warnings(&block)
48
+ warn_level = $VERBOSE
49
+ $VERBOSE = nil
50
+ result = block.call
51
+ $VERBOSE = warn_level
52
+ result
53
+ end
54
+
55
+
56
+
57
+
58
+
59
+ #=begin
60
+ class String
61
+ def black; "\033[30m#{self}\033[0m" end
62
+ def red; "\033[31m#{self}\033[0m" end
63
+ def green; "\033[32m#{self}\033[0m" end
64
+ def brown; "\033[33m#{self}\033[0m" end
65
+ def blue; "\033[34m#{self}\033[0m" end
66
+ def magenta; "\033[35m#{self}\033[0m" end
67
+ def cyan; "\033[36m#{self}\033[0m" end
68
+ def gray; "\033[37m#{self}\033[0m" end
69
+ def bg_black; "\033[40m#{self}\033[0m" end
70
+ def bg_red; "\033[41m#{self}\033[0m" end
71
+ def bg_green; "\033[42m#{self}\033[0m" end
72
+ def bg_brown; "\033[43m#{self}\033[0m" end
73
+ def bg_blue; "\033[44m#{self}\033[0m" end
74
+ def bg_magenta; "\033[45m#{self}\033[0m" end
75
+ def bg_cyan; "\033[46m#{self}\033[0m" end
76
+ def bg_gray; "\033[47m#{self}\033[0m" end
77
+ def bold; "\033[1m#{self}\033[22m" end
78
+ def reverse_color; "\033[7m#{self}\033[27m" end
79
+ end #String
80
+ #=end
81
+
82
+
83
+
84
+
85
+
86
+ # This bypass certification checks... NOT a great idea for production but ok for test / dev
87
+
88
+ silence_warnings do
89
+ OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
90
+ end
91
+
92
+
93
+ # This is what the program accepts as input
94
+
95
+ def usage
96
+ puts "\te.g. compute ".green + "<API-URL-endpoint> <Org name>".magenta + " computetoken".green
97
+ puts "\te.g. compute ".green + "<API-URL-endpoint> <Org name>".magenta + " catalogs".green
98
+ puts "\te.g. compute ".green + "<API-URL-endpoint> <Org name>".magenta + " catalog".green + " <catalog id>".magenta
99
+ puts "\te.g. compute ".green + "<API-URL-endpoint> <Org name>".magenta + " orgvms".green
100
+ puts "\te.g. compute ".green + "<API-URL-endpoint> <Org name>".magenta + " orgvapps".green
101
+ puts "\te.g. compute ".green + "<API-URL-endpoint> <Org name>".magenta + " vdcs".green
102
+ puts "\te.g. compute ".green + "<API-URL-endpoint> <Org name>".magenta + " vdc".green + " <vdc id>".magenta
103
+ puts "\te.g. compute ".green + "<API-URL-endpoint> <Org name>".magenta + " vdc".green + " <vdc id>".magenta + " vapps".green
104
+ puts "\te.g. compute ".green + "<API-URL-endpoint> <Org name>".magenta + " vdc".green + " <vdc id>".magenta + " networks".green
105
+ puts "\n"
106
+
107
+ end #usage
108
+
109
+
110
+ # These are the variables the program accept as inputs (see the usage section for more info)
111
+
112
+
113
+
114
+ $input0 = ARGV[0]
115
+
116
+ $input1 = ARGV[1]
117
+
118
+ $input2 = ARGV[2]
119
+
120
+ $input3 = ARGV[3]
121
+
122
+ $input4 = ARGV[4]
123
+
124
+
125
+ # The if checks if the user called an operation. If not the case, we print the text on how to use the CLI
126
+
127
+
128
+ if $input0 && $input1 && $input2
129
+
130
+ # We login (the login method is in vcautilscore)
131
+
132
+ file_path = "vcautils.yml"
133
+ raise "no file #{file_path}" unless File.exists? file_path
134
+ configuration = YAML.load_file(file_path)
135
+ username = configuration[:username]
136
+ password = configuration[:password]
137
+ mode = configuration[:mode]
138
+ computeapiendpoint = $input0
139
+ orgname = $input1
140
+ puts
141
+ puts "Logging in ...\n\n"
142
+
143
+
144
+ compute = Compute.new()
145
+
146
+ tempapiversionsarray = compute.apiversions(computeapiendpoint)
147
+ if mode == "developer" then puts JSON.pretty_generate(tempapiversionsarray) end
148
+ apiversionsarray = Array.new
149
+ tempapiversionsarray['SupportedVersions']['VersionInfo'].length.times do |i|
150
+ apiversionsarray.push(tempapiversionsarray['SupportedVersions']['VersionInfo'][i]['Version'])
151
+ end
152
+ apiversionsarray = apiversionsarray.sort_by do |x|
153
+ x.split(".").map {|i| i.to_i}
154
+ end
155
+
156
+ apiversion = apiversionsarray.last
157
+
158
+ computetoken = compute.login(username, password, orgname, computeapiendpoint, apiversion)
159
+
160
+ if mode == "developer" then
161
+ puts
162
+ puts "computetoken: " + computetoken
163
+ puts "apiversion: " + apiversion
164
+ end
165
+
166
+ case $input2.chomp
167
+ when 'computetoken'
168
+ puts "To start consuming this instance right away use the following parameters: ".green
169
+ puts " - login url : ".green + "GET ".blue + computeapiendpoint.blue
170
+ puts " - x-vcloud-authorization : ".green + computetoken.blue
171
+ puts " - Accept : ".green + "application/*+xml;version=".blue + apiversion.blue
172
+ puts
173
+ puts " - Available APIs : ".green + apiversionsarray.to_s.blue
174
+ puts
175
+
176
+ when 'vdcs'
177
+ vdcsarray = compute.vdcs(computetoken, computeapiendpoint, apiversion)
178
+ if mode == "developer" then puts JSON.pretty_generate(vdcsarray) end
179
+ vdcsarray["QueryResultRecords"]["OrgVdcRecord"].length.times do |e|
180
+ puts "name : ".green + vdcsarray["QueryResultRecords"]["OrgVdcRecord"][e]["name"].blue
181
+ puts "status : ".green + vdcsarray["QueryResultRecords"]["OrgVdcRecord"][e]["status"].blue
182
+ puts "href : ".green + vdcsarray["QueryResultRecords"]["OrgVdcRecord"][e]["href"].blue
183
+ puts "orgName : ".green + vdcsarray["QueryResultRecords"]["OrgVdcRecord"][e]["orgName"].blue
184
+ puts
185
+ end
186
+
187
+ when 'orgvapps'
188
+ orgvappsarray = compute.orgvapps(computetoken, computeapiendpoint, apiversion)
189
+ if mode == "developer" then puts JSON.pretty_generate(orgvappsarray) end
190
+ if orgvappsarray["QueryResultRecords"]["VAppRecord"] == nil
191
+ puts "The are no vApps in this instance".red
192
+ puts
193
+ else
194
+ orgvappsarray["QueryResultRecords"]["VAppRecord"].length.times do |e|
195
+ puts "name : ".green + orgvappsarray["QueryResultRecords"]["VAppRecord"][e]["name"].blue
196
+ puts "href : ".green + orgvappsarray["QueryResultRecords"]["VAppRecord"][e]["href"].blue
197
+ puts "numberOfVMs : ".green + orgvappsarray["QueryResultRecords"]["VAppRecord"][e]["numberOfVMs"].blue
198
+ puts "vdcName : ".green + orgvappsarray["QueryResultRecords"]["VAppRecord"][e]["vdcName"].blue
199
+ puts
200
+ end
201
+ end
202
+
203
+ when 'orgvms'
204
+ orgvmsarray = compute.orgvms(computetoken, computeapiendpoint, apiversion)
205
+ if mode == "developer" then puts JSON.pretty_generate(orgvmsarray) end
206
+ if orgvmsarray["QueryResultRecords"]["VMRecord"] == nil
207
+ puts "The are no vApps in this instance".red
208
+ puts
209
+ else
210
+ puts
211
+ orgvmsarray["QueryResultRecords"]["VMRecord"].length.times do |e|
212
+ puts "name : ".green + orgvmsarray["QueryResultRecords"]["VMRecord"][e]["name"].blue
213
+ puts "isVAppTemplate : ".green + orgvmsarray["QueryResultRecords"]["VMRecord"][e]["isVAppTemplate"].blue
214
+ puts "containerName : ".green + orgvmsarray["QueryResultRecords"]["VMRecord"][e]["containerName"].blue
215
+ puts
216
+ end
217
+ puts "Please be aware that this list also contains all VM templates in all catalogs. See attribute <isVAppTemplate>.".magenta
218
+ puts
219
+ end
220
+
221
+ when 'catalogs'
222
+ catalogsarray = compute.catalogs(computetoken, computeapiendpoint, apiversion)
223
+ if mode == "developer" then puts JSON.pretty_generate(catalogsarray) end
224
+ catalogsarray["QueryResultRecords"]["CatalogRecord"].length.times do |e|
225
+ puts "name : ".green + catalogsarray["QueryResultRecords"]["CatalogRecord"][e]["name"].blue
226
+ puts "isPublished : ".green + catalogsarray["QueryResultRecords"]["CatalogRecord"][e]["isPublished"].blue
227
+ puts "isShared : ".green + catalogsarray["QueryResultRecords"]["CatalogRecord"][e]["isShared"].blue
228
+ puts "numberOfMedia : ".green + catalogsarray["QueryResultRecords"]["CatalogRecord"][e]["numberOfMedia"].blue
229
+ puts "numberOfVAppTemplates : ".green + catalogsarray["QueryResultRecords"]["CatalogRecord"][e]["numberOfVAppTemplates"].blue
230
+ puts "href : ".green + catalogsarray["QueryResultRecords"]["CatalogRecord"][e]["href"].blue
231
+ puts
232
+ end # catalogsarray["QueryResultRecords"]["CatalogRecord"].length.times
233
+
234
+ when 'catalog'
235
+ if $input3 != nil
236
+ catalogsarray = compute.catalogs(computetoken, computeapiendpoint, apiversion)
237
+ catalogexists = false
238
+ catalogsarray["QueryResultRecords"]["CatalogRecord"].length.times do |e|
239
+ if catalogsarray["QueryResultRecords"]["CatalogRecord"][e]["name"] == $input3
240
+ catalogitemsarray = compute.catalogitems(computetoken, catalogsarray["QueryResultRecords"]["CatalogRecord"][e]["href"], apiversion)
241
+ if mode == "developer" then puts JSON.pretty_generate(catalogitemsarray) end
242
+ if catalogitemsarray["Catalog"]["CatalogItems"] == nil
243
+ puts "The catalog ".red + $input3.blue + " is empty".red
244
+ puts
245
+ else
246
+ catalogitemsarray["Catalog"]["CatalogItems"]["CatalogItem"].length.times do |x|
247
+ puts "CatalogItem name : ".green + catalogitemsarray["Catalog"]["CatalogItems"]["CatalogItem"][x]["name"].blue
248
+ puts "CatalogItem id : ".green + catalogitemsarray["Catalog"]["CatalogItems"]["CatalogItem"][x]["id"].blue
249
+ catalogitemdetails = compute.instancedetails(computetoken, "",catalogitemsarray["Catalog"]["CatalogItems"]["CatalogItem"][x]["href"], apiversion)
250
+ #puts JSON.pretty_generate(catalogitemdetails)
251
+ puts " - Entity name : ".green + catalogitemdetails["CatalogItem"]["Entity"]["name"].blue
252
+ puts " - Entity href : ".green + catalogitemdetails["CatalogItem"]["Entity"]["href"].blue
253
+ puts
254
+ end #catalogitemsarray["Catalog"]["CatalogItems"]["CatalogItem"].length.times do |x|
255
+ end #if catalogitemsarray["Catalog"]["CatalogItems"] == "null"
256
+ catalogexists = true
257
+ end #if catalogsarray["QueryResultRecords"]["CatalogRecord"][e] == $input3
258
+ end #catalogsarray["QueryResultRecords"]["CatalogRecord"].length.times
259
+ if catalogexists == false
260
+ puts "The catalog ".red + $input3.blue + " does not exist".red
261
+ puts
262
+ end #if catalogexists == false
263
+ else #if $input3 != nil
264
+ puts "please provide a catalog name to query".red
265
+ puts
266
+ end #if $input3 != nil
267
+
268
+
269
+
270
+
271
+ when 'vdc'
272
+ if $input3 != nil
273
+ vdcsarray = compute.vdcs(computetoken, computeapiendpoint, apiversion)
274
+ if mode == "developer" then puts JSON.pretty_generate(vdcsarray) end
275
+ vdcexists = false
276
+ vdcsarray["QueryResultRecords"]["OrgVdcRecord"].length.times do |e|
277
+ if vdcsarray["QueryResultRecords"]["OrgVdcRecord"][e]["name"] == $input3
278
+ if $input4 == nil
279
+ #puts JSON.pretty_generate(vdcsarray)
280
+ puts "status : ".bold.green + vdcsarray["QueryResultRecords"]["OrgVdcRecord"][e]["status"].bold.blue
281
+ puts "numberOfVApps : ".bold.green + vdcsarray["QueryResultRecords"]["OrgVdcRecord"][e]["numberOfVApps"].bold.blue
282
+ puts "cpuLimitMhz : ".green + vdcsarray["QueryResultRecords"]["OrgVdcRecord"][e]["cpuLimitMhz"].blue
283
+ puts "cpuUsedMhz : ".green + vdcsarray["QueryResultRecords"]["OrgVdcRecord"][e]["cpuUsedMhz"].blue
284
+ puts "memoryLimitMB : ".green + vdcsarray["QueryResultRecords"]["OrgVdcRecord"][e]["memoryLimitMB"].blue
285
+ puts "memoryUsedMB : ".green + vdcsarray["QueryResultRecords"]["OrgVdcRecord"][e]["memoryUsedMB"].blue
286
+ puts "storageLimitMB : ".green + vdcsarray["QueryResultRecords"]["OrgVdcRecord"][e]["storageLimitMB"].blue
287
+ puts "storageUsedMB : ".green + vdcsarray["QueryResultRecords"]["OrgVdcRecord"][e]["storageUsedMB"].blue
288
+ puts "pvdcHardwareVersion : ".green + vdcsarray["QueryResultRecords"]["OrgVdcRecord"][e]["pvdcHardwareVersion"].blue
289
+ puts
290
+ else #if $input4 == nil
291
+ case $input4.chomp
292
+ when 'networks'
293
+ networksarray = compute.networks(computetoken, vdcsarray["QueryResultRecords"]["OrgVdcRecord"][e]["href"], apiversion)
294
+ if mode == "developer" then puts JSON.pretty_generate(networksarray) end
295
+ networksarray["Network"].length.times do |x|
296
+ networkdetails = compute.networkdetails(computetoken, networksarray["Network"][x]["href"], apiversion)
297
+ if mode == "developer" then puts JSON.pretty_generate(networkdetails) end
298
+ puts "name : ".green + networkdetails["OrgVdcNetwork"]["name"].blue
299
+ puts "href : ".green + networkdetails["OrgVdcNetwork"]["href"].blue
300
+ puts "Configuration : ".green
301
+ puts " - IpScopes : ".green
302
+ puts " - IpScope : ".green
303
+ puts " - Gateway : ".green + networkdetails["OrgVdcNetwork"]["Configuration"]["IpScopes"]["IpScope"]["Gateway"].blue
304
+ puts " - Netmask : ".green + networkdetails["OrgVdcNetwork"]["Configuration"]["IpScopes"]["IpScope"]["Netmask"].blue
305
+ puts " - IsEnabled : ".green + networkdetails["OrgVdcNetwork"]["Configuration"]["IpScopes"]["IpScope"]["IsEnabled"].blue
306
+ puts " - IpRanges : ".green
307
+ puts " - IpRange : ".green
308
+ if networkdetails["OrgVdcNetwork"]["Configuration"]["IpScopes"]["IpScope"]["IpRanges"]
309
+ networkdetails["OrgVdcNetwork"]["Configuration"]["IpScopes"]["IpScope"]["IpRanges"]["IpRange"].length.times do |y|
310
+ puts " - StartAddress : ".green + networkdetails["OrgVdcNetwork"]["Configuration"]["IpScopes"]["IpScope"]["IpRanges"]["IpRange"][y]["StartAddress"].blue
311
+ puts " - EndAddress : ".green + networkdetails["OrgVdcNetwork"]["Configuration"]["IpScopes"]["IpScope"]["IpRanges"]["IpRange"][y]["EndAddress"].blue
312
+ end #networkdetails["OrgVdcNetwork"]["Configuration"]["IpScopes"]["IpScope"]["IpRanges"]["IpRange"].length do |y|
313
+ end #if networkdetails["OrgVdcNetwork"]["Configuration"]["IpScopes"]["IpScope"]["IpRanges"]
314
+ puts " - FenceMode : ".green + networkdetails["OrgVdcNetwork"]["Configuration"]["FenceMode"].blue
315
+ puts " - RetainNetInfoAcrossDeployments : ".green + networkdetails["OrgVdcNetwork"]["Configuration"]["RetainNetInfoAcrossDeployments"].blue
316
+ puts "IsShared : ".green + networkdetails["OrgVdcNetwork"]["IsShared"].blue
317
+ puts
318
+ puts
319
+ end # networksarray["Network"].length.times do |x|
320
+
321
+ else #case $input4.chomp
322
+ puts "The operation ".red + $input4.blue + " against the vdc is not recognized as a valid operation".red
323
+ end #case $input4.chomp
324
+ end #if $input4 == nil
325
+ vdcexists = true
326
+ end #if vdcsarray["QueryResultRecords"]["OrgVdcRecord"][e]["name"] == $input3
327
+ end #vdcsarray["QueryResultRecords"]["OrgVdcRecord"].length.times do |e|
328
+
329
+ if vdcexists == false
330
+ puts "The vdc ".red + $input3.blue + " does not exist".red
331
+ puts
332
+ end #if vdcexists == false
333
+
334
+ else #if $input3 != nil
335
+ puts "please provide a vdc name to query".red
336
+ puts
337
+ end #if $input3 != nil
338
+
339
+
340
+ else #case $input2.chomp
341
+ puts "The operation ".red + $input3.to_s + " against the instance is not recognized as a valid operation".red
342
+ puts
343
+ end #case $input2.chomp
344
+
345
+
346
+
347
+
348
+ # If the user did not specify an operation at all we suggest how to properly use the CLI
349
+
350
+ else #if $input0 && $input1 && input2
351
+ puts "\n"
352
+ puts "You must specify the <API-URL-endpoint>, the <Org name> and a valid operation".red
353
+ puts "e.g. https://us-virginia-1-4.vchs.vmware.com 616ge553-342d-e4-be4a-d50e5sde5283 vdcs".red
354
+ puts "e.g. https://iaas.vcdcloud.com acme catalogs".red
355
+ puts "\n"
356
+ usage()
357
+ puts "\n"
358
+
359
+
360
+
361
+ end #if $input0 && $input1 && input2
362
+
363
+
364
+
365
+
366
+
367
+
368
+
369
+
370
+
371
+
372
+
373
+
374
+
375
+
376
+
377
+
378
+
379
+
380
+
381
+
382
+
383
+
384
+
385
+
386
+
387
+
388
+
389
+
390
+
391
+
392
+
393
+
394
+
395
+
396
+
397
+
398
+
399
+
400
+
401
+
402
+
403
+
@@ -0,0 +1,108 @@
1
+ #################################################################################
2
+ #### Massimo Re Ferre' ####
3
+ #### www.it20.info ####
4
+ #### vcautils, a set of utilities for vCloud Air Consumers ####
5
+ #################################################################################
6
+
7
+
8
+
9
+ class Compute
10
+ include HTTParty
11
+ format :xml
12
+ #debug_output $stderr
13
+
14
+
15
+ def hashtoarray(structure)
16
+ #this function work arounds an issue of httparty (and other REST clients apparently) that do not comply to the XML Schema correctly
17
+ #in some circumstances the httparty response contains a hash whereas it should be an array of hash with one item
18
+ #this function takes input a JSON structure and check if it's a hash. If it is, it will turn it into an array of hash with one element
19
+ #if the input is already an Array of hash it will do nothing
20
+ #for further reference: http://stackoverflow.com/questions/28282125/httparty-response-interpretation-in-ruby/
21
+ structure = [structure] unless structure.is_a? Array
22
+ return structure
23
+ end #hashtoarray
24
+
25
+
26
+ def apiversions(apiendpoint)
27
+ self.class.base_uri apiendpoint
28
+ apiversionsarray = self.class.get('/api/versions')
29
+ return apiversionsarray
30
+ end #setapiversion
31
+
32
+
33
+ def login(username, password, orgname, computeapiendpoint, apiversion)
34
+ credentials = username + "@" + orgname
35
+ self.class.base_uri computeapiendpoint
36
+ self.class.basic_auth credentials, password
37
+ self.class.default_options[:headers] = {"Accept" => "application/*+xml;version=" + apiversion}
38
+ response = self.class.post('/api/sessions')
39
+ computetoken = response.headers['x-vcloud-authorization']
40
+ return computetoken
41
+ end #login
42
+
43
+
44
+ def instancedetails(computetoken, computeapiendpoint, query, apiversion)
45
+ self.class.default_options[:headers] = { "Accept" => "application/*+xml;version=" + apiversion, "x-vcloud-authorization" => computetoken }
46
+ instancedetails = self.class.get(computeapiendpoint + query)
47
+ return instancedetails
48
+ end #login
49
+
50
+
51
+ def vdcs (computetoken, computeapiendpoint, apiversion)
52
+ vdcsarray = instancedetails(computetoken, computeapiendpoint, "/api/admin/vdcs/query", apiversion)
53
+ vdcsarray["QueryResultRecords"]["OrgVdcRecord"] = hashtoarray(vdcsarray["QueryResultRecords"]["OrgVdcRecord"])
54
+ return vdcsarray
55
+ end #vdcs
56
+
57
+
58
+ def catalogs (computetoken, computeapiendpoint, apiversion)
59
+ catalogsarray = instancedetails(computetoken, computeapiendpoint, "/api/catalogs/query", apiversion)
60
+ catalogsarray["QueryResultRecords"]["CatalogRecord"] = hashtoarray(catalogsarray["QueryResultRecords"]["CatalogRecord"])
61
+ return catalogsarray
62
+ end #catalogs
63
+
64
+
65
+ def catalogitems (computetoken, cataloghref, apiversion)
66
+ catalogitemsarray = instancedetails(computetoken, cataloghref, "", apiversion)
67
+ if catalogitemsarray["Catalog"]["CatalogItems"] != nil
68
+ catalogitemsarray["Catalog"]["CatalogItems"]["CatalogItem"] = hashtoarray(catalogitemsarray["Catalog"]["CatalogItems"]["CatalogItem"])
69
+ end
70
+ return catalogitemsarray
71
+ end #catalogitems
72
+
73
+
74
+ def orgvms (computetoken, computeapiendpoint, apiversion)
75
+ orgvmsarray = instancedetails(computetoken, computeapiendpoint, "/api/vms/query", apiversion)
76
+ return orgvmsarray
77
+ end #orgvms
78
+
79
+
80
+ def orgvapps (computetoken, computeapiendpoint, apiversion)
81
+ orgvappsarray = instancedetails(computetoken, computeapiendpoint, "/api/vApps/query", apiversion)
82
+ return orgvappsarray
83
+ end #orgvapps
84
+
85
+
86
+ def networks (computetoken, vdchref, apiversion)
87
+ vdcdetails = instancedetails(computetoken, vdchref, "", apiversion)
88
+ networksarray = vdcdetails["Vdc"]["AvailableNetworks"]
89
+ networksarray["Network"] = hashtoarray(networksarray["Network"])
90
+ return networksarray
91
+ end #networks
92
+
93
+
94
+ def networkdetails (computetoken, networkhref, apiversion)
95
+ networkdetails = instancedetails(computetoken, networkhref, "", apiversion)
96
+ if networkdetails["OrgVdcNetwork"]["Configuration"]["IpScopes"]["IpScope"]["IpRanges"]
97
+ networkdetails["OrgVdcNetwork"]["Configuration"]["IpScopes"]["IpScope"]["IpRanges"]["IpRange"] = hashtoarray(networkdetails["OrgVdcNetwork"]["Configuration"]["IpScopes"]["IpScope"]["IpRanges"]["IpRange"])
98
+ end #if networkdetails["OrgVdcNetwork"]["Configuration"]["IpScopes"]["IpScope"]["IpRanges"]
99
+ return networkdetails
100
+ end #networkdetails
101
+
102
+
103
+
104
+
105
+
106
+ end #Compute
107
+
108
+