Esempio n. 1
0
    def _configure(self, dev):
        self._check_self()

        # Use H:C:T:L format or preserve the path given by the user.
        try:
            (hostid, channelid, targetid, lunid) = \
                    convert_scsi_path_to_hctl(dev)
        except TypeError:
            try:
                (hostid, channelid, targetid, lunid) = dev.split(':')
                hostid = int(hostid)
                channelid = int(channelid)
                targetid = int(targetid)
                lunid = int(lunid)
            except ValueError:
                raise RTSLibError("Cannot find SCSI device by "
                                  + "path, and dev "
                                  + "parameter not in H:C:T:L "
                                  + "format: %s" % dev)
            else:
                udev_path = convert_scsi_hctl_to_path(hostid,
                                                            channelid,
                                                            targetid,
                                                            lunid)
            if not udev_path:
                raise RTSLibError("SCSI device does not exist")
        else:
            udev_path = dev.strip()

        if is_dev_in_use(udev_path):
            raise RTSLibError("Cannot configure StorageObject because "
                              + "device %s (SCSI %d:%d:%d:%d) "
                              % (udev_path, hostid, channelid,
                                 targetid, lunid)
                              + "is already in use")

        self._control("scsi_host_id=%d," % hostid \
                      + "scsi_channel_id=%d," % channelid \
                      + "scsi_target_id=%d," % targetid \
                      + "scsi_lun_id=%d" % lunid)
        self._set_udev_path(udev_path)
        self._enable()

        super(PSCSIStorageObject, self)._configure()
Esempio n. 2
0
    def _configure(self, dev):
        self._check_self()

        # Use H:C:T:L format or preserve the path given by the user.
        try:
            (hostid, channelid, targetid, lunid) = \
                    convert_scsi_path_to_hctl(dev)
        except TypeError:
            try:
                (hostid, channelid, targetid, lunid) = dev.split(':')
                hostid = int(hostid)
                channelid = int(channelid)
                targetid = int(targetid)
                lunid = int(lunid)
            except ValueError:
                raise RTSLibError("Cannot find SCSI device by "
                                  + "path, and dev "
                                  + "parameter not in H:C:T:L "
                                  + "format: %s" % dev)
            else:
                udev_path = convert_scsi_hctl_to_path(hostid,
                                                            channelid,
                                                            targetid,
                                                            lunid)
            if not udev_path:
                raise RTSLibError("SCSI device does not exist")
        else:
            udev_path = dev.strip()

        if is_dev_in_use(udev_path):
            raise RTSLibError("Cannot configure StorageObject because "
                              + "device %s (SCSI %d:%d:%d:%d) "
                              % (udev_path, hostid, channelid,
                                 targetid, lunid)
                              + "is already in use")

        self._control("scsi_host_id=%d," % hostid \
                      + "scsi_channel_id=%d," % channelid \
                      + "scsi_target_id=%d," % targetid \
                      + "scsi_lun_id=%d" % lunid)
        self._set_udev_path(udev_path)
        self._enable()

        super(PSCSIStorageObject, self)._configure()
