Statistics
| Branch: | Tag: | Revision:

one / src / cli / one_helper / onegroup_helper.rb @ d9f96d34

History | View | Annotate | Download (2.37 KB)

1
# -------------------------------------------------------------------------- #
2
# Copyright 2002-2011, OpenNebula Project Leads (OpenNebula.org)             #
3
#                                                                            #
4
# Licensed under the Apache License, Version 2.0 (the "License"); you may    #
5
# not use this file except in compliance with the License. You may obtain    #
6
# a copy of the License at                                                   #
7
#                                                                            #
8
# http://www.apache.org/licenses/LICENSE-2.0                                 #
9
#                                                                            #
10
# Unless required by applicable law or agreed to in writing, software        #
11
# distributed under the License is distributed on an "AS IS" BASIS,          #
12
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
13
# See the License for the specific language governing permissions and        #
14
# limitations under the License.                                             #
15
#--------------------------------------------------------------------------- #
16

    
17
require 'one_helper'
18

    
19
class OneGroupHelper < OpenNebulaHelper::OneHelper
20
    TABLE_CONF_FILE="#{OpenNebulaHelper::TABLE_CONF_PATH}/onegroup.yaml"
21

    
22
    def self.rname
23
        "GROUP"
24
    end
25

    
26
    private
27

    
28
    def factory(id=nil)
29
        if id
30
            OpenNebula::Group.new_with_id(id, @client)
31
        else
32
            xml=OpenNebula::Group.build_xml
33
            OpenNebula::Group.new(xml, @client)
34
        end
35
    end
36

    
37
    def factory_pool(user_flag=-2)
38
        #TBD OpenNebula::UserPool.new(@client, user_flag)
39
        OpenNebula::GroupPool.new(@client)
40
    end
41

    
42
    def format_pool(pool, options, top=false)
43
        table=CLIHelper::ShowTable.new(TABLE_CONF_FILE, self) do
44
            column :ID, "ONE identifier for the Group", :size=>4 do |d|
45
                d["ID"]
46
            end
47

    
48
            column :NAME, "Name of the Group", :left, :size=>15 do |d|
49
                d["NAME"]
50
            end
51
            
52
            column :USER, "Username of the Group owner", :left, :size=>8 do |d|
53
                helper.uid_to_str(d["UID"], options)
54
            end
55

    
56
            default :ID, :USER, :NAME
57
        end
58

    
59
        if top
60
            table.top(pool, options)
61
        else
62
            table.show(pool, options)
63
        end
64
    end
65
end