class OpenNebula::MarketPlace

Constants

MARKETPLACE_METHODS

Constants and Class Methods

MARKETPLACE_STATES
SHORT_MARKETPLACE_STATES

Public Class Methods

build_xml(pe_id=nil) click to toggle source

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)
# 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
new(xml, client) click to toggle source

Class constructor

Calls superclass method
# File lib/opennebula/marketplace.rb, line 61
def initialize(xml, client)
    super(xml,client)
end

Public Instance Methods

allocate(description) click to toggle source

Allocates a new marketplace in OpenNebula

@param description [String] The template of the marketplace.

@return [Integer, OpenNebula::Error] the new ID in case of

success, error otherwise
Calls superclass method
# 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) click to toggle source

Changes the marketplace permissions. Each [Integer] argument must be 1 to allow, 0 deny, -1 do not change

@return [nil, OpenNebula::Error] nil in case of success, Error

otherwise
Calls superclass method
# 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) click to toggle source

Changes the marketplace permissions.

@param octet [String] Permissions octed , e.g. 640 @return [nil, OpenNebula::Error] nil in case of success, Error

otherwise
Calls superclass method
# File lib/opennebula/marketplace.rb, line 119
def chmod_octet(octet)
    super(MARKETPLACE_METHODS[:chmod], octet)
end
chown(uid, gid) click to toggle source

Changes the owner/group

@param uid [Integer] the new owner id. Set to -1 to leave the current one @param gid [Integer] the new group id. Set to -1 to leave the current one

@return [nil, OpenNebula::Error] nil in case of success, Error

otherwise
Calls superclass method
# File lib/opennebula/marketplace.rb, line 110
def chown(uid, gid)
    super(MARKETPLACE_METHODS[:chown], uid, gid)
end
contains(id) click to toggle source

Returns whether or not the marketplace app with id ‘id’ is part of this marketplace

# 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() click to toggle source

Deletes the marketplace

Calls superclass method
# File lib/opennebula/marketplace.rb, line 87
def delete()
    super(MARKETPLACE_METHODS[:delete])
end
disable() click to toggle source

Enables this marketplace

# File lib/opennebula/marketplace.rb, line 150
def disable
    call(MARKETPLACE_METHODS[:enable], @pe_id, false)
end
enable() click to toggle source

Enables this marketplace

# File lib/opennebula/marketplace.rb, line 145
def enable
    call(MARKETPLACE_METHODS[:enable], @pe_id, true)
end
info() click to toggle source

Retrieves the information of the given marketplace.

Calls superclass method
# File lib/opennebula/marketplace.rb, line 70
def info()
    super(MARKETPLACE_METHODS[:info], 'MARKETPLACE')
end
Also aliased as: info!
info!()
Alias for: info
marketapp_ids() click to toggle source

Returns an array with the numeric image ids

# 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) click to toggle source

Renames this marketplace

@param name [String] New name for the marketplace

@return [nil, OpenNebula::Error] nil in case of success, Error

otherwise
# File lib/opennebula/marketplace.rb, line 140
def rename(name)
    call(MARKETPLACE_METHODS[:rename], @pe_id, name)
end
state() click to toggle source

Returns the state of the Zone (numeric value)

# File lib/opennebula/marketplace.rb, line 159
def state
    self['STATE'].to_i
end
state_str() click to toggle source

Returns the state of the Zone (string value)

# File lib/opennebula/marketplace.rb, line 164
def state_str
    MARKETPLACE_STATES[state]
end
update(new_template, append=false) click to toggle source

Replaces the template contents

@param new_template [String] New template contents @param append [true, false] True to append new attributes instead of

replace the whole template

@return [nil, OpenNebula::Error] nil in case of success, Error

otherwise
Calls superclass method
# File lib/opennebula/marketplace.rb, line 99
def update(new_template, append=false)
    super(MARKETPLACE_METHODS[:update], new_template, append ? 1 : 0)
end