1
0
mirror of https://github.com/OpenNebula/one.git synced 2024-12-22 13:33:52 +03:00

development: Homogenous VM_MAD/TM_MAD (vs VMMMAD/TMMAD) name. oned does

not store DS_LOCATION, single get_system_dir() function
This commit is contained in:
Ruben S. Montero 2016-04-10 22:39:21 +02:00
parent 01f1ff5bce
commit 3c389f3270
13 changed files with 61 additions and 89 deletions

View File

@ -277,7 +277,6 @@ public:
int cid,
const string& vmm,
const string& tmm,
const string& ds_location,
int ds_id,
const string& vm_info);
@ -324,7 +323,6 @@ private:
string vmm_mad_name;
string tm_mad_name;
string ds_location;
int ds_id;
time_t stime;
@ -357,7 +355,7 @@ private:
// Remote paths
string checkpoint_file;
string rdeployment_file;
string rsystem_dir;
string system_dir;
/**
* Writes the history record in the DB

View File

@ -499,32 +499,26 @@ public:
// ------------------------------------------------------------------------
/**
* Returns the remote VM directory. The VM remote dir is in the form:
* $DATASTORE_LOCATION/$SYSTEM_DS_ID/$VM_ID. The remote system_dir stores
* $DATASTORE_LOCATION/$SYSTEM_DS_ID/$VM_ID. The system_dir stores
* disks for a running VM in the target host.
* @return the remote system directory for the VM
*/
const string& get_remote_system_dir() const
const string& get_system_dir() const
{
return history->rsystem_dir;
return history->system_dir;
}
/**
* Returns the remote VM directory for the previous host.
* Returns the remote VM directory for the previous host. It maybe different
* if a system ds migration
* The hasPreviousHistory() function MUST be called before this one.
* @return the remote system directory for the VM
*/
const string & get_previous_remote_system_dir() const
const string & get_previous_system_dir() const
{
return previous_history->rsystem_dir;
return previous_history->system_dir;
};
/**
* Returns the local VM directory. The VM local dir is in the form:
* $SYSTEM_DS_BASE_PATH/$VM_ID. Temporary stores VM disks.
* @return the system directory for the VM
*/
string get_system_dir() const;
// ------------------------------------------------------------------------
// History
// ------------------------------------------------------------------------

View File

@ -20,9 +20,8 @@
<xs:element name="CID" type="xs:integer"/>
<xs:element name="STIME" type="xs:integer"/>
<xs:element name="ETIME" type="xs:integer"/>
<xs:element name="VMMMAD" type="xs:string"/>
<xs:element name="VNMMAD" type="xs:string"/>
<xs:element name="TMMAD" type="xs:string"/>
<xs:element name="VM_MAD" type="xs:string"/>
<xs:element name="TM_MAD" type="xs:string"/>
<xs:element name="DS_LOCATION" type="xs:string"/>
<xs:element name="DS_ID" type="xs:integer"/>
<xs:element name="PSTIME" type="xs:integer"/>

View File

@ -150,9 +150,8 @@
<xs:element name="CID" type="xs:integer"/>
<xs:element name="STIME" type="xs:integer"/>
<xs:element name="ETIME" type="xs:integer"/>
<xs:element name="VMMMAD" type="xs:string"/>
<xs:element name="VNMMAD" type="xs:string"/>
<xs:element name="TMMAD" type="xs:string"/>
<xs:element name="VM_MAD" type="xs:string"/>
<xs:element name="TM_MAD" type="xs:string"/>
<xs:element name="DS_LOCATION" type="xs:string"/>
<xs:element name="DS_ID" type="xs:integer"/>
<xs:element name="PSTIME" type="xs:integer"/>

View File

