diff --git a/src/vmm/LibVirtDriverKVM.cc b/src/vmm/LibVirtDriverKVM.cc index 820d27cdf6..65b2ff9aae 100644 --- a/src/vmm/LibVirtDriverKVM.cc +++ b/src/vmm/LibVirtDriverKVM.cc @@ -24,6 +24,56 @@ const float LibVirtDriver::CGROUP_BASE_CPU_SHARES = 1024; +/** + * This function generates the element for network disks + */ +static void do_network_hosts(ofstream& file, + const string& cg_host, + const string& transport) +{ + if (cg_host.empty()) + { + file << "'/>" << endl; + return; + } + + vector::const_iterator it; + vector hosts; + + hosts = one_util::split(cg_host, ' '); + + file << "'>" << endl; + + for (it = hosts.begin(); it != hosts.end(); it++) + { + vector parts = one_util::split(*it, ':'); + + if (parts.empty()) + { + continue; + } + + file << "\t\t\t\t" << endl; + } + + file << "\t\t\t" << endl; +} + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + int LibVirtDriver::deployment_description_kvm( const VirtualMachine * vm, const string& file_name) const @@ -365,21 +415,9 @@ int LibVirtDriver::deployment_description_kvm( << "\t\t\t" << endl; } - else if ( type == "RBD" || type == "RBD_CDROM" || - type == "GLUSTER" || type == "GLUSTER_CDROM" ) + else if ( type == "RBD" || type == "RBD_CDROM" ) { - string protocol = ""; - - if ( type == "RBD" || type == "RBD_CDROM" ) - { - protocol = "rbd"; - } - else - { - protocol = "gluster"; - } - - if ( type == "RBD" || type == "GLUSTER" ) + if (type == "RBD") { file << "\t\t" << endl; } @@ -388,95 +426,47 @@ int LibVirtDriver::deployment_description_kvm( file << "\t\t" << endl; } - file << "\t\t\tget_oid() << "-" << disk_id; } - if ( ceph_host.empty() && gluster_host.empty() ) + do_network_hosts(file, ceph_host, ""); + + if ( !ceph_secret.empty() && !ceph_user.empty()) { - file << "'/>" << endl; + file << "\t\t\t" << endl + << "\t\t\t\t" << endl + << "\t\t\t" << endl; + } + } + else if ( type == "GLUSTER" || type == "GLUSTER_CDROM" ) + { + if ( type == "GLUSTER" ) + { + file << "\t\t" << endl; } else { - vector::const_iterator it; - vector hosts; - - if ( protocol == "rbd" ) - { - hosts = one_util::split(ceph_host, ' '); - } - else - { - hosts = one_util::split(gluster_host, ' '); - } - - file << "'>" << endl; - - for (it = hosts.begin(); it != hosts.end(); it++) - { - vector parts = one_util::split(*it, ':'); - - if (parts.empty()) - { - continue; - } - - file << "\t\t\t\t" << endl; - } - - file << "\t\t\t" << endl; + file << "\t\t" << endl; } - if ( protocol == "rbd" ) + file << "\t\t\t" << endl - << "\t\t\t\t" << endl - << "\t\t\t" << endl; - } + file << vm->get_oid() << "/disk." << disk_id; } + else + { + file << one_util::split(source, '/').back(); + } + + do_network_hosts(file, gluster_host, "tcp"); } else if ( type == "CDROM" ) {