Class: OneVdcHelper

Inherits:
OpenNebulaHelper::OneHelper show all
Defined in:
lib/one_helper/onevdc_helper.rb

Instance Attribute Summary

Attributes inherited from OpenNebulaHelper::OneHelper

#client

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from OpenNebulaHelper::OneHelper

#check_orphan, client, #create_resource, #filterflag_to_i, filterflag_to_i_desc, get_client, get_password, #group_name, #initialize, #list_pool, #list_pool_format, #list_pool_table, #list_pool_top, #list_pool_xml, #list_to_id, list_to_id_desc, name_to_id, #perform_action, #perform_actions, #print_page, #retrieve_resource, #set_client, set_endpoint, set_password, set_user, #show_resource, #start_pager, #stop_pager, table_conf, #to_id, to_id_desc, #user_name

Constructor Details

This class inherits a constructor from OpenNebulaHelper::OneHelper

Class Method Details

.conf_fileObject



25
26
27
# File 'lib/one_helper/onevdc_helper.rb', line 25

def self.conf_file
    "onevdc.yaml"
end

.rnameObject



21
22
23
# File 'lib/one_helper/onevdc_helper.rb', line 21

def self.rname
    "VDC"
end

Instance Method Details

#format_pool(options) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/one_helper/onevdc_helper.rb', line 40

def format_pool(options)
    config_file = self.class.table_conf

    table = CLIHelper::ShowTable.new(config_file, self) do
        column :ID, "ONE identifier for the VDC", :size=>5 do |d|
            d["ID"]
        end

        column :NAME, "Name of the VDC", :left, :size=>30 do |d|
            d["NAME"]
        end

        column :GROUPS, "Number of Groups", :size=>6 do |d|
            ids = d["GROUPS"]["ID"]
            case ids
            when String
                1
            when Array
                ids.size
            when NilClass
                0
            end
        end

        column :CLUSTERS, "Number of Clusters", :size=>8 do |d|
            @ext.id_list_size(d["CLUSTERS"]["CLUSTER"], "CLUSTER") rescue "-"
        end

        column :HOSTS, "Number of Hosts", :size=>5 do |d|
            @ext.id_list_size(d["HOSTS"]["HOST"], "HOST") rescue "-"
        end

        column :VNETS, "Number of Networks", :size=>5 do |d|
            @ext.id_list_size(d["VNETS"]["VNET"], "VNET") rescue "-"
        end

        column :DATASTORES, "Number of Datastores", :size=>10 do |d|
            @ext.id_list_size(d["DATASTORES"]["DATASTORE"], "DATASTORE") rescue "-"
        end

        default :ID, :NAME, :GROUPS, :CLUSTERS, :HOSTS, :VNETS, :DATASTORES
    end

    table
end

#id_list_size(list, resource) ⇒ Object



29
30
31
32
33
34
35
36
37
38
# File 'lib/one_helper/onevdc_helper.rb', line 29

def id_list_size(list, resource)
    case list
    when NilClass
        return 0
    when Array
        return list.size
    when Hash
        return list["#{resource}_ID"] == Vdc::ALL_RESOURCES ? 'ALL' : 1
    end
end