Пример #1
0
    def execute(self):
        """Map the instance's boot disk and discover it."""

        # Search for boot disk on the NovaLink partition
        if self.disk_dvr.mp_uuid in self.disk_dvr.vios_uuids:
            dev_name = self.disk_dvr.get_bootdisk_path(self.instance,
                                                       self.disk_dvr.mp_uuid)
            if dev_name is not None:
                return None, None, dev_name

        self.stg_elem, self.vios_wrap = (
            self.disk_dvr.connect_instance_disk_to_mgmt(self.instance))
        new_maps = pvm_smap.find_maps(self.vios_wrap.scsi_mappings,
                                      client_lpar_id=self.disk_dvr.mp_uuid,
                                      stg_elem=self.stg_elem)
        if not new_maps:
            raise npvmex.NewMgmtMappingNotFoundException(
                stg_name=self.stg_elem.name, vios_name=self.vios_wrap.name)

        # new_maps should be length 1, but even if it's not - i.e. we somehow
        # matched more than one mapping of the same dev to the management
        # partition from the same VIOS - it is safe to use the first one.
        the_map = new_maps[0]
        # Scan the SCSI bus, discover the disk, find its canonical path.
        LOG.info(
            "Discovering device and path for mapping of %(dev_name)s "
            "on the management partition.", {'dev_name': self.stg_elem.name},
            instance=self.instance)
        self.disk_path = mgmt.discover_vscsi_disk(the_map)
        return self.stg_elem, self.vios_wrap, self.disk_path
Пример #2
0
 def test_discover_vscsi_disk(self, mock_realpath, mock_exec, mock_glob):
     scanpath = '/sys/bus/vio/devices/30000005/host*/scsi_host/host*/scan'
     udid = ('275b5d5f88fa5611e48be9000098be9400'
             '13fb2aa55a2d7b8d150cb1b7b6bc04d6')
     devlink = ('/dev/disk/by-id/scsi-SIBM_3303_NVDISK' + udid)
     mapping = mock.Mock()
     mapping.client_adapter.lpar_slot_num = 5
     mapping.backing_storage.udid = udid
     # Realistically, first glob would return  e.g. .../host0/.../host0/...
     # but it doesn't matter for test purposes.
     mock_glob.side_effect = [[scanpath], [devlink]]
     mgmt.discover_vscsi_disk(mapping)
     mock_glob.assert_has_calls(
         [mock.call(scanpath), mock.call('/dev/disk/by-id/*' + udid[-32:])])
     mock_exec.assert_called_with('tee', '-a', scanpath,
                                  process_input='- - -', run_as_root=True)
     mock_realpath.assert_called_with(devlink)
Пример #3
0
 def test_discover_vscsi_disk(self, mock_realpath, mock_dacw, mock_glob):
     scanpath = '/sys/bus/vio/devices/30000005/host*/scsi_host/host*/scan'
     udid = ('275b5d5f88fa5611e48be9000098be9400'
             '13fb2aa55a2d7b8d150cb1b7b6bc04d6')
     devlink = ('/dev/disk/by-id/scsi-SIBM_3303_NVDISK' + udid)
     mapping = mock.Mock()
     mapping.client_adapter.lpar_slot_num = 5
     mapping.backing_storage.udid = udid
     # Realistically, first glob would return  e.g. .../host0/.../host0/...
     # but it doesn't matter for test purposes.
     mock_glob.side_effect = [[scanpath], [devlink]]
     mgmt.discover_vscsi_disk(mapping)
     mock_glob.assert_has_calls(
         [mock.call(scanpath),
          mock.call('/dev/disk/by-id/*' + udid[-32:])])
     mock_dacw.assert_called_with(scanpath, 'a', '- - -')
     mock_realpath.assert_called_with(devlink)
Пример #4
0
    def execute(self):
        """Map the instance's boot disk and discover it."""
        LOG.info(_LI("Mapping boot disk of instance %(instance_name)s to "
                     "management partition."),
                 {'instance_name': self.instance.name})
        self.stg_elem, self.vios_wrap = (
            self.disk_dvr.connect_instance_disk_to_mgmt(self.instance))
        new_maps = pvm_smap.find_maps(
            self.vios_wrap.scsi_mappings, client_lpar_id=self.disk_dvr.mp_uuid,
            stg_elem=self.stg_elem)
        if not new_maps:
            raise npvmex.NewMgmtMappingNotFoundException(
                stg_name=self.stg_elem.name, vios_name=self.vios_wrap.name)

        # new_maps should be length 1, but even if it's not - i.e. we somehow
        # matched more than one mapping of the same dev to the management
        # partition from the same VIOS - it is safe to use the first one.
        the_map = new_maps[0]
        # Scan the SCSI bus, discover the disk, find its canonical path.
        LOG.info(_LI("Discovering device and path for mapping of %(dev_name)s "
                     "on the management partition."),
                 {'dev_name': self.stg_elem.name})
        self.disk_path = mgmt.discover_vscsi_disk(the_map)
        return self.stg_elem, self.vios_wrap, self.disk_path