diff --git a/include/NebulaTemplate.h b/include/NebulaTemplate.h index 4710a71026..224cefec08 100644 --- a/include/NebulaTemplate.h +++ b/include/NebulaTemplate.h @@ -156,7 +156,8 @@ private: const std::string& ln_target, const std::string& clone_target, const std::string& shared, - const std::string& ds_migrate); + const std::string& ds_migrate, + const std::string& driver); /** * Sets a the defaults for a Market diff --git a/share/etc/oned.conf b/share/etc/oned.conf index d941454beb..d59884b4f5 100644 --- a/share/etc/oned.conf +++ b/share/etc/oned.conf @@ -990,11 +990,13 @@ TM_MAD_CONF = [ ] TM_MAD_CONF = [ - NAME = "fs_lvm", LN_TARGET = "SYSTEM", CLONE_TARGET = "SYSTEM", SHARED="YES" + NAME = "fs_lvm", LN_TARGET = "SYSTEM", CLONE_TARGET = "SYSTEM", SHARED="YES", + DRIVER = "raw" ] TM_MAD_CONF = [ - NAME = "qcow2", LN_TARGET = "NONE", CLONE_TARGET = "SYSTEM", SHARED = "YES" + NAME = "qcow2", LN_TARGET = "NONE", CLONE_TARGET = "SYSTEM", SHARED = "YES", + DRIVER = "qcow2" ] TM_MAD_CONF = [ @@ -1004,7 +1006,7 @@ TM_MAD_CONF = [ TM_MAD_CONF = [ NAME = "ceph", LN_TARGET = "NONE", CLONE_TARGET = "SELF", SHARED = "YES", - DS_MIGRATE = "NO" + DS_MIGRATE = "NO", DRIVER = "raw" ] TM_MAD_CONF = [ diff --git a/src/datastore/Datastore.cc b/src/datastore/Datastore.cc index cb1d9bf890..899c23c3cd 100644 --- a/src/datastore/Datastore.cc +++ b/src/datastore/Datastore.cc @@ -107,6 +107,7 @@ void Datastore::disk_attribute( string st; string inherit_val; string current_val; + string type; vector::const_iterator it; @@ -147,6 +148,18 @@ void Datastore::disk_attribute( { disk->replace("DISK_TYPE", Image::disk_type_to_str(get_disk_type())); } + + type = disk->vector_value("TYPE"); + + if (type != "CDROM") + { + get_template_attribute("DRIVER", st); + + if(!st.empty()) + { + disk->replace("DRIVER", st); + } + } } /* ************************************************************************ */ @@ -335,6 +348,13 @@ int Datastore::set_tm_mad(string &tm_mad, string &error_str) replace_template_attribute("CLONE_TARGET", st); + st = vatt->vector_value("DRIVER"); + + if (!st.empty()) + { + replace_template_attribute("DRIVER", st); + } + remove_template_attribute("SHARED"); } diff --git a/src/datastore_mad/remotes/fs/cp b/src/datastore_mad/remotes/fs/cp index 91665aebef..15ff9dee72 100755 --- a/src/datastore_mad/remotes/fs/cp +++ b/src/datastore_mad/remotes/fs/cp @@ -59,7 +59,10 @@ done < <($XPATH /DS_DRIVER_ACTION_DATA/DATASTORE/BASE_PATH \ /DS_DRIVER_ACTION_DATA/IMAGE/TEMPLATE/MD5 \ /DS_DRIVER_ACTION_DATA/IMAGE/TEMPLATE/SHA1 \ /DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/NO_DECOMPRESS \ - /DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/LIMIT_TRANSFER_BW) + /DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/LIMIT_TRANSFER_BW \ + /DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/CONVERT \ + /DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/DRIVER \ + /DS_DRIVER_ACTION_DATA/IMAGE/TYPE) unset i @@ -74,6 +77,9 @@ MD5="${XPATH_ELEMENTS[i++]}" SHA1="${XPATH_ELEMENTS[i++]}" NO_DECOMPRESS="${XPATH_ELEMENTS[i++]}" LIMIT_TRANSFER_BW="${XPATH_ELEMENTS[i++]}" +CONVERT="${XPATH_ELEMENTS[i++]:-yes}" +DRIVER="${XPATH_ELEMENTS[i++]}" +IMAGE_TYPE="${XPATH_ELEMENTS[i++]}" DST=`generate_image_path` IMAGE_HASH=`basename $DST` @@ -85,6 +91,12 @@ if [ "$TYPE" = "2" ]; then NO_DECOMPRESS="${NO_DECOMPRESS:-yes}" fi +# Disable conversion for CD-ROM and 'files' datastores +CONVERT=$(echo "${CONVERT}" | $TR '[:upper:]' '[:lower:]') +if [ "$IMAGE_TYPE" = "1" ] || [ "$TYPE" = "2" ]; then + CONVERT=no +fi + if [ -n "$BRIDGE_LIST" ]; then DOWNLOADER_ARGS=`set_downloader_args "$MD5" "$SHA1" "$NO_DECOMPRESS" "$LIMIT_TRANSFER_BW" "$SRC" -` else @@ -105,6 +117,19 @@ else log "Downloading image $SRC to the image repository" fi +CONVERT_CMD=$(cat < vvalue; @@ -311,6 +312,7 @@ void OpenNebulaTemplate::set_conf_tm(const std::string& name, vvalue.insert(make_pair("CLONE_TARGET", clone_target)); vvalue.insert(make_pair("SHARED", shared)); vvalue.insert(make_pair("DS_MIGRATE", ds_migrate)); + vvalue.insert(make_pair("DRIVER", driver)); vattribute = new VectorAttribute("TM_MAD_CONF", vvalue); conf_default.insert(make_pair(vattribute->name(), vattribute)); diff --git a/src/onedb/local/4.90.0_to_5.3.80.rb b/src/onedb/local/4.90.0_to_5.3.80.rb index 8b34908001..6dda3c6b54 100644 --- a/src/onedb/local/4.90.0_to_5.3.80.rb +++ b/src/onedb/local/4.90.0_to_5.3.80.rb @@ -44,6 +44,8 @@ module Migrator feature_2347() + bug_3705() + log_time() return true @@ -137,4 +139,39 @@ module Migrator def feature_2347 create_table(:vmgroup_pool) end + + ############################################################################ + # Bug 3705 + # Adds DRIVER to CEPH and LVM image datastores + ############################################################################ + def bug_3705 + @db.run "ALTER TABLE datastore_pool RENAME TO old_datastore_pool;" + create_table(:datastore_pool) + + @db.transaction do + @db.fetch("SELECT * FROM old_datastore_pool") do |row| + doc = Nokogiri::XML(row[:body], nil, NOKOGIRI_ENCODING) { |c| + c.default_xml.noblanks + } + + type = xpath(doc, 'TYPE').to_i + tm_mad = xpath(doc, 'TM_MAD') + + if (type == 0) && (["ceph", "fs_lvm"].include?(tm_mad)) + doc.root.xpath("TEMPLATE/DRIVER").each do |d| + d.remove + end + + driver = doc.create_element "DRIVER", "raw" + doc.root.at_xpath("TEMPLATE").add_child(driver) + + row[:body] = doc.root.to_s + end + + @db[:datastore_pool].insert(row) + end + end + + @db.run "DROP TABLE old_datastore_pool;" + end end