Class: OneMarketPlaceHelper

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

Constant Summary collapse

MARKETPLACE =
{
    :name   => "marketplace",
    :short  => "-m id|name",
    :large  => "--marketplace id|name" ,
    :description => "Selects the marketplace",
    :format => String,
    :proc   => lambda { |o, options|
        OpenNebulaHelper.rname_to_id(o, "MARKETPLACE")
    }
}

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



35
36
37
# File 'lib/one_helper/onemarket_helper.rb', line 35

def self.conf_file
    "onemarket.yaml"
end

.rnameObject



31
32
33
# File 'lib/one_helper/onemarket_helper.rb', line 31

def self.rname
    "MARKETPLACE"
end

.state_to_str(id) ⇒ Object



39
40
41
42
43
# File 'lib/one_helper/onemarket_helper.rb', line 39

def self.state_to_str(id)
    state_str = MarketPlace::MARKETPLACE_STATES[id.to_i]

    MarketPlace::SHORT_MARKETPLACE_STATES[state_str]
end

Instance Method Details

#format_pool(options) ⇒ Object



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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/one_helper/onemarket_helper.rb', line 45

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

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

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

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

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

        column :SIZE, "Marketplace total size", :size =>10 do |d|
            OpenNebulaHelper.unit_to_str(d['TOTAL_MB'].to_i, {}, 'M')
        end

        column :AVAIL, "Marketplace free size", :left, :size =>10 do |d|
            if d['TOTAL_MB'].to_i == 0
                "-"
            else
                "#{((d['FREE_MB'].to_f/d['TOTAL_MB'].to_f) * 100).round()}%"
            end
        end

        column :APPS, "Number of marketplace apps", :size=>6 do |d|
            if d["MARKETPLACEAPPS"]["ID"].nil?
                "0"
            else
                [d["MARKETPLACEAPPS"]["ID"]].flatten.size
            end
        end

        column :MAD, "Marketplace driver", :left, :size=>7 do |d|
            d["MARKET_MAD"]
        end

        column :ZONE, "Zone ID", :size=>4 do |d|
            d["ZONE_ID"]
        end

        column :STAT, 'Markeplace status', :left, :size => 4 do |d|
            OneMarketPlaceHelper.state_to_str(d['STATE'])
        end

        default :ID, :NAME, :SIZE, :AVAIL, :APPS, :MAD, :ZONE, :STAT
    end

    table
end