Class: OpenNebula::Zone

Inherits:
PoolElement show all
Defined in:
lib/opennebula/zone.rb

Constant Summary collapse

ZONE_METHODS =

Constants and Class Methods

{
    :info           => "zone.info",
    :allocate       => "zone.allocate",
    :update         => "zone.update",
    :rename         => "zone.rename",
    :delete         => "zone.delete"
}

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from PoolElement

#id, #name, new_with_id, #to_str

Methods inherited from XMLElement

#[], #add_element, #attr, #delete_element, #each, #each_xpath, #element_xml, #has_elements?, #initialize_xml, #name, #retrieve_elements, #template_like_str, #template_str, #template_xml, #text, #to_hash, #to_xml

Constructor Details

#initialize(xml, client) ⇒ Zone

Class constructor



52
53
54
# File 'lib/opennebula/zone.rb', line 52

def initialize(xml, client)
    super(xml,client)
end

Class Method Details

.build_xml(pe_id = nil) ⇒ Object

Creates a Zone description with just its identifier this method should be used to create plain Zone objects. Example:

zone = Zone.new(Zone.build_xml(3),rpc_client)

Parameters:

  • id (Integer)

    the id of the Zone



41
42
43
44
45
46
47
48
49
# File 'lib/opennebula/zone.rb', line 41

def Zone.build_xml(pe_id=nil)
    if pe_id
        zone_xml = "<ZONE><ID>#{pe_id}</ID></ZONE>"
    else
        zone_xml = "<ZONE></ZONE>"
    end

    XMLElement.build_xml(zone_xml,'ZONE')
end

Instance Method Details

#allocate(description) ⇒ nil, OpenNebula::Error

Allocates a new Zone in OpenNebula

Parameters:

  • description (String)

    The template of the Zone.

Returns:



74
75
76
# File 'lib/opennebula/zone.rb', line 74

def allocate(description)
    super(ZONE_METHODS[:allocate], description)
end

#deletenil, OpenNebula::Error

Deletes the Zone

Returns:



93
94
95
# File 'lib/opennebula/zone.rb', line 93

def delete()
    super(ZONE_METHODS[:delete])
end

#infonil, OpenNebula::Error Also known as: info!

Retrieves the information of the given Zone.

Returns:



63
64
65
# File 'lib/opennebula/zone.rb', line 63

def info()
    super(ZONE_METHODS[:info], 'ZONE')
end

#rename(name) ⇒ nil, OpenNebula::Error

Renames this Zone

Parameters:

  • name (String)

    New name for the Zone.

Returns:



103
104
105
# File 'lib/opennebula/zone.rb', line 103

def rename(name)
    return call(ZONE_METHODS[:rename], @pe_id, name)
end

#update(new_template = nil, append = false) ⇒ nil, OpenNebula::Error

Replaces the template contents

Parameters:

  • new_template (String) (defaults to: nil)

    New template contents

  • append (true, false) (defaults to: false)

    True to append new attributes instead of replace the whole template

Returns:



86
87
88
# File 'lib/opennebula/zone.rb', line 86

def update(new_template=nil, append=false)
    super(ZONE_METHODS[:update], new_template, append ? 1 : 0)
end