def test_vols_for_boolean_specs(self): """Test ssc for boolean specs.""" test_vols = set( [self.vol1, self.vol2, self.vol3, self.vol4, self.vol5]) ssc_map = {'mirrored': set([self.vol1]), 'dedup': set([self.vol1, self.vol2, self.vol3]), 'compression': set([self.vol3, self.vol4]), 'thin': set([self.vol5, self.vol2]), 'all': test_vols} test_map = {'mirrored': ('netapp_mirrored', 'netapp_unmirrored'), 'dedup': ('netapp_dedup', 'netapp_nodedup'), 'compression': ('netapp_compression', 'netapp_nocompression'), 'thin': ('netapp_thin_provisioned', 'netapp_thick_provisioned')} for type in test_map.keys(): # type extra_specs = {test_map[type][0]: 'true'} res = ssc_utils.get_volumes_for_specs(ssc_map, extra_specs) self.assertEqual(len(res), len(ssc_map[type])) # opposite type extra_specs = {test_map[type][1]: 'true'} res = ssc_utils.get_volumes_for_specs(ssc_map, extra_specs) self.assertEqual(len(res), len(ssc_map['all'] - ssc_map[type])) # both types extra_specs =\ {test_map[type][0]: 'true', test_map[type][1]: 'true'} res = ssc_utils.get_volumes_for_specs(ssc_map, extra_specs) self.assertEqual(len(res), len(ssc_map['all']))
def _get_avl_volumes(self, size, extra_specs=None): """Get the available volume by size, extra_specs.""" result = [] volumes = ssc_utils.get_volumes_for_specs(self.ssc_vols, extra_specs) if volumes: sorted_vols = sorted(volumes, reverse=True) for vol in sorted_vols: if int(vol.space["size_avl_bytes"]) >= int(size): result.append(vol) return result
def test_vols_for_optional_specs(self): """Test ssc for optional specs.""" test_vols =\ set([self.vol1, self.vol2, self.vol3, self.vol4, self.vol5]) ssc_map = {'mirrored': set([self.vol1]), 'dedup': set([self.vol1, self.vol2, self.vol3]), 'compression': set([self.vol3, self.vol4]), 'thin': set([self.vol5, self.vol2]), 'all': test_vols} extra_specs =\ {'netapp_dedup': 'true', 'netapp:raid_type': 'raid4', 'netapp:disk_type': 'SSD'} res = ssc_utils.get_volumes_for_specs(ssc_map, extra_specs) self.assertEqual(len(res), 1)
def _find_containers(self, size, extra_specs): """Finds suitable containers for given params.""" containers = [] if self.ssc_enabled: vols = ssc_utils.get_volumes_for_specs(self.ssc_vols, extra_specs) sort_vols = sorted(vols, reverse=True) for vol in sort_vols: if self._is_share_eligible(vol.export["path"], size): containers.append(vol) else: for sh in self._mounted_shares: if self._is_share_eligible(sh, size): total_size, total_available, total_allocated = self._get_capacity_info(sh) containers.append((sh, total_available)) containers = [a for a, b in sorted(containers, key=lambda x: x[1], reverse=True)] return containers
def _find_containers(self, size, extra_specs): """Finds suitable containers for given params.""" containers = [] if self.ssc_enabled: vols =\ ssc_utils.get_volumes_for_specs(self.ssc_vols, extra_specs) sort_vols = sorted(vols, reverse=True) for vol in sort_vols: if self._is_share_eligible(vol.export['path'], size): containers.append(vol) else: for sh in self._mounted_shares: if self._is_share_eligible(sh, size): total_size, total_available, total_allocated = \ self._get_capacity_info(sh) containers.append((sh, total_available)) containers = [ a for a, b in sorted( containers, key=lambda x: x[1], reverse=True) ] return containers