Revision c6c217d4

View differences:

src/oca/ruby/OpenNebula/XMLUtils.rb
8 8
        NOKOGIRI=false
9 9
    end
10 10

  
11
    # Require crack library if present, otherwise don't bother
12
    # This is just for OCCI use
13
    begin
14
        require 'crack'
15
    rescue LoadError
16
    end
17 11

  
18 12
    ###########################################################################
19 13
    # The XMLElement class provides an abstraction of the underlying
......
162 156
            str
163 157
        end
164 158

  
165
        def to_hash
166
            if !@hash && @xml
167
                begin
168
                   @hash = Crack::XML.parse(to_xml)
169
                rescue Exception => e
170
                   error = OpenNebula::Error.new(e.message)
171
                   return error
172
                end
173
            end
174
            return @hash
175
        end
176

  
177 159
        def to_xml(pretty=false)
178 160
            if NOKOGIRI
179 161
                @xml.to_xml
......
214 196
                }
215 197
            end
216 198
        end
217

  
218
        def to_hash
219
            if !@hash && @xml
220
                @hash=Crack::XML.parse(to_xml)
221
            end
222
            return @hash
223
        end
224 199
    end
225 200

  
226 201
end
src/oca/ruby/test/ClusterPool_spec.rb
30 30
                end
31 31
            }
32 32
        end
33
        
34
        it "should get a hash representation of the USER_POOL" do
35
            cluster_hash = @cluster_pool.to_hash
36
            cluster_hash['CLUSTER_POOL']['CLUSTER'][0]['ID'].should eql('0')
37
            cluster_hash['CLUSTER_POOL']['CLUSTER'][0]['NAME'].should eql('default')
38
            cluster_hash['CLUSTER_POOL']['CLUSTER'][1]['ID'].should eql('1')
39
            cluster_hash['CLUSTER_POOL']['CLUSTER'][1]['NAME'].should eql('Red')
40
            cluster_hash['CLUSTER_POOL']['CLUSTER'][2]['ID'].should eql('2')
41
            cluster_hash['CLUSTER_POOL']['CLUSTER'][2]['NAME'].should eql('Black')
42
        end
43 33
    end
44 34
    
45 35
    describe "Cluster using REXML" do
......
67 57
                end
68 58
            }
69 59
        end
70
        
71
        it "should get a hash representation of the CLUSTER_POOL" do
72
            cluster_hash = @cluster_pool.to_hash
73
            cluster_hash['CLUSTER_POOL']['CLUSTER'][0]['ID'].should eql('0')
74
            cluster_hash['CLUSTER_POOL']['CLUSTER'][0]['NAME'].should eql('default')
75
            cluster_hash['CLUSTER_POOL']['CLUSTER'][1]['ID'].should eql('1')
76
            cluster_hash['CLUSTER_POOL']['CLUSTER'][1]['NAME'].should eql('Red')
77
            cluster_hash['CLUSTER_POOL']['CLUSTER'][2]['ID'].should eql('2')
78
            cluster_hash['CLUSTER_POOL']['CLUSTER'][2]['NAME'].should eql('Black')
79
        end
80 60
    end
81 61
end
src/oca/ruby/test/Cluster_spec.rb
54 54
            @cluster['ID'].should eql('5')
55 55
            @cluster['NAME'].should eql('Production')
56 56
        end
57

  
58
        it "should get a hash representation of the CLUSTER" do
59
            cluster_hash = @cluster.to_hash
60
            cluster_hash['CLUSTER']['ID'].should eql('5')
61
            cluster_hash['CLUSTER']['NAME'].should eql('Production')
62
        end
63 57
    end
64 58

  
65 59
    describe "Cluster using REXML" do
......
111 105
            @cluster['ID'].should eql('5')
112 106
            @cluster['NAME'].should eql('Production')
113 107
        end
114

  
115
        it "should get a hash representation of the CLUSTER" do
116
            cluster_hash = @cluster.to_hash
117
            cluster_hash['CLUSTER']['ID'].should eql('5')
118
            cluster_hash['CLUSTER']['NAME'].should eql('Production')
119
        end
120 108
    end
121 109

  
122 110

  
src/oca/ruby/test/HostPool_spec.rb
23 23
                host.class.to_s.should eql("OpenNebula::Host")
24 24
                if host.id == 0
25 25
                    host.name.should eql('dummyhost')
