Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package libstorage-ng for openSUSE:Factory checked in at 2021-08-12 09:01:01 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/libstorage-ng (Old) and /work/SRC/openSUSE:Factory/.libstorage-ng.new.1899 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "libstorage-ng" Thu Aug 12 09:01:01 2021 rev:126 rq:910783 version:4.4.33 Changes: -------- --- /work/SRC/openSUSE:Factory/libstorage-ng/libstorage-ng.changes 2021-08-04 22:29:21.217767678 +0200 +++ /work/SRC/openSUSE:Factory/.libstorage-ng.new.1899/libstorage-ng.changes 2021-08-12 09:01:46.866140017 +0200 @@ -1,0 +2,8 @@ +Mon Aug 9 06:47:35 UTC 2021 - [email protected] + +- merge gh#openSUSE/libstorage-ng#827 +- added function to rename a pool +- coding style +- 4.4.33 + +-------------------------------------------------------------------- Old: ---- libstorage-ng-4.4.32.tar.xz New: ---- libstorage-ng-4.4.33.tar.xz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ libstorage-ng.spec ++++++ --- /var/tmp/diff_new_pack.I29O7p/_old 2021-08-12 09:01:47.358139233 +0200 +++ /var/tmp/diff_new_pack.I29O7p/_new 2021-08-12 09:01:47.362139226 +0200 @@ -18,7 +18,7 @@ %define libname %{name}1 Name: libstorage-ng -Version: 4.4.32 +Version: 4.4.33 Release: 0 Summary: Library for storage management License: GPL-2.0-only ++++++ libstorage-ng-4.4.32.tar.xz -> libstorage-ng-4.4.33.tar.xz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libstorage-ng-4.4.32/LIBVERSION new/libstorage-ng-4.4.33/LIBVERSION --- old/libstorage-ng-4.4.32/LIBVERSION 2021-08-04 18:14:17.000000000 +0200 +++ new/libstorage-ng-4.4.33/LIBVERSION 2021-08-09 08:47:35.000000000 +0200 @@ -1 +1 @@ -1.59.0 +1.60.0 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libstorage-ng-4.4.32/VERSION new/libstorage-ng-4.4.33/VERSION --- old/libstorage-ng-4.4.32/VERSION 2021-08-04 18:14:17.000000000 +0200 +++ new/libstorage-ng-4.4.33/VERSION 2021-08-09 08:47:35.000000000 +0200 @@ -1 +1 @@ -4.4.32 +4.4.33 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libstorage-ng-4.4.32/bindings/storage-catches.i new/libstorage-ng-4.4.33/bindings/storage-catches.i --- old/libstorage-ng-4.4.32/bindings/storage-catches.i 2021-08-04 18:14:17.000000000 +0200 +++ new/libstorage-ng-4.4.33/bindings/storage-catches.i 2021-08-09 08:47:35.000000000 +0200 @@ -407,6 +407,7 @@ %catches(storage::Aborted, storage::Exception) storage::Storage::probe(const ProbeCallbacks *probe_callbacks=nullptr); %catches(storage::Exception) storage::Storage::remove_devicegraph(const std::string &name); %catches(storage::Exception) storage::Storage::remove_pool(const std::string &name); +%catches(storage::Exception) storage::Storage::rename_pool(const std::string &old_name, const std::string &new_name); %catches(storage::Exception) storage::Storage::restore_devicegraph(const std::string &name); %catches(storage::DeviceNotFound, storage::DeviceHasWrongType) storage::StrayBlkDevice::find_by_name(Devicegraph *devicegraph, const std::string &name); %catches(storage::DeviceNotFound, storage::DeviceHasWrongType) storage::StrayBlkDevice::find_by_name(const Devicegraph *devicegraph, const std::string &name); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libstorage-ng-4.4.32/storage/Devices/DiskImpl.cc new/libstorage-ng-4.4.33/storage/Devices/DiskImpl.cc --- old/libstorage-ng-4.4.32/storage/Devices/DiskImpl.cc 2021-08-04 18:14:17.000000000 +0200 +++ new/libstorage-ng-4.4.33/storage/Devices/DiskImpl.cc 2021-08-09 08:47:35.000000000 +0200 @@ -140,6 +140,13 @@ } + bool + Disk::Impl::is_brd() const + { + return boost::starts_with(get_name(), DEV_DIR "/ram"); + } + + void Disk::Impl::probe_disks(Prober& prober) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libstorage-ng-4.4.32/storage/Devices/DiskImpl.h new/libstorage-ng-4.4.33/storage/Devices/DiskImpl.h --- old/libstorage-ng-4.4.32/storage/Devices/DiskImpl.h 2021-08-04 18:14:17.000000000 +0200 +++ new/libstorage-ng-4.4.33/storage/Devices/DiskImpl.h 2021-08-09 08:47:35.000000000 +0200 @@ -84,6 +84,7 @@ bool is_pmem() const; bool is_nvme() const; + bool is_brd() const; const string& get_image_filename() const { return image_filename; } void set_image_filename(const string& image_filename) { Impl::image_filename = image_filename; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libstorage-ng-4.4.32/storage/Pool.cc new/libstorage-ng-4.4.33/storage/Pool.cc --- old/libstorage-ng-4.4.32/storage/Pool.cc 2021-08-04 18:14:17.000000000 +0200 +++ new/libstorage-ng-4.4.33/storage/Pool.cc 2021-08-09 08:47:35.000000000 +0200 @@ -68,6 +68,13 @@ } + bool + Pool::exists_device(const Device* device) const + { + return get_impl().exists_device(device); + } + + void Pool::add_device(const Device* device) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libstorage-ng-4.4.32/storage/Pool.h new/libstorage-ng-4.4.33/storage/Pool.h --- old/libstorage-ng-4.4.32/storage/Pool.h 2021-08-04 18:14:17.000000000 +0200 +++ new/libstorage-ng-4.4.33/storage/Pool.h 2021-08-09 08:47:35.000000000 +0200 @@ -97,6 +97,11 @@ void set_userdata(const std::map<std::string, std::string>& userdata); /** + * Check whether the device exists in the pool. + */ + bool exists_device(const Device* device) const; + + /** * Add a device to the pool. The devicegraph the device belongs to is irrelevant. * * @see remove_device(const Device*) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libstorage-ng-4.4.32/storage/PoolImpl.cc new/libstorage-ng-4.4.33/storage/PoolImpl.cc --- old/libstorage-ng-4.4.32/storage/PoolImpl.cc 2021-08-04 18:14:17.000000000 +0200 +++ new/libstorage-ng-4.4.33/storage/PoolImpl.cc 2021-08-09 08:47:35.000000000 +0200 @@ -32,6 +32,16 @@ namespace storage { + + bool + Pool::Impl::exists_device(const Device* device) const + { + ST_CHECK_PTR(device); + + return find(devices.begin(), devices.end(), device->get_sid()) != devices.end(); + } + + void Pool::Impl::add_device(const Device* device) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libstorage-ng-4.4.32/storage/PoolImpl.h new/libstorage-ng-4.4.33/storage/PoolImpl.h --- old/libstorage-ng-4.4.32/storage/PoolImpl.h 2021-08-04 18:14:17.000000000 +0200 +++ new/libstorage-ng-4.4.33/storage/PoolImpl.h 2021-08-09 08:47:35.000000000 +0200 @@ -46,6 +46,8 @@ const map<string, string>& get_userdata() const { return userdata; } void set_userdata(const map<string, string>& userdata) { Impl::userdata = userdata; } + bool exists_device(const Device* device) const; + void add_device(const Device* device); void remove_device(const Device* device); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libstorage-ng-4.4.32/storage/Storage.cc new/libstorage-ng-4.4.33/storage/Storage.cc --- old/libstorage-ng-4.4.32/storage/Storage.cc 2021-08-04 18:14:17.000000000 +0200 +++ new/libstorage-ng-4.4.33/storage/Storage.cc 2021-08-09 08:47:35.000000000 +0200 @@ -299,6 +299,13 @@ } + void + Storage::rename_pool(const std::string& old_name, const std::string& new_name) + { + get_impl().rename_pool(old_name, new_name); + } + + bool Storage::exists_pool(const std::string& name) const { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libstorage-ng-4.4.32/storage/Storage.h new/libstorage-ng-4.4.33/storage/Storage.h --- old/libstorage-ng-4.4.32/storage/Storage.h 2021-08-04 18:14:17.000000000 +0200 +++ new/libstorage-ng-4.4.33/storage/Storage.h 2021-08-09 08:47:35.000000000 +0200 @@ -479,6 +479,8 @@ * Generate pools, e.g. "HDDs (512 B)" for HDDs with 512 B sector size and "SSDs * (4 KiB)" for SSDs with 4 KiB sector size. The pools generated and their names * may change anytime. + * + * This function does not remove pools or devices from pools. It only adds things. */ void generate_pools(const Devicegraph* devicegraph); @@ -497,6 +499,13 @@ void remove_pool(const std::string& name); /** + * Rename a pool. + * + * @throw Exception + */ + void rename_pool(const std::string& old_name, const std::string& new_name); + + /** * Check whether a pool exists by name. */ bool exists_pool(const std::string& name) const; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libstorage-ng-4.4.32/storage/StorageImpl.cc new/libstorage-ng-4.4.33/storage/StorageImpl.cc --- old/libstorage-ng-4.4.32/storage/StorageImpl.cc 2021-08-04 18:14:17.000000000 +0200 +++ new/libstorage-ng-4.4.33/storage/StorageImpl.cc 2021-08-09 08:47:35.000000000 +0200 @@ -476,7 +476,6 @@ // TODO more types, e.g. dasd, multipath? // TODO check partition table? - // TODO do not add already existing devices for (const Disk* disk : Disk::get_all(devicegraph)) { @@ -489,6 +488,8 @@ name = "PMEMs"; else if (disk->is_nvme()) name = "NVMes"; + else if (disk->get_impl().is_brd()) + name = "BRDs"; else if (!disk->is_rotational()) name = "SSDs"; else @@ -497,7 +498,9 @@ name += " (" + byte_to_humanstring(disk->get_region().get_block_size(), false, 2, true) + ")"; Pool* pool = exists_pool(name) ? get_pool(name) : create_pool(name); - pool->add_device(disk); + + if (!pool->exists_device(disk)) + pool->add_device(disk); } } @@ -535,6 +538,23 @@ } + void + Storage::Impl::rename_pool(const string& old_name, const string& new_name) + { + pools_t::iterator it1 = pools.find(old_name); + if (it1 == pools.end()) + ST_THROW(Exception(sformat("pool '%s' not found", old_name))); + + pools_t::iterator it2 = pools.find(new_name); + if (it2 != pools.end()) + ST_THROW(Exception(sformat("pool '%s' already exists", new_name))); + + map<string, Pool>::node_type node = pools.extract(it1); + node.key() = new_name; + pools.insert(std::move(node)); + } + + bool Storage::Impl::exists_pool(const string& name) const { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libstorage-ng-4.4.32/storage/StorageImpl.h new/libstorage-ng-4.4.33/storage/StorageImpl.h --- old/libstorage-ng-4.4.32/storage/StorageImpl.h 2021-08-04 18:14:17.000000000 +0200 +++ new/libstorage-ng-4.4.33/storage/StorageImpl.h 2021-08-09 08:47:35.000000000 +0200 @@ -117,6 +117,8 @@ void remove_pool(const string& name); + void rename_pool(const string& old_name, const string& new_name); + bool exists_pool(const string& name) const; vector<string> get_pool_names() const; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libstorage-ng-4.4.32/storage/Utils/JsonFile.cc new/libstorage-ng-4.4.33/storage/Utils/JsonFile.cc --- old/libstorage-ng-4.4.32/storage/Utils/JsonFile.cc 2021-08-04 18:14:17.000000000 +0200 +++ new/libstorage-ng-4.4.33/storage/Utils/JsonFile.cc 2021-08-09 08:47:35.000000000 +0200 @@ -75,13 +75,12 @@ if (!json_object_object_get_ex(parent, name, &child)) return false; - if (json_object_is_type(child, json_type_string)) - { - value = json_object_get_string(child); - return true; - } + if (!json_object_is_type(child, json_type_string)) + return false; + + value = json_object_get_string(child); - return false; + return true; } @@ -94,15 +93,14 @@ if (!json_object_object_get_ex(parent, name, &child)) return false; - if (json_object_is_type(child, json_type_string)) - { - std::istringstream istr(json_object_get_string(child)); - classic(istr); - istr >> value; - return true; - } + if (!json_object_is_type(child, json_type_string)) + return false; - return false; + std::istringstream istr(json_object_get_string(child)); + classic(istr); + istr >> value; + + return true; } @@ -115,32 +113,33 @@ if (!json_object_object_get_ex(parent, name, &child)) return false; - if (json_object_is_type(child, json_type_string)) - { - std::istringstream istr(json_object_get_string(child)); - classic(istr); - istr >> value; - return true; - } + if (!json_object_is_type(child, json_type_string)) + return false; - return false; + std::istringstream istr(json_object_get_string(child)); + classic(istr); + istr >> value; + + return true; } bool get_child_nodes(json_object* parent, const char* name, vector<json_object*>& children) { - json_object* tmp; - json_object_object_get_ex(parent, name, &tmp); + json_object* child; + + if (!json_object_object_get_ex(parent, name, &child)) + return false; - if (!json_object_is_type(tmp, json_type_array)) + if (!json_object_is_type(child, json_type_array)) return false; children.clear(); - size_t s = json_object_array_length(tmp); + size_t s = json_object_array_length(child); for (size_t i = 0; i < s; ++i) - children.push_back(json_object_array_get_idx(tmp, i)); + children.push_back(json_object_array_get_idx(child, i)); return true; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libstorage-ng-4.4.32/storage/Utils/JsonFile.h new/libstorage-ng-4.4.33/storage/Utils/JsonFile.h --- old/libstorage-ng-4.4.32/storage/Utils/JsonFile.h 2021-08-04 18:14:17.000000000 +0200 +++ new/libstorage-ng-4.4.33/storage/Utils/JsonFile.h 2021-08-09 08:47:35.000000000 +0200 @@ -44,7 +44,7 @@ ~JsonFile(); - json_object* get_root() const { return root; } + json_object* get_root() { return root; } private:
