Class: OpenNebula::Vdc

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

Constant Summary collapse

ALL_RESOURCES =

Constants and Class Methods

"-10"
VDC_METHODS =
{
    :info           => "vdc.info",
    :allocate       => "vdc.allocate",
    :update         => "vdc.update",
    :rename         => "vdc.rename",
    :delete         => "vdc.delete",

    :add_group      => "vdc.addgroup",
    :del_group      => "vdc.delgroup",
    :add_cluster    => "vdc.addcluster",
    :del_cluster    => "vdc.delcluster",
    :add_host       => "vdc.addhost",
    :del_host       => "vdc.delhost",
    :add_datastore  => "vdc.adddatastore",
    :del_datastore  => "vdc.deldatastore",
    :add_vnet       => "vdc.addvnet",
    :del_vnet       => "vdc.delvnet",
}

Instance Attribute Summary

Attributes inherited from PoolElement

#name

Class Method Summary collapse

Instance Method Summary collapse

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) ⇒ Vdc

Class constructor



65
66
67
# File 'lib/opennebula/vdc.rb', line 65

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

Class Method Details

.build_xml(pe_id = nil) ⇒ Object

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

vdc = Vdc.new(Vdc.build_xml(3),rpc_client)

Parameters:

  • id (Integer)

    the id of the Vdc



54
55
56
57
58
59
60
61
62
# File 'lib/opennebula/vdc.rb', line 54

def Vdc.build_xml(pe_id=nil)
    if pe_id
        vdc_xml = "<VDC><ID>#{pe_id}</ID></VDC>"
    else
        vdc_xml = "<VDC></VDC>"
    end

    XMLElement.build_xml(vdc_xml,'VDC')
end

Instance Method Details

#add_cluster(zone_id, cluster_id) ⇒ nil, OpenNebula::Error

Adds a cluster to this VDC

Parameters:

  • zone_id (Integer)

    Zone ID

  • cluster_id (Integer)

    Cluster ID

Returns:



144
145
146
# File 'lib/opennebula/vdc.rb', line 144

def add_cluster(zone_id, cluster_id)
    return call(VDC_METHODS[:add_cluster], @pe_id, zone_id.to_i, cluster_id.to_i)
end

#add_datastore(zone_id, datastore_id) ⇒ nil, OpenNebula::Error

Adds a datastore to this VDC

Parameters:

  • zone_id (Integer)

    Zone ID

  • datastore_id (Integer)

    Datastore ID

Returns:



202
203
204
# File 'lib/opennebula/vdc.rb', line 202

def add_datastore(zone_id, datastore_id)
    return call(VDC_METHODS[:add_datastore], @pe_id, zone_id.to_i, datastore_id.to_i)
end

#add_group(group_id) ⇒ nil, OpenNebula::Error

Adds a group to this VDC

Parameters:

  • group_id (Integer)

    Group ID

Returns:



125
126
127
# File 'lib/opennebula/vdc.rb', line 125

def add_group(group_id)
    return call(VDC_METHODS[:add_group], @pe_id, group_id.to_i)
end

#add_host(zone_id, host_id) ⇒ nil, OpenNebula::Error

Deletes a host from this VDC

Parameters:

  • zone_id (Integer)

    Zone ID

  • host_id (Integer)

    Host ID # Adds a host to this VDC

  • zone_id (Integer)

    Zone ID

  • host_id (Integer)

    Host ID

Returns:



164
165
166
# File 'lib/opennebula/vdc.rb', line 164

def add_host(zone_id, host_id)
    return call(VDC_METHODS[:add_host], @pe_id, zone_id.to_i, host_id.to_i)
end

#add_vnet(zone_id, vnet_id) ⇒ nil, OpenNebula::Error

Adds a vnet to this VDC

Parameters:

  • zone_id (Integer)

    Zone ID

  • vnet_id (Integer)

    Vnet ID

Returns:



222
223
224
# File 'lib/opennebula/vdc.rb', line 222

def add_vnet(zone_id, vnet_id)
    return call(VDC_METHODS[:add_vnet], @pe_id, zone_id.to_i, vnet_id.to_i)
end

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

Allocates a new Vdc in OpenNebula

Parameters:

  • description (String)

    The template of the Vdc.

Returns:



87
88
89
# File 'lib/opennebula/vdc.rb', line 87

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

#del_cluster(zone_id, cluster_id) ⇒ nil, OpenNebula::Error

Deletes a cluster from this VDC

Parameters:

  • zone_id (Integer)

    Zone ID

  • cluster_id (Integer)

    Cluster ID

Returns:



154
155
156
# File 'lib/opennebula/vdc.rb', line 154

def del_cluster(zone_id, cluster_id)
    return call(VDC_METHODS[:del_cluster], @pe_id, zone_id.to_i, cluster_id.to_i)
end

#del_datastore(zone_id, datastore_id) ⇒ nil, OpenNebula::Error

Deletes a datastore from this VDC

Parameters:

  • zone_id (Integer)

    Zone ID

  • datastore_id (Integer)

    Datastore ID

Returns:



212
213
214
# File 'lib/opennebula/vdc.rb', line 212

def del_datastore(zone_id, datastore_id)
    return call(VDC_METHODS[:del_datastore], @pe_id, zone_id.to_i, datastore_id.to_i)
end

#del_group(group_id) ⇒ nil, OpenNebula::Error

Deletes a group from this VDC

Parameters:

  • group_id (Integer)

    Group ID

Returns:



134
135
136
# File 'lib/opennebula/vdc.rb', line 134

def del_group(group_id)
    return call(VDC_METHODS[:del_group], @pe_id, group_id.to_i)
end

#del_host(zone_id, host_id) ⇒ nil, OpenNebula::Error

Returns nil in case of success, Error otherwise.

Returns:



186
187
188
# File 'lib/opennebula/vdc.rb', line 186

def del_host(zone_id, host_id)
    return call(VDC_METHODS[:del_host], @pe_id, zone_id.to_i, host_id.to_i)
end

#del_vnet(zone_id, vnet_id) ⇒ nil, OpenNebula::Error

Deletes a vnet from this VDC

Parameters:

  • zone_id (Integer)

    Zone ID

  • vnet_id (Integer)

    Vnet ID

Returns:



232
233
234
# File 'lib/opennebula/vdc.rb', line 232

def del_vnet(zone_id, vnet_id)
    return call(VDC_METHODS[:del_vnet], @pe_id, zone_id.to_i, vnet_id.to_i)
end

#deletenil, OpenNebula::Error

Deletes the Vdc

Returns:



106
107
108
# File 'lib/opennebula/vdc.rb', line 106

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

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

Retrieves the information of the given Vdc.

Returns:



76
77
78
# File 'lib/opennebula/vdc.rb', line 76

def info()
    super(VDC_METHODS[:info], 'VDC')
end

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

Renames this Vdc

Parameters:

  • name (String)

    New name for the Vdc.

Returns:



116
117
118
# File 'lib/opennebula/vdc.rb', line 116

def rename(name)
    return call(VDC_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:



99
100
101
# File 'lib/opennebula/vdc.rb', line 99

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