def maximum_size_bytes(self): """Gets the biggest volume :returns size in bytes. """ if self._maximum_size_bytes is None: self._maximum_size_bytes = (utils.max_safe( [member.capacity_bytes for member in self.get_members()])) return self._maximum_size_bytes
def maximum_size_mib(self): """Gets the biggest logical drive :returns size in MiB. """ if self._maximum_size_mib is None: self._maximum_size_mib = (utils.max_safe( [member.capacity_mib for member in self.get_members()])) return self._maximum_size_mib
def drives_maximum_size_bytes(self): """Gets the biggest disk :returns the size in MiB. """ if self._drives_maximum_size_bytes is None: self._drives_maximum_size_bytes = (utils.max_safe( [member.capacity_bytes for member in self._drives_list()])) return self._drives_maximum_size_bytes
def physical_drives_maximum_size_mib(self): """Gets the biggest disk :returns the size in MiB. """ if self._physical_drives_maximum_size_mib is None: self._physical_drives_maximum_size_mib = (utils.max_safe([ member.physical_drives.maximum_size_mib for member in self.get_members() ])) return self._physical_drives_maximum_size_mib
def maximum_size_bytes(self): """Gets the biggest disk drive :returns size in bytes. """ if self._maximum_size_bytes is None: self._maximum_size_bytes = (utils.max_safe([ device.get('CapacityBytes') for device in self.devices if device.get('CapacityBytes') is not None ])) return self._maximum_size_bytes
def volumes_maximum_size_bytes(self): """Gets the biggest logical drive :returns the size in MiB. """ if self._volumes_maximum_size_bytes is None: self._volumes_maximum_size_bytes = (utils.max_safe([ member.volumes.maximum_size_bytes for member in self.get_members() ])) return self._volumes_maximum_size_bytes
def get_local_gb(system_obj): """Gets the largest volume or the largest disk :param system_obj: The HPESystem object. :returns the size in GB """ local_max_bytes = 0 logical_max_mib = 0 volume_max_bytes = 0 physical_max_mib = 0 drives_max_bytes = 0 simple_max_bytes = 0 # Gets the resources and properties # its quite possible for a system to lack the resource, hence its # URI may also be lacking. # Check if smart_storage resource exist at the system smart_resource = _get_attribute_value_of(system_obj, 'smart_storage') # Check if storage resource exist at the system storage_resource = _get_attribute_value_of(system_obj, 'storages') if smart_resource is not None: logical_max_mib = _get_attribute_value_of( smart_resource, 'logical_drives_maximum_size_mib', default=0) if storage_resource is not None: volume_max_bytes = _get_attribute_value_of( storage_resource, 'volumes_maximum_size_bytes', default=0) # Get the largest volume from the system. local_max_bytes = utils.max_safe([(logical_max_mib * 1024 * 1024), volume_max_bytes]) # if volume is not found, then traverse through the possible disk drives # and get the biggest disk. if local_max_bytes == 0: if smart_resource is not None: physical_max_mib = _get_attribute_value_of( smart_resource, 'physical_drives_maximum_size_mib', default=0) if storage_resource is not None: drives_max_bytes = _get_attribute_value_of( storage_resource, 'drives_maximum_size_bytes', default=0) # Check if the SimpleStorage resource exist at the system. simple_resource = _get_attribute_value_of(system_obj, 'simple_storages') if simple_resource is not None: simple_max_bytes = _get_attribute_value_of(simple_resource, 'maximum_size_bytes', default=0) local_max_bytes = utils.max_safe([(physical_max_mib * 1024 * 1024), drives_max_bytes, simple_max_bytes]) # Convert the received size to GB and reduce the value by 1 Gb as # ironic requires the local_gb to be returned 1 less than actual size. local_gb = 0 if local_max_bytes > 0: local_gb = int(local_max_bytes / (1024 * 1024 * 1024)) - 1 else: msg = ('The maximum size for the hard disk or logical ' 'volume could not be determined.') LOG.debug(msg) return local_gb
def test_max_safe(self, iterable, expected): actual = utils.max_safe(iterable) self.assertEqual(expected, actual)