From 696e69a957c56879042d8ac8174bd2202dcde42a Mon Sep 17 00:00:00 2001 From: Guillemo Ramos Date: Mon, 20 Jan 2025 16:55:22 +0100 Subject: [PATCH] F #6752: AutoNFS (#3331) This feature auto mounts NFS volumes for datastores. The behavior can be controlled with the following template attributes: - ANFS_ENABLE: YES/NO to enable the automatic NFS management - ANFS_HOST: hostname/IP of the NFS server - ANFS_PATH: of the NFS share for this datastore - ANFS_OPTS: Comma separated options (fstab-like) used for mounting the NFS shares The shared drivers also performs a "garbage-collector" like to unmount NFS volumes on the hypervisors when the datastores are deleted. This operation is performed in a "lazy" way, when VMs are deployed on the hypervisor. * oneimage create: mount/umount DS on demand Signed-off-by: Guillermo Ramos * Move sh mount/umount logic to libfs.sh Signed-off-by: Guillermo Ramos * oneimage delete: mount/umount DS on demand Signed-off-by: Guillermo Ramos * Limit NFS mount/umount from SH code to 30s Signed-off-by: Guillermo Ramos * oneimage clone: mount/umount DS on demand Signed-off-by: Guillermo Ramos * onevm deploy: mount DS on demand Signed-off-by: Guillermo Ramos * Temporal mount only when needed Signed-off-by: Guillermo Ramos * onevm deploy: mount DS on demand (persisten) Signed-off-by: Guillermo Ramos * Linter Signed-off-by: Guillermo Ramos * onevm deploy: umount unneeded DS Signed-off-by: Guillermo Ramos * Allow mount/umount/sed from sudoers Signed-off-by: Guillermo Ramos * Temporal mount: use NFS_AUTO_OPTS Signed-off-by: Guillermo Ramos * Do AutoNFS cleanup even during non-related ops Signed-off-by: Guillermo Ramos * Final refactor and improvements Signed-off-by: Guillermo Ramos * ro values for Datastore object * Wording for AutoNFS RO attributes Signed-off-by: Guillermo Ramos * NFS_AUTO_ENABLE: change 'true' to 'yes' Signed-off-by: Guillermo Ramos * sudoers: merge everythng into ONE_NFS Signed-off-by: Guillermo Ramos * Quote NFS_AUTO_OPTS Signed-off-by: Guillermo Ramos * Fix difference between sudoers specs Signed-off-by: Guillermo Ramos * Touch .automounted in AutoNFS mounts Signed-off-by: Guillermo Ramos * Update sudoers.rb * Update rm * Quote bash variable expansion Signed-off-by: Guillermo Ramos --------- Signed-off-by: Guillermo Ramos Co-authored-by: Ruben S. Montero --- include/BackupJob.h | 2 +- include/Datastore.h | 2 +- include/Group.h | 2 +- include/Hook.h | 2 +- include/Host.h | 2 +- include/MarketPlace.h | 2 +- include/MarketPlaceApp.h | 2 +- include/PoolObjectSQL.h | 2 +- include/SecurityGroup.h | 2 +- include/User.h | 2 +- include/VMGroup.h | 2 +- include/VMTemplate.h | 2 +- include/VirtualNetwork.h | 2 +- include/Zone.h | 2 +- share/pkgs/sudoers/centos/opennebula | 1 + share/pkgs/sudoers/debian/opennebula | 1 + share/pkgs/sudoers/opennebula-node-kvm | 2 +- share/pkgs/sudoers/opennebula-server | 2 +- share/sudoers/sudoers.rb | 5 +- src/cli/one_helper/onevm_helper.rb | 8 +- src/datastore/Datastore.cc | 30 +++++++- src/datastore_mad/remotes/fs/clone | 29 +++++-- src/datastore_mad/remotes/fs/mkfs | 34 ++++++--- src/datastore_mad/remotes/fs/rm | 25 ++++-- src/group/Group.cc | 2 +- src/hm/Hook.cc | 2 +- src/host/Host.cc | 2 +- src/mad/sh/scripts_common.sh | 102 +++++++++++++++++++++++++ src/market/MarketPlace.cc | 2 +- src/market/MarketPlaceApp.cc | 2 +- src/pool/PoolObjectSQL.cc | 15 ++-- src/secgroup/SecurityGroup.cc | 4 +- src/tm_mad/qcow2/clone | 15 ++++ src/tm_mad/qcow2/ln | 31 +++++++- src/um/User.cc | 2 +- src/vm/VirtualMachine.cc | 4 +- src/vm_group/VMGroup.cc | 2 +- src/vm_template/VMTemplate.cc | 2 +- src/vnm/VirtualNetwork.cc | 8 +- src/zone/Zone.cc | 2 +- 40 files changed, 289 insertions(+), 73 deletions(-) diff --git a/include/BackupJob.h b/include/BackupJob.h index 025f63401b..d83be6899e 100644 --- a/include/BackupJob.h +++ b/include/BackupJob.h @@ -266,7 +266,7 @@ protected: * @param error string describing the error if any * @return 0 on success */ - int post_update_template(std::string& error) override + int post_update_template(std::string& error, Template *_old_tmpl) override { remove_template_attribute("NAME"); remove_template_attribute("PRIORITY"); diff --git a/include/Datastore.h b/include/Datastore.h index 14a4190457..c1903794e3 100644 --- a/include/Datastore.h +++ b/include/Datastore.h @@ -444,7 +444,7 @@ private: * @return 0 on success * - encrypt secret attributes. */ - int post_update_template(std::string& error) override; + int post_update_template(std::string& error, Template *old_tmp) override; }; #endif /*DATASTORE_H_*/ diff --git a/include/Group.h b/include/Group.h index e73f6ccdab..769de07a50 100644 --- a/include/Group.h +++ b/include/Group.h @@ -165,7 +165,7 @@ protected: * @param error string describing the error if any * @return 0 on success */ - int post_update_template(std::string& error) override; + int post_update_template(std::string& error, Template *_old_tmpl) override; private: diff --git a/include/Hook.h b/include/Hook.h index d432aa0b28..20b6ef0c25 100644 --- a/include/Hook.h +++ b/include/Hook.h @@ -123,7 +123,7 @@ private: * @param error string describing the error if any * @return 0 on success */ - int post_update_template(std::string& error) override; + int post_update_template(std::string& error, Template *_obj_tmpl) override; // ------------------------------------------------------------------------- // Hook Attributes diff --git a/include/Host.h b/include/Host.h index e3333ff2f7..87fb7cb904 100644 --- a/include/Host.h +++ b/include/Host.h @@ -341,7 +341,7 @@ public: * Executed after an update operation to process the new template * - encrypt secret attributes. */ - int post_update_template(std::string& error) override; + int post_update_template(std::string& error, Template *_old_tmpl) override; /** * Read monitoring from DB diff --git a/include/MarketPlace.h b/include/MarketPlace.h index dcb15cd2a9..8e5440a282 100644 --- a/include/MarketPlace.h +++ b/include/MarketPlace.h @@ -333,7 +333,7 @@ private: * @param error string describing the error if any * @return 0 on success */ - int post_update_template(std::string& error) override; + int post_update_template(std::string& error, Template *_old_tmpl) override; }; #endif /*MARKETPLACE_H*/ diff --git a/include/MarketPlaceApp.h b/include/MarketPlaceApp.h index c9ede546b0..4ca074f474 100644 --- a/include/MarketPlaceApp.h +++ b/include/MarketPlaceApp.h @@ -408,7 +408,7 @@ private: * @param error string describing the error if any * @return 0 on success */ - int post_update_template(std::string& error) override; + int post_update_template(std::string& error, Template *_old_tmpl) override; /** * Factory method for marketplace app templates diff --git a/include/PoolObjectSQL.h b/include/PoolObjectSQL.h index 9988d6c8b4..b781811c20 100644 --- a/include/PoolObjectSQL.h +++ b/include/PoolObjectSQL.h @@ -720,7 +720,7 @@ protected: * @param error string describing the error if any * @return 0 on success */ - virtual int post_update_template(std::string& error) + virtual int post_update_template(std::string& error, Template *_old_tmpl) { return 0; }; diff --git a/include/SecurityGroup.h b/include/SecurityGroup.h index 5036dc4132..0d6d81418e 100644 --- a/include/SecurityGroup.h +++ b/include/SecurityGroup.h @@ -208,7 +208,7 @@ private: * @param error string describing the error if any * @return 0 on success */ - int post_update_template(std::string& error) override; + int post_update_template(std::string& error, Template *_old_tmpl) override; // ************************************************************************* // DataBase implementation (Private) diff --git a/include/User.h b/include/User.h index 910c86eb90..5ed42c2d53 100644 --- a/include/User.h +++ b/include/User.h @@ -422,7 +422,7 @@ protected: * @param error string describing the error if any * @return 0 on success */ - int post_update_template(std::string& error) override; + int post_update_template(std::string& error, Template *_old_tmpl) override; }; #endif /*USER_H_*/ diff --git a/include/VMGroup.h b/include/VMGroup.h index 86d9797ab7..e8fb446bf6 100644 --- a/include/VMGroup.h +++ b/include/VMGroup.h @@ -218,7 +218,7 @@ private: * @param error string describing the error if any * @return 0 on success */ - int post_update_template(std::string& error) override; + int post_update_template(std::string& error, Template *_old_tmpl) override; /** * Factory method for VMGroup templates diff --git a/include/VMTemplate.h b/include/VMTemplate.h index 4e59466402..c9289ab829 100644 --- a/include/VMTemplate.h +++ b/include/VMTemplate.h @@ -146,7 +146,7 @@ private: * @param error Returns the error reason, if any * @return 0 one success */ - int post_update_template(std::string& error) override; + int post_update_template(std::string& error, Template *_old_tmpl) override; /** * Bootstraps the database table(s) associated to the VMTemplate diff --git a/include/VirtualNetwork.h b/include/VirtualNetwork.h index ae60d98f9e..266bfbfe68 100644 --- a/include/VirtualNetwork.h +++ b/include/VirtualNetwork.h @@ -1016,7 +1016,7 @@ private: * @param error string describing the error if any * @return 0 on success */ - int post_update_template(std::string& error) override; + int post_update_template(std::string& error, Template *_old_tmpl) override; /** * Detect changed attributes in new_tmpl, store them as diff --git a/include/Zone.h b/include/Zone.h index afd888c8aa..79ced83f86 100644 --- a/include/Zone.h +++ b/include/Zone.h @@ -225,7 +225,7 @@ private: * @param error string describing the error if any * @return 0 on success */ - int post_update_template(std::string& error) override; + int post_update_template(std::string& error, Template *_old_tmpl) override; }; #endif /*ZONE_H_*/ diff --git a/share/pkgs/sudoers/centos/opennebula b/share/pkgs/sudoers/centos/opennebula index 8d4b8ccfb9..5e388e4cf0 100644 --- a/share/pkgs/sudoers/centos/opennebula +++ b/share/pkgs/sudoers/centos/opennebula @@ -4,6 +4,7 @@ Defaults:oneadmin secure_path = /sbin:/bin:/usr/sbin:/usr/bin Cmnd_Alias ONE_CEPH = /usr/bin/rbd Cmnd_Alias ONE_HA = /usr/bin/systemctl start opennebula-flow, /usr/bin/systemctl stop opennebula-flow, /usr/bin/systemctl start opennebula-gate, /usr/bin/systemctl stop opennebula-gate, /usr/bin/systemctl start opennebula-hem, /usr/bin/systemctl stop opennebula-hem, /usr/bin/systemctl start opennebula-showback.timer, /usr/bin/systemctl stop opennebula-showback.timer, /usr/sbin/service opennebula-flow start, /usr/sbin/service opennebula-flow stop, /usr/sbin/service opennebula-gate start, /usr/sbin/service opennebula-gate stop, /usr/sbin/service opennebula-hem start, /usr/sbin/service opennebula-hem stop, /usr/sbin/arping, /usr/sbin/ip address * Cmnd_Alias ONE_LVM = /usr/sbin/lvcreate, /usr/sbin/lvremove, /usr/sbin/lvs, /usr/sbin/vgdisplay, /usr/sbin/lvchange, /usr/sbin/lvscan, /usr/sbin/lvextend +Cmnd_Alias ONE_NFS = /usr/bin/mount, /usr/bin/umount, /usr/bin/sed -i -f /proc/self/fd/0 /etc/fstab Cmnd_Alias ONE_LXC = /usr/bin/mount, /usr/bin/umount, /usr/bin/bindfs, /usr/sbin/losetup, /usr/bin/qemu-nbd, /usr/bin/lxc-attach, /usr/bin/lxc-config, /usr/bin/lxc-create, /usr/bin/lxc-destroy, /usr/bin/lxc-info, /usr/bin/lxc-ls, /usr/bin/lxc-start, /usr/bin/lxc-stop, /usr/bin/lxc-console, /usr/sbin/e2fsck, /usr/sbin/resize2fs, /usr/sbin/xfs_growfs, /usr/bin/rbd-nbd Cmnd_Alias ONE_MARKET = /usr/lib/one/sh/create_container_image.sh Cmnd_Alias ONE_NET = /usr/sbin/ebtables, /usr/sbin/iptables, /usr/sbin/ip6tables, /usr/sbin/ipset, /usr/sbin/ip link *, /usr/sbin/ip neighbour *, /usr/sbin/ip route *, /usr/sbin/ip rule *, /usr/sbin/ip tuntap *, /usr/sbin/nft, /var/tmp/one/vnm/tproxy, /usr/sbin/bridge vlan * diff --git a/share/pkgs/sudoers/debian/opennebula b/share/pkgs/sudoers/debian/opennebula index 41323b57bd..c14d2ab25a 100644 --- a/share/pkgs/sudoers/debian/opennebula +++ b/share/pkgs/sudoers/debian/opennebula @@ -4,6 +4,7 @@ Defaults:oneadmin secure_path = /sbin:/bin:/usr/sbin:/usr/bin Cmnd_Alias ONE_CEPH = /usr/bin/rbd Cmnd_Alias ONE_HA = /usr/bin/systemctl start opennebula-flow, /usr/bin/systemctl stop opennebula-flow, /usr/bin/systemctl start opennebula-gate, /usr/bin/systemctl stop opennebula-gate, /usr/bin/systemctl start opennebula-hem, /usr/bin/systemctl stop opennebula-hem, /usr/bin/systemctl start opennebula-showback.timer, /usr/bin/systemctl stop opennebula-showback.timer, /usr/sbin/service opennebula-flow start, /usr/sbin/service opennebula-flow stop, /usr/sbin/service opennebula-gate start, /usr/sbin/service opennebula-gate stop, /usr/sbin/service opennebula-hem start, /usr/sbin/service opennebula-hem stop, /usr/bin/arping, /usr/sbin/ip address * Cmnd_Alias ONE_LVM = /usr/sbin/lvcreate, /usr/sbin/lvremove, /usr/sbin/lvs, /usr/sbin/vgdisplay, /usr/sbin/lvchange, /usr/sbin/lvscan, /usr/sbin/lvextend +Cmnd_Alias ONE_NFS = /usr/bin/mount, /usr/bin/umount, /usr/bin/sed -i -f /proc/self/fd/0 /etc/fstab Cmnd_Alias ONE_LXC = /usr/bin/mount, /usr/bin/umount, /usr/bin/bindfs, /usr/sbin/losetup, /usr/bin/qemu-nbd, /usr/bin/lxc-attach, /usr/bin/lxc-config, /usr/bin/lxc-create, /usr/bin/lxc-destroy, /usr/bin/lxc-info, /usr/bin/lxc-ls, /usr/bin/lxc-start, /usr/bin/lxc-stop, /usr/bin/lxc-console, /usr/sbin/e2fsck, /usr/sbin/resize2fs, /usr/sbin/xfs_growfs, /usr/bin/rbd-nbd Cmnd_Alias ONE_MARKET = /usr/lib/one/sh/create_container_image.sh Cmnd_Alias ONE_NET = /usr/sbin/ebtables, /usr/sbin/iptables, /usr/sbin/ip6tables, /usr/sbin/ipset, /usr/sbin/ip link *, /usr/sbin/ip neighbour *, /usr/sbin/ip route *, /usr/sbin/ip rule *, /usr/sbin/ip tuntap *, /usr/sbin/nft, /var/tmp/one/vnm/tproxy, /usr/sbin/bridge vlan * diff --git a/share/pkgs/sudoers/opennebula-node-kvm b/share/pkgs/sudoers/opennebula-node-kvm index f1a0c1b022..ff98576d35 100644 --- a/share/pkgs/sudoers/opennebula-node-kvm +++ b/share/pkgs/sudoers/opennebula-node-kvm @@ -1,2 +1,2 @@ -oneadmin ALL=(ALL:ALL) NOPASSWD: ONE_CEPH, ONE_NET, ONE_OVS, ONE_LVM, ONE_MEM, ONE_VGPU +oneadmin ALL=(ALL:ALL) NOPASSWD: ONE_CEPH, ONE_NET, ONE_OVS, ONE_LVM, ONE_MEM, ONE_VGPU, ONE_NFS oneadmin ALL=(ALL:ALL) NOPASSWD:SETENV: ONE_NETNS diff --git a/share/pkgs/sudoers/opennebula-server b/share/pkgs/sudoers/opennebula-server index 52b8abd2b0..c09dfc8684 100644 --- a/share/pkgs/sudoers/opennebula-server +++ b/share/pkgs/sudoers/opennebula-server @@ -1 +1 @@ -oneadmin ALL=(ALL) NOPASSWD: ONE_CEPH, ONE_HA, ONE_LVM, ONE_MARKET +oneadmin ALL=(ALL) NOPASSWD: ONE_CEPH, ONE_HA, ONE_LVM, ONE_MARKET, ONE_NFS diff --git a/share/sudoers/sudoers.rb b/share/sudoers/sudoers.rb index a431b86277..da9916e553 100644 --- a/share/sudoers/sudoers.rb +++ b/share/sudoers/sudoers.rb @@ -17,7 +17,7 @@ # Holds configuration about sudoers requirements for OpeNebula class Sudoers - NODECMDS = [:NET, :NETNS, :OVS, :LVM, :LXC, :MEM, :VGPU] + NODECMDS = [:NET, :NETNS, :OVS, :LVM, :LXC, :MEM, :VGPU, :NFS] attr_accessor :cmds @@ -77,7 +77,8 @@ class Sudoers ], :MARKET => ["#{lib_location}/sh/create_container_image.sh"], :MEM => ['sysctl vm.drop_caches=3 vm.compact_memory=1'], - :VGPU => ['sudo', '/var/tmp/one/vgpu'] + :VGPU => ['sudo', '/var/tmp/one/vgpu'], + :NFS => ['mount', 'umount', '/usr/bin/sed -i -f /proc/self/fd/0 /etc/fstab'] } end diff --git a/src/cli/one_helper/onevm_helper.rb b/src/cli/one_helper/onevm_helper.rb index c4c6dbc11b..86b838fdb4 100644 --- a/src/cli/one_helper/onevm_helper.rb +++ b/src/cli/one_helper/onevm_helper.rb @@ -841,7 +841,6 @@ class OneVMHelper < OpenNebulaHelper::OneHelper d['TARGET'] end - # rubocop:disable Metrics/LineLength column :IMAGE, '', :left, :size => 35 do |d| d['IMAGE'] || case d['TYPE'].upcase when 'FS' @@ -854,7 +853,6 @@ class OneVMHelper < OpenNebulaHelper::OneHelper end end - # rubocop:enable Metrics/LineLength column :SIZE, '', :left, :size => 9 do |d| if d['SIZE'] @@ -1126,8 +1124,9 @@ class OneVMHelper < OpenNebulaHelper::OneHelper puts - # rubocop:disable Metrics/LineLength + # rubocop:disable Layout/LineLength CLIHelper.print_header(str_h1 % 'SECURITY GROUP TYPE PROTOCOL NETWORK RANGE ', false) + # rubocop:enable Layout/LineLength CLIHelper::ShowTable.new(nil, self) do column :ID, '', :size => 4 do |d| @@ -1179,7 +1178,6 @@ class OneVMHelper < OpenNebulaHelper::OneHelper end.show( [vm_hash['VM']['TEMPLATE']['SECURITY_GROUP_RULE']].flatten, {} ) - # rubocop:enable Metrics/LineLength if !options[:all] while vm.has_elements?('/VM/TEMPLATE/SECURITY_GROUP_RULE') @@ -1273,7 +1271,6 @@ class OneVMHelper < OpenNebulaHelper::OneHelper CLIHelper.print_header('NUMA NODES', false) puts - # rubocop:disable Metrics/LineLength table = CLIHelper::ShowTable.new(nil, self) do column :ID, 'Node ID', :size => 4, :left => false do |d| d['NODE_ID'] @@ -1293,7 +1290,6 @@ class OneVMHelper < OpenNebulaHelper::OneHelper default :ID, :CPUS_IDS, :MEMORY, :TOTAL_CPUS end - # rubocop:enable Metrics/LineLength table.show(numa_nodes) end diff --git a/src/datastore/Datastore.cc b/src/datastore/Datastore.cc index a372b42723..d07cc5a437 100644 --- a/src/datastore/Datastore.cc +++ b/src/datastore/Datastore.cc @@ -946,7 +946,7 @@ int Datastore::from_xml(const string& xml) /* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */ -int Datastore::post_update_template(string& error_str) +int Datastore::post_update_template(string& error_str, Template *old_tmpl) { string new_ds_mad; string new_tm_mad; @@ -960,6 +960,34 @@ int Datastore::post_update_template(string& error_str) string old_tm_mad = tm_mad; string old_ds_mad = ds_mad; + static std::vector ro_options = { + "NFS_AUTO_ENABLE", + "NFS_AUTO_HOST", + "NFS_AUTO_PATH", + "NFS_AUTO_OPTS" + }; + + /* ---------------------------------------------------------------------- */ + /* Check read-only values (for images > 0) */ + /* ---------------------------------------------------------------------- */ + if ( images_size() > 0 && old_tmpl != nullptr) + { + for (const auto& opt : ro_options) + { + string old_v, new_v; + + get_template_attribute(opt, new_v); + + old_tmpl->get(opt, old_v); + + if ( old_v != new_v ) + { + error_str = "Cannot update NFS auto mount options in datastore with existing images"; + return -1; + } + } + } + /* ---------------------------------------------------------------------- */ /* Set the TYPE of the Datastore (class & template) */ /* ---------------------------------------------------------------------- */ diff --git a/src/datastore_mad/remotes/fs/clone b/src/datastore_mad/remotes/fs/clone index bdb4780433..7332a247ef 100755 --- a/src/datastore_mad/remotes/fs/clone +++ b/src/datastore_mad/remotes/fs/clone @@ -48,25 +48,41 @@ while IFS= read -r -d '' element; do done < <($XPATH /DS_DRIVER_ACTION_DATA/DATASTORE/BASE_PATH \ /DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/BRIDGE_LIST \ /DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/DRIVER \ + /DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/NFS_AUTO_ENABLE \ + /DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/NFS_AUTO_HOST \ + /DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/NFS_AUTO_PATH \ + /DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/NFS_AUTO_OPTS \ /DS_DRIVER_ACTION_DATA/IMAGE/PATH) unset i -BASE_PATH="${XPATH_ELEMENTS[i++]}" +DS_BASE_PATH="${XPATH_ELEMENTS[i++]}" BRIDGE_LIST="${XPATH_ELEMENTS[i++]}" DRIVER="${XPATH_ELEMENTS[i++]}" +ANFS_ENABLE="${XPATH_ELEMENTS[i++]}" +ANFS_HOST="${XPATH_ELEMENTS[i++]}" +ANFS_PATH="${XPATH_ELEMENTS[i++]}" +ANFS_OPTS="${XPATH_ELEMENTS[i++]}" SRC="${XPATH_ELEMENTS[i++]}" -set_up_datastore "$BASE_PATH" "$RESTRICTED_DIRS" "$SAFE_DIRS" +set_up_datastore "$DS_BASE_PATH" "$RESTRICTED_DIRS" "$SAFE_DIRS" DST=`generate_image_path` # ------------ Check if format conversion is required ------------- if [ "$DRIVER" = 'qcow2' ] || [ "$DRIVER" = 'raw' ]; then - CP_CMD="$QEMU_IMG convert -O $DRIVER $SRC $DST" + CP_CMD=$(cat < /dev/null; then + timeout -s KILL 30s sudo mount $ANFS_OPTS "$ANFS_HOST:$ANFS_PATH" "$DS_BASE_PATH" + touch "$DS_BASE_PATH/.automounted" +fi + +`autonfs_cleanup_command` +EOF + fi +} diff --git a/src/market/MarketPlace.cc b/src/market/MarketPlace.cc index 988b4670a9..51d56c9f55 100644 --- a/src/market/MarketPlace.cc +++ b/src/market/MarketPlace.cc @@ -399,7 +399,7 @@ int MarketPlace::from_xml(const std::string &xml_str) /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ -int MarketPlace::post_update_template(std::string& error) +int MarketPlace::post_update_template(std::string& error, Template *_old_tmpl) { std::string new_market_mad; diff --git a/src/market/MarketPlaceApp.cc b/src/market/MarketPlaceApp.cc index 943bea784d..07e3dc08e3 100644 --- a/src/market/MarketPlaceApp.cc +++ b/src/market/MarketPlaceApp.cc @@ -344,7 +344,7 @@ int MarketPlaceApp::from_xml(const std::string &xml_str) /* --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- */ -int MarketPlaceApp::post_update_template(string& error) +int MarketPlaceApp::post_update_template(string& error, Template *_old_tmpl) { // ------------------------------------------------------------------------- // Update well known attributes diff --git a/src/pool/PoolObjectSQL.cc b/src/pool/PoolObjectSQL.cc index b880d106e8..806c4553cb 100644 --- a/src/pool/PoolObjectSQL.cc +++ b/src/pool/PoolObjectSQL.cc @@ -294,13 +294,13 @@ int PoolObjectSQL::replace_template( return -1; } - obj_template = move(new_tmpl); + obj_template = std::move(new_tmpl); - if (post_update_template(error) == -1) + if (post_update_template(error, old_tmpl.get()) == -1) { if (old_tmpl) { - obj_template = move(old_tmpl); + obj_template = std::move(old_tmpl); } else { @@ -344,7 +344,9 @@ int PoolObjectSQL::append_template( error ="User Template includes a restricted attribute " + rname; return -1; } + old_tmpl = std::make_unique