Class: OpenNebula::MarketPlace
- Inherits:
-
PoolElement
- Object
- XMLElement
- PoolElement
- OpenNebula::MarketPlace
- Defined in:
- lib/opennebula/marketplace.rb
Constant Summary collapse
- MARKETPLACE_METHODS =
Constants and Class Methods
{ :info => "market.info", :allocate => "market.allocate", :delete => "market.delete", :update => "market.update", :chown => "market.chown", :chmod => "market.chmod", :rename => "market.rename", :enable => "market.enable" }
- MARKETPLACE_STATES =
%w{ENABLED DISABLED}
- SHORT_MARKETPLACE_STATES =
{ "ENABLED" => "on", "DISABLED" => "off" }
Instance Attribute Summary
Attributes inherited from PoolElement
Class Method Summary collapse
-
.build_xml(pe_id = nil) ⇒ Object
Creates a MarketPlace description with just its identifier this method should be used to create plain MarketPlace objects.
Instance Method Summary collapse
-
#allocate(description) ⇒ Integer, OpenNebula::Error
Allocates a new marketplace in OpenNebula.
-
#chmod(owner_u, owner_m, owner_a, group_u, group_m, group_a, other_u, other_m, other_a) ⇒ nil, OpenNebula::Error
Changes the marketplace permissions.
-
#chmod_octet(octet) ⇒ nil, OpenNebula::Error
Changes the marketplace permissions.
-
#chown(uid, gid) ⇒ nil, OpenNebula::Error
Changes the owner/group.
-
#contains(id) ⇒ Object
Returns whether or not the marketplace app with id ‘id’ is part of this marketplace.
-
#delete ⇒ Object
Deletes the marketplace.
-
#disable ⇒ Object
Enables this marketplace.
-
#enable ⇒ Object
Enables this marketplace.
-
#info ⇒ Object
(also: #info!)
Retrieves the information of the given marketplace.
-
#initialize(xml, client) ⇒ MarketPlace
constructor
Class constructor.
-
#marketapp_ids ⇒ Object
Returns an array with the numeric image ids.
-
#rename(name) ⇒ nil, OpenNebula::Error
Renames this marketplace.
-
#state ⇒ Object
Returns the state of the Zone (numeric value).
-
#state_str ⇒ Object
Returns the state of the Zone (string value).
-
#update(new_template, append = false) ⇒ nil, OpenNebula::Error
Replaces the template contents.
Methods inherited from PoolElement
#id, new_with_id, #replace, #to_str
Methods inherited from XMLElement
#[], #add_element, #attr, #delete_element, #each, #each_xpath, #element_xml, #has_elements?, #initialize_xml, #name, #retrieve_elements, #retrieve_xmlelements, #set_content, #template_like_str, #template_str, #template_xml, #text, #to_hash, #to_xml, #xml_nil?
Constructor Details
#initialize(xml, client) ⇒ MarketPlace
Class constructor
61 62 63 |
# File 'lib/opennebula/marketplace.rb', line 61 def initialize(xml, client) super(xml,client) end |
Class Method Details
.build_xml(pe_id = nil) ⇒ Object
Creates a MarketPlace description with just its identifier this method should be used to create plain MarketPlace objects. id
the id of the user
Example:
marketplace = MarketPlace.new(MarketPlace.build_xml(3),rpc_client)
50 51 52 53 54 55 56 57 58 |
# File 'lib/opennebula/marketplace.rb', line 50 def MarketPlace.build_xml(pe_id=nil) if pe_id marketplace_xml = "<MARKETPLACE><ID>#{pe_id}</ID></MARKETPLACE>" else marketplace_xml = "<MARKETPLACE></MARKETPLACE>" end XMLElement.build_xml(marketplace_xml,'MARKETPLACE') end |
Instance Method Details
#allocate(description) ⇒ Integer, OpenNebula::Error
Allocates a new marketplace in OpenNebula
82 83 84 |
# File 'lib/opennebula/marketplace.rb', line 82 def allocate(description) super(MARKETPLACE_METHODS[:allocate], description) end |
#chmod(owner_u, owner_m, owner_a, group_u, group_m, group_a, other_u, other_m, other_a) ⇒ nil, OpenNebula::Error
Changes the marketplace permissions. Each [Integer] argument must be 1 to allow, 0 deny, -1 do not change
128 129 130 131 132 |
# File 'lib/opennebula/marketplace.rb', line 128 def chmod(owner_u, owner_m, owner_a, group_u, group_m, group_a, other_u, other_m, other_a) super(MARKETPLACE_METHODS[:chmod], owner_u, owner_m, owner_a, group_u, group_m, group_a, other_u, other_m, other_a) end |
#chmod_octet(octet) ⇒ nil, OpenNebula::Error
Changes the marketplace permissions.
119 120 121 |
# File 'lib/opennebula/marketplace.rb', line 119 def chmod_octet(octet) super(MARKETPLACE_METHODS[:chmod], octet) end |
#chown(uid, gid) ⇒ nil, OpenNebula::Error
Changes the owner/group
110 111 112 |
# File 'lib/opennebula/marketplace.rb', line 110 def chown(uid, gid) super(MARKETPLACE_METHODS[:chown], uid, gid) end |
#contains(id) ⇒ Object
Returns whether or not the marketplace app with id ‘id’ is part of this marketplace
170 171 172 173 174 175 176 |
# File 'lib/opennebula/marketplace.rb', line 170 def contains(id) #This doesn't work in ruby 1.8.5 #return self["MARKETPLACE/MARKETPLACEAPPS/ID[.=#{uid}]"] != nil id_array = retrieve_elements('MARKETPLACEAPPS/ID') return id_array != nil && id_array.include?(uid.to_s) end |
#delete ⇒ Object
Deletes the marketplace
87 88 89 |
# File 'lib/opennebula/marketplace.rb', line 87 def delete() super(MARKETPLACE_METHODS[:delete]) end |
#disable ⇒ Object
Enables this marketplace
150 151 152 |
# File 'lib/opennebula/marketplace.rb', line 150 def disable call(MARKETPLACE_METHODS[:enable], @pe_id, false) end |
#enable ⇒ Object
Enables this marketplace
145 146 147 |
# File 'lib/opennebula/marketplace.rb', line 145 def enable call(MARKETPLACE_METHODS[:enable], @pe_id, true) end |
#info ⇒ Object Also known as: info!
Retrieves the information of the given marketplace.
70 71 72 |
# File 'lib/opennebula/marketplace.rb', line 70 def info() super(MARKETPLACE_METHODS[:info], 'MARKETPLACE') end |
#marketapp_ids ⇒ Object
Returns an array with the numeric image ids
179 180 181 182 183 184 185 186 187 |
# File 'lib/opennebula/marketplace.rb', line 179 def marketapp_ids array = Array.new self.each("MARKETPLACEAPPS/ID") do |id| array << id.text.to_i end return array end |
#rename(name) ⇒ nil, OpenNebula::Error
Renames this marketplace
140 141 142 |
# File 'lib/opennebula/marketplace.rb', line 140 def rename(name) call(MARKETPLACE_METHODS[:rename], @pe_id, name) end |
#state ⇒ Object
Returns the state of the Zone (numeric value)
159 160 161 |
# File 'lib/opennebula/marketplace.rb', line 159 def state self['STATE'].to_i end |
#state_str ⇒ Object
Returns the state of the Zone (string value)
164 165 166 |
# File 'lib/opennebula/marketplace.rb', line 164 def state_str MARKETPLACE_STATES[state] end |
#update(new_template, append = false) ⇒ nil, OpenNebula::Error
Replaces the template contents
99 100 101 |
# File 'lib/opennebula/marketplace.rb', line 99 def update(new_template, append=false) super(MARKETPLACE_METHODS[:update], new_template, append ? 1 : 0) end |