diff --git a/include/History.h b/include/History.h index a9f0590ae7..ea7fe12345 100644 --- a/include/History.h +++ b/include/History.h @@ -276,7 +276,6 @@ public: const string& hostname, int cid, const string& vmm, - const string& vnm, const string& tmm, const string& ds_location, int ds_id, @@ -323,7 +322,6 @@ private: int cid; string vmm_mad_name; - string vnm_mad_name; string tm_mad_name; string ds_location; diff --git a/include/Host.h b/include/Host.h index 754acfe07b..797dc4d575 100644 --- a/include/Host.h +++ b/include/Host.h @@ -215,15 +215,6 @@ public: return vmm_mad_name; }; - /** - * Retrieves VNM mad name - * @return string vnm mad name - */ - const string& get_vnm_mad() const - { - return vnm_mad_name; - }; - /** * Retrieves IM mad name * @return string im mad name @@ -535,11 +526,6 @@ private: */ string vmm_mad_name; - /** - * Name of the VN driver used to manage networking in this host - */ - string vnm_mad_name; - /** * If Host State = MONITORED last time it got fully monitored or 1 Jan 1970 * Host State = MONITORING* last time it got a signal to be monitored @@ -590,7 +576,6 @@ private: const string& hostname, const string& im_mad_name, const string& vmm_mad_name, - const string& vnm_mad_name, int cluster_id, const string& cluster_name); diff --git a/include/HostPool.h b/include/HostPool.h index 973a8acbb6..c8616eb7e1 100644 --- a/include/HostPool.h +++ b/include/HostPool.h @@ -51,7 +51,6 @@ public: const string& hostname, const string& im_mad_name, const string& vmm_mad_name, - const string& vnm_mad_name, int cluster_id, const string& cluster_name, string& error_str); @@ -273,7 +272,7 @@ private: */ PoolObjectSQL * create() { - return new Host(-1,"","","","",-1,""); + return new Host(-1,"","","",-1,""); }; /** diff --git a/include/LibVirtDriver.h b/include/LibVirtDriver.h index 3b480dd59f..4b31aac621 100644 --- a/include/LibVirtDriver.h +++ b/include/LibVirtDriver.h @@ -27,54 +27,35 @@ class LibVirtDriver : public VirtualMachineManagerDriver { public: - LibVirtDriver( - int userid, - const map &attrs, - bool sudo, - VirtualMachinePool * pool, - const string _emulator): - VirtualMachineManagerDriver(userid, attrs,sudo,pool), - emulator(_emulator) + LibVirtDriver(int userid, const map &attrs, bool sudo, + VirtualMachinePool * pool, const string& emu) + :VirtualMachineManagerDriver(userid, attrs,sudo,pool), emulator(emu) {}; ~LibVirtDriver(){}; private: - static const char * vmware_vnm_name; + static const float CGROUP_BASE_CPU_SHARES; - static const float CGROUP_BASE_CPU_SHARES; + static const int CEPH_DEFAULT_PORT; - static const int CEPH_DEFAULT_PORT; + static const int GLUSTER_DEFAULT_PORT; - static const int GLUSTER_DEFAULT_PORT; + static const int ISCSI_DEFAULT_PORT; - static const int ISCSI_DEFAULT_PORT; - - int deployment_description( - const VirtualMachine * vm, - const string& file_name) const + int deployment_description(const VirtualMachine * vm, const string& fn) const { int rc = -1; if (emulator == "kvm" || emulator == "qemu" ) { - rc = deployment_description_kvm(vm,file_name); - } - else if (emulator == "vmware") - { - rc = deployment_description_vmware(vm,file_name); + rc = deployment_description_kvm(vm, fn); } return rc; } - int deployment_description_kvm( - const VirtualMachine * vm, - const string& file_name) const; - - int deployment_description_vmware( - const VirtualMachine * vm, - const string& file_name) const; + int deployment_description_kvm(const VirtualMachine * v, const string& f) const; const string emulator; }; diff --git a/include/RequestManagerVirtualMachine.h b/include/RequestManagerVirtualMachine.h index f9c35fda30..f5fdc2a1bc 100644 --- a/include/RequestManagerVirtualMachine.h +++ b/include/RequestManagerVirtualMachine.h @@ -71,7 +71,6 @@ protected: int hid, string& name, string& vmm, - string& vnm, int& cluster_id, string& ds_location, bool& is_public_cloud, @@ -101,7 +100,6 @@ protected: int cid, const string& hostname, const string& vmm_mad, - const string& vnm_mad, const string& tm_mad, const string& ds_location, int ds_id, diff --git a/include/VirtualMachine.h b/include/VirtualMachine.h index 3f6317c8bf..94865a9953 100644 --- a/include/VirtualMachine.h +++ b/include/VirtualMachine.h @@ -536,7 +536,6 @@ public: int cid, const string& hostname, const string& vmm_mad, - const string& vnm_mad, const string& tm_mad, const string& ds_location, int ds_id); @@ -595,26 +594,6 @@ public: return previous_history->vmm_mad_name; }; - /** - * Returns the VNM driver name for the current host. The hasHistory() - * function MUST be called before this one. - * @return the VNM mad name - */ - const string & get_vnm_mad() const - { - return history->vnm_mad_name; - }; - - /** - * Returns the VNM driver name for the previous host. The hasPreviousHistory() - * function MUST be called before this one. - * @return the VNM mad name - */ - const string & get_previous_vnm_mad() const - { - return previous_history->vnm_mad_name; - }; - /** * Returns the datastore ID of the system DS for the host. The hasHistory() * function MUST be called before this one. diff --git a/include/VirtualMachineManager.h b/include/VirtualMachineManager.h index 645f865f54..cbbc2055be 100644 --- a/include/VirtualMachineManager.h +++ b/include/VirtualMachineManager.h @@ -229,9 +229,7 @@ private: * Function to format a VMM Driver message in the form: * * hostname - * net_drv * m_hostname - * m_net_drv * domain_id * dfile * cfile @@ -244,9 +242,7 @@ private: * * * @param hostname of the host to perform the action - * @param net_drv name of the vlan driver * @param m_hostname name of the host to migrate the VM - * @param m_net_drv name of the vlan driver * @param domain domain id as returned by the hypervisor * @param dfile deployment file to boot the VM * @param cfile checkpoint file to save the VM @@ -260,9 +256,7 @@ private: */ string * format_message( const string& hostname, - const string& net_drv, const string& m_hostname, - const string& m_net_drv, const string& domain, const string& ldfile, const string& rdfile, diff --git a/include/VirtualNetworkPool.h b/include/VirtualNetworkPool.h index 4ab339820c..991725b3df 100644 --- a/include/VirtualNetworkPool.h +++ b/include/VirtualNetworkPool.h @@ -34,11 +34,15 @@ class VirtualNetworkPool : public PoolSQL { public: - VirtualNetworkPool(SqlDB * db, const string& str_mac_prefix, int default_size, - vector& restricted_attrs, - vector& hook_mads, const string& remotes_location, - const vector& _inherit_attrs, - const VectorAttribute * vlan_conf, const VectorAttribute * vxlan_conf); + VirtualNetworkPool(SqlDB * db, + const string& str_mac_prefix, + int default_size, + vector& restricted_attrs, + vector& hook_mads, + const string& remotes_location, + const vector& _inherit_attrs, + const VectorAttribute * vlan_conf, + const VectorAttribute * vxlan_conf); ~VirtualNetworkPool(){}; diff --git a/src/host/Host.cc b/src/host/Host.cc index a21cada33c..03b55af1d8 100644 --- a/src/host/Host.cc +++ b/src/host/Host.cc @@ -32,7 +32,6 @@ Host::Host( const string& _hostname, const string& _im_mad_name, const string& _vmm_mad_name, - const string& _vnm_mad_name, int _cluster_id, const string& _cluster_name): PoolObjectSQL(id,HOST,_hostname,-1,-1,"","",table), @@ -40,21 +39,16 @@ Host::Host( state(INIT), im_mad_name(_im_mad_name), vmm_mad_name(_vmm_mad_name), - vnm_mad_name(_vnm_mad_name), last_monitored(0), vm_collection("VMS") { - string default_cpu; //TODO - Get these two from oned.conf - string default_mem; - obj_template = new HostTemplate; - add_template_attribute("RESERVED_CPU", default_cpu); - add_template_attribute("RESERVED_MEM", default_cpu); + add_template_attribute("RESERVED_CPU", ""); + add_template_attribute("RESERVED_MEM", ""); replace_template_attribute("IM_MAD", im_mad_name); replace_template_attribute("VM_MAD", vmm_mad_name); - replace_template_attribute("VN_MAD", vnm_mad_name); } Host::~Host() @@ -594,7 +588,6 @@ string& Host::to_xml(string& xml) const "" << state << "" << "" << one_util::escape_xml(im_mad_name) << "" << "" << one_util::escape_xml(vmm_mad_name) << "" << - "" << one_util::escape_xml(vnm_mad_name) << "" << "" << last_monitored << "" << "" << cluster_id << "" << "" << cluster << "" << @@ -628,7 +621,6 @@ int Host::from_xml(const string& xml) rc += xpath(im_mad_name, "/HOST/IM_MAD", "not_found"); rc += xpath(vmm_mad_name, "/HOST/VM_MAD", "not_found"); - rc += xpath(vnm_mad_name, "/HOST/VN_MAD", "not_found"); rc += xpath(last_monitored, "/HOST/LAST_MON_TIME", 0); @@ -688,7 +680,6 @@ int Host::post_update_template(string& error) string vcenter_password; string new_im_mad; string new_vm_mad; - string new_vn_mad; get_template_attribute("VCENTER_PASSWORD", vcenter_password); @@ -718,7 +709,6 @@ int Host::post_update_template(string& error) get_template_attribute("IM_MAD", new_im_mad); get_template_attribute("VM_MAD", new_vm_mad); - get_template_attribute("VN_MAD", new_vn_mad); if (new_im_mad != ""){ im_mad_name = new_im_mad; @@ -728,13 +718,8 @@ int Host::post_update_template(string& error) vmm_mad_name = new_vm_mad; } - if (new_im_mad != ""){ - vnm_mad_name = new_vn_mad; - } - replace_template_attribute("IM_MAD", im_mad_name); replace_template_attribute("VM_MAD", vmm_mad_name); - replace_template_attribute("VN_MAD", vnm_mad_name); return 0; }; diff --git a/src/host/HostPool.cc b/src/host/HostPool.cc index c42c4a494f..cd010efcd6 100644 --- a/src/host/HostPool.cc +++ b/src/host/HostPool.cc @@ -150,7 +150,6 @@ int HostPool::allocate ( const string& hostname, const string& im_mad_name, const string& vmm_mad_name, - const string& vnm_mad_name, int cluster_id, const string& cluster_name, string& error_str) @@ -173,11 +172,6 @@ int HostPool::allocate ( goto error_vmm; } - if ( vnm_mad_name.empty() ) - { - goto error_vnm; - } - host = get(hostname,false); if ( host !=0) @@ -192,7 +186,6 @@ int HostPool::allocate ( hostname, im_mad_name, vmm_mad_name, - vnm_mad_name, cluster_id, cluster_name); @@ -210,10 +203,6 @@ error_vmm: error_str = "VMM_MAD_NAME cannot be empty."; goto error_common; -error_vnm: - error_str = "VNM_MAD_NAME cannot be empty."; - goto error_common; - error_duplicated: oss << "NAME is already taken by HOST " << host->get_oid() << "."; error_str = oss.str(); diff --git a/src/rm/RequestManagerAllocate.cc b/src/rm/RequestManagerAllocate.cc index d7acc328ad..3bbb1dd66f 100644 --- a/src/rm/RequestManagerAllocate.cc +++ b/src/rm/RequestManagerAllocate.cc @@ -631,12 +631,11 @@ int HostAllocate::pool_allocate( string host = xmlrpc_c::value_string(paramList.getString(1)); string im_mad = xmlrpc_c::value_string(paramList.getString(2)); string vmm_mad = xmlrpc_c::value_string(paramList.getString(3)); - string vnm_mad = xmlrpc_c::value_string(paramList.getString(4)); HostPool * hpool = static_cast(pool); - return hpool->allocate(&id, host, im_mad, vmm_mad, vnm_mad, - cluster_id, cluster_name, att.resp_msg); + return hpool->allocate(&id, host, im_mad, vmm_mad, cluster_id, cluster_name, + att.resp_msg); } /* -------------------------------------------------------------------------- */ diff --git a/src/rm/RequestManagerVirtualMachine.cc b/src/rm/RequestManagerVirtualMachine.cc index e864c371f0..6d1df2e939 100644 --- a/src/rm/RequestManagerVirtualMachine.cc +++ b/src/rm/RequestManagerVirtualMachine.cc @@ -321,7 +321,6 @@ int RequestManagerVirtualMachine::get_host_information( int hid, string& name, string& vmm, - string& vnm, int& cluster_id, string& ds_location, bool& is_public_cloud, @@ -345,7 +344,6 @@ int RequestManagerVirtualMachine::get_host_information( name = host->get_name(); vmm = host->get_vmm_mad(); - vnm = host->get_vnm_mad(); cluster_id = host->get_cluster_id(); @@ -439,7 +437,6 @@ int RequestManagerVirtualMachine::add_history(VirtualMachine * vm, int cid, const string& hostname, const string& vmm_mad, - const string& vnm_mad, const string& tm_mad, const string& ds_location, int ds_id, @@ -449,8 +446,7 @@ int RequestManagerVirtualMachine::add_history(VirtualMachine * vm, VirtualMachinePool * vmpool = static_cast(pool); - vm->add_history(hid, cid, hostname, vmm_mad, vnm_mad, tm_mad, ds_location, - ds_id); + vm->add_history(hid, cid, hostname, vmm_mad, tm_mad, ds_location, ds_id); if ( vmpool->update_history(vm) != 0 ) { @@ -786,7 +782,6 @@ void VirtualMachineDeploy::request_execute(xmlrpc_c::paramList const& paramList, string hostname; string vmm_mad; - string vnm_mad; int cluster_id; string ds_location; bool is_public_cloud; @@ -820,7 +815,6 @@ void VirtualMachineDeploy::request_execute(xmlrpc_c::paramList const& paramList, if (get_host_information(hid, hostname, vmm_mad, - vnm_mad, cluster_id, ds_location, is_public_cloud, @@ -967,7 +961,6 @@ void VirtualMachineDeploy::request_execute(xmlrpc_c::paramList const& paramList, cluster_id, hostname, vmm_mad, - vnm_mad, tm_mad, ds_location, ds_id, @@ -1023,7 +1016,6 @@ void VirtualMachineMigrate::request_execute(xmlrpc_c::paramList const& paramList string hostname; string vmm_mad; - string vnm_mad; int cluster_id; set ds_cluster_ids; string ds_location; @@ -1066,7 +1058,6 @@ void VirtualMachineMigrate::request_execute(xmlrpc_c::paramList const& paramList if (get_host_information(hid, hostname, vmm_mad, - vnm_mad, cluster_id, ds_location, is_public_cloud, @@ -1306,7 +1297,6 @@ void VirtualMachineMigrate::request_execute(xmlrpc_c::paramList const& paramList cluster_id, hostname, vmm_mad, - vnm_mad, tm_mad, ds_location, ds_id, diff --git a/src/vm/History.cc b/src/vm/History.cc index 3654d5b479..6bfa6d3240 100644 --- a/src/vm/History.cc +++ b/src/vm/History.cc @@ -44,7 +44,6 @@ History::History( hostname(""), cid(-1), vmm_mad_name(""), - vnm_mad_name(""), tm_mad_name(""), ds_location(""), ds_id(0), @@ -69,7 +68,6 @@ History::History( const string& _hostname, int _cid, const string& _vmm, - const string& _vnm, const string& _tmm, const string& _ds_location, int _ds_id, @@ -80,7 +78,6 @@ History::History( hostname(_hostname), cid(_cid), vmm_mad_name(_vmm), - vnm_mad_name(_vnm), tm_mad_name(_tmm), ds_location(_ds_location), ds_id(_ds_id), @@ -300,26 +297,25 @@ string& History::to_xml(string& xml, bool database) const oss << "" << - "" << oid << "" << - "" << seq << "" << - "" << hostname << ""<< - "" << hid << "" << - "" << cid << "" << - "" << stime << "" << - "" << etime << "" << - "" << one_util::escape_xml(vmm_mad_name) << ""<< - "" << one_util::escape_xml(vnm_mad_name) << ""<< - "" << one_util::escape_xml(tm_mad_name) << "" << - "" << one_util::escape_xml(ds_location) << "" << - "" << ds_id << "" << - "" << prolog_stime << ""<< - "" << prolog_etime << ""<< - "" << running_stime << ""<< - "" << running_etime << ""<< - "" << epilog_stime << ""<< - "" << epilog_etime << ""<< - "" << reason << ""<< - "" << action << ""; + "" << oid << "" << + "" << seq << "" << + "" << hostname << ""<< + "" << hid << "" << + "" << cid << "" << + "" << stime << "" << + "" << etime << "" << + "" << one_util::escape_xml(vmm_mad_name)<<""<< + "" << one_util::escape_xml(tm_mad_name) <<"" << + ""<< one_util::escape_xml(ds_location) <<""<< + "" << ds_id << "" << + "" << prolog_stime << ""<< + "" << prolog_etime << ""<< + "" << running_stime << ""<< + "" << running_etime << ""<< + "" << epilog_stime << ""<< + "" << epilog_etime << ""<< + "" << reason << ""<< + "" << action << ""; if ( database ) { @@ -349,7 +345,6 @@ int History::rebuild_attributes() rc += xpath(stime , "/HISTORY/STIME", 0); rc += xpath(etime , "/HISTORY/ETIME", 0); rc += xpath(vmm_mad_name , "/HISTORY/VMMMAD", "not_found"); - xpath(vnm_mad_name , "/HISTORY/VNMMAD", "dummy"); rc += xpath(tm_mad_name , "/HISTORY/TMMAD", "not_found"); rc += xpath(ds_location , "/HISTORY/DS_LOCATION", "not_found"); rc += xpath(ds_id , "/HISTORY/DS_ID", 0); diff --git a/src/vm/VirtualMachine.cc b/src/vm/VirtualMachine.cc index c43f43f2f3..e1b8ddb92d 100644 --- a/src/vm/VirtualMachine.cc +++ b/src/vm/VirtualMachine.cc @@ -1650,7 +1650,6 @@ void VirtualMachine::add_history( int cid, const string& hostname, const string& vmm_mad, - const string& vnm_mad, const string& tm_mad, const string& ds_location, int ds_id) @@ -1672,17 +1671,8 @@ void VirtualMachine::add_history( to_xml_extended(vm_xml, 0); - history = new History(oid, - seq, - hid, - hostname, - cid, - vmm_mad, - vnm_mad, - tm_mad, - ds_location, - ds_id, - vm_xml); + history = new History(oid, seq, hid, hostname, cid, vmm_mad, tm_mad, + ds_location, ds_id, vm_xml); history_records.push_back(history); }; @@ -1708,7 +1698,6 @@ void VirtualMachine::cp_history() history->hostname, history->cid, history->vmm_mad_name, - history->vnm_mad_name, history->tm_mad_name, history->ds_location, history->ds_id, @@ -1741,7 +1730,6 @@ void VirtualMachine::cp_previous_history() previous_history->hostname, previous_history->cid, previous_history->vmm_mad_name, - previous_history->vnm_mad_name, previous_history->tm_mad_name, previous_history->ds_location, previous_history->ds_id, diff --git a/src/vmm/LibVirtDriverKVM.cc b/src/vmm/LibVirtDriverKVM.cc index 3f892278e9..32a74bbc39 100644 --- a/src/vmm/LibVirtDriverKVM.cc +++ b/src/vmm/LibVirtDriverKVM.cc @@ -161,24 +161,24 @@ int LibVirtDriver::deployment_description_kvm( vector nic; - string mac = ""; - string bridge = ""; - string bridge_ovs = ""; - string script = ""; - string model = ""; - string ip = ""; - string filter = ""; + string mac = ""; + string bridge = ""; + string vn_mad = ""; + string script = ""; + string model = ""; + string ip = ""; + string filter = ""; string default_filter = ""; string default_model = ""; const VectorAttribute * graphics; - string listen = ""; - string port = ""; - string passwd = ""; - string keymap = ""; - string spice_options = ""; + string listen = ""; + string port = ""; + string passwd = ""; + string keymap = ""; + string spice_options = ""; const VectorAttribute * input; @@ -834,14 +834,14 @@ int LibVirtDriver::deployment_description_kvm( for(int i=0; ivector_value("BRIDGE"); - bridge_ovs = nic[i]->vector_value("BRIDGE_OVS"); - mac = nic[i]->vector_value("MAC"); - target = nic[i]->vector_value("TARGET"); - script = nic[i]->vector_value("SCRIPT"); - model = nic[i]->vector_value("MODEL"); - ip = nic[i]->vector_value("IP"); - filter = nic[i]->vector_value("FILTER"); + bridge = nic[i]->vector_value("BRIDGE"); + vn_mad = nic[i]->vector_value("VN_MAD"); + mac = nic[i]->vector_value("MAC"); + target = nic[i]->vector_value("TARGET"); + script = nic[i]->vector_value("SCRIPT"); + model = nic[i]->vector_value("MODEL"); + ip = nic[i]->vector_value("IP"); + filter = nic[i]->vector_value("FILTER"); if ( bridge.empty() ) { @@ -851,21 +851,14 @@ int LibVirtDriver::deployment_description_kvm( { file << "\t\t" << endl; - string * the_bridge = &bridge; - if ( vm->get_vnm_mad() == "ovswitch" ) + if (VirtualNetwork::str_to_driver(vn_mad) == VirtualNetwork::OVSWITCH) { - - if ( !bridge_ovs.empty() ) - { - the_bridge = &bridge_ovs; - } - file << "\t\t\t" << endl; } file << "\t\t\t\n"; + << one_util::escape_xml_attr(bridge) << "/>\n"; } if( !mac.empty() ) diff --git a/src/vmm/LibVirtDriverVMware.cc b/src/vmm/LibVirtDriverVMware.cc deleted file mode 100644 index 21ebdb70ec..0000000000 --- a/src/vmm/LibVirtDriverVMware.cc +++ /dev/null @@ -1,494 +0,0 @@ -/* -------------------------------------------------------------------------- */ -/* Copyright 2002-2015, OpenNebula Project, OpenNebula Systems */ -/* */ -/* Licensed under the Apache License, Version 2.0 (the "License"); you may */ -/* not use this file except in compliance with the License. You may obtain */ -/* a copy of the License at */ -/* */ -/* http://www.apache.org/licenses/LICENSE-2.0 */ -/* */ -/* Unless required by applicable law or agreed to in writing, software */ -/* distributed under the License is distributed on an "AS IS" BASIS, */ -/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ -/* See the License for the specific language governing permissions and */ -/* limitations under the License. */ -/* -------------------------------------------------------------------------- */ - -#include "LibVirtDriver.h" - -#include "Nebula.h" -#include -#include -#include - -/* ************************************************************************** */ -/* LibVirtDriver :: VMware deployment generator */ -/* ************************************************************************** */ - -const char * LibVirtDriver::vmware_vnm_name = "vmware"; - -int LibVirtDriver::deployment_description_vmware( - const VirtualMachine * vm, - const string& file_name) const -{ - ofstream file; - - int num; - - string vcpu; - string memory; - - int memory_in_kb = 0; - - const VectorAttribute * os; - - string arch = ""; - string guestOS = ""; - string pciBridge = ""; - string boot = ""; - - vector boots; - - const VectorAttribute * features; - - vector disk; - const VectorAttribute * context; - - string type = ""; - string target = ""; - string ro = ""; - string source = ""; - string driver = ""; - int disk_id; - string default_driver = ""; - bool readonly; - - vector nic; - - string network_id = ""; - string mac = ""; - string bridge = ""; - string script = ""; - string model = ""; - - string default_model = ""; - - const VectorAttribute * graphics; - - string listen = ""; - string port = ""; - string passwd = ""; - string keymap = ""; - - vector raw; - string data; - string default_raw; - string data_vmx = ""; - - ostringstream metadata; - - // ------------------------------------------------------------------------ - - file.open(file_name.c_str(), ios::out); - - if (file.fail() == true) - { - goto error_vmware_file; - } - - // ------------------------------------------------------------------------ - // Starting XML document - // ------------------------------------------------------------------------ - - file << "" << endl; - - // ------------------------------------------------------------------------ - // Domain name - // ------------------------------------------------------------------------ - - file << "\tone-" << vm->get_oid() << "" << endl; - - // ------------------------------------------------------------------------ - // CPU - // ------------------------------------------------------------------------ - - vm->get_template_attribute("VCPU", vcpu); - - if(vcpu.empty()) - { - get_default("VCPU", vcpu); - } - - if (!vcpu.empty()) - { - file << "\t" << vcpu << "" << endl; - } - - // ------------------------------------------------------------------------ - // Memory - // ------------------------------------------------------------------------ - - vm->get_template_attribute("MEMORY",memory); - - if (!memory.empty()) - { - memory_in_kb = atoi(memory.c_str()) * 1024; - - file << "\t" << memory_in_kb << "" << endl; - } - else - { - goto error_vmware_memory; - } - - // ------------------------------------------------------------------------ - // OS and boot options - // ------------------------------------------------------------------------ - os = vm->get_template_attribute("OS"); - - if( os != 0 ) - { - arch = os->vector_value("ARCH"); - guestOS = os->vector_value("GUESTOS"); - boot = os->vector_value("BOOT"); - } - - if ( arch.empty() ) - { - get_default("OS","ARCH",arch); - - if (arch.empty()) - { - goto error_vmware_arch; - } - } - - if ( !guestOS.empty() ) - { - metadata << "" << guestOS << "" << endl; - } - - if ( boot.empty() ) - { - get_default("OS","BOOT",boot); - } - - // Start writing to the file with the info we got - - file << "\t" << endl; - - file << "\t\thvm" << endl; - - if (!boot.empty()) - { - boots = one_util::split(boot, ','); - - for (vector::const_iterator it=boots.begin(); it!=boots.end(); it++) - { - file << "\t\t" << endl; - } - } - - file << "\t" << endl; - - // ------------------------------------------------------------------------ - // Features - // ------------------------------------------------------------------------ - features = vm->get_template_attribute("FEATURES"); - - if ( features != 0 ) - { - pciBridge = features->vector_value("PCIBRIDGE"); - - if (!pciBridge.empty()) - { - metadata << "" << pciBridge << ""; - } - } - - // ------------------------------------------------------------------------ - // Disks - // ------------------------------------------------------------------------ - - file << "\t" << endl; - - get_default("DISK","DRIVER",default_driver); - - num = vm->get_template_attribute("DISK", disk); - - for (int i=0; i < num ;i++) - { - type = disk[i]->vector_value("TYPE"); - target = disk[i]->vector_value("TARGET"); - ro = disk[i]->vector_value("READONLY"); - source = disk[i]->vector_value("SOURCE"); - driver = disk[i]->vector_value("DRIVER"); - disk[i]->vector_value_str("DISK_ID", disk_id); - - if (target.empty()) - { - goto error_vmware_disk; - } - - readonly = false; - - if ( !ro.empty() ) - { - one_util::toupper(ro); - - if ( ro == "YES" ) - { - readonly = true; - } - } - - one_util::toupper(type); - - // ---- Disk type and source for the image ---- - - if ( type == "BLOCK" ) - { - file << "\t\t" << endl; - file << "\t\t\t" << endl; - } - else if ( type == "CDROM" ) - { - file << "\t\t" << endl; - file << "\t\t\t" << endl; - } - else - { - file << "\t\t" << endl - << "\t\t\t" << endl; - } - - // ---- target device to map the disk ---- - - file << "\t\t\t" << endl; - - // ---- Image Format using qemu driver ---- - - if ( !driver.empty() ) - { - file << "\t\t\t" << endl; - } - else - { - if (!default_driver.empty()) - { - file << "\t\t\t" << endl; - } - } - - // ---- readonly attribute for the disk ---- - - if (readonly) - { - file << "\t\t\t" << endl; - } - - file << "\t\t" << endl; - } - - // ------------------------------------------------------------------------ - // Context Device - // ------------------------------------------------------------------------ - context = vm->get_template_attribute("CONTEXT"); - - if ( context != 0 ) - { - target = context->vector_value("TARGET"); - - context->vector_value_str("DISK_ID", disk_id); - - if ( !target.empty() ) - { - file << "\t\t" << endl; - file << "\t\t\t" << endl; - file << "\t\t\t" << endl; - file << "\t\t\t" << endl; - file << "\t\t" << endl; - } - else - { - vm->log("VMM", Log::WARNING, "Could not find target device to" - " attach context, will continue without it."); - } - } - - // ------------------------------------------------------------------------ - // Network interfaces - // ------------------------------------------------------------------------ - get_default("NIC", "MODEL", default_model); - - num = vm->get_template_attribute("NIC", nic); - - for(int i=0; ivector_value("NETWORK_ID"); - mac = nic[i]->vector_value("MAC"); - target = nic[i]->vector_value("TARGET"); - script = nic[i]->vector_value("SCRIPT"); - model = nic[i]->vector_value("MODEL"); - - if (vm->get_vnm_mad() == LibVirtDriver::vmware_vnm_name) - { - bridge = "one-pg-"; - bridge.append(network_id); - } - else - { - bridge = nic[i]->vector_value("BRIDGE"); - } - - file << "\t\t" << endl; - file << "\t\t\t" << endl; - - if( !mac.empty() ) - { - file << "\t\t\t" << endl; - } - - if( !target.empty() ) - { - file << "\t\t\t" << endl; - } - - if( !script.empty() ) - { - file << "\t\t\t