Class: Vcli::CLI::Show
- Inherits:
-
Thor
- Object
- Thor
- Vcli::CLI::Show
- Defined in:
- lib/vcli/cli/show.rb
Instance Method Summary collapse
- #datacenters ⇒ Object
- #enterprise ⇒ Object
- #templates ⇒ Object
- #users ⇒ Object
- #virtualappliances ⇒ Object
- #virtualdatacenters ⇒ Object
- #virtualmachines ⇒ Object
- #vlans ⇒ Object
Instance Method Details
#datacenters ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/vcli/cli/show.rb', line 26 def datacenters( ) begin abq = AbiquoAPI.new(:abiquo_api_url => Vcli::target, :abiquo_username => Vcli::user, :abiquo_password => Vcli::password) link=AbiquoAPI::Link.new(:href => 'api/admin/datacenters' , :type => 'application/vnd.abiquo.datacenters+json') dc=abq.list(link) dc.each { |l| puts "#{l.name} \t - #{l.id} \t - #{l.location}" if .limits? link2=AbiquoAPI::Link.new(:href => 'api/admin/datacenters/' + l.id.to_s + "/action/getlimits", :type => 'application/vnd.abiquo.limits+json') limits=abq.list(link2) puts "#{limits}.inspect" end } rescue AbiquoAPIClient::Forbidden puts "Forbidden HTTP 403 Received" rescue AbiquoAPIClient::InvalidCredentials puts "Invalid Credentials - HTTP 401 Received" rescue AbiquoAPIClient::BadRequest puts "Bad Request - HTTP 400 or 406 Received" rescue AbiquoAPIClient::NotFound puts "Note Found - HTTP 400 Received" rescue AbiquoAPIClient::UnsupportedMediaType puts "Unsupported Media Type Specified - HTTP 415 Received" end end |
#enterprise ⇒ Object
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 |
# File 'lib/vcli/cli/show.rb', line 195 def enterprise( ) begin abq = AbiquoAPI.new(:abiquo_api_url => Vcli::target, :abiquo_username => Vcli::user, :abiquo_password => Vcli::password) ent=[:ent].to_s if ent.length == 0 link=AbiquoAPI::Link.new(:href => 'api/admin/enterprises', :type => 'application/vnd.abiquo.enterprises+json') enterprises=abq.list(link) enterprises.each { |l| puts "#{l.id} \t - #{l.name}" } else link=AbiquoAPI::Link.new(:href => 'api/admin/enterprises/' + ent + '', :type => 'application/vnd.abiquo.enterprise+json', :client => abq) enterprises=link.get puts 'Enterprise ID - ' + enterprises.id.to_s puts 'Enterprise Name - ' + enterprises.name puts 'CPU Hard Limit - ' + enterprises.cpuCountHardLimit.to_s puts 'CPU Soft Limit - ' + enterprises.cpuCountSoftLimit.to_s puts 'RAM Hard Limit (MB)- ' + enterprises.ramHardLimitInMb.to_s puts 'RAM Soft Limit (MB)- ' + enterprises.ramSoftLimitInMb.to_s puts 'Public IP Hard Limit - ' + enterprises.publicIpsHard.to_s puts 'Public IP Soft Limit - ' + enterprises.publicIpsSoft.to_s puts 'Disk Hard Limit (MB)- ' + enterprises.diskHardLimitInMb.to_s puts 'Disk Soft Limit (MB)- ' + enterprises.diskSoftLimitInMb.to_s puts 'Repository Hard Limit (MB)- ' + enterprises.repositoryHardInMb.to_s puts 'Repository Soft Limit (MB)- ' + enterprises.repositorySoftInMb.to_s puts 'Storage Hard Limit (MB)- ' + enterprises.storageHardInMb.to_s puts 'Storage Soft Limit (MB)- ' + enterprises.storageSoftInMb.to_s puts 'VLANs Hard Limit - ' + enterprises.vlansHard.to_s puts 'VLANs Soft Limit - ' + enterprises.vlansSoft.to_s end rescue AbiquoAPIClient::Forbidden puts "Forbidden HTTP 403 Received" rescue AbiquoAPIClient::InvalidCredentials puts "Invalid Credentials - HTTP 401 Received" rescue AbiquoAPIClient::BadRequest puts "Bad Request - HTTP 400 or 406 Received" rescue AbiquoAPIClient::NotFound puts "Note Found - HTTP 400 Received" rescue AbiquoAPIClient::UnsupportedMediaType puts "Unsupported Media Type Specified - HTTP 415 Received" end end |
#templates ⇒ Object
246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 |
# File 'lib/vcli/cli/show.rb', line 246 def templates( ) abq = AbiquoAPI.new(:abiquo_api_url => Vcli::target, :abiquo_username => Vcli::user, :abiquo_password => Vcli::password) vdc=[:vdc].to_s link=AbiquoAPI::Link.new(:href => 'api/cloud/virtualdatacenters/' + vdc + '/action/templates', :type => 'application/vnd.abiquo.virtualmachinetemplates+json', :client => abq) templates=link.get puts "ID, Name, OS Type, CPU Req, RAM Req" templates.each {|l| puts "#{l.id},#{l.name},#{l.osType},#{l.cpuRequired},#{l.ramRequired}" } end |
#users ⇒ Object
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 |
# File 'lib/vcli/cli/show.rb', line 165 def users( ) begin abq = AbiquoAPI.new(:abiquo_api_url => Vcli::target, :abiquo_username => Vcli::user, :abiquo_password => Vcli::password) abq.user ent=abq.user.link(:enterprise).get link=AbiquoAPI::Link.new(:href => 'api/admin/enterprises/'+ent.id.to_s + '/users', :type => 'application/vnd.abiquo.users+json') users=abq.list(link) puts "UserID,Firstname,Surname,Email" users.each { |m| puts "#{m.id},#{m.name},#{m.surname},#{m.email}" } rescue AbiquoAPIClient::Forbidden puts "Forbidden HTTP 403 Received" rescue AbiquoAPIClient::InvalidCredentials puts "Invalid Credentials - HTTP 401 Received" rescue AbiquoAPIClient::BadRequest puts "Bad Request - HTTP 400 or 406 Received" rescue AbiquoAPIClient::NotFound puts "Note Found - HTTP 400 Received" rescue AbiquoAPIClient::UnsupportedMediaType puts "Unsupported Media Type Specified - HTTP 415 Received" end end |
#virtualappliances ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/vcli/cli/show.rb', line 59 def virtualappliances( ) begin abq = AbiquoAPI.new(:abiquo_api_url => Vcli::target, :abiquo_username => Vcli::user, :abiquo_password => Vcli::password) # Get something on the screen puts "VDC,Appliance Name,Appliance ID" # If --vdc parameter passed vdc=[:vdc].to_s if vdc.length != 0 link2=AbiquoAPI::Link.new(:href => 'api/cloud/virtualdatacenters/' + vdc + '/virtualappliances' , :type => 'application/vnd.abiquo.virtualappliances+json') virtualappliance=abq.list(link2) virtualappliance.each { |l| puts "#{vdc},#{l.name},#{l.id}" } # If no --vdc parameter passwd else # Cycle through all virtualdatacenters link=AbiquoAPI::Link.new(:href => 'api/cloud/virtualdatacenters', :type => 'application/vnd.abiquo.virtualdatacenters+json') virtualdatacenter=abq.list(link) # Cycle through all virtual appliances in virtual datacenter virtualdatacenter.each { |l| link2=AbiquoAPI::Link.new(:href => 'api/cloud/virtualdatacenters/' + l.id.to_s + '/virtualappliances' , :type => 'application/vnd.abiquo.virtualappliances+json') virtualappliance=abq.list(link2) virtualappliance.each { |m| puts "#{l.id},#{m.name},#{m.id}" } } end rescue AbiquoAPIClient::Forbidden puts "Forbidden HTTP 403 Received" rescue AbiquoAPIClient::InvalidCredentials puts "Invalid Credentials - HTTP 401 Received" rescue AbiquoAPIClient::BadRequest puts "Bad Request - HTTP 400 or 406 Received" rescue AbiquoAPIClient::NotFound puts "Note Found - HTTP 400 Received" rescue AbiquoAPIClient::UnsupportedMediaType puts "Unsupported Media Type Specified - HTTP 415 Received" end end |
#virtualdatacenters ⇒ Object
266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 |
# File 'lib/vcli/cli/show.rb', line 266 def virtualdatacenters( ) begin abq = AbiquoAPI.new(:abiquo_api_url => Vcli::target, :abiquo_username => Vcli::user, :abiquo_password => Vcli::password) vdc=[:vdc].to_s if vdc.length==0 link=AbiquoAPI::Link.new(:href => 'api/cloud/virtualdatacenters', :type => 'application/vnd.abiquo.virtualdatacenters+json', :client => abq) vdcs=link.get vdcs.each { |l| puts "#{l.id} \t - #{l.name}" } else link=AbiquoAPI::Link.new(:href => 'api/cloud/virtualdatacenters/' + vdc, :type => 'application/vnd.abiquo.virtualdatacenter+json', :client => abq) l=link.get puts "#{l.id} \t - #{l.name}" puts " - RAM Soft Limit (MB) - #{l.ramSoftLimitInMb}" puts " - RAM Hard Limit (MB) - #{l.ramHardLimitInMb}" puts " - CPU Soft Limit - #{l.cpuCountSoftLimit}" puts " - CPU Hard Limit - #{l.cpuCountHardLimit}" puts " - Disk Soft Limit (MB) - #{l.diskSoftLimitInMb}" puts " - Disk Hard Limit (MB) - #{l.diskHardLimitInMb}" puts " - Storage Soft Limit (MB) - #{l.storageSoftInMb}" puts " - Storage Hard Limit (MB) - #{l.storageHardInMb}" puts " - VLANS Soft Limit - #{l.vlansSoft}" puts " - VLANS Hard Limit - #{l.vlansHard}" puts " - Public IPS Soft Limit - #{l.publicIpsSoft}" puts " - Public IPS Hard Limit - #{l.publicIpsHard}" end rescue AbiquoAPIClient::Forbidden puts "Forbidden HTTP 403 Received" rescue AbiquoAPIClient::InvalidCredentials puts "Invalid Credentials - HTTP 401 Received" rescue AbiquoAPIClient::BadRequest puts "Bad Request - HTTP 400 or 406 Received" rescue AbiquoAPIClient::NotFound puts "Note Found - HTTP 400 Received" rescue AbiquoAPIClient::UnsupportedMediaType puts "Unsupported Media Type Specified - HTTP 415 Received" end end |
#virtualmachines ⇒ Object
317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 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 |
# File 'lib/vcli/cli/show.rb', line 317 def virtualmachines( ) begin abq = AbiquoAPI.new(:abiquo_api_url => Vcli::target, :abiquo_username => Vcli::user, :abiquo_password => Vcli::password) # If --vdc parameter passed va=[:va].to_s vdc=[:vdc].to_s if va.length == 0 && vdc.length == 0 # Cycle through all virtualdatacenters link=AbiquoAPI::Link.new(:href => 'api/cloud/virtualdatacenters', :type => 'application/vnd.abiquo.virtualdatacenters+json') virtualdatacenters=abq.list(link) # Cycle through all virtual appliances in virtual datacenter virtualdatacenters.each { |l| puts "- VDC - #{l.id} " link2=AbiquoAPI::Link.new(:href => 'api/cloud/virtualdatacenters/' + l.id.to_s + '/virtualappliances' , :type => 'application/vnd.abiquo.virtualappliances+json') virtualappliances=abq.list(link2) virtualappliances.each { |m| puts " - Virtual Appliance - #{m.name} - VA ID - #{m.id}" link3=AbiquoAPI::Link.new(:href => 'api/cloud/virtualdatacenters/' + l.id.to_s + '/virtualappliances/' + m.id.to_s + '/virtualmachines' , :type => 'application/vnd.abiquo.virtualmachines+json') virtualmachines=abq.list(link3) virtualmachines.each { |n| puts " - ID: #{n.id}, UUID: #{n.uuid}" puts " - Name: #{n.label}" puts " - CPU: #{n.cpu} RAM: #{n.ram} MB" disksizeInGB = n.hdInBytes/(1024**3) puts " - HD Size: #{disksizeInGB} GB" puts " - State: #{n.state}" } } } elsif vdc.length != 0 && va.length == 0 puts "- VDC - #{vdc.to_s} " link2=AbiquoAPI::Link.new(:href => 'api/cloud/virtualdatacenters/' + vdc.to_s + '/virtualappliances' , :type => 'application/vnd.abiquo.virtualappliances+json') virtualappliances=abq.list(link2) virtualappliances.each { |m| puts " - Virtual Appliance - #{m.name} - VA ID - #{m.id}" link3=AbiquoAPI::Link.new(:href => 'api/cloud/virtualdatacenters/' + vdc.to_s + '/virtualappliances/' + m.id.to_s + '/virtualmachines' , :type => 'application/vnd.abiquo.virtualmachines+json') virtualmachines=abq.list(link3) virtualmachines.each { |n| puts " - ID: #{n.id}, UUID: #{n.uuid}" puts " - Name: #{n.label}" puts " - CPU: #{n.cpu} RAM: #{n.ram} MB" disksizeInGB = n.hdInBytes/(1024**3) puts " - HD Size: #{disksizeInGB} GB" puts " - State: #{n.state}" } } elsif vdc.length != 0 && va.length != 0 link3=AbiquoAPI::Link.new(:href => 'api/cloud/virtualdatacenters/' + vdc.to_s + '/virtualappliances/' + va.to_s + '/virtualmachines' , :type => 'application/vnd.abiquo.virtualmachines+json') virtualmachines=abq.list(link3) virtualmachines.each { |n| puts " - ID: #{n.id}, UUID: #{n.uuid}" puts " - Name: #{n.label}" puts " - CPU: #{n.cpu} RAM: #{n.ram} MB" disksizeInGB = n.hdInBytes/(1024**3) puts " - HD Size: #{disksizeInGB} GB" puts " - State: #{n.state}" } else puts "If options are used the alternatives are as follows:" puts " --VDC xxx --VA xxx" puts " --VDC xxx" puts "using --VA without --VDC is not allowed" end rescue AbiquoAPIClient::Forbidden puts "Forbidden HTTP 403 Received" rescue AbiquoAPIClient::InvalidCredentials puts "Invalid Credentials - HTTP 401 Received" rescue AbiquoAPIClient::BadRequest puts "Bad Request - HTTP 400 or 406 Received" rescue AbiquoAPIClient::NotFound puts "Note Found - HTTP 400 Received" rescue AbiquoAPIClient::UnsupportedMediaType puts "Unsupported Media Type Specified - HTTP 415 Received" end end |
#vlans ⇒ Object
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
# File 'lib/vcli/cli/show.rb', line 108 def vlans( ) begin abq = AbiquoAPI.new(:abiquo_api_url => Vcli::target, :abiquo_username => Vcli::user, :abiquo_password => Vcli::password) # Get something on the screen puts "VLAN ID,VLAN Name,VDC ID,Network,Mask,Gateway" # If --vdc parameter passed vdc=[:vdc].to_s if vdc.length != 0 link=AbiquoAPI::Link.new(:href => 'api/cloud/virtualdatacenters/' + vdc + '/privatenetworks' , :type => 'application/vnd.abiquo.vlans+json') vlans=abq.list(link) vlans.each { |l| puts "#{l.id},#{l.name},#{vdc},#{l.address},#{l.mask},#{l.gateway}" if [:ips] id=l.id.to_s link2=AbiquoAPI::Link.new(:href => 'api/cloud/virtualdatacenters/' + vdc + '/privatenetworks/' + id + '/ips', :type => 'application/vnd.abiquo.privateips+json') listofips=abq.list(link2) listofips.each { |m| puts " - #{m.id}, #{m.ip}, #{m.name}" } end } # If no --vdc parameter passwd else # Cycle through all virtualdatacenters link=AbiquoAPI::Link.new(:href => 'api/cloud/virtualdatacenters', :type => 'application/vnd.abiquo.virtualdatacenters+json') virtualdatacenter=abq.list(link) # Cycle through all virtual appliances in virtual datacenter virtualdatacenter.each { |l| link2=AbiquoAPI::Link.new(:href => 'api/cloud/virtualdatacenters/' + l.id.to_s + '/privatenetworks' , :type => 'application/vnd.abiquo.vlans+json') vlans=abq.list(link2) vlans.each { |m| puts "#{m.id},#{m.name},#{l.id},#{m.address},#{m.mask},#{m.gateway}" } } end rescue AbiquoAPIClient::Forbidden puts "Forbidden HTTP 403 Received" rescue AbiquoAPIClient::InvalidCredentials puts "Invalid Credentials - HTTP 401 Received" rescue AbiquoAPIClient::BadRequest puts "Bad Request - HTTP 400 or 406 Received" rescue AbiquoAPIClient::NotFound puts "Note Found - HTTP 400 Received" rescue AbiquoAPIClient::UnsupportedMediaType puts "Unsupported Media Type Specified - HTTP 415 Received" end end |