26
                    host['STATE'].should eql('2')
27
                    host['IM_MAD'].should eql('im_dummy')
28
                    host['HOST_SHARE/MEM_USAGE'].should eql('1572864')
29
                    host['HOST_SHARE/CPU_USAGE'].should eql('300')
30
                    host['HOST_SHARE/FREE_MEM'].should eql('16777216')
31
                    host['HOST_SHARE/RUNNING_VMS'].should eql('3')
26 32
                elsif host.id == 1
27 33
                    host.name.should eql('thost')
34
                    host['STATE'].should eql('2')
35
                    host['IM_MAD'].should eql('im_dummy')
36
                    host['HOST_SHARE/MEM_USAGE'].should eql('0')
37
                    host['HOST_SHARE/CPU_USAGE'].should eql('0')
38
                    host['HOST_SHARE/FREE_MEM'].should eql('16777216')
39
                    host['HOST_SHARE/RUNNING_VMS'].should eql('0')
28 40
                end
29 41
            }
30 42
        end
31
        
32
        it "should get a hash representation of the HOST_POOL" do
33
            host_hash = @host_pool.to_hash
34
            host_hash['HOST_POOL']['HOST'][0]['ID'].should eql('0')
35
            host_hash['HOST_POOL']['HOST'][0]['NAME'].should eql('dummyhost')
36
            host_hash['HOST_POOL']['HOST'][0]['STATE'].should eql('2')
37
            host_hash['HOST_POOL']['HOST'][0]['IM_MAD'].should eql('im_dummy')
38
            host_hash['HOST_POOL']['HOST'][0]['HOST_SHARE']['MEM_USAGE'].should eql('1572864')
39
            host_hash['HOST_POOL']['HOST'][0]['HOST_SHARE']['CPU_USAGE'].should eql('300')
40
            host_hash['HOST_POOL']['HOST'][0]['HOST_SHARE']['FREE_MEM'].should eql('16777216')
41
            host_hash['HOST_POOL']['HOST'][0]['HOST_SHARE']['RUNNING_VMS'].should eql('3')
42
            host_hash['HOST_POOL']['HOST'][1]['ID'].should eql('1')
43
            host_hash['HOST_POOL']['HOST'][1]['NAME'].should eql('thost')
44
            host_hash['HOST_POOL']['HOST'][1]['STATE'].should eql('2')
45
            host_hash['HOST_POOL']['HOST'][1]['IM_MAD'].should eql('im_dummy')
46
            host_hash['HOST_POOL']['HOST'][1]['HOST_SHARE']['MEM_USAGE'].should eql('0')
47
            host_hash['HOST_POOL']['HOST'][1]['HOST_SHARE']['CPU_USAGE'].should eql('0')
48
            host_hash['HOST_POOL']['HOST'][1]['HOST_SHARE']['FREE_MEM'].should eql('16777216')
49
            host_hash['HOST_POOL']['HOST'][1]['HOST_SHARE']['RUNNING_VMS'].should eql('0')
50
        end
51 43
    end
52 44
    
53 45
    describe "Host using REXML" do
......
68 60
                host.class.to_s.should eql("OpenNebula::Host")
69 61
                if host.id == 0
70 62
                    host.name.should eql('dummyhost')
63
                    host['STATE'].should eql('2')
64
                    host['IM_MAD'].should eql('im_dummy')
65
                    host['HOST_SHARE/MEM_USAGE'].should eql('1572864')
66
                    host['HOST_SHARE/CPU_USAGE'].should eql('300')
67
                    host['HOST_SHARE/FREE_MEM'].should eql('16777216')
68
                    host['HOST_SHARE/RUNNING_VMS'].should eql('3')
71 69
                elsif host.id == 1
72 70
                    host.name.should eql('thost')
71
                    host['STATE'].should eql('2')
72
                    host['IM_MAD'].should eql('im_dummy')
73
                    host['HOST_SHARE/MEM_USAGE'].should eql('0')
74
                    host['HOST_SHARE/CPU_USAGE'].should eql('0')
75
                    host['HOST_SHARE/FREE_MEM'].should eql('16777216')
76
                    host['HOST_SHARE/RUNNING_VMS'].should eql('0')
73 77
                end
74 78
            }
75 79
        end
76
        
77
        it "should get a hash representation of the HOST_POOL" do
78
            host_hash = @host_pool.to_hash
79
            host_hash['HOST_POOL']['HOST'][0]['ID'].should eql('0')
80
            host_hash['HOST_POOL']['HOST'][0]['NAME'].should eql('dummyhost')
81
            host_hash['HOST_POOL']['HOST'][0]['STATE'].should eql('2')
82
            host_hash['HOST_POOL']['HOST'][0]['IM_MAD'].should eql('im_dummy')
83
            host_hash['HOST_POOL']['HOST'][0]['HOST_SHARE']['MEM_USAGE'].should eql('1572864')
84
            host_hash['HOST_POOL']['HOST'][0]['HOST_SHARE']['CPU_USAGE'].should eql('300')
85
            host_hash['HOST_POOL']['HOST'][0]['HOST_SHARE']['FREE_MEM'].should eql('16777216')
86
            host_hash['HOST_POOL']['HOST'][0]['HOST_SHARE']['RUNNING_VMS'].should eql('3')
87
            host_hash['HOST_POOL']['HOST'][1]['ID'].should eql('1')
88
            host_hash['HOST_POOL']['HOST'][1]['NAME'].should eql('thost')
89
            host_hash['HOST_POOL']['HOST'][1]['STATE'].should eql('2')
90
            host_hash['HOST_POOL']['HOST'][1]['IM_MAD'].should eql('im_dummy')
91
            host_hash['HOST_POOL']['HOST'][1]['HOST_SHARE']['MEM_USAGE'].should eql('0')
92
            host_hash['HOST_POOL']['HOST'][1]['HOST_SHARE']['CPU_USAGE'].should eql('0')
93
            host_hash['HOST_POOL']['HOST'][1]['HOST_SHARE']['FREE_MEM'].should eql('16777216')
94
            host_hash['HOST_POOL']['HOST'][1]['HOST_SHARE']['RUNNING_VMS'].should eql('0')
95
        end
96 80
    end
97 81
end
src/oca/ruby/test/Host_spec.rb
67 67
            @host['TEMPLATE/HYPERVISOR'].should eql('dummy')
68 68
            @host['TEMPLATE/TOTALMEMORY'].should eql('16777216')
69 69
        end
70

  
71
        it "should get a hash representation of the HOST" do
72
            host_hash = @host.to_hash
73
            host_hash['HOST']['ID'].should eql('7')
74
            host_hash['HOST']['NAME'].should eql('dummyhost')
75
            host_hash['HOST']['STATE'].should eql('2')
76
            host_hash['HOST']['IM_MAD'].should eql('im_dummy')
77
            host_hash['HOST']['LAST_MON_TIME'].should eql('1277733596')
78
            host_hash['HOST']['HOST_SHARE']['MEM_USAGE'].should eql('1572864')
79
            host_hash['HOST']['HOST_SHARE']['CPU_USAGE'].should eql('300')
80
            host_hash['HOST']['HOST_SHARE']['FREE_CPU'].should eql('800')
81
            host_hash['HOST']['HOST_SHARE']['RUNNING_VMS'].should eql('3')
82
            host_hash['HOST']['TEMPLATE']['CPUSPEED'].should eql('2.2GHz')
83
            host_hash['HOST']['TEMPLATE']['HYPERVISOR'].should eql('dummy')
84
            host_hash['HOST']['TEMPLATE']['TOTALMEMORY'].should eql('16777216')
85
        end
86 70
    end
87 71

  
88 72
    describe "Host using REXML" do
......
147 131
            @host['TEMPLATE/HYPERVISOR'].should eql('dummy')
148 132
            @host['TEMPLATE/TOTALMEMORY'].should eql('16777216')
149 133
        end
150

  
151
        it "should get a hash representation of the HOST" do
152
            host_hash = @host.to_hash
153
            host_hash['HOST']['ID'].should eql('7')
154
            host_hash['HOST']['NAME'].should eql('dummyhost')
155
            host_hash['HOST']['STATE'].should eql('2')
156
            host_hash['HOST']['IM_MAD'].should eql('im_dummy')
157
            host_hash['HOST']['LAST_MON_TIME'].should eql('1277733596')
158
            host_hash['HOST']['HOST_SHARE']['MEM_USAGE'].should eql('1572864')
159
            host_hash['HOST']['HOST_SHARE']['CPU_USAGE'].should eql('300')
160
            host_hash['HOST']['HOST_SHARE']['FREE_CPU'].should eql('800')
161
            host_hash['HOST']['HOST_SHARE']['RUNNING_VMS'].should eql('3')
162
            host_hash['HOST']['TEMPLATE']['CPUSPEED'].should eql('2.2GHz')
163
            host_hash['HOST']['TEMPLATE']['HYPERVISOR'].should eql('dummy')
164
            host_hash['HOST']['TEMPLATE']['TOTALMEMORY'].should eql('16777216')
165
        end
166 134
    end
167 135

  
168 136

  
src/oca/ruby/test/UserPool_spec.rb
23 23
                user.class.to_s.should eql("OpenNebula::User")
24 24
                if user.id == 0
25 25
                    user.name.should eql('oneadmin')
26
                    user['PASSWORD'].should eql('f13a1234833436f71ab846572d251c0d40391e72')
27
                    user['ENABLED'].should eql('True')
26 28
                elsif user.id == 1
27 29
                    user.name.should eql('dan')
30
                    user['PASSWORD'].should eql('d22a12348334v33f71ba846572d25250d40701e72')
31
                    user['ENABLED'].should eql('False')
28 32
                end
29 33
            }
30 34
        end
31
        
32
        it "should get a hash representation of the USER_POOL" do
33
            user_hash = @user_pool.to_hash
34
            user_hash['USER_POOL']['USER'][0]['ID'].should eql('0')
35
            user_hash['USER_POOL']['USER'][0]['NAME'].should eql('oneadmin')
36
            user_hash['USER_POOL']['USER'][0]['PASSWORD'].should eql('f13a1234833436f71ab846572d251c0d40391e72')
37
            user_hash['USER_POOL']['USER'][0]['ENABLED'].should eql('True')
38
            user_hash['USER_POOL']['USER'][1]['ID'].should eql('1')
39
            user_hash['USER_POOL']['USER'][1]['NAME'].should eql('dan')
40
            user_hash['USER_POOL']['USER'][1]['PASSWORD'].should eql('d22a12348334v33f71ba846572d25250d40701e72')
41
            user_hash['USER_POOL']['USER'][1]['ENABLED'].should eql('False')
42
        end
43 35
    end
44 36
    
45 37
    describe "User using REXML" do
......
60 52
                user.class.to_s.should eql("OpenNebula::User")
61 53
                if user.id == 0
62 54
                    user.name.should eql('oneadmin')
55
                    user['PASSWORD'].should eql('f13a1234833436f71ab846572d251c0d40391e72')
56
                    user['ENABLED'].should eql('True')
63 57
                elsif user.id == 1
64 58
                    user.name.should eql('dan')
59
                    user['PASSWORD'].should eql('d22a12348334v33f71ba846572d25250d40701e72')
60
                    user['ENABLED'].should eql('False')
65 61
                end
66 62
            }
67 63
        end
68
        
69
        it "should get a hash representation of the USER_POOL" do
70
            user_hash = @user_pool.to_hash
71
            user_hash['USER_POOL']['USER'][0]['ID'].should eql('0')
72
            user_hash['USER_POOL']['USER'][0]['NAME'].should eql('oneadmin')
73
            user_hash['USER_POOL']['USER'][0]['PASSWORD'].should eql('f13a1234833436f71ab846572d251c0d40391e72')
74
            user_hash['USER_POOL']['USER'][0]['ENABLED'].should eql('True')
75
            user_hash['USER_POOL']['USER'][1]['ID'].should eql('1')
76
            user_hash['USER_POOL']['USER'][1]['NAME'].should eql('dan')
77
            user_hash['USER_POOL']['USER'][1]['PASSWORD'].should eql('d22a12348334v33f71ba846572d25250d40701e72')
78
            user_hash['USER_POOL']['USER'][1]['ENABLED'].should eql('False')
79
        end
80 64
    end
81 65
end
src/oca/ruby/test/User_spec.rb
44 44
            @user['PASSWORD'].should eql('d22a12348334v33f71ba846572d25250d40701e72')
45 45
            @user['ENABLED'].should eql('False')
46 46
        end
47

  
48
        it "should get a hash representation of the USER" do
49
            user_hash = @user.to_hash
50
            user_hash['USER']['ID'].should eql('3')
51
            user_hash['USER']['NAME'].should eql('dan')
52
            user_hash['USER']['PASSWORD'].should eql('d22a12348334v33f71ba846572d25250d40701e72')
53
            user_hash['USER']['ENABLED'].should eql('False')
54
        end
55 47
    end
56 48

  
57 49
    describe "User using REXML" do
......
93 85
            @user['PASSWORD'].should eql('d22a12348334v33f71ba846572d25250d40701e72')
94 86
            @user['ENABLED'].should eql('False')
95 87
        end
96

  
97
        it "should get a hash representation of the USER" do
98
            user_hash = @user.to_hash
99
            user_hash['USER']['ID'].should eql('3')
100
            user_hash['USER']['NAME'].should eql('dan')
101
            user_hash['USER']['PASSWORD'].should eql('d22a12348334v33f71ba846572d25250d40701e72')
102
            user_hash['USER']['ENABLED'].should eql('False')
103
        end
104 88
    end
105 89

  
106 90

  
src/oca/ruby/test/VirtualMachinePool_spec.rb
25 25
                    vm.name.should eql('vm-example')
26 26
                    vm.state.should eql(3)
27 27
                    vm.state_str.should eql('ACTIVE')
28
                    vm['UID'].should eql('0')
29
                    vm['USERNAME'].should eql('oneadmin')
30
                    vm['LAST_POLL'].should eql('1277910006')
31
                    vm['HISTORY/HOSTNAME'].should eql('dummyhost')
32
                    vm['HISTORY/STIME'].should eql('1277375186')
33
                    vm['HISTORY/REASON'].should eql('0')
28 34
                elsif vm.id == 8
29 35
                    vm.name.should eql('vmext')
30 36
                    vm.state.should eql(4)
31 37
                    vm.state_str.should eql('STOPPED')
38
                    vm['UID'].should eql('0')
39
                    vm['USERNAME'].should eql('oneadmin')
40
                    vm['LAST_POLL'].should eql('1277910006')
41
                    vm['HISTORY/HOSTNAME'].should eql('thost')
42
                    vm['HISTORY/STIME'].should eql('1277377556')
43
                    vm['HISTORY/REASON'].should eql('0')
32 44
                end
33 45
            }
34 46
        end
35
        
36
        it "should get a hash representation of the VM_POOL" do
37
            vm_hash = @vm_pool.to_hash
38
            vm_hash['VM_POOL']['VM'][0]['ID'].should eql('6')
39
            vm_hash['VM_POOL']['VM'][0]['UID'].should eql('0')
40
            vm_hash['VM_POOL']['VM'][0]['USERNAME'].should eql('oneadmin')
41
            vm_hash['VM_POOL']['VM'][0]['NAME'].should eql('vm-example')
42
            vm_hash['VM_POOL']['VM'][0]['LAST_POLL'].should eql('1277910006')
43
            vm_hash['VM_POOL']['VM'][0]['HISTORY']['HOSTNAME'].should eql('dummyhost')
44
            vm_hash['VM_POOL']['VM'][0]['HISTORY']['STIME'].should eql('1277375186')
45
            vm_hash['VM_POOL']['VM'][0]['HISTORY']['REASON'].should eql('0')
46
            vm_hash['VM_POOL']['VM'][2]['ID'].should eql('8')
47
            vm_hash['VM_POOL']['VM'][2]['UID'].should eql('0')
48
            vm_hash['VM_POOL']['VM'][2]['USERNAME'].should eql('oneadmin')
49
            vm_hash['VM_POOL']['VM'][2]['NAME'].should eql('vmext')
50
            vm_hash['VM_POOL']['VM'][2]['LAST_POLL'].should eql('1277910006')
51
            vm_hash['VM_POOL']['VM'][2]['HISTORY']['HOSTNAME'].should eql('thost')
52
            vm_hash['VM_POOL']['VM'][2]['HISTORY']['STIME'].should eql('1277377556')
53
            vm_hash['VM_POOL']['VM'][2]['HISTORY']['REASON'].should eql('0')
54
        end
55 47
    end
56 48
    
57 49
    describe "VirtualMachinePool using REXML" do
......
74 66
                    vm.name.should eql('vm-example')
75 67
                    vm.state.should eql(3)
76 68
                    vm.state_str.should eql('ACTIVE')
69
                    vm['UID'].should eql('0')
70
                    vm['USERNAME'].should eql('oneadmin')
71
                    vm['LAST_POLL'].should eql('1277910006')