@ -602,7 +602,7 @@ define(function(require) {
function isNICGraphsSupported(element) {
var history = retrieveLastHistoryRecord(element)
if (history) {
return $.inArray(history.VMMMAD, ['vcenter', 'az', 'sl']) == -1;
return $.inArray(history.VM_MAD, ['vcenter', 'az', 'sl']) == -1;
} else {
return false;
}
@ -611,7 +611,7 @@ define(function(require) {
function isNICAttachSupported(element) {
var history = retrieveLastHistoryRecord(element)
if (history) {
return $.inArray(history.VMMMAD, ['ec2', 'az', 'sl']) == -1;
return $.inArray(history.VM_MAD, ['ec2', 'az', 'sl']) == -1;
} else {
return false;
}

View File

@ -457,7 +457,7 @@ int TransferManager::prolog_transfer_command(
<< vm_tm_mad << " "
<< size << " "
<< vm->get_hostname() << ":"
<< vm->get_remote_system_dir() << "/disk." << disk_id << " "
<< vm->get_system_dir() << "/disk." << disk_id << " "
<< vm->get_oid() << " "
<< vm->get_ds_id()
<< endl;
@ -488,7 +488,7 @@ int TransferManager::prolog_transfer_command(
<< size << " "
<< format << " "
<< vm->get_hostname() << ":"
<< vm->get_remote_system_dir() << "/disk." << disk_id << " "
<< vm->get_system_dir() << "/disk." << disk_id << " "
<< vm->get_oid() << " "
<< vm->get_ds_id()
<< endl;
@ -539,7 +539,7 @@ int TransferManager::prolog_transfer_command(
}
xfr << vm->get_hostname() << ":"
<< vm->get_remote_system_dir() << "/disk." << disk_id << " "
<< vm->get_system_dir() << "/disk." << disk_id << " "
<< vm->get_oid() << " "
<< ds_id
<< endl;
@ -591,7 +591,7 @@ static string prolog_os_transfer_commands(
transform(name.begin(), name.end(), name.begin(), (int(*)(int))tolower);
base_dst << vm->get_remote_system_dir() << "/" << name;
base_dst << vm->get_system_dir() << "/" << name;
xfr << "CLONE " << tm_mad << " "
<< opennebula_hostname << ":" << source << " "
@ -634,7 +634,7 @@ int TransferManager::prolog_context_command(
}
xfr << vm->get_hostname() << ":"
<< vm->get_remote_system_dir() << "/disk." << disk_id << " "
<< vm->get_system_dir() << "/disk." << disk_id << " "
<< vm->get_oid() << " "
<< vm->get_ds_id()
<< endl;
@ -901,9 +901,9 @@ void TransferManager::prolog_migr_action(int vid)
xfr << "MV "
<< tm_mad << " "
<< vm->get_previous_hostname() << ":"
<< vm->get_previous_remote_system_dir() << "/disk." << disk_id << " "
<< vm->get_previous_system_dir() << "/disk." << disk_id << " "
<< vm->get_hostname() << ":"
<< vm->get_remote_system_dir() << "/disk." << disk_id << " "
<< vm->get_system_dir() << "/disk." << disk_id << " "
<< vm->get_oid() << " "
<< ds_id << endl;
}
@ -912,9 +912,9 @@ void TransferManager::prolog_migr_action(int vid)
xfr << "MV "
<< vm_tm_mad << " "
<< vm->get_previous_hostname() << ":"
<< vm->get_previous_remote_system_dir() << " "
<< vm->get_previous_system_dir() << " "
<< vm->get_hostname() << ":"
<< vm->get_remote_system_dir() << " "
<< vm->get_system_dir() << " "
<< vm->get_oid() << " "
<< vm->get_ds_id() << endl;
@ -1052,7 +1052,7 @@ void TransferManager::prolog_resume_action(int vid)
<< nd.get_nebula_hostname() << ":"
<< vm->get_system_dir() << "/disk." << disk_id << " "
<< vm->get_hostname() << ":"
<< vm->get_remote_system_dir() << "/disk." << disk_id << " "
<< vm->get_system_dir() << "/disk." << disk_id << " "
<< vm->get_oid() << " "
<< ds_id << endl;
}
@ -1061,7 +1061,7 @@ void TransferManager::prolog_resume_action(int vid)
xfr << "MV "
<< vm_tm_mad << " "
<< nd.get_nebula_hostname() << ":"<< vm->get_system_dir() << " "
<< vm->get_hostname() << ":" << vm->get_remote_system_dir()<< " "
<< vm->get_hostname() << ":" << vm->get_system_dir()<< " "
<< vm->get_oid() << " "
<< vm->get_ds_id() << endl;
@ -1250,7 +1250,7 @@ void TransferManager::epilog_transfer_command(
xfr << "MVDS "
<< tm_mad << " "
<< vm->get_hostname() << ":"
<< vm->get_remote_system_dir() << "/disk." << disk_id << " "
<< vm->get_system_dir() << "/disk." << disk_id << " "
<< source << " "
<< vm->get_oid() << " "
<< ds_id
@ -1280,7 +1280,7 @@ void TransferManager::epilog_transfer_command(
xfr << "DELETE "
<< tm_mad << " "
<< vm->get_hostname() << ":"
<< vm->get_remote_system_dir() << "/disk." << disk_id << " "
<< vm->get_system_dir() << "/disk." << disk_id << " "
<< vm->get_oid() << " "
<< ds_id_i
<< endl;
@ -1351,7 +1351,7 @@ void TransferManager::epilog_action(int vid)
//DELETE vm_tm_mad hostname:remote_system_dir vmid ds_id
xfr << "DELETE "
<< vm_tm_mad << " "
<< vm->get_hostname() << ":" << vm->get_remote_system_dir() << " "
<< vm->get_hostname() << ":" << vm->get_system_dir() << " "
<< vm->get_oid() << " "
<< vm->get_ds_id() << endl;
@ -1468,7 +1468,7 @@ void TransferManager::epilog_stop_action(int vid)
xfr << "MV "
<< tm_mad << " "
<< vm->get_hostname() << ":"
<< vm->get_remote_system_dir() << "/disk." << disk_id << " "
<< vm->get_system_dir() << "/disk." << disk_id << " "
<< nd.get_nebula_hostname() << ":"
<< vm->get_system_dir() << "/disk." << disk_id << " "
<< vm->get_oid() << " "
@ -1478,7 +1478,7 @@ void TransferManager::epilog_stop_action(int vid)
//MV vm_tm_mad hostname:remote_system_dir fe:system_dir vmid dsid(system)
xfr << "MV "
<< vm_tm_mad << " "
<< vm->get_hostname() << ":" << vm->get_remote_system_dir() << " "
<< vm->get_hostname() << ":" << vm->get_system_dir() << " "
<< nd.get_nebula_hostname() << ":" << vm->get_system_dir() << " "
<< vm->get_oid() << " "
<< vm->get_ds_id() << endl;
@ -1563,7 +1563,7 @@ int TransferManager::epilog_delete_commands(VirtualMachine *vm,
}
host = vm->get_previous_hostname();
system_dir = vm->get_previous_remote_system_dir();
system_dir = vm->get_previous_system_dir();
vm_tm_mad = vm->get_previous_tm_mad();
vm_ds_id = vm->get_previous_ds_id();
@ -1571,7 +1571,7 @@ int TransferManager::epilog_delete_commands(VirtualMachine *vm,
else
{
host = vm->get_hostname();
system_dir = vm->get_remote_system_dir();
system_dir = vm->get_system_dir();
vm_tm_mad = vm->get_tm_mad();
vm_ds_id = vm->get_ds_id();
@ -2068,7 +2068,7 @@ void TransferManager::saveas_hot_action(int vid)
xfr << "CPDS "
<< tm_mad << " "
<< vm->get_hostname() << ":"
<< vm->get_remote_system_dir() << "/disk." << disk_id << " "
<< vm->get_system_dir() << "/disk." << disk_id << " "
<< src << " "
<< snap_id << " "
<< vm->get_oid() << " "
@ -2122,7 +2122,7 @@ void TransferManager::migrate_transfer_command(
<< vm->get_tm_mad() << " "
<< vm->get_previous_hostname() << " "
<< vm->get_hostname() << " "
<< vm->get_remote_system_dir() << " "
<< vm->get_system_dir() << " "
<< vm->get_oid() << " "
<< vm->get_ds_id()
<< endl;
@ -2150,7 +2150,7 @@ int TransferManager::snapshot_transfer_command(
xfr << snap_action << " "
<< tm_mad << " "
<< vm->get_hostname() << ":"
<< vm->get_remote_system_dir() << "/disk." << disk_id << " "
<< vm->get_system_dir() << "/disk." << disk_id << " "
<< snap_id << " "
<< vm->get_oid() << " "
<< ds_id

View File

@ -45,7 +45,6 @@ History::History(
cid(-1),
vmm_mad_name(""),
tm_mad_name(""),
ds_location(""),
ds_id(0),
stime(0),
etime(0),
@ -69,7 +68,6 @@ History::History(
int _cid,
const string& _vmm,
const string& _tmm,
const string& _ds_location,
int _ds_id,
const string& _vm_info):
oid(_oid),
@ -79,7 +77,6 @@ History::History(
cid(_cid),
vmm_mad_name(_vmm),
tm_mad_name(_tmm),
ds_location(_ds_location),
ds_id(_ds_id),
stime(0),
etime(0),
@ -104,9 +101,12 @@ void History::non_persistent_data()
ostringstream os;
string vm_lhome;
string ds_location;
Nebula& nd = Nebula::instance();
nd.get_ds_location(ds_location);
// ----------- Local Locations ------------
os.str("");
os << nd.get_vms_location() << oid;
@ -133,18 +133,16 @@ void History::non_persistent_data()
token_file = os.str();
// ----------- Remote Locations ------------
os.str("");
os << ds_location << "/" << ds_id << "/" << oid;
rsystem_dir = os.str();
system_dir = os.str();
os << "/checkpoint";
checkpoint_file = os.str();
os.str("");
os << rsystem_dir << "/deployment." << seq;
os << system_dir << "/deployment." << seq;
rdeployment_file = os.str();
}
@ -304,9 +302,8 @@ string& History::to_xml(string& xml, bool database) const
"<CID>" << cid << "</CID>" <<
"<STIME>" << stime << "</STIME>" <<
"<ETIME>" << etime << "</ETIME>" <<
"<VMMMAD>" << one_util::escape_xml(vmm_mad_name)<<"</VMMMAD>"<<
"<TMMAD>" << one_util::escape_xml(tm_mad_name) <<"</TMMAD>" <<
"<DS_LOCATION>"<< one_util::escape_xml(ds_location) <<"</DS_LOCATION>"<<
"<VM_MAD>" << one_util::escape_xml(vmm_mad_name)<<"</VM_MAD>"<<
"<TM_MAD>" << one_util::escape_xml(tm_mad_name) <<"</TM_MAD>" <<
"<DS_ID>" << ds_id << "</DS_ID>" <<
"<PSTIME>" << prolog_stime << "</PSTIME>"<<
"<PETIME>" << prolog_etime << "</PETIME>"<<
@ -344,9 +341,8 @@ int History::rebuild_attributes()
rc += xpath(cid , "/HISTORY/CID", -1);
rc += xpath<time_t>(stime , "/HISTORY/STIME", 0);
rc += xpath<time_t>(etime , "/HISTORY/ETIME", 0);
rc += xpath(vmm_mad_name , "/HISTORY/VMMMAD", "not_found");
rc += xpath(tm_mad_name , "/HISTORY/TMMAD", "not_found");
rc += xpath(ds_location , "/HISTORY/DS_LOCATION", "not_found");
rc += xpath(vmm_mad_name , "/HISTORY/VM_MAD", "not_found");
rc += xpath(tm_mad_name , "/HISTORY/TM_MAD", "not_found");
rc += xpath(ds_id , "/HISTORY/DS_ID", 0);
rc += xpath<time_t>(prolog_stime , "/HISTORY/PSTIME", 0);
rc += xpath<time_t>(prolog_etime , "/HISTORY/PETIME", 0);

View File

@ -1679,8 +1679,8 @@ void VirtualMachine::add_history(
to_xml_extended(vm_xml, 0);
history = new History(oid, seq, hid, hostname, cid, vmm_mad, tm_mad,
ds_location, ds_id, vm_xml);
history = new History(oid, seq, hid, hostname, cid, vmm_mad, tm_mad, ds_id,
vm_xml);
history_records.push_back(history);
};
@ -1707,7 +1707,6 @@ void VirtualMachine::cp_history()
history->cid,
history->vmm_mad_name,
history->tm_mad_name,
history->ds_location,
history->ds_id,
vm_xml);
@ -1739,7 +1738,6 @@ void VirtualMachine::cp_previous_history()
previous_history->cid,
previous_history->vmm_mad_name,
previous_history->tm_mad_name,
previous_history->ds_location,
previous_history->ds_id,
vm_xml);
@ -3908,18 +3906,6 @@ int VirtualMachine::from_xml(const string &xml_str)
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
string VirtualMachine::get_system_dir() const
{
ostringstream oss;
oss << history->ds_location << "/" << history->ds_id << "/"<< oid;
return oss.str();
};
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
int VirtualMachine::update_info(const string& monitor_data)
{
int rc;

View File

@ -514,7 +514,7 @@ int LibVirtDriver::deployment_description_kvm(
{
ostringstream dev;
dev << vm->get_remote_system_dir() << "/disk." << disk_id;
dev << vm->get_system_dir() << "/disk." << disk_id;
file << "\t\t<disk type='block' device='disk'>\n"
<< "\t\t\t<source dev=" << one_util::escape_xml_attr(dev.str())
@ -657,7 +657,7 @@ int LibVirtDriver::deployment_description_kvm(
{
ostringstream cd_name;
cd_name << vm->get_remote_system_dir() << "/disk." << disk_id;
cd_name << vm->get_system_dir() << "/disk." << disk_id;
file << "\t\t<disk type='file' device='cdrom'>\n"
<< "\t\t\t<source file="
@ -667,7 +667,7 @@ int LibVirtDriver::deployment_description_kvm(
{
ostringstream fname;
fname << vm->get_remote_system_dir() << "/disk." << disk_id;
fname << vm->get_system_dir() << "/disk." << disk_id;
file << "\t\t<disk type='file' device='disk'>\n"
<< "\t\t\t<source file="
@ -805,7 +805,7 @@ int LibVirtDriver::deployment_description_kvm(
{
ostringstream fname;
fname << vm->get_remote_system_dir() << "/disk." << disk_id;
fname << vm->get_system_dir() << "/disk." << disk_id;
file << "\t\t<disk type='file' device='cdrom'>\n"
<< "\t\t\t<source file="
@ -1145,7 +1145,7 @@ int LibVirtDriver::deployment_description_kvm(
// ------------------------------------------------------------------------
file << "\t<metadata>\n"
<< "\t\t<system_datastore>"
<< one_util::escape_xml(vm->get_remote_system_dir())
<< one_util::escape_xml(vm->get_system_dir())
<< "\t\t</system_datastore>\n"
// << "\t\t<opennebula>\n" << vm->to_xml(vm_xml) << "\t\t</opennebula>\n"
<< "\t</metadata>\n";

View File

@ -482,7 +482,7 @@ static int do_context_command(VirtualMachine * vm, const string& password,
os.str("");
os << vm->get_remote_system_dir() << "/disk." << disk_id;
os << vm->get_system_dir() << "/disk." << disk_id;
disk_path = os.str();
} //else rc == 0 VM has no context
@ -1773,7 +1773,7 @@ void VirtualMachineManager::attach_action(
disk->vector_value("DISK_ID", disk_id);
os << vm->get_remote_system_dir() << "/disk." << disk_id;
os << vm->get_system_dir() << "/disk." << disk_id;
disk_path = os.str();
@ -1893,7 +1893,7 @@ void VirtualMachineManager::detach_action(
epilog_cmd = os.str();
os.str("");
os << vm->get_remote_system_dir() << "/disk." << disk_id;
os << vm->get_system_dir() << "/disk." << disk_id;
disk_path = os.str();
@ -2240,7 +2240,7 @@ void VirtualMachineManager::disk_snapshot_create_action(int vid)
goto error_no_tm_command;
}
os << vm->get_remote_system_dir() << "/disk." << disk_id;
os << vm->get_system_dir() << "/disk." << disk_id;
disk_path = os.str();

View File

@ -346,7 +346,7 @@ int XenDriver::deployment_description(
}
}
file << vm->get_remote_system_dir() << "/disk." << disk_id << ","
file << vm->get_system_dir() << "/disk." << disk_id << ","
<< target;
if ( type == "CDROM" )
@ -387,7 +387,7 @@ int XenDriver::deployment_description(
file << default_driver;
}
file << vm->get_remote_system_dir() << "/disk." << disk_id
file << vm->get_system_dir() << "/disk." << disk_id
<< "," << target << "," << "r'," << endl;
}
else

View File

@ -142,7 +142,7 @@ class VmmAction
ID DEPLOY_ID
TEMPLATE/SECURITY_GROUP_RULE
HISTORY_RECORDS/HISTORY/HOSTNAME
HISTORY_RECORDS/HISTORY/VMMMAD
HISTORY_RECORDS/HISTORY/VM_MAD
)
DRIVER_NAMES = {
@ -979,7 +979,7 @@ class ExecDriver < VirtualMachineDriver
action = ACTION[:disk_snapshot_create]
# Check that live snapshot is supported
vmm_driver_path = 'VM/HISTORY_RECORDS/HISTORY/VMMMAD'
vmm_driver_path = 'VM/HISTORY_RECORDS/HISTORY/VM_MAD'
tm_driver_path = "VM/TEMPLATE/DISK[DISK_SNAPSHOT_ACTIVE='YES']/TM_MAD"
vmm_driver = ensure_xpath(xml_data, id, action, vmm_driver_path)||return

View File

@ -75,10 +75,10 @@ module VNMNetwork
nil
end
# Gets the Hypervisor VMMMAD from the Template
# Gets the Hypervisor VM_MAD from the Template
# @return [String] name of the hypervisor driver
def hypervisor
xpath = 'HISTORY_RECORDS/HISTORY/VMMMAD'
xpath = 'HISTORY_RECORDS/HISTORY/VM_MAD'
@vm_root.root.elements[xpath].text
end