webee 0.2.1 → 0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. data/Rakefile +1 -0
  2. data/examples/basics.rb +13 -1
  3. data/examples/test.rb +14 -9
  4. data/lib/webee.rb +89 -1
  5. metadata +20 -7
data/Rakefile CHANGED
@@ -20,6 +20,7 @@ Jeweler::Tasks.new do |gem|
20
20
  gem.add_runtime_dependency 'rest-client'
21
21
  gem.add_runtime_dependency 'nokogiri'
22
22
  gem.add_runtime_dependency 'builder'
23
+ gem.add_runtime_dependency 'i18n'
23
24
  gem.add_runtime_dependency 'alchemist'
24
25
  gem.add_runtime_dependency 'activesupport'
25
26
  # gem.add_development_dependency 'rspec', '> 1.2.3'
data/examples/basics.rb CHANGED
@@ -166,4 +166,16 @@ WeBee::VDC.all
166
166
  # List all VDCs from a specific Enterprise/Datacenter
167
167
  # Needs Cloud operator privileges
168
168
  #
169
- WeBee::VDC.all :datacenter_id => WeBee::Datacenter.all.first.datacenter_id, :enterprise_id => 3
169
+ vdc = (WeBee::VDC.all :datacenter_id => WeBee::Datacenter.all.first.datacenter_id, :enterprise_id => qa.enterprise_id).first
170
+
171
+ #
172
+ # List all the Virtual Apps in an VDC
173
+ #
174
+ vdc.virtual_appliances.each do |vapp|
175
+ #
176
+ # List the VM in a VAPP
177
+ #
178
+ vapp.virtual_machines.each do |vm|
179
+ #puts vm.name
180
+ end
181
+ end
data/examples/test.rb CHANGED
@@ -5,16 +5,21 @@ require 'active_support'
5
5
 
6
6
  WeBee::Api.user = ENV['user'] || 'admin'
7
7
  WeBee::Api.password = ENV['pass'] || 'xabiquo'
8
- WeBee::Api.url = 'http://10.60.1.24/api'
8
+ WeBee::Api.url = 'http://mothership.60.1.24/api'
9
9
 
10
- #rs = WeBee::RemoteService.create_for_host("10.60.1.24")
10
+ include WeBee
11
11
 
12
- WeBee::Datacenter.create :name => 'BCN'
13
- # :remote_services => rs
14
- #
15
- WeBee::Enterprise.create :name => 'QA'
16
-
17
- WeBee::
18
-
12
+ vdcs = WeBee::VDC.all(:datacenter_id => WeBee::Datacenter.all.first.datacenter_id, :enterprise_id => Enterprise.all.first.enterprise_id)
19
13
 
14
+ #
15
+ # List all the Virtual Apps in an VDC
16
+ #
17
+ vdc.virtual_appliances.each do |vapp|
18
+ #
19
+ # List the VM in a VAPP
20
+ #
21
+ vapp.virtual_machines.each do |vm|
22
+ #puts vm.name
23
+ end
24
+ end
20
25
 
data/lib/webee.rb CHANGED
@@ -28,7 +28,7 @@ end
28
28
 
29
29
  module WeBee
30
30
 
31
- VERSION = '0.2.1'
31
+ VERSION = '0.3'
32
32
 
33
33
 
34
34
  module RestResource
@@ -484,6 +484,8 @@ module WeBee
484
484
  element :vlanHard, :as => :vlan_hard
485
485
  element :hypervisorType, :as => :hypervisortype
486
486
  element :network, :class => VDCNetwork
487
+ element :link, :value => :href, :as => :datacenter_url, :with => {:rel => "datacenter" }
488
+ element :link, :value => :href, :as => :enterprise_url, :with => {:rel => "enterprise" }
487
489
 
488
490
  def self.create(attributes)
489
491
  datacenter = attributes[:datacenter].datacenter_id
@@ -580,6 +582,66 @@ module WeBee
580
582
  def self.find_by_name(name, options = {})