72
                    vm['HISTORY/HOSTNAME'].should eql('dummyhost')
73
                    vm['HISTORY/STIME'].should eql('1277375186')
74
                    vm['HISTORY/REASON'].should eql('0')
77 75
                elsif vm.id == 8
78 76
                    vm.name.should eql('vmext')
79 77
                    vm.state.should eql(4)
80 78
                    vm.state_str.should eql('STOPPED')
79
                    vm['UID'].should eql('0')
80
                    vm['USERNAME'].should eql('oneadmin')
81
                    vm['LAST_POLL'].should eql('1277910006')
82
                    vm['HISTORY/HOSTNAME'].should eql('thost')
83
                    vm['HISTORY/STIME'].should eql('1277377556')
84
                    vm['HISTORY/REASON'].should eql('0')
81 85
                end
82 86
            }
83 87
        end
84
        
85
        it "should get a hash representation of the VM_POOL" do
86
            vm_hash = @vm_pool.to_hash
87
            vm_hash['VM_POOL']['VM'][0]['ID'].should eql('6')
88
            vm_hash['VM_POOL']['VM'][0]['UID'].should eql('0')
89
            vm_hash['VM_POOL']['VM'][0]['USERNAME'].should eql('oneadmin')
90
            vm_hash['VM_POOL']['VM'][0]['NAME'].should eql('vm-example')
91
            vm_hash['VM_POOL']['VM'][0]['LAST_POLL'].should eql('1277910006')
92
            vm_hash['VM_POOL']['VM'][0]['HISTORY']['HOSTNAME'].should eql('dummyhost')
93
            vm_hash['VM_POOL']['VM'][0]['HISTORY']['STIME'].should eql('1277375186')
94
            vm_hash['VM_POOL']['VM'][0]['HISTORY']['REASON'].should eql('0')
95
            vm_hash['VM_POOL']['VM'][2]['ID'].should eql('8')
96
            vm_hash['VM_POOL']['VM'][2]['UID'].should eql('0')
97
            vm_hash['VM_POOL']['VM'][2]['USERNAME'].should eql('oneadmin')
98
            vm_hash['VM_POOL']['VM'][2]['NAME'].should eql('vmext')
99
            vm_hash['VM_POOL']['VM'][2]['LAST_POLL'].should eql('1277910006')
100
            vm_hash['VM_POOL']['VM'][2]['HISTORY']['HOSTNAME'].should eql('thost')
101
            vm_hash['VM_POOL']['VM'][2]['HISTORY']['STIME'].should eql('1277377556')
102
            vm_hash['VM_POOL']['VM'][2]['HISTORY']['REASON'].should eql('0')
103
        end
104 88
    end
105 89
end
src/oca/ruby/test/VirtualMachine_spec.rb
123 123
            @vm['HISTORY/HOSTNAME'].should eql('dummyhost')
124 124
            @vm['HISTORY/PSTIME'].should eql('1277375186')
125 125
        end
126

  
127
        it "should get a hash representation of the VM" do
128
            vm_hash = @vm.to_hash
129
            vm_hash['VM']['ID'].should eql('6')
130
            vm_hash['VM']['NAME'].should eql('vm-example')
131
            vm_hash['VM']['LCM_STATE'].should eql('3')
132
            vm_hash['VM']['DEPLOY_ID'].should eql('dummy')
133
            vm_hash['VM']['TEMPLATE']['MEMORY'].should eql('512')
134
            vm_hash['VM']['TEMPLATE']['CONTEXT']['DNS'].should eql('192.169.1.4')
135
            vm_hash['VM']['TEMPLATE']['DISK'][0]['TARGET'].should eql('sda')
136
            vm_hash['VM']['HISTORY']['HOSTNAME'].should eql('dummyhost')
137
            vm_hash['VM']['HISTORY']['PSTIME'].should eql('1277375186')
138
        end
139 126
    end
140 127

  
141 128
    describe "VirtualMachine using REXML" do
......
256 243
            @vm['HISTORY/HOSTNAME'].should eql('dummyhost')
257 244
            @vm['HISTORY/PSTIME'].should eql('1277375186')
258 245
        end
259

  
260
        it "should get a hash representation of the VM" do
261
            vm_hash = @vm.to_hash
262
            vm_hash['VM']['ID'].should eql('6')
263
            vm_hash['VM']['NAME'].should eql('vm-example')
