From 2cf4744cc0f735af738debac356c8e9d0849acad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20Czern=C3=BD?= Date: Mon, 3 Jun 2024 16:14:14 +0200 Subject: [PATCH] L #-: Astyle 6.4 (#3094) * Add AStyle to smoke tests * Format C++ code using AStyle --- .github/workflows/smoke_tests.yml | 2 + include/AclManager.h | 2 +- include/AclRule.h | 10 +- include/ActionSet.h | 4 +- include/AddressRange.h | 42 +- include/AddressRangeIPAM.h | 4 +- include/AddressRangeInternal.h | 4 +- include/AddressRangePool.h | 20 +- include/Attribute.h | 16 +- include/AuthManager.h | 20 +- include/AuthRequest.h | 12 +- include/BitMap.h | 6 +- include/Callbackable.h | 14 +- include/Client.h | 20 +- include/Cluster.h | 20 +- include/ClusterPool.h | 10 +- include/ClusterTemplate.h | 6 +- include/Clusterable.h | 4 +- include/ClusterableSingle.h | 4 +- include/Datastore.h | 8 +- include/DatastorePool.h | 28 +- include/DatastoreTemplate.h | 6 +- include/DefaultQuotas.h | 6 +- include/DispatchManager.h | 48 +- include/DocumentPool.h | 15 +- include/DocumentTemplate.h | 8 +- include/Driver.h | 53 +- include/DriverManager.h | 13 +- include/EnumString.h | 8 +- include/ExecuteHook.h | 2 +- include/ExtendedAttribute.h | 20 +- include/FedReplicaManager.h | 8 +- include/GroupPool.h | 4 +- include/History.h | 26 +- include/HookAPI.h | 2 +- include/HookManager.h | 2 +- include/HookPool.h | 6 +- include/HookStateHost.h | 2 +- include/HookStateImage.h | 2 +- include/HookStateVM.h | 2 +- include/HookStateVirtualNetwork.h | 2 +- include/Host.h | 29 +- include/HostPool.h | 24 +- include/HostShare.h | 2 +- include/HostShareDatastore.h | 4 +- include/HostShareNUMA.h | 10 +- include/HostSharePCI.h | 4 +- include/HostTemplate.h | 6 +- include/IPAMManager.h | 4 +- include/IPAMRequest.h | 6 +- include/Image.h | 12 +- include/ImageManager.h | 100 +- include/ImagePool.h | 42 +- include/ImageTemplate.h | 6 +- include/InformationManager.h | 12 +- include/LifeCycleManager.h | 2 +- include/Listener.h | 16 +- include/Log.h | 49 +- include/LogDB.h | 18 +- include/LoginToken.h | 16 +- include/MarketPlace.h | 7 +- include/MarketPlaceAppPool.h | 8 +- include/MarketPlaceAppTemplate.h | 4 +- include/MarketPlaceManager.h | 20 +- include/MarketPlacePool.h | 14 +- include/MarketPlaceTemplate.h | 4 +- include/Message.h | 18 +- include/MySqlDB.h | 5 +- include/Nebula.h | 48 +- include/NebulaLog.h | 41 +- include/NebulaService.h | 12 +- include/NebulaTemplate.h | 2 +- include/NebulaUtil.h | 36 +- include/ObjectCollection.h | 6 +- include/ObjectSQL.h | 10 +- include/ObjectXML.h | 2 +- include/OpenNebulaTemplate.h | 4 +- include/PoolObjectSQL.h | 52 +- include/PoolSQL.h | 32 +- include/PostgreSqlDB.h | 29 +- include/Quota.h | 82 +- include/QuotaDatastore.h | 6 +- include/QuotaImage.h | 6 +- include/QuotaNetwork.h | 16 +- include/QuotaVirtualMachine.h | 8 +- include/Quotas.h | 171 +- include/QuotasSQL.h | 26 +- include/RaftManager.h | 15 +- include/RankScheduler.h | 2 +- include/ReplicaManager.h | 10 +- include/ReplicaRequest.h | 4 +- include/ReplicaThread.h | 6 +- include/Request.h | 33 +- include/RequestManagerAcl.h | 10 +- include/RequestManagerAllocate.h | 134 +- include/RequestManagerAllocateDB.h | 8 +- include/RequestManagerChmod.h | 72 +- include/RequestManagerChown.h | 34 +- include/RequestManagerClone.h | 44 +- include/RequestManagerCluster.h | 84 +- include/RequestManagerConnection.h | 6 +- include/RequestManagerDatastore.h | 8 +- include/RequestManagerDelete.h | 4 +- include/RequestManagerDropDB.h | 6 +- include/RequestManagerGroup.h | 20 +- include/RequestManagerHook.h | 4 +- include/RequestManagerHost.h | 12 +- include/RequestManagerImage.h | 32 +- include/RequestManagerInfo.h | 6 +- include/RequestManagerMarketPlaceApp.h | 6 +- include/RequestManagerPoolInfoFilter.h | 36 +- include/RequestManagerProxy.h | 2 +- include/RequestManagerRename.h | 10 +- include/RequestManagerSystem.h | 44 +- include/RequestManagerUpdateDB.h | 16 +- include/RequestManagerUpdateTemplate.h | 38 +- include/RequestManagerUser.h | 38 +- include/RequestManagerVMTemplate.h | 14 +- include/RequestManagerVNTemplate.h | 6 +- include/RequestManagerVdc.h | 38 +- include/RequestManagerVirtualMachine.h | 158 +- include/RequestManagerVirtualNetwork.h | 48 +- include/RequestManagerVirtualRouter.h | 10 +- include/RequestManagerZone.h | 34 +- include/SSLUtil.h | 12 +- include/ScheduledAction.h | 16 +- include/SecurityGroup.h | 14 +- include/SecurityGroupPool.h | 8 +- include/Snapshots.h | 2 +- include/SqlDB.h | 19 +- include/StreamManager.h | 15 +- include/StringBuffer.h | 3 +- include/SystemDB.h | 16 +- include/Template.h | 34 +- include/TransferManager.h | 22 +- include/User.h | 8 +- include/UserPool.h | 26 +- include/UserTemplate.h | 2 +- include/VMActions.h | 5 +- include/VMGroup.h | 8 +- include/VMGroupPool.h | 16 +- include/VMGroupRole.h | 16 +- include/VMGroupRule.h | 2 +- include/VMTemplatePool.h | 10 +- include/VNTemplatePool.h | 8 +- include/Vdc.h | 10 +- include/VdcPool.h | 14 +- include/VirtualMachine.h | 60 +- include/VirtualMachineAttribute.h | 10 +- include/VirtualMachineDisk.h | 42 +- include/VirtualMachineManager.h | 26 +- include/VirtualMachineManagerDriver.h | 90 +- include/VirtualMachineMonitorInfo.h | 2 +- include/VirtualMachineNic.h | 28 +- include/VirtualMachinePool.h | 50 +- include/VirtualMachineTemplate.h | 14 +- include/VirtualNetwork.h | 26 +- include/VirtualNetworkPool.h | 60 +- include/VirtualNetworkTemplate.h | 6 +- include/VirtualRouter.h | 2 +- include/VirtualRouterPool.h | 14 +- include/XMLDriver.h | 4 +- include/XenDriver.h | 4 +- include/Zone.h | 11 +- include/ZonePool.h | 8 +- include/ZoneServer.h | 10 +- share/linters/.astylerc | 27 + share/smoke_tests/tests/05-astyle.sh | 26 + src/acl/AclManager.cc | 164 +- src/acl/AclRule.cc | 56 +- src/authm/AuthManager.cc | 22 +- src/client/Client.cc | 18 +- src/cluster/Cluster.cc | 16 +- src/cluster/ClusterPool.cc | 14 +- src/common/Attribute.cc | 18 +- src/common/ExtendedAttribute.cc | 2 +- src/common/NebulaUtil.cc | 29 +- src/common/SSLUtil.cc | 12 +- src/datastore/Datastore.cc | 38 +- src/datastore/DatastorePool.cc | 52 +- src/dm/DispatchManager.cc | 2 +- src/dm/DispatchManagerActions.cc | 191 +- src/dm/DispatchManagerStates.cc | 64 +- src/document/Document.cc | 24 +- src/group/Group.cc | 200 +- src/group/GroupPool.cc | 24 +- src/hm/ExecuteHook.cc | 7 +- src/hm/Hook.cc | 2 +- src/hm/HookAPI.cc | 23 +- src/hm/HookManager.cc | 28 +- src/hm/HookStateVM.cc | 4 +- src/host/Host.cc | 56 +- src/host/HostMonitoringTemplate.cc | 6 +- src/host/HostPool.cc | 16 +- src/host/HostShare.cc | 46 +- src/host/HostShareNUMA.cc | 32 +- src/host/HostSharePCI.cc | 18 +- src/im/InformationManager.cc | 40 +- src/image/Image.cc | 147 +- src/image/ImageManager.cc | 34 +- src/image/ImageManagerActions.cc | 166 +- src/image/ImageManagerProtocol.cc | 10 +- src/image/ImagePool.cc | 6 +- src/ipamm/IPAMManager.cc | 37 +- src/ipamm/IPAMManagerProtocol.cc | 16 +- src/lcm/LifeCycleActions.cc | 153 +- src/lcm/LifeCycleManager.cc | 2 +- src/lcm/LifeCycleStates.cc | 255 +- src/log/Log.cc | 34 +- src/market/MarketPlace.cc | 80 +- src/market/MarketPlaceApp.cc | 102 +- src/market/MarketPlaceAppPool.cc | 36 +- src/market/MarketPlaceManager.cc | 38 +- src/market/MarketPlaceManagerActions.cc | 56 +- src/market/MarketPlaceManagerProtocol.cc | 8 +- src/market/MarketPlacePool.cc | 52 +- src/monitor/include/HostMonitorManager.h | 8 +- src/monitor/include/MonitorConfigTemplate.h | 2 +- src/monitor/include/MonitorDriver.h | 14 +- src/monitor/include/RPCPool.h | 4 +- src/monitor/include/TCPMonitorDriver.h | 14 +- src/monitor/include/TCPStream.h | 12 +- src/monitor/include/UDPMonitorDriver.h | 14 +- src/monitor/include/UDPStream.h | 9 +- src/monitor/include/VirtualMachineBase.h | 2 +- src/monitor/src/data_model/HostRPCPool.cc | 7 +- src/monitor/src/data_model/VMRPCPool.cc | 4 +- .../src/data_model/VirtualMachineBase.cc | 2 +- src/monitor/src/monitor/HostMonitorManager.cc | 21 +- src/monitor/src/monitor/Monitor.cc | 18 +- .../src/monitor/MonitorConfigTemplate.cc | 22 +- .../src/monitor/MonitorDriverProtocol.cc | 47 +- src/monitor/src/monitor/OneMonitorDriver.cc | 18 +- src/monitor/src/monitor/onemonitord.cc | 7 +- src/nebula/Nebula.cc | 84 +- src/nebula/SystemDB.cc | 18 +- src/nebula/oned.cc | 10 +- src/pool/ObjectCollection.cc | 46 +- src/pool/PoolObjectSQL.cc | 46 +- src/pool/PoolSQL.cc | 14 +- src/protocol/Message.cc | 27 +- src/raft/FedReplicaManager.cc | 10 +- src/raft/RaftManager.cc | 41 +- src/raft/ReplicaManager.cc | 3 +- src/raft/ReplicaThread.cc | 22 +- src/rm/Request.cc | 60 +- src/rm/RequestManager.cc | 99 +- src/rm/RequestManagerAcl.cc | 14 +- src/rm/RequestManagerAllocate.cc | 58 +- src/rm/RequestManagerChmod.cc | 40 +- src/rm/RequestManagerChown.cc | 34 +- src/rm/RequestManagerClone.cc | 14 +- src/rm/RequestManagerCluster.cc | 4 +- src/rm/RequestManagerDatastore.cc | 2 +- src/rm/RequestManagerDelete.cc | 46 +- src/rm/RequestManagerGroup.cc | 8 +- src/rm/RequestManagerHook.cc | 2 +- src/rm/RequestManagerImage.cc | 30 +- src/rm/RequestManagerInfo.cc | 12 +- src/rm/RequestManagerLock.cc | 4 +- src/rm/RequestManagerMarketPlace.cc | 4 +- src/rm/RequestManagerMarketPlaceApp.cc | 4 +- src/rm/RequestManagerPoolInfoFilter.cc | 50 +- src/rm/RequestManagerProxy.cc | 2 +- src/rm/RequestManagerRename.cc | 2 +- src/rm/RequestManagerSecurityGroup.cc | 2 +- src/rm/RequestManagerSystem.cc | 20 +- src/rm/RequestManagerUser.cc | 40 +- src/rm/RequestManagerVMTemplate.cc | 52 +- src/rm/RequestManagerVNTemplate.cc | 14 +- src/rm/RequestManagerVdc.cc | 6 +- src/rm/RequestManagerVirtualMachine.cc | 167 +- src/rm/RequestManagerVirtualNetwork.cc | 40 +- src/rm/RequestManagerVirtualRouter.cc | 2 +- src/rm/RequestManagerZone.cc | 38 +- src/scheduler/include/AclXML.h | 2 +- src/scheduler/include/ClusterPoolXML.h | 4 +- src/scheduler/include/DatastorePoolXML.h | 8 +- src/scheduler/include/HostPoolXML.h | 2 +- src/scheduler/include/HostXML.h | 4 +- src/scheduler/include/MonitorXML.h | 6 +- src/scheduler/include/PoolXML.h | 8 +- src/scheduler/include/RankPolicy.h | 26 +- src/scheduler/include/Resource.h | 9 +- src/scheduler/include/Scheduler.h | 2 +- src/scheduler/include/SchedulerPolicy.h | 10 +- src/scheduler/include/SchedulerTemplate.h | 4 +- src/scheduler/include/UserPoolXML.h | 4 +- src/scheduler/include/UserPriorityPolicy.h | 4 +- src/scheduler/include/UserXML.h | 2 +- src/scheduler/include/VMGroupPoolXML.h | 4 +- src/scheduler/include/VMGroupXML.h | 6 +- src/scheduler/include/VirtualMachinePoolXML.h | 12 +- src/scheduler/include/VirtualMachineXML.h | 6 +- src/scheduler/include/VirtualNetworkPoolXML.h | 2 +- src/scheduler/src/pool/AclXML.cc | 6 +- src/scheduler/src/pool/ClusterPoolXML.cc | 4 +- src/scheduler/src/pool/DatastorePoolXML.cc | 4 +- src/scheduler/src/pool/DatastoreXML.cc | 3 +- src/scheduler/src/pool/HostPoolXML.cc | 6 +- src/scheduler/src/pool/HostXML.cc | 6 +- src/scheduler/src/pool/UserPoolXML.cc | 4 +- src/scheduler/src/pool/VMGroupPoolXML.cc | 4 +- src/scheduler/src/pool/VMGroupXML.cc | 12 +- .../src/pool/VirtualMachinePoolXML.cc | 30 +- src/scheduler/src/pool/VirtualMachineXML.cc | 56 +- .../src/pool/VirtualNetworkPoolXML.cc | 6 +- src/scheduler/src/pool/VirtualNetworkXML.cc | 7 +- src/scheduler/src/sched/Scheduler.cc | 88 +- src/scheduler/src/sched/SchedulerTemplate.cc | 88 +- src/secgroup/SecurityGroup.cc | 27 +- src/secgroup/SecurityGroupPool.cc | 18 +- src/sql/LogDB.cc | 16 +- src/sql/MySqlDB.cc | 29 +- src/sql/OneDB.cc | 200 +- src/sql/PostgreSqlDB.cc | 15 +- src/sql/SqlDB.cc | 2 +- src/sql/SqliteDB.cc | 15 +- src/svncterm_server/glyphs.h | 144574 ++++++++------- src/svncterm_server/svncterm.h | 404 +- src/template/NebulaTemplate.cc | 6 +- src/template/OpenNebulaTemplate.cc | 460 +- src/template/Template.cc | 32 +- src/tm/TransferManager.cc | 524 +- src/um/Quota.cc | 8 +- src/um/QuotaImage.cc | 10 +- src/um/QuotaNetwork.cc | 6 +- src/um/QuotaVirtualMachine.cc | 9 +- src/um/Quotas.cc | 20 +- src/um/QuotasSQL.cc | 6 +- src/um/User.cc | 30 +- src/um/UserPool.cc | 148 +- src/vdc/Vdc.cc | 62 +- src/vdc/VdcPool.cc | 20 +- src/vm/History.cc | 244 +- src/vm/Snapshots.cc | 2 +- src/vm/VMActions.cc | 102 +- src/vm/VirtualMachine.cc | 452 +- src/vm/VirtualMachineContext.cc | 58 +- src/vm/VirtualMachineDisk.cc | 185 +- src/vm/VirtualMachineNic.cc | 26 +- src/vm/VirtualMachineParser.cc | 46 +- src/vm/VirtualMachinePool.cc | 120 +- src/vm/VirtualMachineSystemSnapshot.cc | 2 +- src/vm/VirtualMachineTemplate.cc | 99 +- src/vm_group/VMGroup.cc | 14 +- src/vm_group/VMGroupPool.cc | 8 +- src/vm_group/VMGroupRole.cc | 4 +- src/vm_group/VMGroupRule.cc | 2 +- src/vm_template/ScheduledAction.cc | 12 +- src/vm_template/VMTemplate.cc | 24 +- src/vmm/LibVirtDriverKVM.cc | 95 +- src/vmm/VirtualMachineManager.cc | 1279 +- src/vmm/VirtualMachineManagerDriver.cc | 30 +- src/vmm/VirtualMachineManagerProtocol.cc | 48 +- src/vmm/XMLDriver.cc | 4 +- src/vmm/XenDriver.cc | 36 +- src/vn_template/VNTemplate.cc | 26 +- src/vnm/AddressRange.cc | 138 +- src/vnm/AddressRangeIPAM.cc | 4 +- src/vnm/AddressRangeInternal.cc | 2 +- src/vnm/AddressRangePool.cc | 56 +- src/vnm/VirtualNetwork.cc | 100 +- src/vnm/VirtualNetworkPool.cc | 48 +- src/vrouter/VirtualRouter.cc | 44 +- src/xml/ObjectXML.cc | 24 +- src/zone/Zone.cc | 14 +- src/zone/ZonePool.cc | 26 +- 368 files changed, 79076 insertions(+), 78640 deletions(-) create mode 100644 share/linters/.astylerc create mode 100755 share/smoke_tests/tests/05-astyle.sh diff --git a/.github/workflows/smoke_tests.yml b/.github/workflows/smoke_tests.yml index 9540ef7eb1..72833439e6 100644 --- a/.github/workflows/smoke_tests.yml +++ b/.github/workflows/smoke_tests.yml @@ -16,6 +16,8 @@ jobs: run: gem install rubocop - name: Install CppCheck run: sudo apt install -y cppcheck + - name: Install AStyle + run: sudo apt install -y astyle # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - uses: actions/checkout@v3 diff --git a/include/AclManager.h b/include/AclManager.h index eb665666e9..7e96e8bf1f 100644 --- a/include/AclManager.h +++ b/include/AclManager.h @@ -90,7 +90,7 @@ public: * @return true if the authorization is granted for oneadmin */ bool oneadmin_authorize(const PoolObjectAuth& obj_perms, - AuthRequest::Operation op) const; + AuthRequest::Operation op) const; /** * Adds a new rule to the ACL rule set diff --git a/include/AclRule.h b/include/AclRule.h index f1b709ac4a..43d6d02fbc 100644 --- a/include/AclRule.h +++ b/include/AclRule.h @@ -64,11 +64,11 @@ public: /** * Set the fields of the ACL, and updates its representation */ - void set(int _oid, - long long _user, - long long _resource, - long long _rights, - long long _zone) + void set(int _oid, + long long _user, + long long _resource, + long long _rights, + long long _zone) { oid = _oid; user = _user; diff --git a/include/ActionSet.h b/include/ActionSet.h index c9a56f22f3..683c9c269c 100644 --- a/include/ActionSet.h +++ b/include/ActionSet.h @@ -28,7 +28,7 @@ template class ActionSet { public: - ActionSet():action_set(0UL){}; + ActionSet():action_set(0UL) {}; ActionSet(const T * actions, int actions_len):action_set(0) { for (int i=0; i& vms, - const std::vector& vnets, const std::vector& vrs) const; + const std::vector& vnets, const std::vector& vrs) const; /** * Same as above but without the LEASES section @@ -188,7 +188,7 @@ public: * @return 0 if success */ int allocate_addr(PoolObjectSQL::ObjectType ot, int obid, - VectorAttribute * nic, const std::vector &inherit); + VectorAttribute * nic, const std::vector &inherit); /** * Returns the specific address by mac/ip if is not allocated. The NIC attr @@ -201,13 +201,13 @@ public: * @return 0 if success */ int allocate_by_mac(const std::string& mac, PoolObjectSQL::ObjectType ot, - int obid, VectorAttribute * nic, const std::vector &inherit); + int obid, VectorAttribute * nic, const std::vector &inherit); int allocate_by_ip(const std::string& ip, PoolObjectSQL::ObjectType ot, - int obid, VectorAttribute * nic, const std::vector &inherit); + int obid, VectorAttribute * nic, const std::vector &inherit); int allocate_by_ip6(const std::string& ip6, PoolObjectSQL::ObjectType ot, - int obid, VectorAttribute * nic, const std::vector &inherit); + int obid, VectorAttribute * nic, const std::vector &inherit); /** * Sets the given ip/mac on hold, the address is associated to a VM of @@ -231,7 +231,7 @@ public: int free_addr_by_ip(PoolObjectSQL::ObjectType ot, int id, const std::string& ip); - int free_addr_by_ip6(PoolObjectSQL::ObjectType ot, int id,const std::string& ip); + int free_addr_by_ip6(PoolObjectSQL::ObjectType ot, int id, const std::string& ip); /** * Frees all previous allocated address to the given object @@ -251,7 +251,7 @@ public: * @return the number of addresses freed */ int free_addr_by_range(PoolObjectSQL::ObjectType ot, int obid, - const std::string& mac, unsigned int rsize); + const std::string& mac, unsigned int rsize); /** * Adds the relevant AR definition attributes to the Security Group rule @@ -282,13 +282,13 @@ public: * @return 0 on success */ int reserve_addr_by_mac(int vid, unsigned int rsize, const std::string& mac, - AddressRange *rar); + AddressRange *rar); int reserve_addr_by_ip(int vid, unsigned int rsize, const std::string& ip, - AddressRange *rar); + AddressRange *rar); int reserve_addr_by_ip6(int vid, unsigned int rsize, const std::string& ip, - AddressRange *rar); + AddressRange *rar); // ************************************************************************* // Helpers @@ -415,7 +415,7 @@ protected: * Base constructor it cannot be called directly but from the * AddressRange factory constructor. */ - AddressRange(unsigned int _id):id(_id){}; + AddressRange(unsigned int _id):id(_id) {}; /* ---------------------------------------------------------------------- */ /* Address/AR helper functions to build/parse driver messages */ @@ -440,7 +440,7 @@ protected: * @param oss string stream to write the request to */ void addr_to_xml(unsigned int index, unsigned int size, - std::ostringstream& oss) const; + std::ostringstream& oss) const; /** * Check if the given MAC is valid for this address range by verifying: @@ -589,7 +589,7 @@ private: * @return 0 on success */ static int ip6_to_s(const unsigned int prefix[], const unsigned int mac[], - std::string& ip6_s); + std::string& ip6_s); static int ip6_to_s(const unsigned int ip6_i[], std::string& ip6_s); @@ -664,7 +664,7 @@ private: * Adds a new allocated address to the map. Updates the ALLOCATED attribute */ void set_allocated_addr(PoolObjectSQL::ObjectType ot, int obid, - unsigned int addr_index); + unsigned int addr_index); /** * Sets the address lease as used and fills a NIC attribute with the @@ -677,16 +677,16 @@ private: * @return 0 if success */ void allocate_by_index(unsigned int index, - PoolObjectSQL::ObjectType ot, - int obid, - VectorAttribute* nic, - const std::vector& inherit); + PoolObjectSQL::ObjectType ot, + int obid, + VectorAttribute* nic, + const std::vector& inherit); /** * Frees an address from the map. Updates the ALLOCATED attribute */ int free_allocated_addr(PoolObjectSQL::ObjectType ot, int obid, - unsigned int addr_index); + unsigned int addr_index); /** * Reserve a set of addresses from an starting one @@ -697,7 +697,7 @@ private: * @return 0 on success */ int reserve_addr_by_index(int vid, unsigned int rsize, unsigned int sindex, - AddressRange *rar); + AddressRange *rar); /* ---------------------------------------------------------------------- */ /* Restricted Attributes functions */ diff --git a/include/AddressRangeIPAM.h b/include/AddressRangeIPAM.h index 2ef740833e..e2b3e5cef0 100644 --- a/include/AddressRangeIPAM.h +++ b/include/AddressRangeIPAM.h @@ -26,9 +26,9 @@ class VectorAttribute; class AddressRangeIPAM : public AddressRange { public: - AddressRangeIPAM(unsigned int _id):AddressRange(_id){}; + AddressRangeIPAM(unsigned int _id):AddressRange(_id) {}; - virtual ~AddressRangeIPAM(){}; + virtual ~AddressRangeIPAM() {}; /* ---------------------------------------------------------------------- */ /* AddressRange Interface */ diff --git a/include/AddressRangeInternal.h b/include/AddressRangeInternal.h index 5d138019a9..07d3c2f4ad 100644 --- a/include/AddressRangeInternal.h +++ b/include/AddressRangeInternal.h @@ -26,9 +26,9 @@ class VectorAttribute; class AddressRangeInternal : public AddressRange { public: - AddressRangeInternal(unsigned int _id):AddressRange(_id), next(0){}; + AddressRangeInternal(unsigned int _id):AddressRange(_id), next(0) {}; - virtual ~AddressRangeInternal(){}; + virtual ~AddressRangeInternal() {}; /* ---------------------------------------------------------------------- */ /* AddressRange Interface */ diff --git a/include/AddressRangePool.h b/include/AddressRangePool.h index 03fd62e4b8..196f7969e3 100644 --- a/include/AddressRangePool.h +++ b/include/AddressRangePool.h @@ -88,7 +88,7 @@ public: * @return 0 on success */ int update_ar(std::vector ars, bool keep_restricted, - std::string& error_msg); + std::string& error_msg); /** * Allocates a new *empty* address range. It is not added to the pool as it * needs to be initialized. Only the AR_ID is set. @@ -119,7 +119,7 @@ public: * @return 0 if success */ int allocate_addr(PoolObjectSQL::ObjectType ot, int obid, - VectorAttribute * nic, const std::vector &inherit); + VectorAttribute * nic, const std::vector &inherit); /** * Allocates an address in a suitable address range from the pool by mac/ip @@ -173,13 +173,13 @@ public: * @param mac/ip the specific MAC/IP address requested */ void free_addr(unsigned int arid, PoolObjectSQL::ObjectType ot, int obid, - const std::string& mac); + const std::string& mac); void free_addr_by_ip(unsigned int arid, PoolObjectSQL::ObjectType ot, - int obid, const std::string& ip); + int obid, const std::string& ip); void free_addr_by_ip6(unsigned int arid, PoolObjectSQL::ObjectType ot, - int obid, const std::string& ip); + int obid, const std::string& ip); /** * Frees the given address by MAC/IP from all address ranges containing @@ -214,7 +214,7 @@ public: * @param rsize size of the address range */ int free_addr_by_range(unsigned int arid, PoolObjectSQL::ObjectType ot, - int obid, const std::string& mac, unsigned int rsize); + int obid, const std::string& mac, unsigned int rsize); /** * From a Security Group rule that uses this vnet, creates a new rule @@ -251,7 +251,7 @@ public: * @return 0 on success */ int reserve_addr(int vid, unsigned int rsize, unsigned int ar_id, - AddressRange *rar); + AddressRange *rar); /** * Reserve a number of addresses from an address range from a given ip/mac @@ -263,13 +263,13 @@ public: * @return 0 on success */ int reserve_addr_by_mac(int vid, unsigned int rsize, unsigned int ar_id, - const std::string& mac, AddressRange *rar); + const std::string& mac, AddressRange *rar); int reserve_addr_by_ip(int vid, unsigned int rsize, unsigned int ar_id, - const std::string& ip, AddressRange *rar); + const std::string& ip, AddressRange *rar); int reserve_addr_by_ip6(int vid, unsigned int rsize, unsigned int ar_id, - const std::string& ip, AddressRange *rar); + const std::string& ip, AddressRange *rar); // ************************************************************************* diff --git a/include/Attribute.h b/include/Attribute.h index 80e2109403..63aca38f38 100644 --- a/include/Attribute.h +++ b/include/Attribute.h @@ -45,11 +45,11 @@ public: if ((size >0 && !(isalpha(aname[0]) || aname[0] == '_')) || (size >=3 && (aname[0]=='X' && aname[1]=='M' && aname[2]=='L'))) { - attribute_name.insert(0,"ONE_"); + attribute_name.insert(0, "ONE_"); } }; - virtual ~Attribute(){}; + virtual ~Attribute() {}; enum AttributeType { @@ -144,7 +144,7 @@ public: , attribute_value(sa.attribute_value) {} - ~SingleAttribute(){}; + ~SingleAttribute() {}; /** * Returns the attribute value, a string. @@ -261,7 +261,7 @@ public: {} VectorAttribute(const std::string& name, - const std::map& value) + const std::map& value) : Attribute(name) , attribute_value(value) {} @@ -275,12 +275,12 @@ public: VectorAttribute& operator=(const VectorAttribute& va) = default; - ~VectorAttribute(){}; + ~VectorAttribute() {}; /** * Returns the attribute value, a string. */ - const std::map& value() const + const std::map& value() const { return attribute_value; }; @@ -443,7 +443,7 @@ public: /** * Replace the value of the given attribute with the provided map */ - void replace(const std::map& attr); + void replace(const std::map& attr); /** * The attributes from vattr will be copied to this vector @@ -536,7 +536,7 @@ private: static const int magic_sep_size; - std::map attribute_value; + std::map attribute_value; }; #endif /*ATTRIBUTE_H_*/ diff --git a/include/AuthManager.h b/include/AuthManager.h index 68dc136bf3..2c3142210a 100644 --- a/include/AuthManager.h +++ b/include/AuthManager.h @@ -29,17 +29,17 @@ class AuthRequest; class AuthManager : public DriverManager>, - public Listener + public Listener { public: AuthManager( - time_t timer, - const std::string& mads_location) - : DriverManager(mads_location) - , Listener("Authorization Manager") - , timer_thread(timer, [this](){timer_action();}) - , authz_enabled(false) + time_t timer, + const std::string& mads_location) + : DriverManager(mads_location) + , Listener("Authorization Manager") + , timer_thread(timer, [this]() {timer_action();}) + , authz_enabled(false) { } @@ -88,9 +88,9 @@ private: */ static const char * auth_driver_name; - /** - * True if there is an authorization driver enabled - */ + /** + * True if there is an authorization driver enabled + */ bool authz_enabled; /** diff --git a/include/AuthRequest.h b/include/AuthRequest.h index 0e2bbe4f4d..53619a6952 100644 --- a/include/AuthRequest.h +++ b/include/AuthRequest.h @@ -40,7 +40,7 @@ public: , self_authorize(true) {} - ~AuthRequest(){}; + ~AuthRequest() {}; /** * Authorization Request Type @@ -78,11 +78,11 @@ public: static Operation str_to_operation(const std::string& str) { - if (str == "USE") return USE; - else if (str == "MANAGE") return MANAGE; - else if (str == "ADMIN") return ADMIN; - else if (str == "CREATE") return CREATE; - else return NONE; + if (str == "USE") return USE; + else if (str == "MANAGE") return MANAGE; + else if (str == "ADMIN") return ADMIN; + else if (str == "CREATE") return CREATE; + else return NONE; }; /** diff --git a/include/BitMap.h b/include/BitMap.h index ab4f335d32..1fa2a473eb 100644 --- a/include/BitMap.h +++ b/include/BitMap.h @@ -175,7 +175,7 @@ public: { bs->reset(bit); } - catch(const std::out_of_range& oor){}; + catch(const std::out_of_range& oor) {}; } /** @@ -196,7 +196,7 @@ public: rc = 0; } } - catch(const std::out_of_range& oor){}; + catch(const std::out_of_range& oor) {}; return rc; } @@ -304,7 +304,7 @@ private: else { oss << "INSERT INTO " << db_table << " (id, map) VALUES (" - << id << ",'" << ezipped64 << "')"; + << id << ",'" << ezipped64 << "')"; } int rc = db->exec_wr(oss); diff --git a/include/Callbackable.h b/include/Callbackable.h index 8e5f597083..b37c143014 100644 --- a/include/Callbackable.h +++ b/include/Callbackable.h @@ -43,7 +43,7 @@ public: /** * Datatype for call back pointers */ - typedef int (Callbackable::*Callback)(void *, int, char ** ,char **); + typedef int (Callbackable::*Callback)(void *, int, char **, char **); /** * Set the callback function and custom arguments to be executed by the @@ -91,9 +91,9 @@ public: _mutex.unlock(); } - /** - * set affected rows variable - */ + /** + * set affected rows variable + */ void set_affected_rows(int num_rows) { affected_rows = num_rows; @@ -277,7 +277,7 @@ private: class string_cb : public Callbackable { public: - string_cb(int _total):total_values(_total){}; + string_cb(int _total):total_values(_total) {}; void set_callback(std::string * _str) { @@ -317,7 +317,7 @@ private: class stream_cb : public Callbackable { public: - stream_cb(int _total): total_values(_total){}; + stream_cb(int _total): total_values(_total) {}; void set_callback(std::ostringstream * _oss) { @@ -358,7 +358,7 @@ private: class empty_cb : public Callbackable { public: - void set_callback(Callback _cb, void * _arg = 0){}; + void set_callback(Callback _cb, void * _arg = 0) {}; bool isCallBackSet() override { diff --git a/include/Client.h b/include/Client.h index 84b2b1e81a..81f4bd8bd8 100644 --- a/include/Client.h +++ b/include/Client.h @@ -48,7 +48,7 @@ public: * Singleton initializer */ static Client * initialize(const std::string& secret, - const std::string& endpoint, size_t message_size, unsigned int tout) + const std::string& endpoint, size_t message_size, unsigned int tout) { if ( _client == 0 ) { @@ -69,16 +69,16 @@ public: */ static int read_oneauth(std::string &secret, std::string& error); - /** + /** * Performs a xmlrpc call to the initialized server * @param method name * @param plist initialized param list * @param result of the xmlrpc call */ void call(const std::string& method, const xmlrpc_c::paramList& plist, - xmlrpc_c::value * const result); + xmlrpc_c::value * const result); - /** + /** * Performs a xmlrpc call * @param endpoint of server * @param method name @@ -89,10 +89,10 @@ public: * @return 0 */ static int call(const std::string& endpoint, const std::string& method, - const xmlrpc_c::paramList& plist, unsigned int _timeout, - xmlrpc_c::value * const result, std::string& error); + const xmlrpc_c::paramList& plist, unsigned int _timeout, + xmlrpc_c::value * const result, std::string& error); - /** + /** * Performs an xmlrpc call to the initialized server and credentials. * This method automatically adds the credential argument. * @param method name @@ -102,7 +102,7 @@ public: * @param ... xmlrpc arguments */ void call(const std::string &method, const std::string &format, - xmlrpc_c::value * const result, ...); + xmlrpc_c::value * const result, ...); private: /** @@ -117,12 +117,12 @@ private: * @throws Exception if the authorization options are invalid */ Client(const std::string& secret, const std::string& endpoint, size_t message_size, - unsigned int tout); + unsigned int tout); std::string one_auth; std::string one_endpoint; - unsigned int timeout; + unsigned int timeout; static Client * _client; }; diff --git a/include/Cluster.h b/include/Cluster.h index 1bef698be6..1ae18235f3 100644 --- a/include/Cluster.h +++ b/include/Cluster.h @@ -122,7 +122,7 @@ private: unsigned int base_port = vnc_bitmap.get_start_bit(); unsigned int hint_port = base_port + (vmid % (65535 - base_port)); - return vnc_bitmap.get(hint_port,port); + return vnc_bitmap.get(hint_port, port); } void release_vnc_port(int port) @@ -233,17 +233,17 @@ private: * @param db pointer to the db * @return 0 on success */ - int select(SqlDB *db, const std::string& _name, int _uid) override - { - int rc = PoolObjectSQL::select(db, _name, _uid); + int select(SqlDB *db, const std::string& _name, int _uid) override + { + int rc = PoolObjectSQL::select(db, _name, _uid); - if ( rc != 0 ) - { - return rc; - } + if ( rc != 0 ) + { + return rc; + } - return vnc_bitmap.select(oid, db); - } + return vnc_bitmap.select(oid, db); + } /** * Checks if all the collections are empty, and therefore this cluster diff --git a/include/ClusterPool.h b/include/ClusterPool.h index eaac082ca9..5d0f64a10f 100644 --- a/include/ClusterPool.h +++ b/include/ClusterPool.h @@ -29,7 +29,7 @@ public: const VectorAttribute * vnc_conf, const std::vector& encrypted_attrs); - ~ClusterPool(){}; + ~ClusterPool() {}; /* ---------------------------------------------------------------------- */ /* Constants for DB management */ @@ -175,7 +175,7 @@ public: rc = Cluster::bootstrap(_db); rc += _db->exec_local_wr( - BitMap<0>::bootstrap(one_db::cluster_bitmap_table, oss_bitmap)); + BitMap<0>::bootstrap(one_db::cluster_bitmap_table, oss_bitmap)); return rc; }; @@ -192,7 +192,7 @@ public: * @return 0 on success */ int dump(std::string& oss, const std::string& where, int sid, int eid, - bool desc) override + bool desc) override { return PoolSQL::dump(oss, "CLUSTER_POOL", "body", one_db::cluster_table, where, @@ -207,7 +207,7 @@ public: * @param cids vector of cluster ids */ static void cluster_acl_filter(std::ostringstream& filter, - PoolObjectSQL::ObjectType auth_object, const std::vector& cids); + PoolObjectSQL::ObjectType auth_object, const std::vector& cids); /** * Returns the Datastore Clusters performing a DB query @@ -269,7 +269,7 @@ private: */ PoolObjectSQL * create() override { - return new Cluster(-1,"",0, &vnc_conf); + return new Cluster(-1, "", 0, &vnc_conf); }; }; diff --git a/include/ClusterTemplate.h b/include/ClusterTemplate.h index a4e326816a..beda21e831 100644 --- a/include/ClusterTemplate.h +++ b/include/ClusterTemplate.h @@ -27,11 +27,11 @@ class ClusterTemplate : public Template { public: ClusterTemplate(): - Template(false,'=',"TEMPLATE"){}; + Template(false, '=', "TEMPLATE") {}; - ~ClusterTemplate(){}; + ~ClusterTemplate() {}; - ClusterTemplate(ClusterTemplate& ct):Template(ct){}; + ClusterTemplate(ClusterTemplate& ct):Template(ct) {}; // ------------------------------------------------------------------------- // Encrypted attributes interface implementation diff --git a/include/Clusterable.h b/include/Clusterable.h index aba37a1918..529f67b293 100644 --- a/include/Clusterable.h +++ b/include/Clusterable.h @@ -69,9 +69,9 @@ public: protected: Clusterable(const std::set &_cluster_ids): - cluster_ids("CLUSTERS", _cluster_ids){}; + cluster_ids("CLUSTERS", _cluster_ids) {}; - ~Clusterable(){}; + ~Clusterable() {}; /** * IDs of the clusters this object belongs to. diff --git a/include/ClusterableSingle.h b/include/ClusterableSingle.h index 79b6d3d8c8..31c49468f5 100644 --- a/include/ClusterableSingle.h +++ b/include/ClusterableSingle.h @@ -58,9 +58,9 @@ protected: ClusterableSingle(int _cluster_id, const std::string& _cluster): cluster_id(_cluster_id), - cluster(_cluster){}; + cluster(_cluster) {}; - ~ClusterableSingle(){}; + ~ClusterableSingle() {}; /** * ID of the cluster this object belongs to. diff --git a/include/Datastore.h b/include/Datastore.h index af55b20268..925a161053 100644 --- a/include/Datastore.h +++ b/include/Datastore.h @@ -318,22 +318,22 @@ private: /** * Disk types for the Images created in this datastore */ - Image::DiskType disk_type; + Image::DiskType disk_type; /** * Total datastore capacity in MB */ - long long total_mb; + long long total_mb; /** * Available datastore capacity in MB */ - long long free_mb; + long long free_mb; /** * Used datastore capacity in MB */ - long long used_mb; + long long used_mb; /** * Datastore state diff --git a/include/DatastorePool.h b/include/DatastorePool.h index b683c07152..58c09d3695 100644 --- a/include/DatastorePool.h +++ b/include/DatastorePool.h @@ -29,7 +29,7 @@ public: const std::vector& _inherit_attrs, const std::vector& encrypted_attrs); - ~DatastorePool(){}; + ~DatastorePool() {}; /* ---------------------------------------------------------------------- */ /* Constants for DB management */ @@ -149,10 +149,10 @@ public: * @return 0 on success */ int dump(std::string& oss, const std::string& where, int sid, int eid, - bool desc) override + bool desc) override { return PoolSQL::dump(oss, "DATASTORE_POOL", "body", one_db::ds_table, - where, sid, eid, desc); + where, sid, eid, desc); }; /** @@ -161,18 +161,18 @@ public: * * @return 0 on success */ - int list(std::vector& oids) - { + int list(std::vector& oids) + { return PoolSQL::list(oids, one_db::ds_table); - } + } - /** - * Adds to the disk the datastore inherit attributes and conf values - * @param ds_id of the datastore to use - * @para disk vector attribute for the disk - * - * @return -1 if the DS does not exists - */ + /** + * Adds to the disk the datastore inherit attributes and conf values + * @param ds_id of the datastore to use + * @para disk vector attribute for the disk + * + * @return -1 if the DS does not exists + */ int disk_attribute(int ds_id, VirtualMachineDisk * disk); /** @@ -209,7 +209,7 @@ private: { std::set empty; - return new Datastore(-1,-1,"","", 0, 0, empty); + return new Datastore(-1, -1, "", "", 0, 0, empty); }; }; diff --git a/include/DatastoreTemplate.h b/include/DatastoreTemplate.h index 40924b021a..618bca68db 100644 --- a/include/DatastoreTemplate.h +++ b/include/DatastoreTemplate.h @@ -27,11 +27,11 @@ class DatastoreTemplate : public Template { public: DatastoreTemplate(): - Template(false,'=',"TEMPLATE"){}; + Template(false, '=', "TEMPLATE") {}; - ~DatastoreTemplate(){}; + ~DatastoreTemplate() {}; - DatastoreTemplate(DatastoreTemplate& dt):Template(dt){}; + DatastoreTemplate(DatastoreTemplate& dt):Template(dt) {}; // ------------------------------------------------------------------------- // Encrypted attributes interface implementation diff --git a/include/DefaultQuotas.h b/include/DefaultQuotas.h index 041a9bcd42..fa8df56e4e 100644 --- a/include/DefaultQuotas.h +++ b/include/DefaultQuotas.h @@ -28,11 +28,11 @@ public: const char * _net_xpath, const char * _img_xpath, const char * _vm_xpath): - Quotas(_ds_xpath, _net_xpath, _img_xpath, _vm_xpath, true), - root_elem(_root_elem) + Quotas(_ds_xpath, _net_xpath, _img_xpath, _vm_xpath, true), + root_elem(_root_elem) {}; - ~DefaultQuotas(){}; + ~DefaultQuotas() {}; /** * Generates a string representation of the quotas in XML format diff --git a/include/DispatchManager.h b/include/DispatchManager.h index 0de08a9a69..46a990e15b 100644 --- a/include/DispatchManager.h +++ b/include/DispatchManager.h @@ -47,10 +47,10 @@ public: ~DispatchManager() = default; - /** - * Initializes internal pointers to other managers. Must be called when - * all the other managers exist in Nebula::instance - */ + /** + * Initializes internal pointers to other managers. Must be called when + * all the other managers exist in Nebula::instance + */ void init_managers(); /** @@ -122,7 +122,7 @@ public: * in a wrong a state */ int terminate(int vid, bool hard, const RequestAttributes& request, - std::string& error_str); + std::string& error_str); /** * Shuts down a VM, but it is saved in the system DS instead of destroyed. @@ -133,7 +133,7 @@ public: * in a wrong a state */ int undeploy(int vid, bool hard, const RequestAttributes& ra, - std::string& error_str); + std::string& error_str); /** * Powers off a VM. @@ -144,7 +144,7 @@ public: * in a wrong a state */ int poweroff(int vid, bool hard, const RequestAttributes& ra, - std::string& error_str); + std::string& error_str); /** * Holds a VM. @@ -245,7 +245,7 @@ public: * @return 0 on success */ int retry(std::unique_ptr vm, const RequestAttributes& ra, - std::string& error_str); + std::string& error_str); /** * Reboots a VM preserving any resource and RUNNING state @@ -256,7 +256,7 @@ public: * in a wrong a state */ int reboot(int vid, bool hard, const RequestAttributes& ra, - std::string& error_str); + std::string& error_str); /** * Set the re-scheduling flag for the VM (must be in RUNNING state) @@ -268,7 +268,7 @@ public: * in a wrong a state */ int resched(int vid, bool do_resched, const RequestAttributes& ra, - std::string& error_str); + std::string& error_str); /** * Starts the attach disk action. @@ -280,7 +280,7 @@ public: * @return 0 on success, -1 otherwise */ int attach(int vid, VirtualMachineTemplate * tmpl, - const RequestAttributes& ra, std::string& error_str); + const RequestAttributes& ra, std::string& error_str); /** * Starts the detach disk action. @@ -292,7 +292,7 @@ public: * @return 0 on success, -1 otherwise */ int detach(int id, int disk_id, const RequestAttributes& ra, - std::string& error_str); + std::string& error_str); /** * Starts the attach NIC action. @@ -304,7 +304,7 @@ public: * @return 0 on success, -1 otherwise */ int attach_nic(int vid, VirtualMachineTemplate * tmpl, - const RequestAttributes& ra, std::string& error_str); + const RequestAttributes& ra, std::string& error_str); /** * Starts the detach NIC action. @@ -316,7 +316,7 @@ public: * @return 0 on success, -1 otherwise */ int detach_nic(int id, int nic_id, const RequestAttributes& ra, - std::string& error_str); + std::string& error_str); /** * Starts the snapshot create action @@ -330,7 +330,7 @@ public: * @return 0 on success, -1 otherwise */ int snapshot_create(int vid, std::string& name, int& snap_id, - const RequestAttributes& ra, std::string& error_str); + const RequestAttributes& ra, std::string& error_str); /** * Starts the snapshot revert action @@ -343,7 +343,7 @@ public: * @return 0 on success, -1 otherwise */ int snapshot_revert(int vid, int snap_id, const RequestAttributes& ra, - std::string& error_str); + std::string& error_str); /** * Starts the snapshot delete action @@ -356,7 +356,7 @@ public: * @return 0 on success, -1 otherwise */ int snapshot_delete(int vid, int snap_id, const RequestAttributes& ra, - std::string& error_str); + std::string& error_str); /** * Starts the disk snapshot create action @@ -371,7 +371,7 @@ public: * @return 0 on success, -1 otherwise */ int disk_snapshot_create(int vid, int did, const std::string& name, - int& snap_id, const RequestAttributes& ra, std::string& error_str); + int& snap_id, const RequestAttributes& ra, std::string& error_str); /** * Reverts the disk state to a previous snapshot @@ -385,7 +385,7 @@ public: * @return 0 on success, -1 otherwise */ int disk_snapshot_revert(int vid, int did, int snap_id, - const RequestAttributes& ra, std::string& error_str); + const RequestAttributes& ra, std::string& error_str); /** * Deletes a disk snapshot @@ -399,7 +399,7 @@ public: * @return 0 on success, -1 otherwise */ int disk_snapshot_delete(int vid, int did, int snap_id, - const RequestAttributes& ra, std::string& error_str); + const RequestAttributes& ra, std::string& error_str); /** * Starts the disk resize create action @@ -413,7 +413,7 @@ public: * @return 0 on success, -1 otherwise */ int disk_resize(int vid, int did, long long new_size, - const RequestAttributes& ra, std::string& error_str); + const RequestAttributes& ra, std::string& error_str); /** * Update virtual machine context @@ -425,7 +425,7 @@ public: * @return 0 on success, -1 otherwise */ int live_updateconf(std::unique_ptr vm, - const RequestAttributes& ra, std::string& error_str); + const RequestAttributes& ra, std::string& error_str); /** * Attach a new SG to a VM NIC @@ -439,7 +439,7 @@ public: * @return 0 on success, -1 otherwise */ int attach_sg(int vid, int nicid, int sgid, - const RequestAttributes& ra, std::string& error_str); + const RequestAttributes& ra, std::string& error_str); /** * Detach a SG from VM NIC @@ -453,7 +453,7 @@ public: * @return 0 on success, -1 otherwise */ int detach_sg(int vid, int nicid, int sgid, - const RequestAttributes& ra, std::string& error_str); + const RequestAttributes& ra, std::string& error_str); //-------------------------------------------------------------------------- // DM Actions associated with a VM state transition diff --git a/include/DocumentPool.h b/include/DocumentPool.h index c37665310d..667b6dd1d4 100644 --- a/include/DocumentPool.h +++ b/include/DocumentPool.h @@ -29,11 +29,12 @@ class DocumentPool : public PoolSQL public: DocumentPool(SqlDB * db, const std::vector& ea) : - PoolSQL(db, one_db::doc_table) { + PoolSQL(db, one_db::doc_table) + { DocumentTemplate::parse_encrypted(ea); }; - ~DocumentPool(){}; + ~DocumentPool() {}; /** * Allocates a new object, writing it in the pool database. No memory is @@ -61,9 +62,9 @@ public: std::string& error_str) { *oid = PoolSQL::allocate( - new Document(-1, uid, gid, uname, gname, umask, type, - std::move(template_contents)), - error_str); + new Document(-1, uid, gid, uname, gname, umask, type, + std::move(template_contents)), + error_str); return *oid; } @@ -103,7 +104,7 @@ public: * @return 0 on success */ int dump(std::string& oss, const std::string& where, int sid, int eid, - bool desc) override + bool desc) override { return PoolSQL::dump(oss, "DOCUMENT_POOL", "body", one_db::doc_table, where, sid, eid, desc); @@ -125,7 +126,7 @@ private: */ PoolObjectSQL * create() override { - return new Document(-1,-1,-1,"","",0,0,0); + return new Document(-1, -1, -1, "", "", 0, 0, 0); }; }; diff --git a/include/DocumentTemplate.h b/include/DocumentTemplate.h index bd50ec3adf..14c8f22238 100644 --- a/include/DocumentTemplate.h +++ b/include/DocumentTemplate.h @@ -25,13 +25,13 @@ class DocumentTemplate : public Template { public: - DocumentTemplate() : Template(false,'=',"TEMPLATE"){}; + DocumentTemplate() : Template(false, '=', "TEMPLATE") {}; - ~DocumentTemplate(){}; + ~DocumentTemplate() {}; - DocumentTemplate(DocumentTemplate& dt):Template(dt){}; + DocumentTemplate(DocumentTemplate& dt):Template(dt) {}; - DocumentTemplate(const Template& tmpl):Template(tmpl){}; + DocumentTemplate(const Template& tmpl):Template(tmpl) {}; // ------------------------------------------------------------------------- // Encrypted attributes interface implementation diff --git a/include/Driver.h b/include/Driver.h index d14960fda7..c3cafec716 100644 --- a/include/Driver.h +++ b/include/Driver.h @@ -190,7 +190,7 @@ private: template void Driver - ::stop_driver(int secs) +::stop_driver(int secs) { if ( pid == -1 ) { @@ -230,7 +230,7 @@ void Driver template int Driver - ::start_driver(std::string& error) +::start_driver(std::string& error) { // Open communication pipes int to_drv_pipe[2]; @@ -249,35 +249,35 @@ int Driver switch (pid) { - case -1: // Error - error = "Error forking to start driver, "; - error.append(strerror(errno)); - return -1; - - case 0: // Child process (driver) - close(to_drv_pipe[1]); - close(from_drv_pipe[0]); - - if ( dup2(to_drv_pipe[0], 0) != 0 || dup2(from_drv_pipe[1], 1) != 1 ) - { - error = "Error setting communication pipes, "; + case -1: // Error + error = "Error forking to start driver, "; error.append(strerror(errno)); return -1; - } - close(to_drv_pipe[0]); - close(from_drv_pipe[1]); + case 0: // Child process (driver) + close(to_drv_pipe[1]); + close(from_drv_pipe[0]); - close(2); + if ( dup2(to_drv_pipe[0], 0) != 0 || dup2(from_drv_pipe[1], 1) != 1 ) + { + error = "Error setting communication pipes, "; + error.append(strerror(errno)); + return -1; + } - execlp(cmd.c_str(), cmd.c_str(), arg.c_str(), (char*)NULL); + close(to_drv_pipe[0]); + close(from_drv_pipe[1]); - error = "Error starting driver, "; - error.append(strerror(errno)); - return -1; + close(2); - default: - break; + execlp(cmd.c_str(), cmd.c_str(), arg.c_str(), (char*)NULL); + + error = "Error starting driver, "; + error.append(strerror(errno)); + return -1; + + default: + break; } // Parent process (daemon) @@ -337,11 +337,12 @@ int Driver template void Driver - ::start_listener() +::start_listener() { streamer.fd(from_drv); - stream_thr = std::thread([this](){ + stream_thr = std::thread([this]() + { while(streamer.action_loop(concurrency) == -1 && !terminate.load()) { std::string error; diff --git a/include/DriverManager.h b/include/DriverManager.h index 00aa4d0d8d..18ed012c9f 100644 --- a/include/DriverManager.h +++ b/include/DriverManager.h @@ -45,7 +45,7 @@ public: * for all installed drivers. Must be called after load_drivers method. */ void register_action(typename D::message_t::msg_enum t, - std::function)> a); + std::function)> a); /** * Start all drivers @@ -137,7 +137,7 @@ int DriverManager::load_driver(const VectorAttribute* mad_config) } auto rc = drivers.insert(std::make_pair(name, - std::unique_ptr(new D(exec, args, threads)))); + std::unique_ptr(new D(exec, args, threads)))); if (rc.second) { @@ -191,7 +191,7 @@ D * DriverManager::get_driver(const std::string& name) const template void DriverManager::register_action(typename D::message_t::msg_enum t, - std::function)> a) + std::function)> a) { for (auto& driver : drivers) { @@ -211,7 +211,7 @@ int DriverManager::start(std::string& error) if (rc != 0) { NebulaLog::error("DrM", "Unable to start driver '" + driver.first - + "': " + error); + + "': " + error); return rc; } } @@ -229,7 +229,8 @@ void DriverManager::stop(int secs) for (auto& driver : drivers) { int _secs = secs; - threads.push_back(std::thread([_secs, &driver] () { + threads.push_back(std::thread([_secs, &driver] () + { driver.second->stop(_secs); })); } @@ -300,7 +301,7 @@ void DriverManager::add_request(SyncRequest *ar) ar->id = request_id++; - sync_requests.insert(sync_requests.end(),std::make_pair(ar->id,ar)); + sync_requests.insert(sync_requests.end(), std::make_pair(ar->id, ar)); } /* -------------------------------------------------------------------------- */ diff --git a/include/EnumString.h b/include/EnumString.h index e66d1d8642..5dff389e69 100644 --- a/include/EnumString.h +++ b/include/EnumString.h @@ -66,10 +66,10 @@ public: const std::string& _to_str(T ev) const { const auto it = std::find_if(enum_map.begin(), enum_map.end(), - [ev](const std::pair & t) -> bool - { - return t.second == ev; - }); + [ev](const std::pair & t) -> bool + { + return t.second == ev; + }); return it->first; } diff --git a/include/ExecuteHook.h b/include/ExecuteHook.h index 5ea4300a17..58eba7d106 100644 --- a/include/ExecuteHook.h +++ b/include/ExecuteHook.h @@ -25,7 +25,7 @@ class ExecuteHook { public: ExecuteHook(const std::string& _name, const std::string& _cmd, - const std::string& _arg, const std::string& rl); + const std::string& _arg, const std::string& rl); ~ExecuteHook() = default; diff --git a/include/ExtendedAttribute.h b/include/ExtendedAttribute.h index 0a3f1e0e39..fd03ec8e8c 100644 --- a/include/ExtendedAttribute.h +++ b/include/ExtendedAttribute.h @@ -105,12 +105,12 @@ protected: * @param va pointer to the VectorAttribute. */ ExtendedAttribute(VectorAttribute *_va): - Attribute(_va->name()) ,va(_va), id(-1) {}; + Attribute(_va->name()), va(_va), id(-1) {}; ExtendedAttribute(VectorAttribute *_va, int _id): - Attribute(_va->name()) ,va(_va), id(_id) {}; + Attribute(_va->name()), va(_va), id(_id) {}; - virtual ~ExtendedAttribute(){}; + virtual ~ExtendedAttribute() {}; /* ---------------------------------------------------------------------- */ /* Attribute Interface */ @@ -168,7 +168,7 @@ protected: * Creates the ExtenededAttribute set * @param dispose elements upon set destruction */ - ExtendedAttributeSet(bool _dispose):dispose(_dispose){}; + ExtendedAttributeSet(bool _dispose):dispose(_dispose) {}; virtual ~ExtendedAttributeSet(); @@ -207,12 +207,12 @@ protected: return map_it != rhs.map_it; } - AttributeIterator(){}; - AttributeIterator(const AttributeIterator& ait):map_it(ait.map_it){}; + AttributeIterator() {}; + AttributeIterator(const AttributeIterator& ait):map_it(ait.map_it) {}; AttributeIterator(const std::map::iterator& _map_it):map_it(_map_it){}; + ExtendedAttribute *>::iterator& _map_it):map_it(_map_it) {}; - virtual ~AttributeIterator(){}; + virtual ~AttributeIterator() {}; protected: std::map::iterator map_it; @@ -259,12 +259,12 @@ protected: * @param vas vector of attribute to use */ void init_attribute_map(const std::string& id_name, - std::vector& vas); + std::vector& vas); /** * Abstract method to create the VirtualMachineAttributes for this set */ virtual ExtendedAttribute * attribute_factory(VectorAttribute * va, - int id) const = 0; + int id) const = 0; /** * @return the number of elements in the set diff --git a/include/FedReplicaManager.h b/include/FedReplicaManager.h index be9254bb8c..bece907dc4 100644 --- a/include/FedReplicaManager.h +++ b/include/FedReplicaManager.h @@ -80,7 +80,7 @@ public: * @return 0 on success -1 if a xml-rpc/network error occurred */ int xmlrpc_replicate_log(int zone_id, bool& success, uint64_t& last, - std::string& err); + std::string& err); /** * Start the replication threads, and updates the server list of the zone @@ -139,9 +139,9 @@ private: struct ZoneServers { ZoneServers(int z, uint64_t l, const std::string& s): - zone_id(z), endpoint(s), next(l), last(UINT64_MAX){}; + zone_id(z), endpoint(s), next(l), last(UINT64_MAX) {}; - ~ZoneServers(){}; + ~ZoneServers() {}; int zone_id; @@ -166,7 +166,7 @@ private: * @return 0 on success, -1 otherwise */ int get_next_record(int zone_id, std::string& zedp, LogDBRecord& lr, - std::string& error); + std::string& error); }; diff --git a/include/GroupPool.h b/include/GroupPool.h index 44029496fe..60f6ebdd62 100644 --- a/include/GroupPool.h +++ b/include/GroupPool.h @@ -26,7 +26,7 @@ class GroupPool : public PoolSQL public: GroupPool(SqlDB * db, bool is_federation_slave, - const std::vector& restricted_attrs); + const std::vector& restricted_attrs); ~GroupPool() = default; @@ -172,7 +172,7 @@ private: */ PoolObjectSQL * create() override { - return new Group(-1,""); + return new Group(-1, ""); }; }; diff --git a/include/History.h b/include/History.h index a62702123a..75f7849937 100644 --- a/include/History.h +++ b/include/History.h @@ -32,17 +32,17 @@ public: History(int oid, int _seq = -1); History( - int oid, - int seq, - int hid, - const std::string& hostname, - int cid, - const std::string& vmm, - const std::string& tmm, - int ds_id, - const std::string& vm_info); + int oid, + int seq, + int hid, + const std::string& hostname, + int cid, + const std::string& vmm, + const std::string& tmm, + int ds_id, + const std::string& vm_info); - ~History(){}; + ~History() {}; /** * Function to write the History Record in an output stream @@ -144,10 +144,10 @@ private: * @param db pointer to the database. * @return 0 on success. */ - int update(SqlDB * db) override - { + int update(SqlDB * db) override + { return insert_replace(db, true); - } + } /** * Removes the all history records from the DB diff --git a/include/HookAPI.h b/include/HookAPI.h index fc1edc5055..5d9b6bc01c 100644 --- a/include/HookAPI.h +++ b/include/HookAPI.h @@ -53,7 +53,7 @@ private: // ************************************************************************* HookAPI() = default; - HookAPI(const std::string& _call): call(_call){}; + HookAPI(const std::string& _call): call(_call) {}; virtual ~HookAPI() = default; diff --git a/include/HookManager.h b/include/HookManager.h index 9d4dd18fb0..6c76ee3fba 100644 --- a/include/HookManager.h +++ b/include/HookManager.h @@ -28,7 +28,7 @@ class HookManager : public DriverManager>, - public Listener + public Listener { public: diff --git a/include/HookPool.h b/include/HookPool.h index feb39464b6..37bc5e9e89 100644 --- a/include/HookPool.h +++ b/include/HookPool.h @@ -29,9 +29,9 @@ class HookPool : public PoolSQL { public: - HookPool(SqlDB * db) : PoolSQL(db, one_db::hook_table){}; + HookPool(SqlDB * db) : PoolSQL(db, one_db::hook_table) {}; - ~HookPool(){}; + ~HookPool() {}; /** * Function to allocate a new Hook object @@ -84,7 +84,7 @@ public: * @return 0 on success */ int dump(std::string& oss, const std::string& where, int sid, int eid, - bool desc) override + bool desc) override { return PoolSQL::dump(oss, "HOOK_POOL", "body", one_db::hook_table, where, sid, eid, desc); diff --git a/include/HookStateHost.h b/include/HookStateHost.h index ff5613fe47..ac2740c586 100644 --- a/include/HookStateHost.h +++ b/include/HookStateHost.h @@ -40,7 +40,7 @@ private: // Constructor/Destructor // ************************************************************************* - HookStateHost():state(Host::INIT){}; + HookStateHost():state(Host::INIT) {}; virtual ~HookStateHost() = default; diff --git a/include/HookStateImage.h b/include/HookStateImage.h index 48bfd5281f..751c7e2342 100644 --- a/include/HookStateImage.h +++ b/include/HookStateImage.h @@ -40,7 +40,7 @@ private: // Constructor/Destructor // ************************************************************************* - HookStateImage():state(Image::INIT){}; + HookStateImage():state(Image::INIT) {}; virtual ~HookStateImage() = default; diff --git a/include/HookStateVM.h b/include/HookStateVM.h index eb2d713fa7..a30e4b113e 100644 --- a/include/HookStateVM.h +++ b/include/HookStateVM.h @@ -41,7 +41,7 @@ private: // ************************************************************************* HookStateVM():state(VirtualMachine::INIT), - lcm_state(VirtualMachine::LCM_INIT){}; + lcm_state(VirtualMachine::LCM_INIT) {}; virtual ~HookStateVM() = default; diff --git a/include/HookStateVirtualNetwork.h b/include/HookStateVirtualNetwork.h index e171a69af2..0abdd50e75 100644 --- a/include/HookStateVirtualNetwork.h +++ b/include/HookStateVirtualNetwork.h @@ -40,7 +40,7 @@ private: // Constructor/Destructor // ************************************************************************* - HookStateVirtualNetwork():state(VirtualNetwork::INIT){}; + HookStateVirtualNetwork():state(VirtualNetwork::INIT) {}; virtual ~HookStateVirtualNetwork() = default; diff --git a/include/Host.h b/include/Host.h index a71f32448c..ee85093b8d 100644 --- a/include/Host.h +++ b/include/Host.h @@ -67,15 +67,24 @@ public: state = INIT; - if ( st == "INIT" ) { + if ( st == "INIT" ) + { state = INIT; - } else if ( st == "MONITORED" ) { + } + else if ( st == "MONITORED" ) + { state = MONITORED; - } else if ( st == "ERROR" ) { + } + else if ( st == "ERROR" ) + { state = ERROR; - } else if ( st == "DISABLED" ) { + } + else if ( st == "DISABLED" ) + { state = DISABLED; - } else if ( st == "OFFLINE" ) { + } + else if ( st == "OFFLINE" ) + { state = OFFLINE; } else @@ -129,11 +138,11 @@ public: */ int from_xml(const std::string &xml_str) override; - /** - * Checks if the host is a remote public cloud - * @return true if the host is a remote public cloud - */ - bool is_public_cloud() const; + /** + * Checks if the host is a remote public cloud + * @return true if the host is a remote public cloud + */ + bool is_public_cloud() const; /** * Sets the current host offline, it will not be monitored nor used by the diff --git a/include/HostPool.h b/include/HostPool.h index 655aedbf26..c2f5fc6940 100644 --- a/include/HostPool.h +++ b/include/HostPool.h @@ -42,13 +42,13 @@ public: * @return the oid assigned to the object or -1 in case of failure */ int allocate ( - int * oid, - const std::string& hostname, - const std::string& im_mad_name, - const std::string& vmm_mad_name, - int cluster_id, - const std::string& cluster_name, - std::string& error_str); + int * oid, + const std::string& hostname, + const std::string& im_mad_name, + const std::string& vmm_mad_name, + int cluster_id, + const std::string& cluster_name, + std::string& error_str); /** * Updates a Host in the data base. It also updates the previous state @@ -154,9 +154,9 @@ public: if ( auto host = get(oid) ) { - host->add_capacity(sr); + host->add_capacity(sr); - update(host.get()); + update(host.get()); } else { @@ -210,10 +210,10 @@ public: * @return 0 on success */ int dump(std::string& oss, const std::string& where, int sid, int eid, - bool desc) override + bool desc) override { return PoolSQL::dump(oss, "HOST_POOL", "body", one_db::host_table, - where, sid, eid, desc); + where, sid, eid, desc); }; /** @@ -271,7 +271,7 @@ private: */ PoolObjectSQL * create() override { - return new Host(-1,"","","",-1,""); + return new Host(-1, "", "", "", -1, ""); }; }; diff --git a/include/HostShare.h b/include/HostShare.h index e366ffe2b6..54bbb4e685 100644 --- a/include/HostShare.h +++ b/include/HostShare.h @@ -36,7 +36,7 @@ class HostShare : public ObjectXML public: HostShare(); - ~HostShare(){}; + ~HostShare() {}; /** * Pin policy for the host diff --git a/include/HostShareDatastore.h b/include/HostShareDatastore.h index cc1b28dd12..7cdf976e00 100644 --- a/include/HostShareDatastore.h +++ b/include/HostShareDatastore.h @@ -28,9 +28,9 @@ class HostShareDatastore : public Template { public: HostShareDatastore() : Template(false, '=', "DATASTORES"), disk_usage(0), - max_disk(0), free_disk(0), used_disk(0){}; + max_disk(0), free_disk(0), used_disk(0) {}; - virtual ~HostShareDatastore(){}; + virtual ~HostShareDatastore() {}; /** * Updates the Datastore information from the monitorization template. diff --git a/include/HostShareNUMA.h b/include/HostShareNUMA.h index db6dcc3f9a..9c7b8ee13b 100644 --- a/include/HostShareNUMA.h +++ b/include/HostShareNUMA.h @@ -103,7 +103,7 @@ public: * @return 0 on success */ int allocate_ht_cpus(int id, unsigned int tcpus, unsigned int tc, - std::string &c_s); + std::string &c_s); /** * Remove allocation for the given CPUs @@ -259,7 +259,7 @@ private: * @param update if true also adds the core to the object Template */ void set_core(unsigned int id, std::string& cpus, unsigned int vms_thread, - bool dedicated, bool update); + bool dedicated, bool update); /** * Regenerate the template representation of the CORES for this node. @@ -279,7 +279,7 @@ private: * @param update if true also adds the page to the object Template */ void set_hugepage(unsigned long size, unsigned int nr, - unsigned long usage, bool update); + unsigned long usage, bool update); void update_hugepage(unsigned long size); @@ -326,7 +326,7 @@ private: class HostShareNUMA { public: - HostShareNUMA():threads_core(1){}; + HostShareNUMA():threads_core(1) {}; virtual ~HostShareNUMA() { @@ -470,7 +470,7 @@ private: }; bool schedule_nodes(NUMANodeRequest &nr, unsigned int thr, bool dedicated, - unsigned long hpsz_kb, std::set &pci, bool do_alloc); + unsigned long hpsz_kb, std::set &pci, bool do_alloc); }; #endif /*HOST_SHARE_NUMA_H_*/ diff --git a/include/HostSharePCI.h b/include/HostSharePCI.h index 2c2ba1616e..cfc07d647b 100644 --- a/include/HostSharePCI.h +++ b/include/HostSharePCI.h @@ -47,7 +47,7 @@ class HostSharePCI : public Template { public: - HostSharePCI() : Template(false, '=', "PCI_DEVICES"){}; + HostSharePCI() : Template(false, '=', "PCI_DEVICES") {}; HostSharePCI(const HostSharePCI& src); @@ -148,7 +148,7 @@ private: PCIDevice(const PCIDevice& src); - ~PCIDevice(){}; + ~PCIDevice() {}; unsigned int vendor_id; unsigned int device_id; diff --git a/include/HostTemplate.h b/include/HostTemplate.h index 78f468bfd3..d8ef0d7ef2 100644 --- a/include/HostTemplate.h +++ b/include/HostTemplate.h @@ -26,11 +26,11 @@ class HostTemplate : public Template { public: - HostTemplate() : Template(false,'=',"TEMPLATE"){}; + HostTemplate() : Template(false, '=', "TEMPLATE") {}; - ~HostTemplate(){}; + ~HostTemplate() {}; - HostTemplate(HostTemplate& ht):Template(ht){}; + HostTemplate(HostTemplate& ht):Template(ht) {}; // ------------------------------------------------------------------------- // Encrypted attributes interface implementation diff --git a/include/IPAMManager.h b/include/IPAMManager.h index 6535ced8bd..ea0bd0f9de 100644 --- a/include/IPAMManager.h +++ b/include/IPAMManager.h @@ -32,14 +32,14 @@ class VectorAttribute; class IPAMManager : public DriverManager>, - public Listener + public Listener { public: IPAMManager(time_t timer, const std::string& mad_location) : DriverManager(mad_location) , Listener("IPAM Manager") - , timer_thread(timer, [this](){timer_action();}) + , timer_thread(timer, [this]() {timer_action();}) { } diff --git a/include/IPAMRequest.h b/include/IPAMRequest.h index a9ac1a60d6..194a2934bb 100644 --- a/include/IPAMRequest.h +++ b/include/IPAMRequest.h @@ -37,16 +37,16 @@ public: /* IPAM Request constructors */ /* ---------------------------------------------------------------------- */ IPAMRequest(VectorAttribute * _ar_vattr) : IPAMRequest(_ar_vattr, - "
"){}; + "
") {}; IPAMRequest(VectorAttribute * _ar_vattr, const std::string& _address_xml); IPAMRequest(AddressRange * _ar) : IPAMRequest(_ar, - "
"){}; + "
") {}; IPAMRequest(AddressRange * _ar, const std::string& _address_xml); - virtual ~IPAMRequest(){}; + virtual ~IPAMRequest() {}; /* ---------------------------------------------------------------------- */ /* Driver message formatting and processing */ diff --git a/include/Image.h b/include/Image.h index e480d0e9c7..f4ffa4d4ff 100644 --- a/include/Image.h +++ b/include/Image.h @@ -210,7 +210,7 @@ public: * @return true if the image is set to persistent, false otherwise */ static bool test_set_persistent(Template * image_template, int uid, int gid, - bool is_allocate); + bool is_allocate); /** * Returns the source path of the image @@ -458,8 +458,8 @@ public: if ((snapshots.size() > 0) && !persis) { - error_str = "Image has snapshots."; - return -1; + error_str = "Image has snapshots."; + return -1; } switch (state) @@ -662,9 +662,9 @@ private: */ long long size_mb; - /** - * Image state - */ + /** + * Image state + */ ImageState state; ImageState prev_state; diff --git a/include/ImageManager.h b/include/ImageManager.h index 505c41bcb7..efdb1df8d6 100644 --- a/include/ImageManager.h +++ b/include/ImageManager.h @@ -38,13 +38,13 @@ public: DatastorePool * _dspool, const std::string& _mads_location, int _monitor_vm_disk): - DriverManager(_mads_location), - timer_thread(_timer_period, [this](){timer_action();}), - timer_period(_timer_period), - monitor_period(_monitor_period), - monitor_vm_disk(_monitor_vm_disk), - ipool(_ipool), - dspool(_dspool) + DriverManager(_mads_location), + timer_thread(_timer_period, [this]() {timer_action();}), + timer_period(_timer_period), + monitor_period(_monitor_period), + monitor_vm_disk(_monitor_vm_disk), + ipool(_ipool), + dspool(_dspool) { } @@ -97,7 +97,7 @@ public: * @return pointer to the image or 0 if could not be acquired */ std::unique_ptr acquire_image(int vm_id, const std::string& name, - int uid, bool attach, std::string& error); + int uid, bool attach, std::string& error); /** * Releases an image and triggers any needed operations in the repo @@ -176,7 +176,7 @@ public: * @return 0 on success */ int set_clone_state(PoolObjectSQL::ObjectType ot, int new_id, - int cloning_id, std::string& error); + int cloning_id, std::string& error); /** * Sets the state to CLONE for the given image @@ -235,15 +235,15 @@ public: * occurred describing the error. * @result 0 on success */ - int stat_image(Template* img_tmpl, - const std::string& ds_tmpl, - std::string& res); + int stat_image(Template* img_tmpl, + const std::string& ds_tmpl, + std::string& res); - /** - * Trigger a monitor action for the datastore. - * @param ds_id id of the datastore to monitor - */ - void monitor_datastore(int ds_id); + /** + * Trigger a monitor action for the datastore. + * @param ds_id id of the datastore to monitor + */ + void monitor_datastore(int ds_id); /** * Set the snapshots for the given image. The image MUST be persistent @@ -251,13 +251,13 @@ public: * @param iid id of image * @param s snapshot list */ - void set_image_snapshots(int iid, const Snapshots& s); + void set_image_snapshots(int iid, const Snapshots& s); - /** - * Clear the snapshots of an image by setting an empty set. - * @param iid id of image - */ - void clear_image_snapshots(int iid); + /** + * Clear the snapshots of an image by setting an empty set. + * @param iid id of image + */ + void clear_image_snapshots(int iid); /** * Set the size for the given image. The image MUST be persistent @@ -265,34 +265,34 @@ public: * @param iid id of image * @param size */ - void set_image_size(int iid, long long size); + void set_image_size(int iid, long long size); - /** - * Deletes the snapshot of an image - * @param iid id of image - * @param sid id of the snapshot - * @param error_str Error reason, if any - * @return 0 on success - */ - int delete_snapshot(int iid, int sid, std::string& error); + /** + * Deletes the snapshot of an image + * @param iid id of image + * @param sid id of the snapshot + * @param error_str Error reason, if any + * @return 0 on success + */ + int delete_snapshot(int iid, int sid, std::string& error); - /** - * Reverts image state to a previous snapshot - * @param iid id of image - * @param sid id of the snapshot - * @param error_str Error reason, if any - * @return 0 on success - */ - int revert_snapshot(int iid, int sid, std::string& error); + /** + * Reverts image state to a previous snapshot + * @param iid id of image + * @param sid id of the snapshot + * @param error_str Error reason, if any + * @return 0 on success + */ + int revert_snapshot(int iid, int sid, std::string& error); - /** - * Flattens ths snapshot by commiting changes to base image. - * @param iid id of image - * @param sid id of the snapshot - * @param error_str Error reason, if any - * @return 0 on success - */ - int flatten_snapshot(int iid, int sid, std::string& error); + /** + * Flattens ths snapshot by commiting changes to base image. + * @param iid id of image + * @param sid id of the snapshot + * @param error_str Error reason, if any + * @return 0 on success + */ + int flatten_snapshot(int iid, int sid, std::string& error); private: /** @@ -369,8 +369,8 @@ private: * @return the XML message */ static std::string format_message(const std::string& img_data, - const std::string& ds_data, - const std::string& extra_data); + const std::string& ds_data, + const std::string& extra_data); // ------------------------------------------------------------------------- // Protocol implementation, procesing messages from driver diff --git a/include/ImagePool.h b/include/ImagePool.h index 7074528529..47cea246f7 100644 --- a/include/ImagePool.h +++ b/include/ImagePool.h @@ -44,7 +44,7 @@ public: const std::vector& encrypted_attrs, const std::vector& inherit_attrs); - ~ImagePool(){}; + ~ImagePool() {}; /** * Function to allocate a new Image object @@ -69,23 +69,23 @@ public: * -2 in case of template parse failure */ int allocate ( - int uid, - int gid, - const std::string& uname, - const std::string& gname, - int umask, - std::unique_ptr img_template, - int ds_id, - const std::string& ds_name, - Image::DiskType disk_type, - const std::string& ds_data, - Datastore::DatastoreType ds_type, - const std::string& ds_mad, - const std::string& tm_mad, - const std::string& extra_data, - int source_img_id, - int * oid, - std::string& error_str); + int uid, + int gid, + const std::string& uname, + const std::string& gname, + int umask, + std::unique_ptr img_template, + int ds_id, + const std::string& ds_name, + Image::DiskType disk_type, + const std::string& ds_data, + Datastore::DatastoreType ds_type, + const std::string& ds_mad, + const std::string& tm_mad, + const std::string& extra_data, + int source_img_id, + int * oid, + std::string& error_str); /** * Updates an Image in the data base. It also updates the previous state @@ -130,7 +130,7 @@ public: */ std::unique_ptr get(const std::string& name, int uid) { - return PoolSQL::get(name,uid); + return PoolSQL::get(name, uid); } /** @@ -167,7 +167,7 @@ public: * @return 0 on success */ int dump(std::string& oss, const std::string& where, int sid, int eid, - bool desc) override + bool desc) override { return PoolSQL::dump(oss, "IMAGE_POOL", "body", one_db::image_table, where, sid, eid, desc); @@ -261,7 +261,7 @@ private: */ PoolObjectSQL * create() override { - return new Image(-1,-1,"","",0,0); + return new Image(-1, -1, "", "", 0, 0); }; }; diff --git a/include/ImageTemplate.h b/include/ImageTemplate.h index 3d0eddf791..0a63d0266a 100644 --- a/include/ImageTemplate.h +++ b/include/ImageTemplate.h @@ -25,11 +25,11 @@ class ImageTemplate : public Template { public: - ImageTemplate() : Template(true,'=',"TEMPLATE"){}; + ImageTemplate() : Template(true, '=', "TEMPLATE") {}; - ImageTemplate(const Template& tmpl):Template(tmpl){}; + ImageTemplate(const Template& tmpl):Template(tmpl) {}; - ~ImageTemplate(){}; + ~ImageTemplate() {}; bool is_saving() { diff --git a/include/InformationManager.h b/include/InformationManager.h index ecdff17434..bbea948e5f 100644 --- a/include/InformationManager.h +++ b/include/InformationManager.h @@ -30,12 +30,12 @@ class InformationManager : public DriverManager> { public: InformationManager( - HostPool * _hpool, - VirtualMachinePool * _vmpool, - const std::string& mad_location) - : DriverManager(mad_location) - , hpool(_hpool) - , vmpool(_vmpool) + HostPool * _hpool, + VirtualMachinePool * _vmpool, + const std::string& mad_location) + : DriverManager(mad_location) + , hpool(_hpool) + , vmpool(_vmpool) { } diff --git a/include/LifeCycleManager.h b/include/LifeCycleManager.h index 0a033f71b8..002aad9e1b 100644 --- a/include/LifeCycleManager.h +++ b/include/LifeCycleManager.h @@ -241,7 +241,7 @@ private: * image may need to be set to error state. */ void clean_up_vm(VirtualMachine *vm, bool dispose, int& image_id, - int uid, int gid, int req_id, Template& quota_tmpl); + int uid, int gid, int req_id, Template& quota_tmpl); }; #endif /*LIFE_CYCLE_MANAGER_H_*/ diff --git a/include/Listener.h b/include/Listener.h index d3283b98ca..555440a540 100644 --- a/include/Listener.h +++ b/include/Listener.h @@ -75,14 +75,16 @@ public: end = false; - timer_thread = std::thread([&, s, timer]{ + timer_thread = std::thread([&, s, timer] + { std::unique_lock ul(lock); while (true) { - bool tout = cond.wait_for(ul, std::chrono::duration(s), [&]{ - return end == true; + bool tout = cond.wait_for(ul, std::chrono::duration(s), [&] + { + return end == true; }); if (end) @@ -159,7 +161,8 @@ public: */ void finalize() { - trigger([&] { + trigger([&] + { NebulaLog::info("Lis", "Stopping " + name); finalize_action(); @@ -184,7 +187,8 @@ protected: */ void start() { - loop_thread = std::thread([&] { + loop_thread = std::thread([&] + { NebulaLog::info("Lis", name + " started."); loop(); @@ -204,7 +208,7 @@ protected: { std::unique_lock ul(lock); - cond.wait(ul, [&]{return (end || !pending.empty());}); + cond.wait(ul, [&] {return (end || !pending.empty());}); if (end) { diff --git a/include/Log.h b/include/Log.h index 0106f89f3c..c8a050c27e 100644 --- a/include/Log.h +++ b/include/Log.h @@ -31,7 +31,8 @@ class Log { public: - enum MessageType { + enum MessageType + { ERROR = 0, WARNING = 1, INFO = 2, @@ -42,9 +43,9 @@ public: static const char error_names[]; - Log(const MessageType _level = WARNING):log_level(_level){}; + Log(const MessageType _level = WARNING):log_level(_level) {}; - virtual ~Log(){}; + virtual ~Log() {}; MessageType get_log_level() const { @@ -73,7 +74,7 @@ public: clock_gettime(CLOCK_MONOTONIC, &eend); sec = (eend.tv_sec + (eend.tv_nsec * 1e-9)) - (estart->tv_sec + - (estart->tv_nsec * 1e-9)); + (estart->tv_nsec * 1e-9)); return sec; } @@ -83,9 +84,9 @@ public: // ------------------------------------------------------------------------- virtual void log( - const char * module, - const MessageType type, - const char * message) = 0; + const char * module, + const MessageType type, + const char * message) = 0; protected: /** @@ -116,9 +117,9 @@ public: virtual ~FileLog(); void log( - const char * module, - const MessageType type, - const char * message) override; + const char * module, + const MessageType type, + const char * message) override; private: std::string log_file_name; @@ -133,19 +134,19 @@ public: FileLogTS(const std::string& file_name, const MessageType level = WARNING, std::ios_base::openmode mode = std::ios_base::app) - :FileLog(file_name,level,mode) + :FileLog(file_name, level, mode) { } ~FileLogTS() = default; void log( - const char * module, - const MessageType type, - const char * message) override + const char * module, + const MessageType type, + const char * message) override { std::lock_guard lock(log_mutex); - FileLog::log(module,type,message); + FileLog::log(module, type, message); } private: @@ -162,18 +163,18 @@ private: class StdLog : public Log { public: - StdLog(const MessageType level):Log(level){}; + StdLog(const MessageType level):Log(level) {}; StdLog(const MessageType level, int oid, const PoolObjectSQL::ObjectType obj_type); - ~StdLog(){}; + ~StdLog() {}; void log( - const char * module, - const MessageType type, - const char * message) override; + const char * module, + const MessageType type, + const char * message) override; private: std::string resource_label; @@ -195,12 +196,12 @@ public: int oid, const PoolObjectSQL::ObjectType obj_type); - ~SysLog(){}; + ~SysLog() {}; void log( - const char * module, - const MessageType type, - const char * message) override; + const char * module, + const MessageType type, + const char * message) override; /** * Return the associated syslog level diff --git a/include/LogDB.h b/include/LogDB.h index b858f821a6..3d36b4e8ff 100644 --- a/include/LogDB.h +++ b/include/LogDB.h @@ -29,9 +29,9 @@ class LogDBRecord : public Callbackable { public: - /** - * Index for this log entry (and previous) - */ + /** + * Index for this log entry (and previous) + */ uint64_t index; uint64_t prev_index; @@ -83,7 +83,7 @@ class LogDB : public SqlDB { public: LogDB(SqlDB * _db, bool solo, bool cache, uint64_t log_retention, - uint64_t limit_purge); + uint64_t limit_purge); virtual ~LogDB(); @@ -126,8 +126,8 @@ public: * @return 0 on sucess, -1 on failure */ int insert_log_record(uint64_t index, unsigned int term, - const std::ostringstream& sql, time_t timestamp, uint64_t fed_index, - bool replace); + const std::ostringstream& sql, time_t timestamp, uint64_t fed_index, + bool replace); /** * Replicate a log record on followers. It will also replicate any missing @@ -383,7 +383,7 @@ private: * @return -1 on failure, index of the inserted record on success */ uint64_t insert_log_record(unsigned int term, const std::ostringstream& sql, - time_t timestamp, uint64_t fed_index); + time_t timestamp, uint64_t fed_index); }; // ----------------------------------------------------------------------------- @@ -393,9 +393,9 @@ private: class FedLogDB: public SqlDB { public: - FedLogDB(LogDB *db):_logdb(db){}; + FedLogDB(LogDB *db):_logdb(db) {}; - virtual ~FedLogDB(){}; + virtual ~FedLogDB() {}; int exec_wr(std::ostringstream& cmd) override; diff --git a/include/LoginToken.h b/include/LoginToken.h index c0a96bc423..9765215858 100644 --- a/include/LoginToken.h +++ b/include/LoginToken.h @@ -35,13 +35,13 @@ class SessionToken { public: - SessionToken():expiration_time(0), token(""){}; + SessionToken():expiration_time(0), token("") {}; - virtual ~SessionToken(){}; + virtual ~SessionToken() {}; - /** - * Clears the token if not valid - */ + /** + * Clears the token if not valid + */ void reset(); /** @@ -89,9 +89,9 @@ class LoginToken: public SessionToken { public: - LoginToken():SessionToken(), egid(-1){}; + LoginToken():SessionToken(), egid(-1) {}; - virtual ~LoginToken(){}; + virtual ~LoginToken() {}; /** * Check if the token is valid (same as the one provided, and not expired) @@ -155,7 +155,7 @@ private: class LoginTokenPool { public: - LoginTokenPool(){}; + LoginTokenPool() {}; ~LoginTokenPool(); diff --git a/include/MarketPlace.h b/include/MarketPlace.h index b1faae63a7..642db050cc 100644 --- a/include/MarketPlace.h +++ b/include/MarketPlace.h @@ -45,9 +45,12 @@ public: state = ENABLED; - if ( st == "ENABLED" ) { + if ( st == "ENABLED" ) + { state = ENABLED; - } else if ( st == "DISABLED" ) { + } + else if ( st == "DISABLED" ) + { state = DISABLED; } else diff --git a/include/MarketPlaceAppPool.h b/include/MarketPlaceAppPool.h index 5981fca87b..584b35786b 100644 --- a/include/MarketPlaceAppPool.h +++ b/include/MarketPlaceAppPool.h @@ -27,7 +27,7 @@ class MarketPlaceAppPool : public PoolSQL public: MarketPlaceAppPool(SqlDB * db):PoolSQL(db, one_db::mp_app_table) {}; - ~MarketPlaceAppPool(){}; + ~MarketPlaceAppPool() {}; /* ---------------------------------------------------------------------- */ /* Methods for DB management */ @@ -81,7 +81,7 @@ public: * already imported */ int import(const std::string& t64, int mp_id, const std::string& mp_name, - int& app_id, std::string& error_str); + int& app_id, std::string& error_str); /** * Gets an object from the pool (if needed the object is loaded from the @@ -154,7 +154,7 @@ public: * @return 0 on success */ int dump(std::string& oss, const std::string& where, int sid, int eid, - bool desc) override + bool desc) override { return PoolSQL::dump(oss, "MARKETPLACEAPP_POOL", "body", one_db::mp_app_table, where, sid, eid, desc); @@ -172,7 +172,7 @@ public: */ PoolObjectSQL * create() override { - return new MarketPlaceApp(-1,-1,"","", 0, 0); + return new MarketPlaceApp(-1, -1, "", "", 0, 0); }; /** diff --git a/include/MarketPlaceAppTemplate.h b/include/MarketPlaceAppTemplate.h index 661cbcae48..5606bdb319 100644 --- a/include/MarketPlaceAppTemplate.h +++ b/include/MarketPlaceAppTemplate.h @@ -26,9 +26,9 @@ class MarketPlaceAppTemplate : public Template { public: MarketPlaceAppTemplate(): - Template(false,'=',"TEMPLATE"){}; + Template(false, '=', "TEMPLATE") {}; - ~MarketPlaceAppTemplate(){}; + ~MarketPlaceAppTemplate() {}; }; /* -------------------------------------------------------------------------- */ diff --git a/include/MarketPlaceManager.h b/include/MarketPlaceManager.h index 407dd67498..40aa1e33d5 100644 --- a/include/MarketPlaceManager.h +++ b/include/MarketPlaceManager.h @@ -108,23 +108,23 @@ public: */ int delete_app(int appid, const std::string& market_data, std::string& err); - /** - * Trigger a monitor action for the marketplace . - * @param ds_id id of the datastore to monitor - */ - void monitor_market(int ds_id); + /** + * Trigger a monitor action for the marketplace . + * @param ds_id id of the datastore to monitor + */ + void monitor_market(int ds_id); - /** - * Relsease resources locked by this app during the import phase - * @param appid of the app - */ + /** + * Relsease resources locked by this app during the import phase + * @param appid of the app + */ void release_app_resources(int appid); private: /** * Generic name for the marketplace driver */ - static const char * market_driver_name; + static const char * market_driver_name; /** * Timer action async execution diff --git a/include/MarketPlacePool.h b/include/MarketPlacePool.h index 3c1fdf28ec..34058f9f5c 100644 --- a/include/MarketPlacePool.h +++ b/include/MarketPlacePool.h @@ -29,7 +29,7 @@ public: MarketPlacePool(SqlDB * db, bool is_federation_slave); - ~MarketPlacePool(){}; + ~MarketPlacePool() {}; /* ---------------------------------------------------------------------- */ /* Methods for DB management */ @@ -118,10 +118,10 @@ public: * @return 0 on success */ int dump(std::string& oss, const std::string& where, int sid, int eid, - bool desc) override + bool desc) override { return PoolSQL::dump(oss, "MARKETPLACE_POOL", "body", one_db::mp_table, - where, sid, eid, desc); + where, sid, eid, desc); }; /** @@ -130,10 +130,10 @@ public: * * @return 0 on success */ - int list(std::vector& oids) - { + int list(std::vector& oids) + { return PoolSQL::list(oids, one_db::mp_table); - } + } /** * Factory method to produce objects @@ -141,7 +141,7 @@ public: */ PoolObjectSQL * create() override { - return new MarketPlace(-1,-1,"","", 0, 0); + return new MarketPlace(-1, -1, "", "", 0, 0); }; }; diff --git a/include/MarketPlaceTemplate.h b/include/MarketPlaceTemplate.h index 47ac0bdb63..937a7c7e72 100644 --- a/include/MarketPlaceTemplate.h +++ b/include/MarketPlaceTemplate.h @@ -26,9 +26,9 @@ class MarketPlaceTemplate : public Template { public: MarketPlaceTemplate(): - Template(false,'=',"TEMPLATE"){}; + Template(false, '=', "TEMPLATE") {}; - ~MarketPlaceTemplate(){}; + ~MarketPlaceTemplate() {}; }; /* -------------------------------------------------------------------------- */ diff --git a/include/Message.h b/include/Message.h index 4e31a93c03..92c838157a 100644 --- a/include/Message.h +++ b/include/Message.h @@ -196,17 +196,17 @@ private: template Message - ::Message(E type, std::string &&status, int oid, const std::string& payload) - : _type(type) - , _status(std::move(status)) - , _oid(oid) - , _payload(payload) +::Message(E type, std::string &&status, int oid, const std::string& payload) + : _type(type) + , _status(std::move(status)) + , _oid(oid) + , _payload(payload) { } template int Message - ::parse_from(const std::string& input) +::parse_from(const std::string& input) { std::istringstream is(input); std::string buffer; @@ -279,7 +279,7 @@ error: template int Message - ::write_to(std::string& out) const +::write_to(std::string& out) const { out.clear(); @@ -332,7 +332,7 @@ int Message template int Message - ::write_to(int fd) const +::write_to(int fd) const { std::string out; @@ -351,7 +351,7 @@ int Message template int Message - ::write_to(std::ostream& oss) const +::write_to(std::ostream& oss) const { std::string out; diff --git a/include/MySqlDB.h b/include/MySqlDB.h index c5904e1594..3f04f46c82 100644 --- a/include/MySqlDB.h +++ b/include/MySqlDB.h @@ -155,14 +155,15 @@ public: throw std::runtime_error("Aborting oned, MySQL support not compiled!"); }; - ~MySqlDB(){}; + ~MySqlDB() {}; char * escape_str(const std::string& str) const override {return nullptr;}; void free_str(char * str) const override {}; protected: - int exec_ext(std::ostringstream& c, Callbackable *o, bool q) override { + int exec_ext(std::ostringstream& c, Callbackable *o, bool q) override + { return -1; }; }; diff --git a/include/Nebula.h b/include/Nebula.h index 6b32baf3b3..a5e6a3083f 100644 --- a/include/Nebula.h +++ b/include/Nebula.h @@ -383,7 +383,7 @@ public: */ template int get_configuration_attribute(int uid, int gid, const std::string& name, - T& value) const + T& value) const { if ( uid != -1 ) { @@ -431,7 +431,7 @@ public: * Gets a DS configuration attribute */ int get_ds_conf_attribute(const std::string& ds_name, - const VectorAttribute* &value) const + const VectorAttribute* &value) const { return get_conf_attribute("DS_MAD_CONF", ds_name, value); }; @@ -440,7 +440,7 @@ public: * Gets a VN configuration attribute */ int get_vn_conf_attribute(const std::string& vn_name, - const VectorAttribute* &value) const + const VectorAttribute* &value) const { return get_conf_attribute("VN_MAD_CONF", vn_name, value); } @@ -449,7 +449,7 @@ public: * Gets a TM configuration attribute */ int get_tm_conf_attribute(const std::string& tm_name, - const VectorAttribute* &value) const + const VectorAttribute* &value) const { return get_conf_attribute("TM_MAD_CONF", tm_name, value); }; @@ -458,7 +458,7 @@ public: * Gets a Market configuration attribute */ int get_market_conf_attribute( const std::string& mk_name, - const VectorAttribute* &value) const + const VectorAttribute* &value) const { return get_conf_attribute("MARKET_MAD_CONF", mk_name, value); }; @@ -468,8 +468,8 @@ public: */ template int get_auth_conf_attribute(const std::string& driver, - const std::string& attribute, - T& value) const + const std::string& attribute, + T& value) const { return get_conf_attribute("AUTH_MAD_CONF", driver, attribute, value); }; @@ -572,9 +572,9 @@ public: * @return 0 on success */ int insert_sys_attribute( - const std::string& attr_name, - const std::string& xml_attr, - std::string& error_str) + const std::string& attr_name, + const std::string& xml_attr, + std::string& error_str) { return system_db->insert_sys_attribute(attr_name, xml_attr, error_str); }; @@ -585,9 +585,9 @@ public: * @return 0 on success */ int update_sys_attribute( - const std::string& attr_name, - const std::string& xml_attr, - std::string& error_str) + const std::string& attr_name, + const std::string& xml_attr, + std::string& error_str) { return system_db->update_sys_attribute(attr_name, xml_attr, error_str); }; @@ -609,10 +609,10 @@ public: "/DEFAULT_USER_QUOTAS/IMAGE_QUOTA", "/DEFAULT_USER_QUOTAS/VM_QUOTA") , default_group_quota("DEFAULT_GROUP_QUOTAS", - "/DEFAULT_GROUP_QUOTAS/DATASTORE_QUOTA", - "/DEFAULT_GROUP_QUOTAS/NETWORK_QUOTA", - "/DEFAULT_GROUP_QUOTAS/IMAGE_QUOTA", - "/DEFAULT_GROUP_QUOTAS/VM_QUOTA") + "/DEFAULT_GROUP_QUOTAS/DATASTORE_QUOTA", + "/DEFAULT_GROUP_QUOTAS/NETWORK_QUOTA", + "/DEFAULT_GROUP_QUOTAS/IMAGE_QUOTA", + "/DEFAULT_GROUP_QUOTAS/VM_QUOTA") , system_db(0), db_backend_type("sqlite"), logdb(0), fed_logdb(0) , vmpool(0), hpool(0), vnpool(0), upool(0), ipool(0), gpool(0), tpool(0) , dspool(0), clpool(0), docpool(0), zonepool(0), secgrouppool(0) @@ -728,9 +728,9 @@ private: * @return a reference to the generated string */ int get_conf_attribute( - const std::string& key, - const std::string& name, - const VectorAttribute* &value) const; + const std::string& key, + const std::string& name, + const VectorAttribute* &value) const; /** * Gets a Generic configuration attribute @@ -741,10 +741,10 @@ private: */ template int get_conf_attribute( - const std::string& key, - const std::string& name, - const std::string& vname, - T& value) const + const std::string& key, + const std::string& name, + const std::string& vname, + T& value) const { const VectorAttribute* vattr; diff --git a/include/NebulaLog.h b/include/NebulaLog.h index f3b33b72f9..242b13eb3e 100644 --- a/include/NebulaLog.h +++ b/include/NebulaLog.h @@ -28,7 +28,8 @@ class NebulaLog { public: - enum LogType { + enum LogType + { FILE = 0, FILE_TS = 1, STD = 2, @@ -41,11 +42,11 @@ public: // --------------------------------------------------------------- static void init_log_system( - LogType ltype, - Log::MessageType clevel, - const char * filename, - std::ios_base::openmode mode, - const std::string& daemon) + LogType ltype, + Log::MessageType clevel, + const char * filename, + std::ios_base::openmode mode, + const std::string& daemon) { _log_type = ltype; @@ -92,27 +93,27 @@ public: } static void log( - const char * module, - const Log::MessageType type, - const char * message) + const char * module, + const Log::MessageType type, + const char * message) { - logger->log(module,type,message); + logger->log(module, type, message); }; static void log( - const char * module, - const Log::MessageType type, - const std::ostringstream& message) + const char * module, + const Log::MessageType type, + const std::ostringstream& message) { - logger->log(module,type,message.str().c_str()); + logger->log(module, type, message.str().c_str()); }; static void log( - const char * module, - const Log::MessageType type, - const std::string& message) + const char * module, + const Log::MessageType type, + const std::string& message) { - logger->log(module,type,message.c_str()); + logger->log(module, type, message.c_str()); }; static void error(const char* module, const std::string& msg) @@ -156,9 +157,9 @@ public: }; private: - NebulaLog(){}; + NebulaLog() {}; - ~NebulaLog(){}; + ~NebulaLog() {}; static LogType _log_type; static Log * logger; diff --git a/include/NebulaService.h b/include/NebulaService.h index bbd200eb2f..a679d98a54 100644 --- a/include/NebulaService.h +++ b/include/NebulaService.h @@ -48,14 +48,14 @@ public: * @return the debug level, to instantiate Log'ers */ Log::MessageType get_debug_level( - Log::MessageType default_ = Log::ERROR) const; + Log::MessageType default_ = Log::ERROR) const; /** * Returns the value of LOG->SYSTEM in oned.conf file * @return the logging system CERR, FILE_TS or SYSLOG */ NebulaLog::LogType get_log_system( - NebulaLog::LogType default_ = NebulaLog::UNDEFINED) const; + NebulaLog::LogType default_ = NebulaLog::UNDEFINED) const; /** * Returns the value of ONE_LOCATION env variable. When this variable is @@ -137,11 +137,11 @@ public: */ static std::string version() { - std::ostringstream os; - os << "OpenNebula " << code_version(); - os << " (" << GITVERSION << ")"; + std::ostringstream os; + os << "OpenNebula " << code_version(); + os << " (" << GITVERSION << ")"; - return os.str(); + return os.str(); }; /** diff --git a/include/NebulaTemplate.h b/include/NebulaTemplate.h index 6f77dc3026..7bd532db1f 100644 --- a/include/NebulaTemplate.h +++ b/include/NebulaTemplate.h @@ -28,7 +28,7 @@ class NebulaTemplate : public Template { public: NebulaTemplate(const std::string& etc_location, const char * _conf_name, - const char * root_name) + const char * root_name) : Template(false, '=', root_name) , hidden_attributes{ { "DB", { "PASSWD" } } } { diff --git a/include/NebulaUtil.h b/include/NebulaUtil.h index f8699eab41..b1c54668ec 100644 --- a/include/NebulaUtil.h +++ b/include/NebulaUtil.h @@ -66,22 +66,22 @@ namespace one_util std::string sha256_digest(const std::string& in); - /** - * AES256 encryption - * @param in the string to encrypt - * @param password to encrypt data - * @return a pointer to the encrypted string (must be freed) or nullptr in case of - * error - */ + /** + * AES256 encryption + * @param in the string to encrypt + * @param password to encrypt data + * @return a pointer to the encrypted string (must be freed) or nullptr in case of + * error + */ std::string * aes256cbc_encrypt(const std::string& in, const std::string& password); - /** - * AES256 decryption - * @param in the base64 string to decrypt - * @param password to decrypt data - * @return a pointer to the decrypted string (must be freed) or nullptr in case of - * error - */ + /** + * AES256 decryption + * @param in the base64 string to decrypt + * @param password to decrypt data + * @return a pointer to the decrypted string (must be freed) or nullptr in case of + * error + */ std::string * aes256cbc_decrypt(const std::string& in, const std::string& password); /** @@ -177,7 +177,7 @@ namespace one_util } std::vector split(const std::string& st, char delim, - bool clean_empty = true); + bool clean_empty = true); /** * Splits a string, using the given delimiter @@ -212,7 +212,7 @@ namespace one_util */ template <> void split_unique(const std::string& st, char delim, - std::set& result); + std::set& result); /** * Joins the given element with the delimiter @@ -319,11 +319,11 @@ namespace one_util * @return a string copy */ std::string gsub(const std::string& st, const std::string& sfind, - const std::string& replacement); + const std::string& replacement); template std::set set_intersection(const std::set &first, const std::set - &second) + &second) { std::set output; diff --git a/include/ObjectCollection.h b/include/ObjectCollection.h index 57b9922e1e..47f516741a 100644 --- a/include/ObjectCollection.h +++ b/include/ObjectCollection.h @@ -31,12 +31,12 @@ class ObjectCollection public: ObjectCollection(const std::string& _collection_name) - :collection_name(_collection_name){}; + :collection_name(_collection_name) {}; ObjectCollection(const std::string& cname, const std::set& cset) - :collection_name(cname), collection_set(cset){}; + :collection_name(cname), collection_set(cset) {}; - ~ObjectCollection(){}; + ~ObjectCollection() {}; /** * Adds an ID to the set. diff --git a/include/ObjectSQL.h b/include/ObjectSQL.h index 1700a000d7..d8a8693031 100644 --- a/include/ObjectSQL.h +++ b/include/ObjectSQL.h @@ -39,7 +39,7 @@ protected: * @return 0 on success */ virtual int select( - SqlDB * db) = 0; + SqlDB * db) = 0; /** * Writes the ObjectSQL in the database. @@ -47,8 +47,8 @@ protected: * @return 0 on success */ virtual int insert( - SqlDB * db, - std::string& error_str) = 0; + SqlDB * db, + std::string& error_str) = 0; /** * Updates the ObjectSQL in the database. @@ -56,7 +56,7 @@ protected: * @return 0 on success */ virtual int update( - SqlDB * db) = 0; + SqlDB * db) = 0; /** * Removes the ObjectSQL from the database. @@ -64,7 +64,7 @@ protected: * @return 0 on success */ virtual int drop( - SqlDB * db) = 0; + SqlDB * db) = 0; }; #endif /*OBJECT_SQL_H_*/ diff --git a/include/ObjectXML.h b/include/ObjectXML.h index 3d4f2cdf23..4bed0e228c 100644 --- a/include/ObjectXML.h +++ b/include/ObjectXML.h @@ -70,7 +70,7 @@ public: xmlNodePtr cur; xmlChar * str_ptr; - obj = xmlXPathEvalExpression(reinterpret_cast(expr),ctx); + obj = xmlXPathEvalExpression(reinterpret_cast(expr), ctx); if (obj == 0) { diff --git a/include/OpenNebulaTemplate.h b/include/OpenNebulaTemplate.h index a62f3add98..74d05fe96e 100644 --- a/include/OpenNebulaTemplate.h +++ b/include/OpenNebulaTemplate.h @@ -34,7 +34,7 @@ public: const std::string& _conf_name = conf_name): NebulaTemplate(etc_location, _conf_name.c_str(), "OPENNEBULA_CONFIGURATION"), var_location(_var_location) - {}; + {}; ~OpenNebulaTemplate() = default; @@ -54,7 +54,7 @@ public: * Returns action set from a string of actions seperated by commas */ static int set_vm_auth_ops(const std::string& ops_str, - ActionSet& ops_set, std::string& error); + ActionSet& ops_set, std::string& error); /** * @param action diff --git a/include/PoolObjectSQL.h b/include/PoolObjectSQL.h index f1593e2bdf..64a0284840 100644 --- a/include/PoolObjectSQL.h +++ b/include/PoolObjectSQL.h @@ -158,31 +158,31 @@ public: const std::string& _uname, const std::string& _gname, const char * _table) - :ObjectSQL(), - ObjectXML(), - oid(id), - obj_type(_obj_type), - name(_name), - uid(_uid), - gid(_gid), - uname(_uname), - gname(_gname), - owner_u(1), - owner_m(1), - owner_a(0), - group_u(0), - group_m(0), - group_a(0), - other_u(0), - other_m(0), - other_a(0), - locked(LockStates::ST_NONE), - lock_owner(-1), - lock_req_id(-1), - lock_time(0), - ro(false), - _mutex(nullptr), - table(_table) + :ObjectSQL(), + ObjectXML(), + oid(id), + obj_type(_obj_type), + name(_name), + uid(_uid), + gid(_gid), + uname(_uname), + gname(_gname), + owner_u(1), + owner_m(1), + owner_a(0), + group_u(0), + group_m(0), + group_a(0), + other_u(0), + other_m(0), + other_a(0), + locked(LockStates::ST_NONE), + lock_owner(-1), + lock_req_id(-1), + lock_time(0), + ro(false), + _mutex(nullptr), + table(_table) { }; @@ -625,7 +625,7 @@ protected: * @return -1 if not found or oid otherwise */ static int select_oid(SqlDB *db, const char * _table, const std::string& _name, - int _uid); + int _uid); /** * Check if the object exists diff --git a/include/PoolSQL.h b/include/PoolSQL.h index d017d6f7fe..d443c199c8 100644 --- a/include/PoolSQL.h +++ b/include/PoolSQL.h @@ -52,8 +52,8 @@ public: * @return the oid assigned to the object or -1 in case of failure */ virtual int allocate( - PoolObjectSQL *objsql, - std::string& error_str); + PoolObjectSQL *objsql, + std::string& error_str); /** * Gets an object from the pool (if needed the object is loaded from the @@ -153,9 +153,9 @@ public: * @return 0 on success */ virtual int search( - std::vector& oids, - const char * table, - const std::string& where); + std::vector& oids, + const char * table, + const std::string& where); /** * List the objects in the pool @@ -165,8 +165,8 @@ public: * @return 0 on success */ int list( - std::vector& oids, - const char * table) + std::vector& oids, + const char * table) { return search(oids, table, ""); } @@ -179,7 +179,7 @@ public: * @return 0 on success. */ virtual int update( - PoolObjectSQL * objsql) + PoolObjectSQL * objsql) { return objsql->update(db); }; @@ -245,10 +245,10 @@ public: * @return 0 on success */ virtual int dump_extended(std::string& oss, - const std::string& where, - int sid, - int eid, - bool desc) + const std::string& where, + int sid, + int eid, + bool desc) { return dump(oss, where, sid, eid, desc); } @@ -328,10 +328,10 @@ public: /** * Return true if feature is supported */ - bool supports(SqlDB::SqlFeature ft) - { - return db->supports(ft); - } + bool supports(SqlDB::SqlFeature ft) + { + return db->supports(ft); + } protected: diff --git a/include/PostgreSqlDB.h b/include/PostgreSqlDB.h index 297f47777c..e47d2305ba 100644 --- a/include/PostgreSqlDB.h +++ b/include/PostgreSqlDB.h @@ -35,12 +35,12 @@ class PostgreSqlDB : public SqlDB { public: PostgreSqlDB( - const std::string& _server, - int _port, - const std::string& _user, - const std::string& _password, - const std::string& _database, - int _connections); + const std::string& _server, + int _port, + const std::string& _user, + const std::string& _password, + const std::string& _database, + int _connections); ~PostgreSqlDB(); @@ -168,24 +168,25 @@ class PostgreSqlDB : public SqlDB { public: PostgreSqlDB( - const std::string& _server, - int _port, - const std::string& _user, - const std::string& _password, - const std::string& _database, - int _connections) + const std::string& _server, + int _port, + const std::string& _user, + const std::string& _password, + const std::string& _database, + int _connections) { throw std::runtime_error("Aborting oned, PostgreSQL support not compiled!"); } - ~PostgreSqlDB(){} + ~PostgreSqlDB() {} char * escape_str(const std::string& str) const override {return 0;}; void free_str(char * str) const override {}; protected: - int exec_ext(std::ostringstream& c, Callbackable *o, bool q) override { + int exec_ext(std::ostringstream& c, Callbackable *o, bool q) override + { return -1; }; }; diff --git a/include/Quota.h b/include/Quota.h index 9198be7cd0..ddb663d9fc 100644 --- a/include/Quota.h +++ b/include/Quota.h @@ -66,20 +66,20 @@ public: /** * Returns the name that identifies the quota in a template */ - virtual const char * get_quota_name() const = 0; + virtual const char * get_quota_name() const = 0; - /** - * Gets a quota identified by its ID. - * @param id of the quota - * @param va The quota, if it is found - * @return 0 on success, -1 if not found - */ - virtual int get_quota(const std::string& id, VectorAttribute **va) = 0; + /** + * Gets a quota identified by its ID. + * @param id of the quota + * @param va The quota, if it is found + * @return 0 on success, -1 if not found + */ + virtual int get_quota(const std::string& id, VectorAttribute **va) = 0; protected: - QuotaInterface(){}; + QuotaInterface() {}; - virtual ~QuotaInterface(){}; + virtual ~QuotaInterface() {}; }; /** @@ -120,9 +120,9 @@ class QuotaDecorator : public QuotaInterface } protected: - QuotaDecorator(QuotaInterface * _quota):quota(_quota){}; + QuotaDecorator(QuotaInterface * _quota):quota(_quota) {}; - virtual ~QuotaDecorator(){}; + virtual ~QuotaDecorator() {}; QuotaInterface * quota; }; @@ -162,33 +162,33 @@ public: /** * Returns the name that identifies the quota in a template */ - const char * get_quota_name() const override - { + const char * get_quota_name() const override + { return template_name; - } + } - /** - * Gets a quota identified by its ID. - * @param id of the quota - * @param va The quota, if it is found - * @return 0 on success, -1 if not found - */ - int get_quota(const std::string& id, VectorAttribute **va) override - { - std::map::iterator it; - return get_quota(id, va, it); - } + /** + * Gets a quota identified by its ID. + * @param id of the quota + * @param va The quota, if it is found + * @return 0 on success, -1 if not found + */ + int get_quota(const std::string& id, VectorAttribute **va) override + { + std::map::iterator it; + return get_quota(id, va, it); + } - /** - * Value for limit default - */ - static const int DEFAULT; - static const std::string DEFAULT_STR; + /** + * Value for limit default + */ + static const int DEFAULT; + static const std::string DEFAULT_STR; - /** - * Value for "unlimited" limit - */ - static const int UNLIMITED; + /** + * Value for "unlimited" limit + */ + static const int UNLIMITED; protected: @@ -201,9 +201,9 @@ protected: template_name(_template_name), metrics(_metrics), num_metrics(_num_metrics), - is_default(_is_default){}; + is_default(_is_default) {}; - virtual ~Quota(){}; + virtual ~Quota() {}; /** * Generic Quota Names @@ -278,8 +278,8 @@ protected: * @return 0 on success, -1 if not found */ virtual int get_default_quota(const std::string& id, - Quotas& default_quotas, - VectorAttribute **va) = 0; + Quotas& default_quotas, + VectorAttribute **va) = 0; /** * Gets a quota identified by its ID. @@ -319,7 +319,7 @@ private: */ void add(VectorAttribute * nq) { - attributes.insert(make_pair(nq->name(), nq)); + attributes.insert(make_pair(nq->name(), nq)); } /** @@ -340,7 +340,7 @@ private: * @return 0 on success or -1 if wrong limits */ int update_limits(VectorAttribute* quota, - const VectorAttribute* va); + const VectorAttribute* va); /** * Extract the limits for the defined quota metrics from a given attribute diff --git a/include/QuotaDatastore.h b/include/QuotaDatastore.h index a5da521fb1..645b082ab4 100644 --- a/include/QuotaDatastore.h +++ b/include/QuotaDatastore.h @@ -44,7 +44,7 @@ public: is_default) {}; - ~QuotaDatastore(){}; + ~QuotaDatastore() {}; /** * Check if the resource allocation will exceed the quota limits. If not @@ -74,8 +74,8 @@ protected: * @return 0 on success, -1 if not found */ int get_default_quota(const std::string& id, - Quotas& default_quotas, - VectorAttribute **va) override; + Quotas& default_quotas, + VectorAttribute **va) override; static const char * DS_METRICS[]; diff --git a/include/QuotaImage.h b/include/QuotaImage.h index 68a6cd23b7..fbf8bbcd88 100644 --- a/include/QuotaImage.h +++ b/include/QuotaImage.h @@ -42,7 +42,7 @@ public: is_default) {}; - ~QuotaImage(){}; + ~QuotaImage() {}; /** * Check if the resource allocation will exceed the quota limits. If not @@ -72,8 +72,8 @@ protected: * @return 0 on success, -1 if not found */ int get_default_quota(const std::string& id, - Quotas& default_quotas, - VectorAttribute **va) override; + Quotas& default_quotas, + VectorAttribute **va) override; static const char * IMAGE_METRICS[]; diff --git a/include/QuotaNetwork.h b/include/QuotaNetwork.h index cefcc5a2fc..ec0286f303 100644 --- a/include/QuotaNetwork.h +++ b/include/QuotaNetwork.h @@ -34,9 +34,9 @@ class QuotaNetwork : public Quota { public: QuotaNetwork(bool is_default): Quota("NETWORK_QUOTA", "NETWORK", NET_METRICS, - NUM_NET_METRICS, is_default) {}; + NUM_NET_METRICS, is_default) {}; - virtual ~QuotaNetwork(){}; + virtual ~QuotaNetwork() {}; /** * Check if the resource allocation will exceed the quota limits. If not @@ -72,8 +72,8 @@ protected: * @return 0 on success, -1 if not found */ int get_default_quota(const std::string& id, - Quotas& default_quotas, - VectorAttribute **va) override; + Quotas& default_quotas, + VectorAttribute **va) override; static const char * NET_METRICS[]; @@ -97,7 +97,7 @@ private: * @return true if the operation can be performed */ bool check(PoolObjectSQL::ObjectType otype, Template* tmpl, - Quotas& default_quotas, std::string& error); + Quotas& default_quotas, std::string& error); /** * Decrement usage counters when freeing a lease. This method considers @@ -116,9 +116,9 @@ private: class QuotaNetworkVirtualRouter: public QuotaDecorator { public: - QuotaNetworkVirtualRouter(QuotaNetwork *qn):QuotaDecorator(qn){}; + QuotaNetworkVirtualRouter(QuotaNetwork *qn):QuotaDecorator(qn) {}; - virtual ~QuotaNetworkVirtualRouter(){}; + virtual ~QuotaNetworkVirtualRouter() {}; bool check(Template* tmpl, Quotas& default_quotas, std::string& err) override { @@ -127,7 +127,7 @@ public: return qn->check(PoolObjectSQL::VROUTER, tmpl, default_quotas, err); } -void del(Template* tmpl) override + void del(Template* tmpl) override { QuotaNetwork * qn = static_cast(quota); diff --git a/include/QuotaVirtualMachine.h b/include/QuotaVirtualMachine.h index 3ac9c588da..4e9ce0138c 100644 --- a/include/QuotaVirtualMachine.h +++ b/include/QuotaVirtualMachine.h @@ -53,7 +53,7 @@ public: is_default) {}; - ~QuotaVirtualMachine(){}; + ~QuotaVirtualMachine() {}; /** * Check if the resource allocation will exceed the quota limits. If not @@ -126,9 +126,9 @@ protected: * @return 0 on success, -1 if not found */ int get_default_quota( - const std::string& id, - Quotas& default_quotas, - VectorAttribute **va) override; + const std::string& id, + Quotas& default_quotas, + VectorAttribute **va) override; static const char * VM_METRICS[]; diff --git a/include/Quotas.h b/include/Quotas.h index 32f7fa9cc4..9457b97cfc 100644 --- a/include/Quotas.h +++ b/include/Quotas.h @@ -30,7 +30,8 @@ public: /** * Different quota types */ - enum QuotaType { + enum QuotaType + { DATASTORE, /**< Checks Datastore usage */ VM, /**< Checks VM usage (MEMORY, CPU and VMS) */ NETWORK, /**< Checks Network usage (leases) */ @@ -52,71 +53,71 @@ public: * Delete usage from quota counters. * @param tmpl Template with the quota usage */ - void ds_del(Template * tmpl) - { + void ds_del(Template * tmpl) + { datastore_quota.del(tmpl); - } + } - /** - * Gets a Datastore quota identified by its ID. - * - * @param id of the quota - * @param va The quota, if it is found - * - * @return 0 on success, -1 if not found - */ - int ds_get(const std::string& id, VectorAttribute **va) - { - return datastore_quota.get_quota(id, va); - } + /** + * Gets a Datastore quota identified by its ID. + * + * @param id of the quota + * @param va The quota, if it is found + * + * @return 0 on success, -1 if not found + */ + int ds_get(const std::string& id, VectorAttribute **va) + { + return datastore_quota.get_quota(id, va); + } - /** - * Add VM quota usage, without checking limits - * @param tmpl Template with the quota usage - */ - void vm_add(Template * tmpl) - { - vm_quota.add(tmpl); - } + /** + * Add VM quota usage, without checking limits + * @param tmpl Template with the quota usage + */ + void vm_add(Template * tmpl) + { + vm_quota.add(tmpl); + } - /** - * Gets a VM quota identified by its ID. - * - * @param id of the quota - * @param va The quota, if it is found - * - * @return 0 on success, -1 if not found - */ - int vm_get(const std::string& id, VectorAttribute **va) - { - return vm_quota.get_quota(id, va); - } + /** + * Gets a VM quota identified by its ID. + * + * @param id of the quota + * @param va The quota, if it is found + * + * @return 0 on success, -1 if not found + */ + int vm_get(const std::string& id, VectorAttribute **va) + { + return vm_quota.get_quota(id, va); + } - /** - * Gets a Network quota identified by its ID. - * - * @param id of the quota - * @param va The quota, if it is found - * - * @return 0 on success, -1 if not found - */ - int network_get(const std::string& id, VectorAttribute **va) - { - return network_quota.get_quota(id, va); - } + /** + * Gets a Network quota identified by its ID. + * + * @param id of the quota + * @param va The quota, if it is found + * + * @return 0 on success, -1 if not found + */ + int network_get(const std::string& id, VectorAttribute **va) + { + return network_quota.get_quota(id, va); + } - /** - * Gets an Image quota identified by its ID. - * - * @param id of the quota - * @param va The quota, if it is found - * - * @return 0 on success, -1 if not found - */ - int image_get(const std::string& id, VectorAttribute **va) - { - return image_quota.get_quota(id, va); - } + /** + * Gets an Image quota identified by its ID. + * + * @param id of the quota + * @param va The quota, if it is found + * + * @return 0 on success, -1 if not found + */ + int image_get(const std::string& id, VectorAttribute **va) + { + return image_quota.get_quota(id, va); + } /** * Check quota, it updates usage counters if quotas are not exceeded. @@ -126,7 +127,7 @@ public: * @param error_str string describing the error * @return true if resource can be allocated, false otherwise */ - bool quota_check(QuotaType type, + bool quota_check(QuotaType type, Template *tmpl, Quotas& default_quotas, std::string& error_str); @@ -140,10 +141,10 @@ public: * @param error_str string describing the error * @return true if resource can be updated, false otherwise */ - bool quota_update(QuotaType type, - Template *tmpl, - Quotas& default_quotas, - std::string& error_str); + bool quota_update(QuotaType type, + Template *tmpl, + Quotas& default_quotas, + std::string& error_str); /** * Delete usage from the given quota counters. @@ -229,12 +230,12 @@ public: } } - /** - * Delete a set of Datastore usage attributes from quota counters. Each - * quota datastore is associate to a given image. NOTE: The templates - * *ARE FREED* by this function - * @param ds_quotas a map with image_id and a tmpl with usage attributes - */ + /** + * Delete a set of Datastore usage attributes from quota counters. Each + * quota datastore is associate to a given image. NOTE: The templates + * *ARE FREED* by this function + * @param ds_quotas a map with image_id and a tmpl with usage attributes + */ static void ds_del_recreate(int uid, int gid, std::vector