webee 0.3.3 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- data/examples/all_vms.rb +31 -0
- data/lib/webee.rb +39 -3
- metadata +5 -3
data/examples/all_vms.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
$: << '../lib'
|
2
|
+
require 'webee'
|
3
|
+
require 'md5'
|
4
|
+
require 'active_support'
|
5
|
+
require 'term/ansicolor'
|
6
|
+
|
7
|
+
class String
|
8
|
+
include Term::ANSIColor
|
9
|
+
end
|
10
|
+
|
11
|
+
WeBee::Api.user = ENV['user'] || 'admin'
|
12
|
+
WeBee::Api.password = ENV['pass'] || 'xabiquo'
|
13
|
+
WeBee::Api.url = 'http://server/api'
|
14
|
+
|
15
|
+
include WeBee
|
16
|
+
|
17
|
+
Datacenter.all.each do |dc|
|
18
|
+
dc.racks.each do |rack|
|
19
|
+
puts "Rack: #{rack.name}"
|
20
|
+
rack.machines.each do |machine|
|
21
|
+
puts "Machine:".green.bold + " #{machine.name} (#{machine.virtual_machines.size} VMs)"
|
22
|
+
machine.virtual_machines.each do |vm|
|
23
|
+
if vm.managed?
|
24
|
+
puts " Name:".yellow.bold + " #{vm.name} " + "Enterprise:".yellow.bold + " #{vm.enterprise.name} " + "VDC:".yellow.bold + " #{vm.vdc.name}"
|
25
|
+
else
|
26
|
+
puts " Name:".yellow.bold + " #{vm.name} "
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/webee.rb
CHANGED
@@ -28,7 +28,7 @@ end
|
|
28
28
|
|
29
29
|
module WeBee
|
30
30
|
|
31
|
-
VERSION = '0.3.
|
31
|
+
VERSION = '0.3.4'
|
32
32
|
|
33
33
|
module RestResource
|
34
34
|
|
@@ -82,7 +82,6 @@ module WeBee
|
|
82
82
|
@url = build_url(url)
|
83
83
|
end
|
84
84
|
|
85
|
-
private
|
86
85
|
def build_url(url)
|
87
86
|
port ||= 80
|
88
87
|
uri = URI.parse(url)
|
@@ -385,6 +384,8 @@ module WeBee
|
|
385
384
|
element :ramUsed, :as => :ram_used
|
386
385
|
element :virtualSwitch, :as => :virtual_switch
|
387
386
|
elements :datastore, :as => :datastores, :class => Datastore
|
387
|
+
element :link, :value => :href, :as => :virtual_machines_url, :with => {:title => "virtualmachines" }
|
388
|
+
element :link, :value => :href, :as => :rack_url, :with => { :rel => "rack" }
|
388
389
|
|
389
390
|
def virtual_switches
|
390
391
|
virtual_switch.split('/')
|
@@ -428,6 +429,20 @@ module WeBee
|
|
428
429
|
xm.target!
|
429
430
|
end
|
430
431
|
|
432
|
+
def rack
|
433
|
+
doc = Nokogiri.parse(RestClient.get(Api.build_url(rack_url) , :accept => :xml))
|
434
|
+
Rack.parse doc.root.to_s
|
435
|
+
end
|
436
|
+
|
437
|
+
def virtual_machines
|
438
|
+
items = []
|
439
|
+
doc = Nokogiri.parse(RestClient.get(Api.build_url(virtual_machines_url) , :accept => :xml))
|
440
|
+
doc.search('//virtualMachine').each do |node|
|
441
|
+
items << VirtualMachine.parse(node.to_s)
|
442
|
+
end
|
443
|
+
items
|
444
|
+
end
|
445
|
+
|
431
446
|
end
|
432
447
|
|
433
448
|
class RemoteServiceType
|
@@ -849,7 +864,7 @@ module WeBee
|
|
849
864
|
end
|
850
865
|
|
851
866
|
def enterprise
|
852
|
-
doc = Nokogiri.parse(RestClient.get(Api.
|
867
|
+
doc = Nokogiri.parse(RestClient.get(Api.build_url(enterprise_url) , :accept => :xml))
|
853
868
|
Enterprise.parse doc.root.to_s
|
854
869
|
end
|
855
870
|
|
@@ -868,6 +883,27 @@ module WeBee
|
|
868
883
|
element :highDisponibility, :as => :high_disponibility
|
869
884
|
element :password
|
870
885
|
element :id, :as => :virtualmachine_id
|
886
|
+
element :idType, :as => :id_type
|
887
|
+
element :link, :value => :href, :as => :vdc_url, :with => {:rel => "virtualdatacenter" }
|
888
|
+
element :link, :value => :href, :as => :enterprise_url, :with => {:rel => "enterprise" }
|
889
|
+
|
890
|
+
def vdc
|
891
|
+
return nil if not managed?
|
892
|
+
# FIXME: Buggy Abiquo ABI missing some relations
|
893
|
+
doc = Nokogiri.parse(RestClient.get(Api.build_url(vdc_url) , :accept => :xml))
|
894
|
+
Rack.parse doc.root.to_s
|
895
|
+
end
|
896
|
+
|
897
|
+
def managed?
|
898
|
+
id_type.eql?("0") ? false : true
|
899
|
+
end
|
900
|
+
|
901
|
+
def enterprise
|
902
|
+
return nil if not managed?
|
903
|
+
# FIXME: Buggy Abiquo ABI missing some relations
|
904
|
+
doc = Nokogiri.parse(RestClient.get(Api.build_url(enterprise_url) , :accept => :xml))
|
905
|
+
Enterprise.parse doc.root.to_s
|
906
|
+
end
|
871
907
|
|
872
908
|
end
|
873
909
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: webee
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 4
|
10
|
+
version: 0.3.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Sergio Rubio
|
@@ -130,6 +130,7 @@ files:
|
|
130
130
|
- README.md
|
131
131
|
- Rakefile
|
132
132
|
- bin/webee
|
133
|
+
- examples/all_vms.rb
|
133
134
|
- examples/basics.rb
|
134
135
|
- examples/bootstrap.rb
|
135
136
|
- examples/list_hypervisors.rb
|
@@ -178,6 +179,7 @@ signing_key:
|
|
178
179
|
specification_version: 3
|
179
180
|
summary: Abiquo API Ruby Implementation
|
180
181
|
test_files:
|
182
|
+
- examples/all_vms.rb
|
181
183
|
- examples/basics.rb
|
182
184
|
- examples/bootstrap.rb
|
183
185
|
- examples/list_hypervisors.rb
|