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
693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 |
# File 'lib/webee.rb', line 693 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
716 717 718 |
# File 'lib/webee.rb', line 716 def self.find_by_name(name, = {}) Enterprise.all().find_all { |e| e.name =~ /#{name}/ } end |
Instance Method Details
#create_user(params) ⇒ Object
735 736 737 738 |
# File 'lib/webee.rb', line 735 def create_user(params) params[:enterprise] = self User.create params end |
#create_vdc(params) ⇒ Object
740 741 742 743 |
# File 'lib/webee.rb', line 740 def create_vdc(params) params[:enterprise] = self VDC.create(params) end |
#delete ⇒ Object
686 687 688 |
# File 'lib/webee.rb', line 686 def delete RestClient.delete(Api.url + "/admin/enterprises/#{resource_id}") end |
#enterprise_id ⇒ Object
771 772 773 |
# File 'lib/webee.rb', line 771 def enterprise_id resource_id end |
#limits ⇒ Object
677 678 679 680 681 682 683 684 |
# File 'lib/webee.rb', line 677 def limits items = [] doc = Nokogiri.parse(RestClient.get(Api.url + "/admin/enterprises/#{resource_id}/limits")) doc.search('//limit').each do |node| items << DatacenterLimit.parse(node.to_s) end items end |
#ovf_packages ⇒ Object
720 721 722 |
# File 'lib/webee.rb', line 720 def ovf_packages WeBee::OVFPackage.all(resource_id) end |
#set_limits_for_datacenter(dc, params = {}) ⇒ Object
745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 |
# File 'lib/webee.rb', line 745 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
724 725 726 727 728 729 730 731 732 733 |
# File 'lib/webee.rb', line 724 def users col = [] doc = Nokogiri.parse(RestClient.get(Api.url + "/admin/enterprises/#{resource_id}/users")) doc.search('//user').each do |node| user = User.parse(node.to_s) col << user user.enterprise_id = resource_id end col end |