Class: OneSecurityGroupHelper

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

Overview

Helper class for Security Group commands

Constant Summary collapse

RECOVER =
{
    :name   => 'recover',
    :short  => '-r',
    :large  => '--recover',
    :description => 'If set the commit operation will only operate on '\
        'outdated and error VMs. This is intended for retrying updates of '\
        'VMs or reinitialize the updating process if oned stopped or fail.'
}

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



37
38
39
# File 'lib/one_helper/onesecgroup_helper.rb', line 37

def self.conf_file
    'onesecgroup.yaml'
end

.rnameObject



33
34
35
# File 'lib/one_helper/onesecgroup_helper.rb', line 33

def self.rname
    'SECURITY_GROUP'
end

Instance Method Details

#format_pool(options) ⇒ Object



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
85
86
87
88
# File 'lib/one_helper/onesecgroup_helper.rb', line 41

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

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

        column :NAME, 'Name of the Security Group', :left, :size=>20 do |d|
            d['NAME']
        end

        column :USER, 'Username of the Security Group owner', :left,
               :size=>15 do |d|
            helper.user_name(d, options)
        end

        column :GROUP, 'Group of the Security Group', :left, :size=>15 do |d|
            helper.group_name(d, options)
        end

        column :UPDATED, 'Number of VMs with updated rules', :size=>8 do |d|
            if d['UPDATED_VMS']['ID'].nil?
                '0'
            else
                [d['UPDATED_VMS']['ID']].flatten.size
            end
        end

        column :OUTDATED, 'Number of VMs with outdated rules', :size=>8 do |d|
            if d['OUTDATED_VMS']['ID'].nil?
                '0'
            else
                [d['OUTDATED_VMS']['ID']].flatten.size
            end
        end

        column :ERROR, 'Number of VMs that failed to update rules', :size=>8 do |d|
            if d['ERROR_VMS']['ID'].nil?
                '0'
            else
                [d['ERROR_VMS']['ID']].flatten.size
            end
        end

        default :ID, :USER, :GROUP, :NAME, :UPDATED, :OUTDATED, :ERROR
    end
end