Bug #2098: Do not delete VMs that cannot be monitored

This commit is contained in:
Carlos Martín committed 2013-07-05 17:11:46 +02:00
1 parent ffdc33edef
commit e8b2c72592
3 files changed
+79 -33

No files matched your search

+60 -22
View File
@@ -78,60 +78,98 @@ NODE_TABLE = CLIHelper::ShowTable.new(nil, self) do
st << "\u2193 "
end
st << d['vm_info']['VM']["ID"]
if d['vm_info'].nil?
st << d['deploy_id'].to_s
else
st << d['vm_info']['VM']["ID"]
end
st
end
column :NAME, "Name of the Virtual Machine", :left,
:size=>23 do |d|
if d['vm_info']['VM']["RESCHED"] == "1"
"*#{d["NAME"]}"
if !d['vm_info'].nil?
if d['vm_info']['VM']["RESCHED"] == "1"
"*#{d["NAME"]}"
else
d['vm_info']['VM']["NAME"]
end
else
d['vm_info']['VM']["NAME"]
""
end
end
column :USER, "Username of the Virtual Machine owner", :left,
:size=>8 do |d|
d['vm_info']['VM']["UNAME"]
if !d['vm_info'].nil?
d['vm_info']['VM']["UNAME"]
else
""
end
end
column :GROUP, "Group of the Virtual Machine", :left,
:size=>8 do |d|
d['vm_info']['VM']["GNAME"]
if !d['vm_info'].nil?
d['vm_info']['VM']["GNAME"]
else
""
end
end
column :STAT, "Actual status", :size=>4 do |d,e|
OneVMHelper.state_to_str(d['vm_info']['VM']["STATE"], d['vm_info']['VM']["LCM_STATE"])
if !d['vm_info'].nil?
OneVMHelper.state_to_str(d['vm_info']['VM']["STATE"], d['vm_info']['VM']["LCM_STATE"])
else
""
end
end
column :UCPU, "CPU percentage used by the VM", :size=>4 do |d|
d['vm_info']['VM']["CPU"]
if !d['vm_info'].nil?
d['vm_info']['VM']["CPU"]
else
""
end
end
column :UMEM, "Memory used by the VM", :size=>7 do |d|
OpenNebulaHelper.unit_to_str(d['vm_info']['VM']["MEMORY"].to_i, {})
if !d['vm_info'].nil?
OpenNebulaHelper.unit_to_str(d['vm_info']['VM']["MEMORY"].to_i, {})
else
""
end
end
column :HOST, "Host where the VM is running", :left, :size=>20 do |d|
if d['vm_info']['VM']['HISTORY_RECORDS'] && d['vm_info']['VM']['HISTORY_RECORDS']['HISTORY']
state_str = VirtualMachine::VM_STATE[d['vm_info']['VM']['STATE'].to_i]
if %w{ACTIVE SUSPENDED}.include? state_str
history = if d['vm_info']['VM']['HISTORY_RECORDS']['HISTORY'].instance_of?(Array)
d['vm_info']['VM']['HISTORY_RECORDS']['HISTORY'].last
else
d['vm_info']['VM']['HISTORY_RECORDS']['HISTORY']
end
if !d['vm_info'].nil?
if d['vm_info']['VM']['HISTORY_RECORDS'] && d['vm_info']['VM']['HISTORY_RECORDS']['HISTORY']
state_str = VirtualMachine::VM_STATE[d['vm_info']['VM']['STATE'].to_i]
if %w{ACTIVE SUSPENDED}.include? state_str
history = if d['vm_info']['VM']['HISTORY_RECORDS']['HISTORY'].instance_of?(Array)
d['vm_info']['VM']['HISTORY_RECORDS']['HISTORY'].last
else
d['vm_info']['VM']['HISTORY_RECORDS']['HISTORY']
end
history['HOSTNAME']
history['HOSTNAME']
end
end
else
""
end
end
column :TIME, "Time since the VM was submitted", :size=>10 do |d|
stime = d['vm_info']['VM']["STIME"].to_i
etime = d['vm_info']['VM']["ETIME"]=="0" ? Time.now.to_i : d['vm_info']['VM']["ETIME"].to_i
dtime = etime-stime
OpenNebulaHelper.period_to_str(dtime, false)
if !d['vm_info'].nil?
stime = d['vm_info']['VM']["STIME"].to_i
etime = d['vm_info']['VM']["ETIME"]=="0" ? Time.now.to_i : d['vm_info']['VM']["ETIME"].to_i
dtime = etime-stime
OpenNebulaHelper.period_to_str(dtime, false)
else
""
end
end
default :VM_ID, :NAME, :STAT, :UCPU, :UMEM, :HOST, :TIME
+2 -2
View File
@@ -197,6 +197,8 @@ module OpenNebula
success = false
node['vm_info'] = nil
new_nodes << node
else
node['vm_info'] = vm.to_hash
@@ -256,8 +258,6 @@ module OpenNebula
'deploy_id' => vm_id,
}
# vm.info is not performed, this creates an empty VM xml
# containing only the ID
vm = OpenNebula::VirtualMachine.new_with_id(vm_id, @service.client)
rc = vm.info
if OpenNebula.is_error?(rc)
@@ -1610,17 +1610,25 @@ function updateServiceInfo(request,elem){
if (role.nodes) {
$.each(role.nodes, function(){
var vm_info = this.vm_info;
if (vm_info) {
var info = [];
if (this.scale_up) {
info.push("<i class='icon-arrow-up'/>");
} else if (this.disposed) {
info.push("<i class='icon-arrow-down'/>");
} else {
info.push("");
}
var info = [];
if (this.scale_up) {
info.push("<i class='icon-arrow-up'/>");
} else if (this.disposed) {
info.push("<i class='icon-arrow-down'/>");
} else {
info.push("");
}
if (vm_info) {
vms.push(info.concat(vMachineElementArray(vm_info)));
} else {
empty_arr = [
'<input class="check_item" type="checkbox" id="vm_'+this.deploy_id+'" name="selected_items" value="'+this.deploy_id+'"/>',
this.deploy_id,
'', '', '', '', '', '', '', '', '', '' ];
vms.push(info.concat(empty_arr));
}
});