Class: WeBee::Enterprise
- Inherits:
-
Object
- Object
- WeBee::Enterprise
- Includes:
- SAXMachine, RestResource
- Defined in:
- lib/webee.rb
Class Method Summary collapse
-
.create(attributes = {}) ⇒ Object
may raise Exception if recuest is not successful.
- .find_by_name(name, options = {}) ⇒ Object
Instance Method Summary collapse
- #create_user(params) ⇒ Object
- #create_vdc(params) ⇒ Object
- #delete ⇒ Object
- #enterprise_id ⇒ Object
- #limits ⇒ Object
- #ovf_packages ⇒ Object
- #set_limits_for_datacenter(dc, params = {}) ⇒ Object
- #users ⇒ Object
- #vdcs ⇒ Object
Methods included from RestResource
Methods included from SAXMachine
Class Method Details
.create(attributes = {}) ⇒ Object
may raise Exception if recuest is not successful
772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 |
# File 'lib/webee.rb', line 772 def self.create(attributes = {}) xm = Builder::XmlMarkup.new xm.enterprise { xm.name attributes[:name] xm.cpuSoft(attributes[:cpu_soft] || "0") xm.cpuHard(attributes[:cpu_hard] || "0") xm.vlanSoft(attributes[:vlan_soft] || "0") xm.vlanHard(attributes[:vlan_hard] || "0") xm.ramSoft(attributes[:ram_soft] || "0") xm.ramHard(attributes[:ram_hard] || "0") xm.repositorySoft(attributes[:repository_soft] || "0") xm.repositoryHard(attributes[:repository_hard] || "0") xm.publicIpsSoft(attributes[:public_ip_soft] || "0" ) xm.publicIpsHard(attributes[:public_ip_hard] || "0" ) xm.hdSoft(attributes[:hd_soft] || "0") xm.hdHard(attributes[:hd_hard] || "0") xm.storageSoft(attributes[:storage_soft] || "0") xm.storageHard(attributes[:storage_hard] || "0") } res = RestClient.post(Api.url + '/admin/enterprises', xm.target!, :content_type => :xml) Enterprise.parse(res) end |
.find_by_name(name, options = {}) ⇒ Object
795 796 797 |
# File 'lib/webee.rb', line 795 def self.find_by_name(name, = {}) Enterprise.all().find_all { |e| e.name =~ /#{name}/ } end |
Instance Method Details
#create_user(params) ⇒ Object
814 815 816 817 |
# File 'lib/webee.rb', line 814 def create_user(params) params[:enterprise] = self User.create params end |
#create_vdc(params) ⇒ Object
819 820 821 822 |
# File 'lib/webee.rb', line 819 def create_vdc(params) params[:enterprise] = self VDC.create(params) end |
#delete ⇒ Object
765 766 767 |
# File 'lib/webee.rb', line 765 def delete RestClient.delete(Api.url + "/admin/enterprises/#{resource_id}") end |
#enterprise_id ⇒ Object
850 851 852 |
# File 'lib/webee.rb', line 850 def enterprise_id resource_id end |
#limits ⇒ Object
756 757 758 759 760 761 762 763 |
# File 'lib/webee.rb', line 756 def limits items = [] doc = Nokogiri.parse(RestClient.get(Api.url + "/admin/enterprises/#{resource_id}/limits", :accept => :xml)) doc.search('//limit').each do |node| items << DatacenterLimit.parse(node.to_s) end items end |
#ovf_packages ⇒ Object
799 800 801 |
# File 'lib/webee.rb', line 799 def ovf_packages WeBee::OVFPackage.all(resource_id) end |
#set_limits_for_datacenter(dc, params = {}) ⇒ Object
824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 |
# File 'lib/webee.rb', line 824 def set_limits_for_datacenter(dc, params = {}) datacenter = dc.datacenter_id xm = Builder::XmlMarkup.new xm.limit { xm.cpuSoft(params[:cpu_soft] || "0") xm.cpuHard(params[:cpu_hard] || "0") xm.vlanSoft(params[:vlan_soft] || "0") xm.vlanHard(params[:vlan_hard] || "0") xm.ramSoft(params[:ram_soft] || "0") xm.ramHard(params[:ram_hard] || "0") xm.repositorySoft(params[:repository_soft] || "0") xm.repositoryHard(params[:repository_hard] || "0") xm.publicIpsSoft(params[:public_ip_soft] || "0" ) xm.publicIpsHard(params[:public_ip_hard] || "0" ) xm.hdSoft(params[:hd_soft] || "0") xm.hdHard(params[:hd_hard] || "0") xm.storageSoft(params[:storage_soft] || "0") xm.storageHard(params[:storage_hard] || "0") } res = RestClient.post(Api.url + "/admin/enterprises/#{resource_id}/limits?datacenter=#{datacenter}", xm.target!, :content_type => :xml) end |
#users ⇒ Object
803 804 805 806 807 808 809 810 811 812 |
# File 'lib/webee.rb', line 803 def users col = [] doc = Nokogiri.parse(RestClient.get(Api.url + "/admin/enterprises/#{resource_id}/users", :accept => :xml)) doc.search('//user').each do |node| user = User.parse(node.to_s) col << user user.enterprise_id = resource_id end col end |