mirror of
https://github.com/OpenNebula/one.git
synced 2025-01-11 05:17:41 +03:00
F #3859: IMPORT_VM_ID = DEPLOY_ID = UUID
This commit is contained in:
parent
29db1c2c5c
commit
33b22ad1ba
@ -902,6 +902,7 @@ VM_RESTRICTED_ATTR = "DISK/VCENTER_INSTANCE_ID"
|
||||
#VM_RESTRICTED_ATTR = "DISK/SIZE"
|
||||
VM_RESTRICTED_ATTR = "DISK/ORIGINAL_SIZE"
|
||||
VM_RESTRICTED_ATTR = "DISK/SIZE_PREV"
|
||||
VM_RESTRICTED_ATTR = "DEPLOY_ID"
|
||||
VM_RESTRICTED_ATTR = "CPU_COST"
|
||||
VM_RESTRICTED_ATTR = "MEMORY_COST"
|
||||
VM_RESTRICTED_ATTR = "DISK_COST"
|
||||
|
@ -664,7 +664,7 @@ class OneHostHelper < OpenNebulaHelper::OneHelper
|
||||
.split("\n")
|
||||
name = wild['VM_NAME']
|
||||
import = wild_tmplt.select do |line|
|
||||
line[/IMPORT_VM_ID/]
|
||||
line[/DEPLOY_ID/]
|
||||
end[0].split('=')[1].tr('"', ' ').strip
|
||||
memory = wild_tmplt.select do |line|
|
||||
line[/MEMORY/]
|
||||
|
@ -183,7 +183,7 @@ int Host::update_info(Template &tmpl)
|
||||
|
||||
obj_template->get("TOTALCPU", total_cpu);
|
||||
obj_template->get("TOTALMEMORY", total_mem);
|
||||
|
||||
|
||||
if (host_share.get_total_cpu() == total_cpu &&
|
||||
host_share.get_total_mem() == total_mem)
|
||||
{
|
||||
@ -275,7 +275,7 @@ void Host::update_wilds()
|
||||
{
|
||||
VirtualMachinePool * vmpool = Nebula::instance().get_vmpool();
|
||||
|
||||
vmid = vmpool->get_vmid(vatt->vector_value("UUID"));
|
||||
vmid = vmpool->get_vmid(vatt->vector_value("DEPLOY_ID"));
|
||||
}
|
||||
|
||||
if (vmid == -1)
|
||||
@ -290,7 +290,7 @@ void Host::update_wilds()
|
||||
|
||||
if (wname.empty())
|
||||
{
|
||||
wname = vatt->vector_value("UUID");
|
||||
wname = vatt->vector_value("DEPLOY_ID");
|
||||
}
|
||||
|
||||
wild << wname;
|
||||
|
@ -198,7 +198,7 @@ void InformationManager::_undefined(unique_ptr<Message<OpenNebulaMessages>> msg)
|
||||
|
||||
void InformationManager::_host_state(unique_ptr<Message<OpenNebulaMessages>> msg)
|
||||
{
|
||||
NebulaLog::debug("InM", "HOST_STATE update from host: " +
|
||||
NebulaLog::ddebug("InM", "HOST_STATE update from host: " +
|
||||
to_string(msg->oid()) + ". Host information: " + msg->payload());
|
||||
|
||||
|
||||
@ -250,7 +250,7 @@ void InformationManager::_host_state(unique_ptr<Message<OpenNebulaMessages>> msg
|
||||
|
||||
void InformationManager::_host_system(unique_ptr<Message<OpenNebulaMessages>> msg)
|
||||
{
|
||||
NebulaLog::debug("InM", "HOST_SYSTEM update from host: " +
|
||||
NebulaLog::ddebug("InM", "HOST_SYSTEM update from host: " +
|
||||
to_string(msg->oid()) + ". Host information: " + msg->payload());
|
||||
|
||||
char * error_msg;
|
||||
@ -388,7 +388,6 @@ void InformationManager::_vm_state(unique_ptr<Message<OpenNebulaMessages>> msg)
|
||||
int id;
|
||||
|
||||
string deploy_id;
|
||||
string uuid;
|
||||
string state_str;
|
||||
string vm_msg;
|
||||
|
||||
@ -405,13 +404,12 @@ void InformationManager::_vm_state(unique_ptr<Message<OpenNebulaMessages>> msg)
|
||||
}
|
||||
|
||||
vm_tmpl->vector_value("DEPLOY_ID", deploy_id);
|
||||
vm_tmpl->vector_value("UUID", uuid);
|
||||
vm_tmpl->vector_value("STATE", state_str);
|
||||
|
||||
if (id < 0)
|
||||
{
|
||||
// Check wild VMs
|
||||
id = vmpool->get_vmid(uuid);
|
||||
id = vmpool->get_vmid(deploy_id);
|
||||
|
||||
if (id < 0)
|
||||
{
|
||||
|
@ -235,6 +235,7 @@ end
|
||||
# @vm[:name]
|
||||
# @vm[:id] from one-<id>
|
||||
# @vm[:uuid] (deployment id)
|
||||
# @vm[:deploy_id] (deployment id)
|
||||
# @vm[:fc_state] Firecracker state
|
||||
# @vm[:state] OpenNebula state
|
||||
# @vm[:netrx]
|
||||
@ -266,6 +267,8 @@ class Domain
|
||||
@vm[:name] = @name
|
||||
@vm[:uuid] = hash['id']
|
||||
|
||||
@vm[:deploy_id] = hash['id']
|
||||
|
||||
m = @vm[:name].match(/^one-(\d*)$/)
|
||||
|
||||
if m
|
||||
@ -433,7 +436,7 @@ module DomainList
|
||||
mon_s = ''
|
||||
|
||||
@vms.each do |_uuid, vm|
|
||||
mon_s << "VM = [ ID=\"#{vm[:id]}\", UUID=\"#{vm[:uuid]}\","
|
||||
mon_s << "VM = [ ID=\"#{vm[:id]}\", DEPLOY_ID=\"#{vm[:deploy_id]}\","
|
||||
mon_s << " MONITOR=\"#{vm.to_monitor}\"]\n"
|
||||
end
|
||||
|
||||
|
@ -181,6 +181,7 @@ end
|
||||
# @vm[:name]
|
||||
# @vm[:id] from one-<id>, -1 if wild
|
||||
# @vm[:uuid]
|
||||
# @vm[:deploy_id]
|
||||
# @vm[:kvm_state] KVM-qemu state
|
||||
# @vm[:reason] reason for state transition
|
||||
# @vm[:state] OpenNebula state
|
||||
@ -220,6 +221,8 @@ class Domain
|
||||
@vm[:name] = hash['NAME']
|
||||
@vm[:uuid] = hash['UUID']
|
||||
|
||||
@vm[:deploy_id] = hash['UUID']
|
||||
|
||||
m = @vm[:name].match(/^one-(\d*)$/)
|
||||
|
||||
if m
|
||||
@ -317,7 +320,7 @@ class Domain
|
||||
tmpl << "VCPU=#{vcpu}\n"
|
||||
tmpl << "MEMORY=#{mem}\n"
|
||||
tmpl << "HYPERVISOR=\"kvm\"\n"
|
||||
tmpl << "IMPORT_VM_ID=\"#{uuid}\"\n"
|
||||
tmpl << "DEPLOY_ID=\"#{uuid}\"\n"
|
||||
tmpl << "OS=[ARCH=\"#{arch}\"]\n"
|
||||
tmpl << features_txt << "\n" unless features_txt.empty?
|
||||
tmpl << spice_txt << "\n" unless spice_txt.empty?
|
||||
@ -516,7 +519,7 @@ module DomainList
|
||||
mon_s = ''
|
||||
|
||||
@vms.each do |_uuid, vm|
|
||||
mon_s << "VM = [ ID=\"#{vm[:id]}\", UUID=\"#{vm[:uuid]}\","
|
||||
mon_s << "VM = [ ID=\"#{vm[:id]}\", DEPLOY_ID=\"#{vm[:deploy_id]}\","
|
||||
mon_s << " MONITOR=\"#{vm.to_monitor}\"]\n"
|
||||
end
|
||||
|
||||
@ -530,7 +533,7 @@ module DomainList
|
||||
@vms.each do |_uuid, vm|
|
||||
next if vm[:id] != -1 || vm[:template].empty?
|
||||
|
||||
mon_s << "VM = [ID=\"#{vm[:id]}\", UUID=\"#{vm[:uuid]}\","
|
||||
mon_s << "VM = [ID=\"#{vm[:id]}\", DEPLOY_ID=\"#{vm[:deploy_id]}\","
|
||||
mon_s << " VM_NAME=\"#{vm.name}\","
|
||||
mon_s << " IMPORT_TEMPLATE=\"#{vm[:template]}\"]\n"
|
||||
end
|
||||
|
@ -138,8 +138,8 @@ module LXD
|
||||
CPU = #{cpu}
|
||||
VCPU = #{vcpu}
|
||||
MEMORY = #{mem}
|
||||
HYPERVISOR = "lxd"
|
||||
IMPORT_VM_ID = "#{@deploy_id}"
|
||||
HYPERVISOR = "lxd"
|
||||
DEPLOY_ID = "#{@deploy_id}"
|
||||
OS = [ ARCH="#{arch}" ]
|
||||
EOT
|
||||
|
||||
@ -149,7 +149,7 @@ module LXD
|
||||
private
|
||||
|
||||
def template_string_header
|
||||
"VM = [ ID=#{@id}, UUID=#{@uuid}, "
|
||||
"VM = [ ID=#{@id}, DEPLOY_ID=#{@deploy_id}, "
|
||||
end
|
||||
|
||||
def parse_memory(memory)
|
||||
|
@ -61,6 +61,7 @@ class VirtualMachineDB
|
||||
uuid
|
||||
id
|
||||
name
|
||||
deploy_id
|
||||
timestamp
|
||||
missing
|
||||
state
|
||||
@ -126,10 +127,11 @@ class VirtualMachineDB
|
||||
|
||||
if vm_db.nil?
|
||||
@db.execute(
|
||||
"INSERT INTO #{@dataset} VALUES (?, ?, ?, ?, ?, ?, ?)",
|
||||
"INSERT INTO #{@dataset} VALUES (?, ?, ?, ?, ?, ?, ?, ?)",
|
||||
[uuid,
|
||||
vm[:id].to_i,
|
||||
vm[:name],
|
||||
vm[:deploy_id],
|
||||
time,
|
||||
0,
|
||||
vm[:state],
|
||||
@ -140,13 +142,14 @@ class VirtualMachineDB
|
||||
next
|
||||
end
|
||||
|
||||
# Updates timestamp and uuid (e.g. VM recreated in KVM)
|
||||
# Updates timestamp and uuid/deploy_id (e.g. VM recreated in KVM)
|
||||
@db.execute(
|
||||
"UPDATE #{@dataset} SET " \
|
||||
"state = '#{vm[:state]}', " \
|
||||
"missing = 0, " \
|
||||
"timestamp = #{time}, " \
|
||||
"uuid = '#{uuid}' " \
|
||||
"uuid = '#{uuid}', " \
|
||||
"deploy_id = '#{vm[:deploy_id]}' "\
|
||||
"#{filter}"
|
||||
)
|
||||
|
||||
@ -192,7 +195,7 @@ class VirtualMachineDB
|
||||
#
|
||||
def bootstrap
|
||||
sql = 'CREATE TABLE IF NOT EXISTS states(uuid VARCHAR(128) PRIMARY KEY,'
|
||||
sql << ' id INTEGER, name VARCHAR(128), timestamp INTEGER,'
|
||||
sql << ' id INTEGER, name VARCHAR(128), deploy_id VARCHAR(128), timestamp INTEGER,'
|
||||
sql << ' missing INTEGER, state VARCHAR(128), hyperv VARCHAR(128))'
|
||||
|
||||
@db.execute(sql)
|
||||
@ -209,10 +212,11 @@ class VirtualMachineDB
|
||||
|
||||
DomainList.state_info(host, host_id).each do |uuid, vm|
|
||||
@db.execute(
|
||||
"INSERT INTO #{@dataset} VALUES (?, ?, ?, ?, ?, ?, ?)",
|
||||
"INSERT INTO #{@dataset} VALUES (?, ?, ?, ?, ?, ?, ?, ?)",
|
||||
[uuid,
|
||||
vm[:id].to_i,
|
||||
vm[:name],
|
||||
vm[:deploy_id],
|
||||
time,
|
||||
0,
|
||||
vm[:state],
|
||||
@ -226,18 +230,17 @@ class VirtualMachineDB
|
||||
end
|
||||
|
||||
def vm_to_status(vm, state = vm[:state])
|
||||
"VM = [ ID=\"#{vm[:id]}\", DEPLOY_ID=\"#{vm[:name]}\", " \
|
||||
" UUID=\"#{vm[:uuid]}\", STATE=\"#{state}\" ]\n"
|
||||
"VM = [ ID=\"#{vm[:id]}\", DEPLOY_ID=\"#{vm[:deploy_id]}\", " \
|
||||
" STATE=\"#{state}\" ]\n"
|
||||
end
|
||||
|
||||
def vm_db_to_status(vm, state = vm[col_name_to_idx('state')])
|
||||
id = col_name_to_idx('id')
|
||||
name = col_name_to_idx('name')
|
||||
uuid = col_name_to_idx('uuid')
|
||||
id = col_name_to_idx('id')
|
||||
deploy_id = col_name_to_idx('deploy_id')
|
||||
|
||||
|
||||
"VM = [ ID=\"#{vm[id]}\", DEPLOY_ID=\"#{vm[name]}\", " \
|
||||
" UUID=\"#{vm[uuid]}\", STATE=\"#{state}\" ]\n"
|
||||
"VM = [ ID=\"#{vm[id]}\", DEPLOY_ID=\"#{vm[deploy_id]}\", " \
|
||||
" STATE=\"#{state}\" ]\n"
|
||||
end
|
||||
|
||||
# Load configuration file and parse user provided options
|
||||
|
@ -40,6 +40,8 @@ module DomainList
|
||||
vm[:uuid] = "#{name}-#{Socket.gethostname}"
|
||||
vm[:state] = one_status(container)
|
||||
|
||||
vm[:deploy_id] = name
|
||||
|
||||
m = vm[:name].match(/^one-(\d*)$/)
|
||||
|
||||
if m
|
||||
|
@ -179,7 +179,7 @@ module PublicCloudDriver
|
||||
"PUBLIC_CLOUD = [\n"\
|
||||
" TYPE =\"#{@hypervisor}\"\n"\
|
||||
"]\n"\
|
||||
"IMPORT_VM_ID = \"#{vm[:uuid]}\"\n"\
|
||||
"DEPLOY_ID = \"#{vm[:uuid]}\"\n"\
|
||||
"SCHED_REQUIREMENTS = \"NAME=\\\"#{@host}\\\"\"\n"\
|
||||
"DESCRIPTION = \"Imported from #{@hypervisor} "\
|
||||
"from #{vm[:name]}\"\n"
|
||||
|
@ -239,7 +239,8 @@ module OpenNebula
|
||||
vi_client = VCenterDriver::VIClient.new_from_host(self["ID"])
|
||||
importer = VCenterDriver::VmmImporter.new(@client, vi_client)
|
||||
|
||||
return importer.import({wild: wild, template: template, one_item: vm, host: self['ID']})
|
||||
return importer.import({wild: wild, template: template,
|
||||
one_item: vm, host: self['ID']})
|
||||
else
|
||||
rc = vm.allocate(template)
|
||||
|
||||
|
@ -998,8 +998,8 @@ int VirtualMachine::insert(SqlDB * db, string& error_str)
|
||||
// -------------------------------------------------------------------------
|
||||
// Get and set DEPLOY_ID for imported VMs
|
||||
// -------------------------------------------------------------------------
|
||||
user_obj_template->get("IMPORT_VM_ID", value);
|
||||
user_obj_template->erase("IMPORT_VM_ID");
|
||||
user_obj_template->get("DEPLOY_ID", value);
|
||||
user_obj_template->erase("DEPLOY_ID");
|
||||
|
||||
if (!value.empty())
|
||||
{
|
||||
@ -1012,14 +1012,7 @@ int VirtualMachine::insert(SqlDB * db, string& error_str)
|
||||
else
|
||||
{
|
||||
obj_template->add("IMPORTED", "YES");
|
||||
|
||||
user_obj_template->get("DEPLOY_ID", deploy_id);
|
||||
user_obj_template->erase("DEPLOY_ID");
|
||||
|
||||
if (deploy_id.empty())
|
||||
{
|
||||
deploy_id = value;
|
||||
}
|
||||
deploy_id = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -159,7 +159,7 @@ int VirtualMachinePool::allocate(
|
||||
|
||||
vm->prev_state = vm->state;
|
||||
|
||||
vm->user_obj_template->get("IMPORT_VM_ID", deploy_id);
|
||||
vm->user_obj_template->get("DEPLOY_ID", deploy_id);
|
||||
|
||||
if (!deploy_id.empty())
|
||||
{
|
||||
|
@ -345,6 +345,7 @@ class AzureDriver
|
||||
vm = { :uuid => i.vm_id,
|
||||
:id => one_id || -1,
|
||||
:name => i.name,
|
||||
:deploy_id => i.vm_id,
|
||||
:type => i.hardware_profile.vm_size,
|
||||
:state => vm_state(i) }
|
||||
|
||||
@ -796,11 +797,12 @@ module DomainList
|
||||
|
||||
info = {}
|
||||
vms.each do |vm|
|
||||
info[vm[:uuid]] = { :id => vm[:id],
|
||||
:uuid => vm[:uuid],
|
||||
:name => vm[:name],
|
||||
:state => vm[:state],
|
||||
:hyperv => 'az' }
|
||||
info[vm[:uuid]] = { :id => vm[:id],
|
||||
:uuid => vm[:uuid],
|
||||
:deploy_id => vm[:deploy_id],
|
||||
:name => vm[:name],
|
||||
:state => vm[:state],
|
||||
:hyperv => 'az' }
|
||||
end
|
||||
|
||||
info
|
||||
|
@ -750,6 +750,7 @@ class EC2Driver
|
||||
vm = { :uuid => i.instance_id,
|
||||
:id => one_id || -1,
|
||||
:name => i.instance_id,
|
||||
:deploy_id => i.instance_id,
|
||||
:type => i.instance_type,
|
||||
:state => vm_state }
|
||||
|
||||
@ -1030,11 +1031,12 @@ module DomainList
|
||||
|
||||
info = {}
|
||||
vms.each do |vm|
|
||||
info[vm[:uuid]] = { :id => vm[:id],
|
||||
:uuid => vm[:uuid],
|
||||
:name => vm[:name],
|
||||
:state => vm[:state],
|
||||
:hyperv => 'ec2' }
|
||||
info[vm[:uuid]] = { :id => vm[:id],
|
||||
:uuid => vm[:uuid],
|
||||
:name => vm[:name],
|
||||
:state => vm[:state],
|
||||
:deploy_id => vm[:deploy_id],
|
||||
:hyperv => 'ec2' }
|
||||
end
|
||||
|
||||
info
|
||||
|
@ -204,6 +204,7 @@ class One2OneDriver
|
||||
|
||||
vm = { :id => id,
|
||||
:uuid => deploy_id,
|
||||
:deploy_id => deploy_id,
|
||||
:name => remote_vm.name,
|
||||
:state => vm_state(remote_vm),
|
||||
:type => "#{cpu}cpu/#{memory}memory" }
|
||||
@ -588,11 +589,12 @@ module DomainList
|
||||
|
||||
info = {}
|
||||
vms.each do |vm|
|
||||
info[vm[:uuid]] = { :id => vm[:id],
|
||||
:uuid => vm[:uuid],
|
||||
:name => vm[:name],
|
||||
:state => vm[:state],
|
||||
:hyperv => 'opennebula' }
|
||||
info[vm[:uuid]] = { :id => vm[:id],
|
||||
:uuid => vm[:uuid],
|
||||
:deploy_id => vm[:deploy_id],
|
||||
:name => vm[:name],
|
||||
:state => vm[:state],
|
||||
:hyperv => 'opennebula' }
|
||||
end
|
||||
|
||||
info
|
||||
|
Loading…
Reference in New Issue
Block a user