581
583
  VDC.all(options).find_all { |vdc| vdc.name =~ /#{name}/ }
582
584
  end
585
+
586
+ #
587
+ # List all the virtual appliances in this virtual datacenter
588
+ #
589
+ def virtual_appliances
590
+ items = []
591
+ doc = Nokogiri.parse(RestClient.get(Api.url + "/cloud/virtualdatacenters/#{vdc_id}/virtualappliances", :accept => :xml))
592
+ doc.search('//virtualAppliance').each do |node|
593
+ vapp = VirtualAppliance.parse(node.to_s)
594
+ vapp.vdc_id = vdc_id
595
+ items << vapp
596
+ end
597
+ items
598
+ end
599
+
600
+ end
601
+
602
+ class VirtualAppliance
603
+ include SAXMachine
604
+
605
+ attr_accessor :vdc_id
606
+
607
+ element :name
608
+ element :highDisponibility, :as => :high_disponibility
609
+ element :error
610
+ element :publicApp, :as => :public_app
611
+ element :state
612
+ element :subState, :as => :sub_state
613
+ element :id, :as => :virtual_appliance_id
614
+
615
+ def virtual_machines
616
+ items = []
617
+ doc = Nokogiri.parse(RestClient.get(Api.url + "/cloud/virtualdatacenters/#{vdc_id}/virtualappliances/#{virtual_appliance_id}/virtualmachines", :accept => :xml))
618
+ doc.search('//virtualMachine').each do |node|
619
+ items << VirtualMachine.parse(node.to_s)
620
+ end
621
+ items
622
+ end
623
+ end
624
+
625
+ class DatacenterLimit
626
+ include SAXMachine
627
+
628
+ element :id, :as => :datacenter_limit_id
629
+ element :ramSoft, :as => :ram_soft
630
+ element :ramHard, :as => :ram_hard
631
+ element :cpuSoft, :as => :cpu_soft
632
+ element :cpuHard, :as => :cpu_hard
633
+ element :storageSoft, :as => :storage_soft
634
+ element :storageHard, :as => :storage_hard
635
+ element :repositorySoft, :as => :repository_soft
636
+ element :repositoryHard, :as => :repository_hard
637
+ element :publicIpsSoft, :as => :public_ip_soft
638
+ element :publicIpsHard, :as => :public_ip_hard
639
+ element :hdSoft, :as => :hd_soft
640
+ element :hdHard, :as => :hd_hard
641
+ element :vlanSoft, :as => :vlan_soft
642
+ element :vlanHard, :as => :vlan_hard
643
+ element :idEnterprise, :as => :enterprise_id
644
+ element :idDataCenter, :as => :datacenter_id
583
645
 
584
646
  end
585
647
 
@@ -607,7 +669,16 @@ module WeBee
607
669
  element :vlanSoft, :as => :vlan_soft
608
670
  element :vlanHard, :as => :vlan_hard
609
671
  element :isReservationRestricted, :as => :is_reservation_restricted
672
+ element :link, :value => :href, :as => :limits_url, :with => {:rel => "limits" }
610
673
 
674
+ def limits
675
+ items = []
676
+ doc = Nokogiri.parse(RestClient.get(Api.url + "/admin/enterprises/#{resource_id}/limits"))
677
+ doc.search('//limit').each do |node|
678
+ items << DatacenterLimit.parse(node.to_s)
679
+ end
680
+ items
681
+ end
611
682
 
612
683
  def delete
613
684
  RestClient.delete(Api.url + "/admin/enterprises/#{resource_id}")
@@ -760,6 +831,23 @@ module WeBee
760
831
 
761
832
  end
762
833
 
834
+ class VirtualMachine
835
+ include SAXMachine
836
+
837
+ element :name
838
+ element :description
839
+ element :ram
840
+ element :cpu
841
+ element :hd
842
+ element :vrdpIP, :as => :vdrp_ip
843
+ element :vrdpPort, :as => :vdrp_port
844
+ element :state
845
+ element :highDisponibility, :as => :high_disponibility
846
+ element :password
847
+ element :id, :as => :virtualmachine_id
848
+
849
+ end
850
+
763
851
  class UserRole
764
852
 
765
853
  def self.cloud_admin
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webee
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 13
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 2
9
- - 1
10
- version: 0.2.1
8
+ - 3
9
+ version: "0.3"
11
10
  platform: ruby
12
11
  authors:
13
12
  - Sergio Rubio
@@ -15,7 +14,7 @@ autorequire:
15
14
  bindir: bin
16
15
  cert_chain: []
17
16
 
18
- date: 2011-09-09 00:00:00 Z
17
+ date: 2011-09-12 00:00:00 Z
19
18
  dependencies:
20
19
  - !ruby/object:Gem::Dependency
21
20
  name: sax-machine
@@ -74,7 +73,7 @@ dependencies:
74
73
  type: :runtime
75
74
  version_requirements: *id004
76
75
  - !ruby/object:Gem::Dependency
77
- name: alchemist
76
+ name: i18n
78
77
  prerelease: false
79
78
  requirement: &id005 !ruby/object:Gem::Requirement
80
79
  none: false
@@ -88,7 +87,7 @@ dependencies:
88
87
  type: :runtime
89
88
  version_requirements: *id005
90
89
  - !ruby/object:Gem::Dependency
91
- name: activesupport
90
+ name: alchemist
92
91
  prerelease: false
93
92
  requirement: &id006 !ruby/object:Gem::Requirement
94
93
  none: false
@@ -101,6 +100,20 @@ dependencies:
101
100
  version: "0"
102
101
  type: :runtime
103
102
  version_requirements: *id006
103
+ - !ruby/object:Gem::Dependency
104
+ name: activesupport
105
+ prerelease: false
106
+ requirement: &id007 !ruby/object:Gem::Requirement
107
+ none: false
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ hash: 3
112
+ segments:
113
+ - 0
114
+ version: "0"
115
+ type: :runtime
116
+ version_requirements: *id007
104
117
  description: Abiquo API Ruby Implementation
105
118
  email: sergio@rubio.name
106
119
  executables: