Class: OneVMGroupHelper

Inherits:
OpenNebulaHelper::OneHelper show all
Defined in:
lib/one_helper/onevmgroup_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



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

def self.conf_file
    "onevmgroup.yaml"
end

.rnameObject



20
21
22
# File 'lib/one_helper/onevmgroup_helper.rb', line 20

def self.rname
    "VM_GROUP"
end

Instance Method Details

#format_pool(options) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
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
# File 'lib/one_helper/onevmgroup_helper.rb', line 28

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

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

        column :NAME, "Name of the VM Group", :left, :size=>15 do |d|
            d["NAME"]
        end

        column :USER, "Username of the VM Group owner", :left,
                :size=>8 do |d|
            helper.user_name(d, options)
        end

        column :GROUP, "Group of the VM Group", :left, :size=>8 do |d|
            helper.group_name(d, options)
        end

        column :VMS, "Number of VMs in the VM Group", :left, :size=>4 do |d|
            vms   = 0

            if !d["ROLES"]["ROLE"].nil?
     	roles = [d["ROLES"]["ROLE"]].flatten
                roles.each { |r|
                    vms += r["VMS"].split(',').size if !r["VMS"].nil?
                }
            end

            vms
        end

        column :ROLES, "Roles in the VM Group", :left, :size=>36 do |d|
            begin
                roles = [d["ROLES"]["ROLE"]].flatten
                roles_names = ""

                if !roles.nil?
                    rnames = roles.collect { |i| i["NAME"] }
                    roles_names = rnames.join(", ") if !rnames.empty?
                end

                roles_names
            rescue
                "-"
            end
        end

        default :ID, :USER, :GROUP, :NAME, :VMS, :ROLES
    end

    table
end