Class: OneVdcHelper

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

Overview

Helper class for VDC commands

Instance Attribute Summary

Attributes inherited from OpenNebulaHelper::OneHelper

#client

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from OpenNebulaHelper::OneHelper

#backup_mode_valid?, #check_orphan, client, #create_resource, #filterflag_to_i, filterflag_to_i_desc, get_client, get_password, #group_name, #initialize, list_layout_help, #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, template_input_help, #to_id, to_id_desc, #user_name

Constructor Details

This class inherits a constructor from OpenNebulaHelper::OneHelper

Class Method Details

.conf_fileObject



28
29
30
# File 'lib/one_helper/onevdc_helper.rb', line 28

def self.conf_file
    'onevdc.yaml'
end

.rnameObject



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

def self.rname
    'VDC'
end

Instance Method Details

#format_pool(_options) ⇒ Object



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
85
# File 'lib/one_helper/onevdc_helper.rb', line 43

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

    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
end

#id_list_size(list, resource) ⇒ Object



32
33
34
35
36
37
38
39
40
41
# File 'lib/one_helper/onevdc_helper.rb', line 32

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