From 07e35cdc8af6599f2c896b00cbe3c351d175f4a3 Mon Sep 17 00:00:00 2001 From: Javi Fontan Date: Mon, 27 Jan 2014 15:56:52 +0100 Subject: [PATCH] feature #2202: add native gluster support with kvm --- src/vmm/LibVirtDriverKVM.cc | 80 ++++++++++++++++++++++++++++++++----- 1 file changed, 69 insertions(+), 11 deletions(-) diff --git a/src/vmm/LibVirtDriverKVM.cc b/src/vmm/LibVirtDriverKVM.cc index 93e01caa85..820d27cdf6 100644 --- a/src/vmm/LibVirtDriverKVM.cc +++ b/src/vmm/LibVirtDriverKVM.cc @@ -64,6 +64,8 @@ int LibVirtDriver::deployment_description_kvm( string ceph_host = ""; string ceph_secret= ""; string ceph_user = ""; + string gluster_host = ""; + string gluster_volume = ""; int disk_id; string default_driver = ""; @@ -331,6 +333,8 @@ int LibVirtDriver::deployment_description_kvm( ceph_host = disk->vector_value("CEPH_HOST"); ceph_secret = disk->vector_value("CEPH_SECRET"); ceph_user = disk->vector_value("CEPH_USER"); + gluster_host = disk->vector_value("GLUSTER_HOST"); + gluster_volume = disk->vector_value("GLUSTER_VOLUME"); disk->vector_value_str("DISK_ID", disk_id); @@ -361,9 +365,21 @@ int LibVirtDriver::deployment_description_kvm( << "\t\t\t" << endl; } - else if ( type == "RBD" || type == "RBD_CDROM" ) + else if ( type == "RBD" || type == "RBD_CDROM" || + type == "GLUSTER" || type == "GLUSTER_CDROM" ) { - if (type == "RBD") + string protocol = ""; + + if ( type == "RBD" || type == "RBD_CDROM" ) + { + protocol = "rbd"; + } + else + { + protocol = "gluster"; + } + + if ( type == "RBD" || type == "GLUSTER" ) { file << "\t\t" << endl; } @@ -372,21 +388,55 @@ int LibVirtDriver::deployment_description_kvm( file << "\t\t" << endl; } - file << "\t\t\tget_oid() << "-" << disk_id; } - if ( ceph_host.empty() ) + if ( ceph_host.empty() && gluster_host.empty() ) { file << "'/>" << endl; } else { vector::const_iterator it; - vector hosts = one_util::split(ceph_host, ' '); + vector hosts; + + if ( protocol == "rbd" ) + { + hosts = one_util::split(ceph_host, ' '); + } + else + { + hosts = one_util::split(gluster_host, ' '); + } file << "'>" << endl; @@ -406,18 +456,26 @@ int LibVirtDriver::deployment_description_kvm( file << "' port='" << parts[1]; } + if ( protocol == "gluster" ) + { + file << "' transport='tcp"; + } + file << "'/>" << endl; } file << "\t\t\t" << endl; } - if ( !ceph_secret.empty() && !ceph_user.empty()) + if ( protocol == "rbd" ) { - file << "\t\t\t" << endl - << "\t\t\t\t" << endl - << "\t\t\t" << endl; + if ( !ceph_secret.empty() && !ceph_user.empty()) + { + file << "\t\t\t" << endl + << "\t\t\t\t" << endl + << "\t\t\t" << endl; + } } } else if ( type == "CDROM" )