Revision 104387a7

View differences:

src/cli/client_utilities.rb
62 62
    :id => {
63 63
        :name => "ID",
64 64
        :size => 4,
65
        :proc => lambda {|d,e| d["oid"] }
65
        :proc => lambda {|d,e| d["OID"] }
66 66
    },
67 67
    :name => {
68 68
        :name => "NAME",
69 69
        :size => 8,
70
        :proc => lambda {|d,e| d["deploy_id"] }
70
        :proc => lambda {|d,e| d["DEPLOY_ID"] }
71 71
    },
72 72
    :stat => {
73 73
        :name => "STAT",
......
294 294
end
295 295

  
296 296
def str_running_time(data)
297
    stime=Time.at(data["stime"].to_i)
298
    if data["etime"]=="0"
297
    stime=Time.at(data["STIME"].to_i)
298
    if data["ETIME"]=="0"
299 299
        etime=Time.now
300 300
    else
301
        etime=Time.at(data["etime"].to_i)
301
        etime=Time.at(data["ETIME"].to_i)
302 302
    end
303 303
    dtime=Time.at(etime-stime).getgm
304 304

  
src/cli/command_parse.rb
15 15
#--------------------------------------------------------------------------- #
16 16

  
17 17
require 'optparse'
18
require 'pp'
19 18

  
20 19
class CommandParse
21 20
    
src/cli/onehost
42 42
    :name => {
43 43
        :name => "NAME",
44 44
        :desc => "Hostname",
45
        :size => 25,
45
        :size => 15,
46 46
        :left => true,
47 47
        :proc => lambda {|d,e| d.name }
48 48
    },
49 49
    :cluster => {
50 50
        :name => "CLUSTER",
51 51
        :desc => "Clustername",
52
        :size => 25,
52
        :size => 15,
53 53
        :left => true,
54 54
        :proc => lambda {|d,e| d.cluster }
55 55
    },
......
216 216
        exit -1
217 217
    end
218 218
    
219
    host['host_share/running_vms'].to_i
219
    host['HOST_SHARE/RUNNING_VMS'].to_i
220 220

  
221 221
end
222 222

  
src/cli/oneuser
51 51
        :desc => "password of the user",
52 52
        :size => 50,
53 53
        :left => true,
54
        :proc => lambda {|d,e| d[:password] }
54
        :proc => lambda {|d,e| d['PASSWORD'] }
55 55
    },
56 56
   
57 57
    :default => [:id, :user, :password]
src/cli/onevm
68 68
        :desc => "CPU percentage used by the VM",
69 69
        :size => 3,
70 70
        :proc => lambda {|d,e|
71
            d["cpu"]
71
            d["CPU"]
72 72
        }
73 73
    },
74 74
    :mem => {
75 75
        :name => "MEM",
76 76
        :desc => "Memory used by the VM",
77 77
        :size => 7,
78
        :proc => lambda {|d,e| d["memory"] }
78
        :proc => lambda {|d,e| d["MEMORY"] }
79 79
    },
80 80
    :hostname => {
81 81
        :name => "HOSTNAME",
......
100 100
        :name => "ID",
101 101
        :desc => "ONE identifier for the VM",
102 102
        :size => 4,
103
        :proc => lambda {|d,e| d["id"] }
103
        :proc => lambda {|d,e| d["ID"] }
104 104
    },
105 105
    :seq => {
106 106
        :name => "SEQ",
107 107
        :desc => "Sequence number",
108 108
        :size => 3,
109
        :proc => lambda {|d,e| d["seq"] }
109
        :proc => lambda {|d,e| d["SEQ"] }
110 110
    },
111 111
    :hostname => {
112 112
        :name => "HOSTNAME",
113 113
        :desc => "Name of the host where the VM was submited",
114 114
        :size => 15,
115
        :proc => lambda {|d,e| d["host_name"] }
115
        :proc => lambda {|d,e| d["HOST_NAME"] }
116 116
    },
117 117
    :stime => {
118 118
        :name => "STIME",
119 119
        :desc => "Start time",
120 120
        :size => 14,
121 121
        :proc => lambda {|d,e|
122
            t=Time.at(d["stime"].to_i)
122
            t=Time.at(d["STIME"].to_i)
123 123
            t.strftime("%m/%d %H:%M:%S")
124 124
        }
125 125
    },
......
128 128
        :desc => "End time",
129 129
        :size => 14,
130 130
        :proc => lambda {|d,e|
131
            if d["etime"].to_i==0
131
            if d["ETIME"].to_i==0
132 132
                "--"
133 133
            else
134
                t=Time.at(d["etime"].to_i)
134
                t=Time.at(d["ETIME"].to_i)
135 135
                t.strftime("%m/%d %H:%M:%S")
136 136
            end
137 137
        }
......
141 141
        :desc => "Total time",
142 142
        :size => 11,
143 143
        :proc => lambda {|d,e|
144
            d["time"]
144
            d["TIME"]
145 145
        }
146 146
    },
147 147
    :reason => {
......
149 149
        :desc => "Reason for state change",
150 150
        :size => "6",
151 151
        :proc => lambda {|d,e|
152
            OpenNebula::VirtualMachine.get_reason(d["reason"])
152
            OpenNebula::VirtualMachine.get_reason(d["REASON"])
153 153
        }
154 154
    },
155 155

  
......
234 234
    def get_vm_history(vm)
235 235
        {
236 236
            'id'        => vm.id,
237
            'seq'       => vm['history/seq'],
238
            'host_name' => vm['history/hostname'],
239
            'stime'     => vm['history/stime'],
240
            'etime'     => vm['history/etime'],
237
            'seq'       => vm['HISTORY/SEQ'],
238
            'host_name' => vm['HISTORY/HOSTNAME'],
239
            'stime'     => vm['HISTORY/STIME'],
240
            'etime'     => vm['HISTORY/ETIME'],
241 241
            'time'      => str_running_time(vm),
242
            'reason'    => vm['history/reason']
242
            'reason'    => vm['HISTORY/REASON']
243 243
        }
244 244
    end
245 245

  
......
274 274

  
275 275
    def list_vm_history_array(ids, options=nil)
276 276
        get_vms_history(ids).each {|vm|
277
            puts "History for VM #{vm['id']}"
277
            puts "History for VM #{vm['ID']}"
278 278
            puts
279 279
            list_vm_history(vm, options)
280 280
            puts
src/cli/onevnet
58 58
        :desc => "NType of virtual network",
59 59
        :size => 6,
60 60
        :proc => lambda {|d,e| 
61
                          if(d["type"] == "0")
61
                          if(d["TYPE"] == "0")
62 62
                              return "Ranged"
63 63
                          else
64
                              if (d["type"] == "1")
64
                              if (d["TYPE"] == "1")
65 65
                                  return "Fixed"
66 66
                              end
67 67
                          end
......
77 77
        :name => "BRIDGE",
78 78
        :desc => "Bridge associated to the virtual network",
79 79
        :size => 6,
80
        :proc => lambda {|d,e| d["bridge"] }
80
        :proc => lambda {|d,e| d["BRIDGE"] }
81 81
    },
82 82
    :public => {
83 83
        :name => "PUBLIC",
src/oca/ruby/OpenNebula/Pool.rb
2 2
module OpenNebula
3 3
    # The Pool class represents a generic OpenNebula Pool in XML format
4 4
    # and provides the basic functionality to handle the Pool elements
5
    require 'pp'
5
    
6 6
    class Pool < XMLPool
7 7
        include Enumerable
8 8

  

Also available in: Unified diff