From 07e35cdc8af6599f2c896b00cbe3c351d175f4a3 Mon Sep 17 00:00:00 2001 From: Javi Fontan Date: Mon, 27 Jan 2014 15:56:52 +0100 Subject: [PATCH 1/5] 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" ) From a11d0ca3c40bec9ed4b20d1d300aaa4ea9f787d6 Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Thu, 6 Feb 2014 16:47:45 +0100 Subject: [PATCH 2/5] feature #2202: Small refactor of Ceph/Gluster disk generation --- src/vmm/LibVirtDriverKVM.cc | 170 +++++++++++++++++------------------- 1 file changed, 80 insertions(+), 90 deletions(-) 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" ) { From 69ccb20216c7de2ed95d510e4721bce82f7f227e Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Thu, 6 Feb 2014 16:51:04 +0100 Subject: [PATCH 3/5] feature #2202: Add INHERIT attributes for GLUSTER DS --- share/etc/oned.conf | 3 +++ 1 file changed, 3 insertions(+) diff --git a/share/etc/oned.conf b/share/etc/oned.conf index 18eb97706f..27b6d9a913 100644 --- a/share/etc/oned.conf +++ b/share/etc/oned.conf @@ -735,4 +735,7 @@ INHERIT_DATASTORE_ATTR = "CEPH_HOST" INHERIT_DATASTORE_ATTR = "CEPH_SECRET" INHERIT_DATASTORE_ATTR = "CEPH_USER" +INHERIT_DATASTORE_ATTR = "GLUSTER_HOST" +INHERIT_DATASTORE_ATTR = "GLUSTER_VOLUME" + INHERIT_VNET_ATTR = "VLAN_TAGGED_ID" From 1b48b0b93c18c8b0c46a42b575c99b8261f25389 Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Thu, 6 Feb 2014 17:03:50 +0100 Subject: [PATCH 4/5] Moved TM_MAD_CONF attributes in oned.conf --- share/etc/oned.conf | 140 +++++++++++++++++++------------------------- 1 file changed, 60 insertions(+), 80 deletions(-) diff --git a/share/etc/oned.conf b/share/etc/oned.conf index 27b6d9a913..e9b8e7ff38 100644 --- a/share/etc/oned.conf +++ b/share/etc/oned.conf @@ -404,24 +404,6 @@ VM_MAD = [ # -t: number of threads, i.e. number of transfers made at the same time # -d: list of transfer drivers separated by commas, if not defined all the # drivers available will be enabled -# -# The configuration for each driver is defined in TM_MAD_CONF. These -# values are used when creating a new datastore and should not be modified -# since they define the datastore behaviour. -# name : name of the transfer driver, listed in the -d option of the -# TM_MAD section -# ln_target : determines how the persistent images will be cloned when -# a new VM is instantiated. -# NONE: The image will be linked and no more storage capacity will be used -# SELF: The image will be cloned in the Images datastore -# SYSTEM: The image will be cloned in the System datastore -# clone_target : determines how the non persistent images will be -# cloned when a new VM is instantiated. -# NONE: The image will be linked and no more storage capacity will be used -# SELF: The image will be cloned in the Images datastore -# SYSTEM: The image will be cloned in the System datastore -# shared : determines if the storage holding the system datastore is shared -# among the different hosts or not. Valid values: "yes" or "no" #******************************************************************************* TM_MAD = [ @@ -429,62 +411,6 @@ TM_MAD = [ arguments = "-t 15 -d dummy,lvm,shared,fs_lvm,qcow2,ssh,vmfs,ceph" ] -TM_MAD_CONF = [ - name = "dummy", - ln_target = "NONE", - clone_target= "SYSTEM", - shared = "yes" -] - -TM_MAD_CONF = [ - name = "lvm", - ln_target = "NONE", - clone_target= "SELF", - shared = "yes" -] - -TM_MAD_CONF = [ - name = "shared", - ln_target = "NONE", - clone_target= "SYSTEM", - shared = "yes" -] - -TM_MAD_CONF = [ - name = "fs_lvm", - ln_target = "SYSTEM", - clone_target= "SYSTEM", - shared = "yes" -] - -TM_MAD_CONF = [ - name = "qcow2", - ln_target = "NONE", - clone_target= "SYSTEM", - shared = "yes" -] - -TM_MAD_CONF = [ - name = "ssh", - ln_target = "SYSTEM", - clone_target= "SYSTEM", - shared = "no" -] - -TM_MAD_CONF = [ - name = "vmfs", - ln_target = "NONE", - clone_target= "SYSTEM", - shared = "yes" -] - -TM_MAD_CONF = [ - name = "ceph", - ln_target = "NONE", - clone_target= "SELF", - shared = "yes" -] - #******************************************************************************* # Datastore Driver Configuration #******************************************************************************* @@ -686,6 +612,12 @@ SESSION_EXPIRATION_TIME = 900 DEFAULT_UMASK = 177 +#******************************************************************************* +# OneGate +#******************************************************************************* + +#ONEGATE_ENDPOINT = "http://frontend:5030" + #******************************************************************************* # Restricted Attributes Configuration #******************************************************************************* @@ -704,12 +636,6 @@ VM_RESTRICTED_ATTR = "NIC/BRIDGE" IMAGE_RESTRICTED_ATTR = "SOURCE" -#******************************************************************************* -# OneGate -#******************************************************************************* - -#ONEGATE_ENDPOINT = "http://frontend:5030" - #******************************************************************************* # Inherited Attributes Configuration #******************************************************************************* @@ -739,3 +665,57 @@ INHERIT_DATASTORE_ATTR = "GLUSTER_HOST" INHERIT_DATASTORE_ATTR = "GLUSTER_VOLUME" INHERIT_VNET_ATTR = "VLAN_TAGGED_ID" + +#******************************************************************************* +# Transfer Manager Driver Behavior Configuration +#******************************************************************************* +# The configuration for each driver is defined in TM_MAD_CONF. These +# values are used when creating a new datastore and should not be modified +# since they define the datastore behavior. +# name : name of the transfer driver, listed in the -d option of the +# TM_MAD section +# ln_target : determines how the persistent images will be cloned when +# a new VM is instantiated. +# NONE: The image will be linked and no more storage capacity will be used +# SELF: The image will be cloned in the Images datastore +# SYSTEM: The image will be cloned in the System datastore +# clone_target : determines how the non persistent images will be +# cloned when a new VM is instantiated. +# NONE: The image will be linked and no more storage capacity will be used +# SELF: The image will be cloned in the Images datastore +# SYSTEM: The image will be cloned in the System datastore +# shared : determines if the storage holding the system datastore is shared +# among the different hosts or not. Valid values: "yes" or "no" +#******************************************************************************* + +TM_MAD_CONF = [ + name = "dummy", ln_target = "NONE", clone_target = "SYSTEM", shared = "yes" +] + +TM_MAD_CONF = [ + name = "lvm", ln_target = "NONE", clone_target = "SELF", shared = "yes" +] + +TM_MAD_CONF = [ + name = "shared", ln_target = "NONE", clone_target = "SYSTEM", shared = "yes" +] + +TM_MAD_CONF = [ + name = "fs_lvm", ln_target = "SYSTEM", clone_target = "SYSTEM", shared="yes" +] + +TM_MAD_CONF = [ + name = "qcow2", ln_target = "NONE", clone_target = "SYSTEM", shared = "yes" +] + +TM_MAD_CONF = [ + name = "ssh", ln_target = "SYSTEM", clone_target = "SYSTEM", shared = "no" +] + +TM_MAD_CONF = [ + name = "vmfs", ln_target = "NONE", clone_target= "SYSTEM", shared = "yes" +] + +TM_MAD_CONF = [ + name = "ceph", ln_target = "NONE", clone_target = "SELF", shared = "yes" +] From 62f6e89009fdde7afe5e421cbdd1270280a6639a Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Thu, 6 Feb 2014 22:31:45 +0100 Subject: [PATCH 5/5] feature #2202: Add comments to oned.conf --- share/etc/oned.conf | 3 +++ 1 file changed, 3 insertions(+) diff --git a/share/etc/oned.conf b/share/etc/oned.conf index e9b8e7ff38..289675d4e0 100644 --- a/share/etc/oned.conf +++ b/share/etc/oned.conf @@ -614,6 +614,9 @@ DEFAULT_UMASK = 177 #******************************************************************************* # OneGate +# ONEGATE_ENDPOINT: The URL for the onegate server (the Gate to OpenNebula for +# VMs). The onegate server is started using a separate command. The endpoint +# MUST be consistent with the values in onegate-server.conf #******************************************************************************* #ONEGATE_ENDPOINT = "http://frontend:5030"