Class: Zona::VDC

Inherits:
OZonesElement show all
Defined in:
zona/VDCElement.rb

Overview

This class describes a single VDC element. It can be used to allocate, delete, add hosts, remove hosts and retrieve full information for a VDC.

Constant Summary

VDC_KIND =

String describing the kind of this resource Should become part of the requests to server: get /vdc/…

"vdc"

Instance Attribute Summary

Attributes inherited from OZonesElement

name, pe_id

Class Method Summary (collapse)

Instance Method Summary (collapse)

Methods inherited from OZonesElement

new_with_id

Methods inherited from JSONElement

#[], #initialize_json

Constructor Details

- (String) initialize(hash, client)

Initializes a VDC object instance

Parameters:

  • hash (Hash)

    VDC description

  • client (Zona::Client)

    OZones Client



45
46
47
# File 'zona/VDCElement.rb', line 45

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

Class Method Details

+ (Hash, Zona::Error) build_json(pe_id = nil)

Builds minimal JSON description for a VDC

Parameters:

  • pe_id (Integer) (defaults to: nil)

    VDC’s ID

Returns:

  • (Hash, Zona::Error)

    Hash description of the object, or Error



32
33
34
35
36
37
38
39
# File 'zona/VDCElement.rb', line 32

def self.build_json(pe_id=nil)
    if pe_id
        json = "{\"VDC\":{\"ID\":#{pe_id}}}"
    else
        json = '{"VDC":{}}'
    end
    OZonesJSON.build_json(json,:VDC)
end

Instance Method Details

- (Object) add_datastores(ds_array, options = {}) Also known as: add_datastore



92
93
94
# File 'zona/VDCElement.rb', line 92

def add_datastores(ds_array,options={})
    addresource(:DATASTORES, ds_array, options)
end

- (Zona::Error) add_hosts(hosts_array, options = {}) Also known as: add_host

Adds hosts to a VDC. The specified hosts are added to the VDC’s current ones. in the zone to be added which already belong to other VDCs

Parameters:

  • hosts_array (Array<#to_i>)

    array of hosts IDs

  • options (Hash) (defaults to: {})

    a hash of options

Options Hash (options):

  • :force (Boolean)

    allows hosts to add hosts

Returns:



84
85
86
# File 'zona/VDCElement.rb', line 84

def add_hosts(hosts_array,options={})
    addresource(:HOSTS, hosts_array, options)
end

- (Object) add_networks(net_array, options = {}) Also known as: add_network



88
89
90
# File 'zona/VDCElement.rb', line 88

def add_networks(net_array,options={})
    addresource(:NETWORKS, net_array, options)
end

- (Zona::Error) allocate(template)

Allocates a new element from a JSON description

Parameters:

  • template (String)

    element description

Returns:



66
67
68
# File 'zona/VDCElement.rb', line 66

def allocate(template)
    super(VDC_KIND,template)
end

- (Zona::Error) allocate_hash(template)

Allocates a new element from a hash description

Parameters:

  • template (Hash)

    element description

Returns:



59
60
61
# File 'zona/VDCElement.rb', line 59

def allocate_hash(template)
    super(VDC_KIND,template)
end

- (Object) del_datastores(ds_array) Also known as: del_datastore



108
109
110
# File 'zona/VDCElement.rb', line 108

def del_datastores(ds_array)
    delresource(:DATASTORES, ds_array)
end

- (Zona::Error) del_hosts(hosts_array) Also known as: del_host

Delete hosts from a VDC. The specified hosts are removed from the VDC. to be removed. If a host is not in the VDC, then it is ignored.

Parameters:

  • hosts_array (Array<#to_i>)

    array of the VDC’s hosts IDs

Returns:



100
101
102
# File 'zona/VDCElement.rb', line 100

def del_hosts(hosts_array)
    delresource(:HOSTS, hosts_array)
end

- (Object) del_networks(net_array) Also known as: del_network



104
105
106
# File 'zona/VDCElement.rb', line 104

def del_networks(net_array)
    delresource(:NETWORKS, net_array)
end

- (Zona::Error) delete

Deletes current element

Returns:



72
73
74
# File 'zona/VDCElement.rb', line 72

def delete
    super(VDC_KIND)
end

- (Zona::Error) info

Retrieves details about this object and fills in the information hash

Returns:



52
53
54
# File 'zona/VDCElement.rb', line 52

def info
    super(VDC_KIND,:VDC)
end