1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-16 22:50:10 +03:00

Revert "F #3859: Use DEPLOY_ID for wilds (#4726)"

This reverts commit fb96648fec1289abeb3c6481c1f8f66597a0bc32.
This commit is contained in:
Ruben S. Montero 2020-05-14 14:57:09 +02:00
parent 476ac338a0
commit 152d82647d
No known key found for this signature in database
GPG Key ID: A0CEA6FA880A1D87
10 changed files with 37 additions and 24 deletions

View File

@ -664,7 +664,7 @@ class OneHostHelper < OpenNebulaHelper::OneHelper
.split("\n")
name = wild['VM_NAME']
import = wild_tmplt.select do |line|
line[/DEPLOY_ID/]
line[/IMPORT_VM_ID/]
end[0].split('=')[1].tr('"', ' ').strip
memory = wild_tmplt.select do |line|
line[/MEMORY/]

View File

@ -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("DEPLOY_ID"));
vmid = vmpool->get_vmid(vatt->vector_value("UUID"));
}
if (vmid == -1)
@ -290,7 +290,7 @@ void Host::update_wilds()
if (wname.empty())
{
wname = vatt->vector_value("DEPLOY_ID");
wname = vatt->vector_value("UUID");
}
wild << wname;

View File

@ -198,7 +198,7 @@ void InformationManager::_undefined(unique_ptr<Message<OpenNebulaMessages>> msg)
void InformationManager::_host_state(unique_ptr<Message<OpenNebulaMessages>> msg)
{
NebulaLog::ddebug("InM", "HOST_STATE update from host: " +
NebulaLog::debug("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::ddebug("InM", "HOST_SYSTEM update from host: " +
NebulaLog::debug("InM", "HOST_SYSTEM update from host: " +
to_string(msg->oid()) + ". Host information: " + msg->payload());
char * error_msg;
@ -388,6 +388,7 @@ void InformationManager::_vm_state(unique_ptr<Message<OpenNebulaMessages>> msg)
int id;
string deploy_id;
string uuid;
string state_str;
string vm_msg;
@ -404,12 +405,13 @@ 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(deploy_id);
id = vmpool->get_vmid(uuid);
if (id < 0)
{

View File

@ -317,7 +317,7 @@ class Domain
tmpl << "VCPU=#{vcpu}\n"
tmpl << "MEMORY=#{mem}\n"
tmpl << "HYPERVISOR=\"kvm\"\n"
tmpl << "DEPLOY_ID=\"#{name}\"\n"
tmpl << "IMPORT_VM_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 +516,7 @@ module DomainList
mon_s = ''
@vms.each do |_uuid, vm|
mon_s << "VM = [ ID=\"#{vm[:id]}\", DEPLOY_ID=\"#{vm[:name]}\","
mon_s << "VM = [ ID=\"#{vm[:id]}\", UUID=\"#{vm[:uuid]}\","
mon_s << " MONITOR=\"#{vm.to_monitor}\"]\n"
end
@ -530,7 +530,7 @@ module DomainList
@vms.each do |_uuid, vm|
next if vm[:id] != -1 || vm[:template].empty?
mon_s << "VM = [ID=\"#{vm[:id]}\", DEPLOY_ID=\"#{vm[:name]}\","
mon_s << "VM = [ID=\"#{vm[:id]}\", UUID=\"#{vm[:uuid]}\","
mon_s << " VM_NAME=\"#{vm.name}\","
mon_s << " IMPORT_TEMPLATE=\"#{vm[:template]}\"]\n"
end

View File

@ -36,6 +36,7 @@ module LXD
@container = container
@deploy_id = @container.name
@uuid = "#{@deploy_id}-#{Socket.gethostname}"
if @deploy_id =~ /^one-\d+/
@wild = false
@ -138,7 +139,7 @@ module LXD
VCPU = #{vcpu}
MEMORY = #{mem}
HYPERVISOR = "lxd"
DEPLOY_ID = "#{@deploy_id}"
IMPORT_VM_ID = "#{@deploy_id}"
OS = [ ARCH="#{arch}" ]
EOT
@ -148,7 +149,7 @@ module LXD
private
def template_string_header
"VM = [ ID=#{@id}, DEPLOY_ID=#{@deploy_id}, "
"VM = [ ID=#{@id}, UUID=#{@uuid}, "
end
def parse_memory(memory)

View File

@ -227,15 +227,17 @@ class VirtualMachineDB
def vm_to_status(vm, state = vm[:state])
"VM = [ ID=\"#{vm[:id]}\", DEPLOY_ID=\"#{vm[:name]}\", " \
" STATE=\"#{state}\" ]\n"
" UUID=\"#{vm[:uuid]}\", 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')
"VM = [ ID=\"#{vm[id]}\", DEPLOY_ID=\"#{vm[name]}\", " \
" STATE=\"#{state}\" ]\n"
" UUID=\"#{vm[uuid]}\", STATE=\"#{state}\" ]\n"
end
# Load configuration file and parse user provided options

View File

@ -307,13 +307,13 @@ void HostMonitorManager::update_last_monitor(int oid)
/* -------------------------------------------------------------------------- */
void HostMonitorManager::monitor_vm(int oid,
const string& deploy_id,
const string& uuid,
const Template &tmpl)
{
if (oid < 0)
{
// Wild VM, check if it is imported to OpenNebula
oid = vmpool->get_vmid(deploy_id);
oid = vmpool->get_vmid(uuid);
if (oid < 0)
{

View File

@ -64,7 +64,7 @@ void MonitorDriverProtocol::_monitor_vm(message_t msg)
{
int id = -1;
string monitor_b64;
string deploy_id;
string uuid;
if (vm->vector_value("ID", id) != 0)
{
@ -72,7 +72,7 @@ void MonitorDriverProtocol::_monitor_vm(message_t msg)
}
vm->vector_value("MONITOR", monitor_b64);
vm->vector_value("DEPLOY_ID", deploy_id);
vm->vector_value("UUID", uuid);
auto monitor_plain = one_util::base64_decode(monitor_b64);
@ -95,11 +95,11 @@ void MonitorDriverProtocol::_monitor_vm(message_t msg)
delete monitor_plain;
auto it = vms_templ.find(deploy_id);
auto it = vms_templ.find(uuid);
if (it == vms_templ.end())
{
vms_templ.insert(make_pair(std::move(deploy_id),
vms_templ.insert(make_pair(std::move(uuid),
make_pair(id, std::move(mon_tmpl))));
}
else

View File

@ -998,20 +998,28 @@ int VirtualMachine::insert(SqlDB * db, string& error_str)
// -------------------------------------------------------------------------
// Get and set DEPLOY_ID for imported VMs
// -------------------------------------------------------------------------
user_obj_template->get("DEPLOY_ID", deploy_id);
user_obj_template->erase("DEPLOY_ID");
user_obj_template->get("IMPORT_VM_ID", value);
user_obj_template->erase("IMPORT_VM_ID");
if (!value.empty())
{
const char * one_vms = "^one-[[:digit:]]+$";
if (one_util::regex_match(one_vms, deploy_id.c_str()) == 0)
if (one_util::regex_match(one_vms, value.c_str()) == 0)
{
goto error_one_vms;
}
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;
}
}
}

View File

@ -159,7 +159,7 @@ int VirtualMachinePool::allocate(
vm->prev_state = vm->state;
vm->user_obj_template->get("DEPLOY_ID", deploy_id);
vm->user_obj_template->get("IMPORT_VM_ID", deploy_id);
if (!deploy_id.empty())
{