Esempio n. 1
0
    def test_detach_storage(self):
        """Detach storage from some mappings."""
        # In v1wrap, all five maps are associated with LPAR 2
        num_matches = 5
        self.assertEqual(num_matches, len(self.v1wrap.scsi_mappings))
        # Beforehand, four of them have storage and one does not.
        self.assertEqual(
            4,
            len([
                sm.backing_storage for sm in self.v1wrap.scsi_mappings
                if sm.backing_storage is not None
            ]))
        removals = scsi_mapper.detach_storage(self.v1wrap, 2)
        # The number of mappings is the same afterwards.
        self.assertEqual(num_matches, len(self.v1wrap.scsi_mappings))
        # But now the mappings have no storage
        for smap in self.v1wrap.scsi_mappings:
            self.assertIsNone(smap.backing_storage)
        # The return list contains all the mappings
        self.assertEqual(num_matches, len(removals))
        # The return list members contain the storage (the four that had it
        # beforehand).
        self.assertEqual(
            4,
            len([
                sm.backing_storage for sm in removals
                if sm.backing_storage is not None
            ]))

        # In v2wrap, there are four VOptMedia mappings
        num_matches = 4
        match_class = pvm_stor.VOptMedia
        # Number of mappings should be the same before and after.
        len_before = len(self.v2wrap.scsi_mappings)
        self.assertEqual(
            num_matches,
            len([
                1 for sm in self.v2wrap.scsi_mappings
                if isinstance(sm.backing_storage, match_class)
            ]))
        removals = scsi_mapper.detach_storage(
            self.v2wrap,
            None,
            match_func=scsi_mapper.gen_match_func(match_class))
        self.assertEqual(num_matches, len(removals))
        # The number of mappings is the same as beforehand.
        self.assertEqual(len_before, len(self.v2wrap.scsi_mappings))
        # Now there should be no mappings with VOptMedia
        self.assertEqual(
            0,
            len([
                1 for sm in self.v2wrap.scsi_mappings
                if isinstance(sm.backing_storage, match_class)
            ]))
        # The removals contain the storage
        self.assertEqual(
            num_matches,
            len([
                1 for sm in removals
                if isinstance(sm.backing_storage, match_class)
            ]))
Esempio n. 2
0
 def detach_vopt_from_map(vios_w):
     return tsk_map.detach_storage(vios_w, lpar_uuid,
                                   match_func=match_func)