opennebula 6.6.2 → 6.7.80.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/DriverExecHelper.rb +1 -1
- data/lib/HostSyncManager.rb +111 -0
- data/lib/cloud/CloudClient.rb +1 -1
- data/lib/host.rb +1 -1
- data/lib/opennebula/acl.rb +2 -1
- data/lib/opennebula/backupjob.rb +250 -0
- data/lib/opennebula/backupjob_pool.rb +82 -0
- data/lib/opennebula/client.rb +2 -2
- data/lib/opennebula/group.rb +1 -1
- data/lib/opennebula/ldap_auth.rb +2 -2
- data/lib/opennebula/lockable_ext.rb +1 -0
- data/lib/opennebula/oneflow_client.rb +115 -108
- data/lib/opennebula/pool_element.rb +48 -47
- data/lib/opennebula/ssh_auth.rb +102 -79
- data/lib/opennebula/virtual_machine.rb +297 -299
- data/lib/opennebula/vm_group.rb +35 -1
- data/lib/opennebula.rb +3 -1
- data/lib/virtual_wire.rb +1 -1
- metadata +7 -4
@@ -18,225 +18,218 @@ require 'opennebula/lockable_ext'
|
|
18
18
|
require 'opennebula/pool_element'
|
19
19
|
|
20
20
|
module OpenNebula
|
21
|
+
|
21
22
|
class VirtualMachine < PoolElement
|
23
|
+
|
22
24
|
#######################################################################
|
23
25
|
# Constants and Class Methods
|
24
26
|
#######################################################################
|
25
27
|
|
26
28
|
VM_METHODS = {
|
27
|
-
:info =>
|
28
|
-
:allocate =>
|
29
|
-
:action =>
|
30
|
-
:migrate =>
|
31
|
-
:deploy =>
|
32
|
-
:chown =>
|
33
|
-
:chmod =>
|
34
|
-
:monitoring =>
|
35
|
-
:attach =>
|
36
|
-
:detach =>
|
37
|
-
:rename =>
|
38
|
-
:update =>
|
39
|
-
:resize =>
|
40
|
-
:snapshotcreate =>
|
41
|
-
:snapshotrevert =>
|
42
|
-
:snapshotdelete =>
|
43
|
-
:attachnic =>
|
44
|
-
:detachnic =>
|
45
|
-
:recover =>
|
46
|
-
:disksaveas =>
|
47
|
-
:disksnapshotcreate =>
|
48
|
-
:disksnapshotrevert =>
|
49
|
-
:disksnapshotdelete =>
|
50
|
-
:disksnapshotrename =>
|
51
|
-
:diskresize =>
|
52
|
-
:updateconf =>
|
53
|
-
:lock =>
|
54
|
-
:unlock =>
|
55
|
-
:schedadd =>
|
56
|
-
:scheddelete =>
|
57
|
-
:schedupdate =>
|
58
|
-
:attachsg =>
|
59
|
-
:detachsg =>
|
60
|
-
:backup =>
|
61
|
-
:updatenic =>
|
62
|
-
:backupcancel =>
|
29
|
+
:info => 'vm.info',
|
30
|
+
:allocate => 'vm.allocate',
|
31
|
+
:action => 'vm.action',
|
32
|
+
:migrate => 'vm.migrate',
|
33
|
+
:deploy => 'vm.deploy',
|
34
|
+
:chown => 'vm.chown',
|
35
|
+
:chmod => 'vm.chmod',
|
36
|
+
:monitoring => 'vm.monitoring',
|
37
|
+
:attach => 'vm.attach',
|
38
|
+
:detach => 'vm.detach',
|
39
|
+
:rename => 'vm.rename',
|
40
|
+
:update => 'vm.update',
|
41
|
+
:resize => 'vm.resize',
|
42
|
+
:snapshotcreate => 'vm.snapshotcreate',
|
43
|
+
:snapshotrevert => 'vm.snapshotrevert',
|
44
|
+
:snapshotdelete => 'vm.snapshotdelete',
|
45
|
+
:attachnic => 'vm.attachnic',
|
46
|
+
:detachnic => 'vm.detachnic',
|
47
|
+
:recover => 'vm.recover',
|
48
|
+
:disksaveas => 'vm.disksaveas',
|
49
|
+
:disksnapshotcreate => 'vm.disksnapshotcreate',
|
50
|
+
:disksnapshotrevert => 'vm.disksnapshotrevert',
|
51
|
+
:disksnapshotdelete => 'vm.disksnapshotdelete',
|
52
|
+
:disksnapshotrename => 'vm.disksnapshotrename',
|
53
|
+
:diskresize => 'vm.diskresize',
|
54
|
+
:updateconf => 'vm.updateconf',
|
55
|
+
:lock => 'vm.lock',
|
56
|
+
:unlock => 'vm.unlock',
|
57
|
+
:schedadd => 'vm.schedadd',
|
58
|
+
:scheddelete => 'vm.scheddelete',
|
59
|
+
:schedupdate => 'vm.schedupdate',
|
60
|
+
:attachsg => 'vm.attachsg',
|
61
|
+
:detachsg => 'vm.detachsg',
|
62
|
+
:backup => 'vm.backup',
|
63
|
+
:updatenic => 'vm.updatenic',
|
64
|
+
:backupcancel => 'vm.backupcancel'
|
63
65
|
}
|
64
66
|
|
65
|
-
VM_STATE
|
66
|
-
|
67
|
-
|
68
|
-
LCM_STATE
|
69
|
-
LCM_INIT
|
70
|
-
PROLOG
|
71
|
-
BOOT
|
72
|
-
RUNNING
|
73
|
-
MIGRATE
|
74
|
-
SAVE_STOP
|
75
|
-
SAVE_SUSPEND
|
76
|
-
SAVE_MIGRATE
|
77
|
-
PROLOG_MIGRATE
|
78
|
-
PROLOG_RESUME
|
79
|
-
EPILOG_STOP
|
80
|
-
EPILOG
|
81
|
-
SHUTDOWN
|
82
|
-
CANCEL
|
83
|
-
FAILURE
|
84
|
-
CLEANUP_RESUBMIT
|
85
|
-
UNKNOWN
|
86
|
-
HOTPLUG
|
87
|
-
SHUTDOWN_POWEROFF
|
88
|
-
BOOT_UNKNOWN
|
89
|
-
BOOT_POWEROFF
|
90
|
-
BOOT_SUSPENDED
|
91
|
-
BOOT_STOPPED
|
92
|
-
CLEANUP_DELETE
|
93
|
-
HOTPLUG_SNAPSHOT
|
94
|
-
HOTPLUG_NIC
|
95
|
-
HOTPLUG_SAVEAS
|
96
|
-
HOTPLUG_SAVEAS_POWEROFF
|
97
|
-
HOTPLUG_SAVEAS_SUSPENDED
|
98
|
-
SHUTDOWN_UNDEPLOY
|
99
|
-
EPILOG_UNDEPLOY
|
100
|
-
PROLOG_UNDEPLOY
|
101
|
-
BOOT_UNDEPLOY
|
102
|
-
HOTPLUG_PROLOG_POWEROFF
|
103
|
-
HOTPLUG_EPILOG_POWEROFF
|
104
|
-
BOOT_MIGRATE
|
105
|
-
BOOT_FAILURE
|
106
|
-
BOOT_MIGRATE_FAILURE
|
107
|
-
PROLOG_MIGRATE_FAILURE
|
108
|
-
PROLOG_FAILURE
|
109
|
-
EPILOG_FAILURE
|
110
|
-
EPILOG_STOP_FAILURE
|
111
|
-
EPILOG_UNDEPLOY_FAILURE
|
112
|
-
PROLOG_MIGRATE_POWEROFF
|
113
|
-
PROLOG_MIGRATE_POWEROFF_FAILURE
|
114
|
-
PROLOG_MIGRATE_SUSPEND
|
115
|
-
PROLOG_MIGRATE_SUSPEND_FAILURE
|
116
|
-
BOOT_UNDEPLOY_FAILURE
|
117
|
-
BOOT_STOPPED_FAILURE
|
118
|
-
PROLOG_RESUME_FAILURE
|
119
|
-
PROLOG_UNDEPLOY_FAILURE
|
120
|
-
DISK_SNAPSHOT_POWEROFF
|
121
|
-
DISK_SNAPSHOT_REVERT_POWEROFF
|
122
|
-
DISK_SNAPSHOT_DELETE_POWEROFF
|
123
|
-
DISK_SNAPSHOT_SUSPENDED
|
124
|
-
DISK_SNAPSHOT_REVERT_SUSPENDED
|
125
|
-
DISK_SNAPSHOT_DELETE_SUSPENDED
|
126
|
-
DISK_SNAPSHOT
|
127
|
-
DISK_SNAPSHOT_REVERT
|
128
|
-
DISK_SNAPSHOT_DELETE
|
129
|
-
PROLOG_MIGRATE_UNKNOWN
|
130
|
-
PROLOG_MIGRATE_UNKNOWN_FAILURE
|
131
|
-
DISK_RESIZE
|
132
|
-
DISK_RESIZE_POWEROFF
|
133
|
-
DISK_RESIZE_UNDEPLOYED
|
134
|
-
HOTPLUG_NIC_POWEROFF
|
135
|
-
HOTPLUG_RESIZE
|
136
|
-
HOTPLUG_SAVEAS_UNDEPLOYED
|
137
|
-
HOTPLUG_SAVEAS_STOPPED
|
138
|
-
BACKUP
|
139
|
-
BACKUP_POWEROFF
|
140
|
-
|
67
|
+
VM_STATE=['INIT', 'PENDING', 'HOLD', 'ACTIVE', 'STOPPED', 'SUSPENDED', 'DONE', 'FAILED',
|
68
|
+
'POWEROFF', 'UNDEPLOYED', 'CLONING', 'CLONING_FAILURE']
|
69
|
+
|
70
|
+
LCM_STATE=[
|
71
|
+
'LCM_INIT',
|
72
|
+
'PROLOG',
|
73
|
+
'BOOT',
|
74
|
+
'RUNNING',
|
75
|
+
'MIGRATE',
|
76
|
+
'SAVE_STOP',
|
77
|
+
'SAVE_SUSPEND',
|
78
|
+
'SAVE_MIGRATE',
|
79
|
+
'PROLOG_MIGRATE',
|
80
|
+
'PROLOG_RESUME',
|
81
|
+
'EPILOG_STOP',
|
82
|
+
'EPILOG',
|
83
|
+
'SHUTDOWN',
|
84
|
+
'CANCEL',
|
85
|
+
'FAILURE',
|
86
|
+
'CLEANUP_RESUBMIT',
|
87
|
+
'UNKNOWN',
|
88
|
+
'HOTPLUG',
|
89
|
+
'SHUTDOWN_POWEROFF',
|
90
|
+
'BOOT_UNKNOWN',
|
91
|
+
'BOOT_POWEROFF',
|
92
|
+
'BOOT_SUSPENDED',
|
93
|
+
'BOOT_STOPPED',
|
94
|
+
'CLEANUP_DELETE',
|
95
|
+
'HOTPLUG_SNAPSHOT',
|
96
|
+
'HOTPLUG_NIC',
|
97
|
+
'HOTPLUG_SAVEAS',
|
98
|
+
'HOTPLUG_SAVEAS_POWEROFF',
|
99
|
+
'HOTPLUG_SAVEAS_SUSPENDED',
|
100
|
+
'SHUTDOWN_UNDEPLOY',
|
101
|
+
'EPILOG_UNDEPLOY',
|
102
|
+
'PROLOG_UNDEPLOY',
|
103
|
+
'BOOT_UNDEPLOY',
|
104
|
+
'HOTPLUG_PROLOG_POWEROFF',
|
105
|
+
'HOTPLUG_EPILOG_POWEROFF',
|
106
|
+
'BOOT_MIGRATE',
|
107
|
+
'BOOT_FAILURE',
|
108
|
+
'BOOT_MIGRATE_FAILURE',
|
109
|
+
'PROLOG_MIGRATE_FAILURE',
|
110
|
+
'PROLOG_FAILURE',
|
111
|
+
'EPILOG_FAILURE',
|
112
|
+
'EPILOG_STOP_FAILURE',
|
113
|
+
'EPILOG_UNDEPLOY_FAILURE',
|
114
|
+
'PROLOG_MIGRATE_POWEROFF',
|
115
|
+
'PROLOG_MIGRATE_POWEROFF_FAILURE',
|
116
|
+
'PROLOG_MIGRATE_SUSPEND',
|
117
|
+
'PROLOG_MIGRATE_SUSPEND_FAILURE',
|
118
|
+
'BOOT_UNDEPLOY_FAILURE',
|
119
|
+
'BOOT_STOPPED_FAILURE',
|
120
|
+
'PROLOG_RESUME_FAILURE',
|
121
|
+
'PROLOG_UNDEPLOY_FAILURE',
|
122
|
+
'DISK_SNAPSHOT_POWEROFF',
|
123
|
+
'DISK_SNAPSHOT_REVERT_POWEROFF',
|
124
|
+
'DISK_SNAPSHOT_DELETE_POWEROFF',
|
125
|
+
'DISK_SNAPSHOT_SUSPENDED',
|
126
|
+
'DISK_SNAPSHOT_REVERT_SUSPENDED',
|
127
|
+
'DISK_SNAPSHOT_DELETE_SUSPENDED',
|
128
|
+
'DISK_SNAPSHOT',
|
129
|
+
'DISK_SNAPSHOT_REVERT',
|
130
|
+
'DISK_SNAPSHOT_DELETE',
|
131
|
+
'PROLOG_MIGRATE_UNKNOWN',
|
132
|
+
'PROLOG_MIGRATE_UNKNOWN_FAILURE',
|
133
|
+
'DISK_RESIZE',
|
134
|
+
'DISK_RESIZE_POWEROFF',
|
135
|
+
'DISK_RESIZE_UNDEPLOYED',
|
136
|
+
'HOTPLUG_NIC_POWEROFF',
|
137
|
+
'HOTPLUG_RESIZE',
|
138
|
+
'HOTPLUG_SAVEAS_UNDEPLOYED',
|
139
|
+
'HOTPLUG_SAVEAS_STOPPED',
|
140
|
+
'BACKUP',
|
141
|
+
'BACKUP_POWEROFF'
|
142
|
+
]
|
141
143
|
|
142
144
|
SHORT_VM_STATES={
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
145
|
+
'INIT' => 'init',
|
146
|
+
'PENDING' => 'pend',
|
147
|
+
'HOLD' => 'hold',
|
148
|
+
'ACTIVE' => 'actv',
|
149
|
+
'STOPPED' => 'stop',
|
150
|
+
'SUSPENDED' => 'susp',
|
151
|
+
'DONE' => 'done',
|
152
|
+
'FAILED' => 'fail',
|
153
|
+
'POWEROFF' => 'poff',
|
154
|
+
'UNDEPLOYED' => 'unde',
|
155
|
+
'CLONING' => 'clon',
|
156
|
+
'CLONING_FAILURE' => 'fail'
|
155
157
|
}
|
156
158
|
|
157
159
|
SHORT_LCM_STATES={
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
160
|
+
'PROLOG' => 'prol',
|
161
|
+
'BOOT' => 'boot',
|
162
|
+
'RUNNING' => 'runn',
|
163
|
+
'MIGRATE' => 'migr',
|
164
|
+
'SAVE_STOP' => 'save',
|
165
|
+
'SAVE_SUSPEND' => 'save',
|
166
|
+
'SAVE_MIGRATE' => 'save',
|
167
|
+
'PROLOG_MIGRATE' => 'migr',
|
168
|
+
'PROLOG_RESUME' => 'prol',
|
169
|
+
'EPILOG_STOP' => 'epil',
|
170
|
+
'EPILOG' => 'epil',
|
171
|
+
'SHUTDOWN' => 'shut',
|
172
|
+
'CANCEL' => 'shut',
|
173
|
+
'FAILURE' => 'fail',
|
174
|
+
'CLEANUP_RESUBMIT' => 'clea',
|
175
|
+
'UNKNOWN' => 'unkn',
|
176
|
+
'HOTPLUG' => 'hotp',
|
177
|
+
'SHUTDOWN_POWEROFF' => 'shut',
|
178
|
+
'BOOT_UNKNOWN' => 'boot',
|
179
|
+
'BOOT_POWEROFF' => 'boot',
|
180
|
+
'BOOT_SUSPENDED' => 'boot',
|
181
|
+
'BOOT_STOPPED' => 'boot',
|
182
|
+
'CLEANUP_DELETE' => 'clea',
|
183
|
+
'HOTPLUG_SNAPSHOT' => 'snap',
|
184
|
+
'HOTPLUG_NIC' => 'hotp',
|
185
|
+
'HOTPLUG_SAVEAS' => 'hotp',
|
186
|
+
'HOTPLUG_SAVEAS_POWEROFF' => 'hotp',
|
187
|
+
'HOTPLUG_SAVEAS_SUSPENDED' => 'hotp',
|
188
|
+
'SHUTDOWN_UNDEPLOY' => 'shut',
|
189
|
+
'EPILOG_UNDEPLOY' => 'epil',
|
190
|
+
'PROLOG_UNDEPLOY' => 'prol',
|
191
|
+
'BOOT_UNDEPLOY' => 'boot',
|
192
|
+
'HOTPLUG_PROLOG_POWEROFF' => 'hotp',
|
193
|
+
'HOTPLUG_EPILOG_POWEROFF' => 'hotp',
|
194
|
+
'BOOT_MIGRATE' => 'boot',
|
195
|
+
'BOOT_FAILURE' => 'fail',
|
196
|
+
'BOOT_MIGRATE_FAILURE' => 'fail',
|
197
|
+
'PROLOG_MIGRATE_FAILURE' => 'fail',
|
198
|
+
'PROLOG_FAILURE' => 'fail',
|
199
|
+
'EPILOG_FAILURE' => 'fail',
|
200
|
+
'EPILOG_STOP_FAILURE' => 'fail',
|
201
|
+
'EPILOG_UNDEPLOY_FAILURE' => 'fail',
|
202
|
+
'PROLOG_MIGRATE_POWEROFF' => 'migr',
|
203
|
+
'PROLOG_MIGRATE_POWEROFF_FAILURE' => 'fail',
|
204
|
+
'PROLOG_MIGRATE_SUSPEND' => 'migr',
|
205
|
+
'PROLOG_MIGRATE_SUSPEND_FAILURE' => 'fail',
|
206
|
+
'BOOT_UNDEPLOY_FAILURE' => 'fail',
|
207
|
+
'BOOT_STOPPED_FAILURE' => 'fail',
|
208
|
+
'PROLOG_RESUME_FAILURE' => 'fail',
|
209
|
+
'PROLOG_UNDEPLOY_FAILURE' => 'fail',
|
210
|
+
'DISK_SNAPSHOT_POWEROFF' => 'snap',
|
211
|
+
'DISK_SNAPSHOT_REVERT_POWEROFF' => 'snap',
|
212
|
+
'DISK_SNAPSHOT_DELETE_POWEROFF' => 'snap',
|
213
|
+
'DISK_SNAPSHOT_SUSPENDED' => 'snap',
|
214
|
+
'DISK_SNAPSHOT_REVERT_SUSPENDED'=> 'snap',
|
215
|
+
'DISK_SNAPSHOT_DELETE_SUSPENDED'=> 'snap',
|
216
|
+
'DISK_SNAPSHOT' => 'snap',
|
217
|
+
'DISK_SNAPSHOT_DELETE' => 'snap',
|
218
|
+
'PROLOG_MIGRATE_UNKNOWN' => 'migr',
|
219
|
+
'PROLOG_MIGRATE_UNKNOWN_FAILURE' => 'fail',
|
220
|
+
'DISK_RESIZE' => 'drsz',
|
221
|
+
'DISK_RESIZE_POWEROFF' => 'drsz',
|
222
|
+
'DISK_RESIZE_UNDEPLOYED' => 'drsz',
|
223
|
+
'HOTPLUG_NIC_POWEROFF' => 'hotp',
|
224
|
+
'HOTPLUG_RESIZE' => 'hotp',
|
225
|
+
'HOTPLUG_SAVEAS_UNDEPLOYED' => 'hotp',
|
226
|
+
'HOTPLUG_SAVEAS_STOPPED' => 'hotp',
|
227
|
+
'BACKUP' => 'back',
|
228
|
+
'BACKUP_POWEROFF' => 'back'
|
227
229
|
}
|
228
230
|
|
229
|
-
HISTORY_ACTION
|
230
|
-
|
231
|
-
delete-recreate reboot reboot-hard resched unresched poweroff
|
232
|
-
poweroff-hard disk-attach disk-detach nic-attach nic-detach
|
233
|
-
disk-snapshot-create disk-snapshot-delete terminate terminate-hard
|
234
|
-
disk-resize deploy chown chmod updateconf rename resize update
|
235
|
-
snapshot-resize snapshot-delete snapshot-revert disk-saveas
|
236
|
-
disk-snapshot-revert recover retry monitor disk-snapshot-rename
|
237
|
-
alias-attach alias-detach poweroff-migrate poweroff-hard-migrate
|
238
|
-
backup nic-update
|
239
|
-
}
|
231
|
+
HISTORY_ACTION=['none', 'migrate', 'live-migrate', 'shutdown', 'shutdown-hard', 'undeploy',
|
232
|
+
'undeploy-hard', 'hold', 'release', 'stop', 'suspend', 'resume', 'boot', 'delete', 'delete-recreate', 'reboot', 'reboot-hard', 'resched', 'unresched', 'poweroff', 'poweroff-hard', 'disk-attach', 'disk-detach', 'nic-attach', 'nic-detach', 'disk-snapshot-create', 'disk-snapshot-delete', 'terminate', 'terminate-hard', 'disk-resize', 'deploy', 'chown', 'chmod', 'updateconf', 'rename', 'resize', 'update', 'snapshot-resize', 'snapshot-delete', 'snapshot-revert', 'disk-saveas', 'disk-snapshot-revert', 'recover', 'retry', 'monitor', 'disk-snapshot-rename', 'alias-attach', 'alias-detach', 'poweroff-migrate', 'poweroff-hard-migrate', 'backup', 'nic-update']
|
240
233
|
|
241
234
|
EXTERNAL_IP_ATTRS = [
|
242
235
|
'GUEST_IP',
|
@@ -249,14 +242,15 @@ module OpenNebula
|
|
249
242
|
|
250
243
|
# VirtualMachineDriver constants
|
251
244
|
module Driver
|
245
|
+
|
252
246
|
POLL_ATTRIBUTE = {
|
253
|
-
:memory =>
|
254
|
-
:cpu =>
|
255
|
-
:nettx =>
|
256
|
-
:netrx =>
|
257
|
-
:state =>
|
258
|
-
:disk_size =>
|
259
|
-
:snapshot_size =>
|
247
|
+
:memory => 'MEMORY',
|
248
|
+
:cpu => 'CPU',
|
249
|
+
:nettx => 'NETTX',
|
250
|
+
:netrx => 'NETRX',
|
251
|
+
:state => 'STATE',
|
252
|
+
:disk_size => 'DISK_SIZE',
|
253
|
+
:snapshot_size => 'SNAPSHOT_SIZE'
|
260
254
|
}
|
261
255
|
|
262
256
|
VM_STATE = {
|
@@ -266,6 +260,7 @@ module OpenNebula
|
|
266
260
|
:deleted => 'd',
|
267
261
|
:unknown => '-'
|
268
262
|
}
|
263
|
+
|
269
264
|
end
|
270
265
|
|
271
266
|
# Creates a VirtualMachine description with just its identifier
|
@@ -275,25 +270,25 @@ module OpenNebula
|
|
275
270
|
# Example:
|
276
271
|
# vm = VirtualMachine.new(VirtualMachine.build_xml(3),rpc_client)
|
277
272
|
#
|
278
|
-
def
|
273
|
+
def self.build_xml(pe_id = nil)
|
279
274
|
if pe_id
|
280
275
|
vm_xml = "<VM><ID>#{pe_id}</ID></VM>"
|
281
276
|
else
|
282
|
-
vm_xml =
|
277
|
+
vm_xml = '<VM></VM>'
|
283
278
|
end
|
284
279
|
|
285
280
|
XMLElement.build_xml(vm_xml, 'VM')
|
286
281
|
end
|
287
282
|
|
288
|
-
def
|
289
|
-
|
283
|
+
def self.get_history_action(action)
|
284
|
+
HISTORY_ACTION[action.to_i]
|
290
285
|
end
|
291
286
|
|
292
287
|
# Class constructor
|
293
288
|
def initialize(xml, client)
|
294
289
|
LockableExt.make_lockable(self, VM_METHODS)
|
295
290
|
|
296
|
-
super(xml,client)
|
291
|
+
super(xml, client)
|
297
292
|
end
|
298
293
|
|
299
294
|
#######################################################################
|
@@ -305,7 +300,7 @@ module OpenNebula
|
|
305
300
|
super(VM_METHODS[:info], 'VM', decrypt)
|
306
301
|
end
|
307
302
|
|
308
|
-
|
303
|
+
alias info! info
|
309
304
|
|
310
305
|
# Allocates a new VirtualMachine in OpenNebula
|
311
306
|
#
|
@@ -316,7 +311,7 @@ module OpenNebula
|
|
316
311
|
#
|
317
312
|
# @return [nil, OpenNebula::Error] nil in case of success, Error
|
318
313
|
# otherwise
|
319
|
-
def allocate(description, hold=false)
|
314
|
+
def allocate(description, hold = false)
|
320
315
|
super(VM_METHODS[:allocate], description, hold)
|
321
316
|
end
|
322
317
|
|
@@ -328,7 +323,7 @@ module OpenNebula
|
|
328
323
|
#
|
329
324
|
# @return [nil, OpenNebula::Error] nil in case of success, Error
|
330
325
|
# otherwise
|
331
|
-
def update(new_template=nil, append=false)
|
326
|
+
def update(new_template = nil, append = false)
|
332
327
|
super(VM_METHODS[:update], new_template, append ? 1 : 0)
|
333
328
|
end
|
334
329
|
|
@@ -337,7 +332,7 @@ module OpenNebula
|
|
337
332
|
# @param indent [true,false] indents the resulting string, defaults to true
|
338
333
|
#
|
339
334
|
# @return [String] The USER_TEMPLATE
|
340
|
-
def user_template_str(indent=true)
|
335
|
+
def user_template_str(indent = true)
|
341
336
|
template_like_str('USER_TEMPLATE', indent)
|
342
337
|
end
|
343
338
|
|
@@ -353,7 +348,7 @@ module OpenNebula
|
|
353
348
|
end
|
354
349
|
|
355
350
|
def replace(opts = {})
|
356
|
-
super(opts,
|
351
|
+
super(opts, 'USER_TEMPLATE')
|
357
352
|
end
|
358
353
|
|
359
354
|
# Initiates the instance of the VM on the target host.
|
@@ -368,40 +363,40 @@ module OpenNebula
|
|
368
363
|
#
|
369
364
|
# @return [nil, OpenNebula::Error] nil in case of success, Error
|
370
365
|
# otherwise
|
371
|
-
def deploy(host_id, enforce=false, ds_id
|
366
|
+
def deploy(host_id, enforce = false, ds_id = -1, extra_template = '')
|
372
367
|
enforce ||= false
|
373
368
|
ds_id ||= -1
|
374
|
-
extra_template ||=
|
369
|
+
extra_template ||= ''
|
375
370
|
|
376
|
-
|
371
|
+
info
|
377
372
|
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
373
|
+
call(VM_METHODS[:deploy],
|
374
|
+
@pe_id,
|
375
|
+
host_id.to_i,
|
376
|
+
enforce,
|
377
|
+
ds_id.to_i,
|
378
|
+
extra_template)
|
384
379
|
end
|
385
380
|
|
386
381
|
# Shutdowns an already deployed VM
|
387
|
-
def terminate(hard=false)
|
382
|
+
def terminate(hard = false)
|
388
383
|
action(hard ? 'terminate-hard' : 'terminate')
|
389
384
|
end
|
390
385
|
|
391
|
-
|
386
|
+
alias shutdown terminate
|
392
387
|
|
393
388
|
# Shuts down an already deployed VM, saving its state in the system DS
|
394
|
-
def undeploy(hard=false)
|
389
|
+
def undeploy(hard = false)
|
395
390
|
action(hard ? 'undeploy-hard' : 'undeploy')
|
396
391
|
end
|
397
392
|
|
398
393
|
# Powers off a running VM
|
399
|
-
def poweroff(hard=false)
|
394
|
+
def poweroff(hard = false)
|
400
395
|
action(hard ? 'poweroff-hard' : 'poweroff')
|
401
396
|
end
|
402
397
|
|
403
398
|
# Reboots an already deployed VM
|
404
|
-
def reboot(hard=false)
|
399
|
+
def reboot(hard = false)
|
405
400
|
action(hard ? 'reboot-hard' : 'reboot')
|
406
401
|
end
|
407
402
|
|
@@ -436,10 +431,10 @@ module OpenNebula
|
|
436
431
|
# @return [nil, OpenNebula::Error] nil in case of success, Error
|
437
432
|
# otherwise
|
438
433
|
def disk_attach(disk_template)
|
439
|
-
|
434
|
+
call(VM_METHODS[:attach], @pe_id, disk_template)
|
440
435
|
end
|
441
436
|
|
442
|
-
|
437
|
+
alias attachdisk disk_attach
|
443
438
|
|
444
439
|
# Detaches a disk from a running VM
|
445
440
|
#
|
@@ -447,10 +442,10 @@ module OpenNebula
|
|
447
442
|
# @return [nil, OpenNebula::Error] nil in case of success, Error
|
448
443
|
# otherwise
|
449
444
|
def disk_detach(disk_id)
|
450
|
-
|
445
|
+
call(VM_METHODS[:detach], @pe_id, disk_id)
|
451
446
|
end
|
452
447
|
|
453
|
-
|
448
|
+
alias detachdisk disk_detach
|
454
449
|
|
455
450
|
# Attaches a NIC to a running VM
|
456
451
|
#
|
@@ -458,7 +453,7 @@ module OpenNebula
|
|
458
453
|
# @return [nil, OpenNebula::Error] nil in case of success, Error
|
459
454
|
# otherwise
|
460
455
|
def nic_attach(nic_template)
|
461
|
-
|
456
|
+
call(VM_METHODS[:attachnic], @pe_id, nic_template)
|
462
457
|
end
|
463
458
|
|
464
459
|
# Detaches a NIC from a running VM
|
@@ -467,7 +462,7 @@ module OpenNebula
|
|
467
462
|
# @return [nil, OpenNebula::Error] nil in case of success, Error
|
468
463
|
# otherwise
|
469
464
|
def nic_detach(nic_id)
|
470
|
-
|
465
|
+
call(VM_METHODS[:detachnic], @pe_id, nic_id)
|
471
466
|
end
|
472
467
|
|
473
468
|
# Updates a NIC for a running VM
|
@@ -479,7 +474,7 @@ module OpenNebula
|
|
479
474
|
# @return [nil, OpenNebula::Error] nil in case of success, Error
|
480
475
|
# otherwise
|
481
476
|
def nic_update(nic_id, nic_template, append = false)
|
482
|
-
|
477
|
+
call(VM_METHODS[:updatenic], @pe_id, nic_id, nic_template, append ? 1 : 0)
|
483
478
|
end
|
484
479
|
|
485
480
|
# Attaches a Security Groupt to a running VM
|
@@ -489,7 +484,7 @@ module OpenNebula
|
|
489
484
|
# @return [nil, OpenNebula::Error] nil in case of success, Error
|
490
485
|
# otherwise
|
491
486
|
def sg_attach(nic_id, sg_id)
|
492
|
-
|
487
|
+
call(VM_METHODS[:attachsg], @pe_id, nic_id, sg_id)
|
493
488
|
end
|
494
489
|
|
495
490
|
# Detaches a Security Group from a running VM
|
@@ -498,7 +493,7 @@ module OpenNebula
|
|
498
493
|
# @return [nil, OpenNebula::Error] nil in case of success, Error
|
499
494
|
# otherwise
|
500
495
|
def sg_detach(nic_id, sg_id)
|
501
|
-
|
496
|
+
call(VM_METHODS[:detachsg], @pe_id, nic_id, sg_id)
|
502
497
|
end
|
503
498
|
|
504
499
|
# Sets the re-scheduling flag for the VM
|
@@ -530,13 +525,13 @@ module OpenNebula
|
|
530
525
|
#
|
531
526
|
# @return [nil, OpenNebula::Error] nil in case of success, Error
|
532
527
|
# otherwise
|
533
|
-
def migrate(host_id, live=false, enforce=false, ds_id
|
528
|
+
def migrate(host_id, live = false, enforce = false, ds_id = -1, mtype = 0)
|
534
529
|
call(VM_METHODS[:migrate], @pe_id, host_id.to_i, live==true,
|
535
|
-
|
530
|
+
enforce, ds_id.to_i, mtype)
|
536
531
|
end
|
537
532
|
|
538
533
|
# @deprecated use {#migrate} instead
|
539
|
-
def live_migrate(host_id, enforce=false)
|
534
|
+
def live_migrate(host_id, enforce = false)
|
540
535
|
migrate(host_id, true, enforce)
|
541
536
|
end
|
542
537
|
|
@@ -552,16 +547,15 @@ module OpenNebula
|
|
552
547
|
#
|
553
548
|
# @return [Integer, OpenNebula::Error] the new Image ID in case of
|
554
549
|
# success, error otherwise
|
555
|
-
def disk_saveas(disk_id, image_name, image_type=
|
556
|
-
return Error.new('ID not defined')
|
550
|
+
def disk_saveas(disk_id, image_name, image_type = '', snap_id = -1)
|
551
|
+
return Error.new('ID not defined') unless @pe_id
|
557
552
|
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
return rc
|
553
|
+
@client.call(VM_METHODS[:disksaveas],
|
554
|
+
@pe_id,
|
555
|
+
disk_id,
|
556
|
+
image_name,
|
557
|
+
image_type,
|
558
|
+
snap_id)
|
565
559
|
end
|
566
560
|
|
567
561
|
# Resize the VM
|
@@ -576,7 +570,7 @@ module OpenNebula
|
|
576
570
|
# @return [nil, OpenNebula::Error] nil in case of success, Error
|
577
571
|
# otherwise
|
578
572
|
def resize(capacity_template, enforce)
|
579
|
-
|
573
|
+
call(VM_METHODS[:resize], @pe_id, capacity_template, enforce)
|
580
574
|
end
|
581
575
|
|
582
576
|
# Changes the owner/group
|
@@ -602,7 +596,7 @@ module OpenNebula
|
|
602
596
|
# @return [nil, OpenNebula::Error] nil in case of success, Error
|
603
597
|
# otherwise
|
604
598
|
def chmod(owner_u, owner_m, owner_a, group_u, group_m, group_a, other_u,
|
605
|
-
|
599
|
+
other_m, other_a)
|
606
600
|
super(VM_METHODS[:chmod], owner_u, owner_m, owner_a, group_u,
|
607
601
|
group_m, group_a, other_u, other_m, other_a)
|
608
602
|
end
|
@@ -625,16 +619,16 @@ module OpenNebula
|
|
625
619
|
# }
|
626
620
|
#
|
627
621
|
def monitoring(xpath_expressions)
|
628
|
-
|
622
|
+
super(VM_METHODS[:monitoring], xpath_expressions)
|
629
623
|
end
|
630
624
|
|
631
625
|
# Retrieves this VM's monitoring data from OpenNebula, in XML
|
632
626
|
#
|
633
627
|
# @return [String] VM monitoring data, in XML
|
634
|
-
def monitoring_xml
|
635
|
-
return Error.new('ID not defined')
|
628
|
+
def monitoring_xml
|
629
|
+
return Error.new('ID not defined') unless @pe_id
|
636
630
|
|
637
|
-
|
631
|
+
@client.call(VM_METHODS[:monitoring], @pe_id)
|
638
632
|
end
|
639
633
|
|
640
634
|
# Renames this VM
|
@@ -644,7 +638,7 @@ module OpenNebula
|
|
644
638
|
# @return [nil, OpenNebula::Error] nil in case of success, Error
|
645
639
|
# otherwise
|
646
640
|
def rename(name)
|
647
|
-
|
641
|
+
call(VM_METHODS[:rename], @pe_id, name)
|
648
642
|
end
|
649
643
|
|
650
644
|
# Creates a new VM snapshot
|
@@ -653,11 +647,11 @@ module OpenNebula
|
|
653
647
|
#
|
654
648
|
# @return [Integer, OpenNebula::Error] The new snaphost ID in case
|
655
649
|
# of success, Error otherwise
|
656
|
-
def snapshot_create(name=
|
657
|
-
return Error.new('ID not defined')
|
650
|
+
def snapshot_create(name = '')
|
651
|
+
return Error.new('ID not defined') unless @pe_id
|
658
652
|
|
659
|
-
name ||=
|
660
|
-
|
653
|
+
name ||= ''
|
654
|
+
@client.call(VM_METHODS[:snapshotcreate], @pe_id, name)
|
661
655
|
end
|
662
656
|
|
663
657
|
# Reverts to a snapshot
|
@@ -667,7 +661,7 @@ module OpenNebula
|
|
667
661
|
# @return [nil, OpenNebula::Error] nil in case of success, Error
|
668
662
|
# otherwise
|
669
663
|
def snapshot_revert(snap_id)
|
670
|
-
|
664
|
+
call(VM_METHODS[:snapshotrevert], @pe_id, snap_id)
|
671
665
|
end
|
672
666
|
|
673
667
|
# Deletes a VM snapshot
|
@@ -677,7 +671,7 @@ module OpenNebula
|
|
677
671
|
# @return [nil, OpenNebula::Error] nil in case of success, Error
|
678
672
|
# otherwise
|
679
673
|
def snapshot_delete(snap_id)
|
680
|
-
|
674
|
+
call(VM_METHODS[:snapshotdelete], @pe_id, snap_id)
|
681
675
|
end
|
682
676
|
|
683
677
|
# Takes a new snapshot of a disk
|
@@ -687,7 +681,7 @@ module OpenNebula
|
|
687
681
|
#
|
688
682
|
# @return [Integer, OpenNebula::Error] The new snapshot ID or error
|
689
683
|
def disk_snapshot_create(disk_id, name)
|
690
|
-
|
684
|
+
call(VM_METHODS[:disksnapshotcreate], @pe_id, disk_id, name)
|
691
685
|
end
|
692
686
|
|
693
687
|
# Reverts disk state to a previously taken snapshot
|
@@ -698,7 +692,7 @@ module OpenNebula
|
|
698
692
|
# @return [nil, OpenNebula::Error] nil in case of success, Error
|
699
693
|
# otherwise
|
700
694
|
def disk_snapshot_revert(disk_id, snap_id)
|
701
|
-
|
695
|
+
call(VM_METHODS[:disksnapshotrevert], @pe_id, disk_id, snap_id)
|
702
696
|
end
|
703
697
|
|
704
698
|
# Deletes a disk snapshot
|
@@ -709,7 +703,7 @@ module OpenNebula
|
|
709
703
|
# @return [nil, OpenNebula::Error] nil in case of success, Error
|
710
704
|
# otherwise
|
711
705
|
def disk_snapshot_delete(disk_id, snap_id)
|
712
|
-
|
706
|
+
call(VM_METHODS[:disksnapshotdelete], @pe_id, disk_id, snap_id)
|
713
707
|
end
|
714
708
|
|
715
709
|
# Renames a disk snapshot
|
@@ -721,7 +715,7 @@ module OpenNebula
|
|
721
715
|
# @return [nil, OpenNebula::Error] nil in case of success, Error
|
722
716
|
# otherwise
|
723
717
|
def disk_snapshot_rename(disk_id, snap_id, new_name)
|
724
|
-
|
718
|
+
call(VM_METHODS[:disksnapshotrename], @pe_id, disk_id, snap_id, new_name)
|
725
719
|
end
|
726
720
|
|
727
721
|
# Changes the size of a disk
|
@@ -731,7 +725,7 @@ module OpenNebula
|
|
731
725
|
#
|
732
726
|
# @return [nil, OpenNebula::Error] nil in case of success or error
|
733
727
|
def disk_resize(disk_id, size)
|
734
|
-
|
728
|
+
call(VM_METHODS[:diskresize], @pe_id, disk_id, size.to_s)
|
735
729
|
end
|
736
730
|
|
737
731
|
# Recovers an ACTIVE VM
|
@@ -742,11 +736,11 @@ module OpenNebula
|
|
742
736
|
# @return [nil, OpenNebula::Error] nil in case of success, Error
|
743
737
|
# otherwise
|
744
738
|
def recover(result)
|
745
|
-
|
739
|
+
call(VM_METHODS[:recover], @pe_id, result)
|
746
740
|
end
|
747
741
|
|
748
742
|
# Deletes a VM from the pool
|
749
|
-
def delete(recreate=false)
|
743
|
+
def delete(recreate = false)
|
750
744
|
if recreate
|
751
745
|
recover(4)
|
752
746
|
else
|
@@ -762,12 +756,13 @@ module OpenNebula
|
|
762
756
|
# can be updated are: INPUT/{TYPE, BUS}; RAW/{TYPE, DATA, DATA_VMX},
|
763
757
|
# OS/{BOOT, BOOTLOADER, ARCH, MACHINE, KERNEL, INITRD},
|
764
758
|
# FEATURES/{ACPI, APIC, PAE, LOCALTIME, HYPERV, GUEST_AGENT},
|
765
|
-
#
|
759
|
+
# GRAPHICS/{TYPE, LISTEN, PASSWD, KEYMAP},
|
760
|
+
# and VIDEO/{TYPE, IOMMU, ATS, VRAM, RESOLUTION}
|
766
761
|
# @param append, append template, do not delete empty attributes
|
767
762
|
# @return [nil, OpenNebula::Error] nil in case of success, Error
|
768
763
|
# otherwise
|
769
764
|
def updateconf(new_conf, append = false)
|
770
|
-
|
765
|
+
call(VM_METHODS[:updateconf], @pe_id, new_conf, append ? 1 : 0)
|
771
766
|
end
|
772
767
|
|
773
768
|
# Add sched actions
|
@@ -776,7 +771,7 @@ module OpenNebula
|
|
776
771
|
# @return [nil, OpenNebula::Error] nil in case of success, Error
|
777
772
|
# otherwise
|
778
773
|
def sched_action_add(sched_template)
|
779
|
-
|
774
|
+
call(VM_METHODS[:schedadd], @pe_id, sched_template)
|
780
775
|
end
|
781
776
|
|
782
777
|
# Delete sched action
|
@@ -785,7 +780,7 @@ module OpenNebula
|
|
785
780
|
# @return [nil, OpenNebula::Error] nil in case of success, Error
|
786
781
|
# otherwise
|
787
782
|
def sched_action_delete(sched_id)
|
788
|
-
|
783
|
+
call(VM_METHODS[:scheddelete], @pe_id, sched_id.to_i)
|
789
784
|
end
|
790
785
|
|
791
786
|
# Update sched_action
|
@@ -795,8 +790,8 @@ module OpenNebula
|
|
795
790
|
# @return [nil, OpenNebula::Error] nil in case of success, Error
|
796
791
|
# otherwise
|
797
792
|
def sched_action_update(sched_id, sched_template)
|
798
|
-
|
799
|
-
|
793
|
+
call(VM_METHODS[:schedupdate], @pe_id, sched_id.to_i,
|
794
|
+
sched_template)
|
800
795
|
end
|
801
796
|
|
802
797
|
# Generate a backup for the VM (backup config must be set)
|
@@ -805,15 +800,15 @@ module OpenNebula
|
|
805
800
|
# @return [Integer, OpenNebula::Error] ID of the resulting BACKUP image
|
806
801
|
# in case of success, Error otherwise.
|
807
802
|
def backup(ds_id = -1, reset = false)
|
808
|
-
|
803
|
+
@client.call(VM_METHODS[:backup], @pe_id, ds_id, reset)
|
809
804
|
end
|
810
805
|
|
811
806
|
# Cancel ongoing backup operation for the VM
|
812
807
|
#
|
813
808
|
# @return [nil, OpenNebula::Error] nil in case of sucess, Error
|
814
809
|
# otherwise.
|
815
|
-
def backup_cancel
|
816
|
-
|
810
|
+
def backup_cancel
|
811
|
+
@client.call(VM_METHODS[:backupcancel], @pe_id)
|
817
812
|
end
|
818
813
|
|
819
814
|
########################################################################
|
@@ -844,7 +839,7 @@ module OpenNebula
|
|
844
839
|
def status
|
845
840
|
short_state_str=SHORT_VM_STATES[state_str]
|
846
841
|
|
847
|
-
if short_state_str==
|
842
|
+
if short_state_str=='actv'
|
848
843
|
short_state_str=SHORT_LCM_STATES[lcm_state_str]
|
849
844
|
end
|
850
845
|
|
@@ -866,7 +861,7 @@ module OpenNebula
|
|
866
861
|
retrieve_xmlelements('//HISTORY')[seq].to_xml
|
867
862
|
end
|
868
863
|
|
869
|
-
def wait_state(state, timeout=120)
|
864
|
+
def wait_state(state, timeout = 120)
|
870
865
|
require 'opennebula/wait_ext'
|
871
866
|
|
872
867
|
extend OpenNebula::WaitExt
|
@@ -878,7 +873,7 @@ module OpenNebula
|
|
878
873
|
true
|
879
874
|
end
|
880
875
|
|
881
|
-
def wait_state2(state, lcm_state, timeout=120)
|
876
|
+
def wait_state2(state, lcm_state, timeout = 120)
|
882
877
|
extend OpenNebula::WaitExt
|
883
878
|
|
884
879
|
rc = wait2(state, lcm_state, timeout)
|
@@ -888,26 +883,27 @@ module OpenNebula
|
|
888
883
|
true
|
889
884
|
end
|
890
885
|
|
891
|
-
|
886
|
+
private
|
887
|
+
|
892
888
|
def action(name)
|
893
|
-
return Error.new('ID not defined')
|
889
|
+
return Error.new('ID not defined') unless @pe_id
|
894
890
|
|
895
891
|
rc = @client.call(VM_METHODS[:action], name, @pe_id)
|
896
|
-
rc = nil
|
892
|
+
rc = nil unless OpenNebula.is_error?(rc)
|
897
893
|
|
898
|
-
|
894
|
+
rc
|
899
895
|
end
|
900
896
|
|
901
|
-
def wait_lcm_state(state, timeout=10)
|
902
|
-
vm_state =
|
903
|
-
lcm_state =
|
897
|
+
def wait_lcm_state(state, timeout = 10)
|
898
|
+
vm_state = ''
|
899
|
+
lcm_state = ''
|
904
900
|
|
905
901
|
timeout.times do
|
906
|
-
rc = info
|
902
|
+
rc = info
|
907
903
|
return rc if OpenNebula.is_error?(rc)
|
908
904
|
|
909
|
-
vm_state = state_str
|
910
|
-
lcm_state = lcm_state_str
|
905
|
+
vm_state = state_str
|
906
|
+
lcm_state = lcm_state_str
|
911
907
|
|
912
908
|
if lcm_state == state
|
913
909
|
return true
|
@@ -916,8 +912,10 @@ module OpenNebula
|
|
916
912
|
sleep 1
|
917
913
|
end
|
918
914
|
|
919
|
-
|
915
|
+
Error.new("Timeout expired for state #{state}. "<<
|
920
916
|
"VM is in state #{vm_state}, #{lcm_state}")
|
921
917
|
end
|
918
|
+
|
922
919
|
end
|
920
|
+
|
923
921
|
end
|