Esempio n. 3
0
    def _configure(self, dev):
        self._check_self()
        parent_hostid = self.backstore.index
        legacy = self.backstore.legacy_mode
        if legacy:
            try:
                (hostid, channelid, targetid, lunid) = \
                        convert_scsi_path_to_hctl(dev)
            except TypeError:
                try:
                    (channelid, targetid, lunid) = dev.split(':')
                    channelid = int(channelid)
                    targetid = int(targetid)
                    lunid = int(lunid)
                except ValueError:
                    raise RTSLibError("Cannot find SCSI device by " +
                                      "path, and dev parameter not " +
                                      "in C:T:L format: %s." % dev)
                else:
                    udev_path = convert_scsi_hctl_to_path(
                        parent_hostid, channelid, targetid, lunid)
                if not udev_path:
                    raise RTSLibError("SCSI device does not exist.")
            else:
                if hostid != parent_hostid:
                    raise RTSLibError("The specified SCSI device does " +
                                      "not belong to the backstore.")
                else:
                    udev_path = dev.strip()
        else:
            # The Backstore is not in legacy mode.
            # Use H:C:T:L format or preserve the path given by the user.
            try:
                (hostid, channelid, targetid, lunid) = \
                        convert_scsi_path_to_hctl(dev)
            except TypeError:
                try:
                    (hostid, channelid, targetid, lunid) = dev.split(':')
                    hostid = int(hostid)
                    channelid = int(channelid)
                    targetid = int(targetid)
                    lunid = int(lunid)
                except ValueError:
                    raise RTSLibError("Cannot find SCSI device by " +
                                      "path, and dev " +
                                      "parameter not in H:C:T:L " +
                                      "format: %s." % dev)
                else:
                    udev_path = convert_scsi_hctl_to_path(
                        hostid, channelid, targetid, lunid)
                if not udev_path:
                    raise RTSLibError("SCSI device does not exist.")
            else:
                udev_path = dev.strip()

        if is_dev_in_use(udev_path):
            raise RTSLibError("Cannot configure StorageObject because " +
                              "device %s (SCSI %d:%d:%d:%d) " %
                              (udev_path, hostid, channelid, targetid, lunid) +
                              "is already in use.")

        if legacy:
            self._control("scsi_channel_id=%d," % channelid \
                          + "scsi_target_id=%d," % targetid \
                          + "scsi_lun_id=%d" %  lunid)
        else:
            self._control("scsi_host_id=%d," % hostid \
                          + "scsi_channel_id=%d," % channelid \
                          + "scsi_target_id=%d," % targetid \
                          + "scsi_lun_id=%d" % lunid)
        self._set_udev_path(udev_path)
        self._enable()
Esempio n. 4
0
    def _configure(self, dev):
        self._check_self()
        parent_hostid = self.backstore.index
        legacy = self.backstore.legacy_mode
        if legacy:
            try:
                (hostid, channelid, targetid, lunid) = \
                        convert_scsi_path_to_hctl(dev)
            except TypeError:
                try:
                    (channelid, targetid, lunid) = dev.split(':')
                    channelid = int(channelid)
                    targetid = int(targetid)
                    lunid = int(lunid)
                except ValueError:
                    raise RTSLibError("Cannot find SCSI device by "
                                      + "path, and dev parameter not "
                                      + "in C:T:L format: %s." % dev)
                else:
                    udev_path = convert_scsi_hctl_to_path(parent_hostid,
                                                                channelid,
                                                                targetid,
                                                                lunid)
                if not udev_path:
                    raise RTSLibError("SCSI device does not exist.")
            else:
                if hostid != parent_hostid:
                    raise RTSLibError("The specified SCSI device does "
                                      + "not belong to the backstore.")
                else:
                    udev_path = dev.strip()
        else:
            # The Backstore is not in legacy mode.
            # Use H:C:T:L format or preserve the path given by the user.
            try:
                (hostid, channelid, targetid, lunid) = \
                        convert_scsi_path_to_hctl(dev)
            except TypeError:
                try:
                    (hostid, channelid, targetid, lunid) = dev.split(':')
                    hostid = int(hostid)
                    channelid = int(channelid)
                    targetid = int(targetid)
                    lunid = int(lunid)
                except ValueError:
                    raise RTSLibError("Cannot find SCSI device by "
                                      + "path, and dev "
                                      + "parameter not in H:C:T:L "
                                      + "format: %s." % dev)
                else:
                    udev_path = convert_scsi_hctl_to_path(hostid,
                                                                channelid,
                                                                targetid,
                                                                lunid)
                if not udev_path:
                    raise RTSLibError("SCSI device does not exist.")
            else:
                udev_path = dev.strip()

        if is_dev_in_use(udev_path):
            raise RTSLibError("Cannot configure StorageObject because "
                              + "device %s (SCSI %d:%d:%d:%d) "
                              % (udev_path, hostid, channelid,
                                 targetid, lunid)
                              + "is already in use.")

        if legacy:
            self._control("scsi_channel_id=%d," % channelid \
                          + "scsi_target_id=%d," % targetid \
                          + "scsi_lun_id=%d" %  lunid)
        else:
            self._control("scsi_host_id=%d," % hostid \
                          + "scsi_channel_id=%d," % channelid \
                          + "scsi_target_id=%d," % targetid \
                          + "scsi_lun_id=%d" % lunid)
        self._set_udev_path(udev_path)
        self._enable()