264
            vm_hash['VM']['LCM_STATE'].should eql('3')
265
            vm_hash['VM']['DEPLOY_ID'].should eql('dummy')
266
            vm_hash['VM']['TEMPLATE']['MEMORY'].should eql('512')
267
            vm_hash['VM']['TEMPLATE']['CONTEXT']['DNS'].should eql('192.169.1.4')
268
            vm_hash['VM']['TEMPLATE']['DISK'][0]['TARGET'].should eql('sda')
269
            vm_hash['VM']['HISTORY']['HOSTNAME'].should eql('dummyhost')
270
            vm_hash['VM']['HISTORY']['PSTIME'].should eql('1277375186')
271
        end
272 246
    end
273 247

  
274 248

  
src/oca/ruby/test/VirtualNetworkPool_spec.rb
28 28
                vn.class.to_s.should eql("OpenNebula::VirtualNetwork")
29 29
                if vn.id == 4
30 30
                    vn.name.should eql('Red LAN')
31
                    vn['UID'].should eql('0')
32
                    vn['USERNAME'].should eql('oneadmin')
33
                    vn['TYPE'].should eql('0')
34
                    vn['BRIDGE'].should eql('vbr0')
35
                    vn['TOTAL_LEASES'].should eql('0')
31 36
                elsif vn.id == 5
32 37
                    vn.name.should eql('Public')
38
                    vn['UID'].should eql('0')
39
                    vn['USERNAME'].should eql('oneadmin')
40
                    vn['TYPE'].should eql('0')
41
                    vn['BRIDGE'].should eql('vbr0')
42
                    vn['TOTAL_LEASES'].should eql('1')
33 43
                end
34 44
            }
35 45
        end
36
        
37
        it "should get a hash representation of the VNET_POOL" do
38
            vnet_hash = @vnet_pool.to_hash
39
            vnet_hash['VNET_POOL']['VNET'][0]['ID'].should eql('4')
40
            vnet_hash['VNET_POOL']['VNET'][0]['UID'].should eql('0')
41
            vnet_hash['VNET_POOL']['VNET'][0]['USERNAME'].should eql('oneadmin')
42
            vnet_hash['VNET_POOL']['VNET'][0]['NAME'].should eql('Red LAN')
43
            vnet_hash['VNET_POOL']['VNET'][0]['TYPE'].should eql('0')
44
            vnet_hash['VNET_POOL']['VNET'][0]['BRIDGE'].should eql('vbr0')
45
            vnet_hash['VNET_POOL']['VNET'][0]['TOTAL_LEASES'].should eql('0')
46
            vnet_hash['VNET_POOL']['VNET'][1]['ID'].should eql('5')
47
            vnet_hash['VNET_POOL']['VNET'][1]['UID'].should eql('0')
48
            vnet_hash['VNET_POOL']['VNET'][1]['USERNAME'].should eql('oneadmin')
49
            vnet_hash['VNET_POOL']['VNET'][1]['NAME'].should eql('Public')
50
            vnet_hash['VNET_POOL']['VNET'][1]['TYPE'].should eql('0')
51
            vnet_hash['VNET_POOL']['VNET'][1]['BRIDGE'].should eql('vbr0')
52
            vnet_hash['VNET_POOL']['VNET'][1]['TOTAL_LEASES'].should eql('1')
53
        end
54 46
    end
55 47
    
56 48
    describe "VirtualNetwork using REXML" do
......
76 68
                vn.class.to_s.should eql("OpenNebula::VirtualNetwork")
77 69
                if vn.id == 4
78 70
                    vn.name.should eql('Red LAN')
71
                    vn['UID'].should eql('0')
72
                    vn['USERNAME'].should eql('oneadmin')
73
                    vn['TYPE'].should eql('0')
74
                    vn['BRIDGE'].should eql('vbr0')
75
                    vn['TOTAL_LEASES'].should eql('0')
79 76
                elsif vn.id == 5
80 77
                    vn.name.should eql('Public')
78
                    vn['UID'].should eql('0')
79
                    vn['USERNAME'].should eql('oneadmin')
80
                    vn['TYPE'].should eql('0')
81
                    vn['BRIDGE'].should eql('vbr0')
82
                    vn['TOTAL_LEASES'].should eql('1')
81 83
                end
82 84
            }
83 85
        end
84
        
85
        it "should get a hash representation of the VNET_POOL" do
86
            vnet_hash = @vnet_pool.to_hash
87
            vnet_hash['VNET_POOL']['VNET'][0]['ID'].should eql('4')
88
            vnet_hash['VNET_POOL']['VNET'][0]['UID'].should eql('0')
89
            vnet_hash['VNET_POOL']['VNET'][0]['USERNAME'].should eql('oneadmin')
90
            vnet_hash['VNET_POOL']['VNET'][0]['NAME'].should eql('Red LAN')
91
            vnet_hash['VNET_POOL']['VNET'][0]['TYPE'].should eql('0')
92
            vnet_hash['VNET_POOL']['VNET'][0]['BRIDGE'].should eql('vbr0')
93
            vnet_hash['VNET_POOL']['VNET'][0]['TOTAL_LEASES'].should eql('0')
94
            vnet_hash['VNET_POOL']['VNET'][1]['ID'].should eql('5')
95
            vnet_hash['VNET_POOL']['VNET'][1]['UID'].should eql('0')
96
            vnet_hash['VNET_POOL']['VNET'][1]['USERNAME'].should eql('oneadmin')
97
            vnet_hash['VNET_POOL']['VNET'][1]['NAME'].should eql('Public')
98
            vnet_hash['VNET_POOL']['VNET'][1]['TYPE'].should eql('0')
99
            vnet_hash['VNET_POOL']['VNET'][1]['BRIDGE'].should eql('vbr0')
100
            vnet_hash['VNET_POOL']['VNET'][1]['TOTAL_LEASES'].should eql('1')
101
        end
102 86
    end
103 87
end
src/oca/ruby/test/VirtualNetwork_spec.rb
47 47
            @vnet['LEASES/LEASE/IP'].should eql('192.168.0.1')
48 48
            @vnet['LEASES/LEASE/USED'].should eql('1')
49 49
        end
50

  
51
        it "should get a hash representation of the VNET" do
52
            vnet_hash = @vnet.to_hash
53
            vnet_hash['VNET']['NAME'].should eql('Red LAN')
54
            vnet_hash['VNET']['BRIDGE'].should eql('vbr0')
55
            vnet_hash['VNET']['TEMPLATE']['NETWORK_ADDRESS'].should eql('192.168.0.0')
56
            vnet_hash['VNET']['ID'].should eql('3')
57
            vnet_hash['VNET']['NAME'].should eql('Red LAN')
58
            vnet_hash['VNET']['BRIDGE'].should eql('vbr0')
59
            vnet_hash['VNET']['TEMPLATE']['NETWORK_ADDRESS'].should eql('192.168.0.0')
60
            vnet_hash['VNET']['TEMPLATE']['TYPE'].should eql('RANGED')
61
            vnet_hash['VNET']['LEASES']['LEASE']['IP'].should eql('192.168.0.1')
62
            vnet_hash['VNET']['LEASES']['LEASE']['USED'].should eql('1')
63
        end
64 50
    end
65 51

  
66 52
    describe "VirtualNetwork using REXML" do
......
105 91
            @vnet['LEASES/LEASE/IP'].should eql('192.168.0.1')
106 92
            @vnet['LEASES/LEASE/USED'].should eql('1')
107 93
        end
108

  
109
        it "should get a hash representation of the VNET" do
110
            vnet_hash = @vnet.to_hash
111
            vnet_hash['VNET']['NAME'].should eql('Red LAN')
112
            vnet_hash['VNET']['BRIDGE'].should eql('vbr0')
113
            vnet_hash['VNET']['TEMPLATE']['NETWORK_ADDRESS'].should eql('192.168.0.0')
114
            vnet_hash['VNET']['ID'].should eql('3')
115
            vnet_hash['VNET']['NAME'].should eql('Red LAN')
116
            vnet_hash['VNET']['BRIDGE'].should eql('vbr0')
117
            vnet_hash['VNET']['TEMPLATE']['NETWORK_ADDRESS'].should eql('192.168.0.0')
118
            vnet_hash['VNET']['TEMPLATE']['TYPE'].should eql('RANGED')
119
            vnet_hash['VNET']['LEASES']['LEASE']['IP'].should eql('192.168.0.1')
120
            vnet_hash['VNET']['LEASES']['LEASE']['USED'].should eql('1')
121
        end
122 94
    end
123 95

  
124 96

  

Also available in: Unified diff