Пример #1
0
    log.debug("Rescanning LUNs...")
    iScsiIFs = vmkctl.StorageInfoImpl().GetiScsiInterfaces()
    if len(iScsiIFs) < 1:
        raise SystemError, "No iSCSI interfaces found, or found but their option "\
                           "ROMs are misconfigured.  Cannot configure iSCSI."
        # This could happen if 1) the NIC doesn't support iSCSI or (2) the data
        # in the NIC's option ROM doesn't make sense (in a way that the sanity
        # checks in validateIQN() didn't catch).

    ## TODO: we should scan only on sofware iScsi interfaces, but for the time being
    ## ScsiInterfaceImpl::IsSoftwareiScsi() doesn't work and Prasanna doesn't
    ## know when he'll be able to take care of that.
    for intf in iScsiIFs:
        try:
            log.debug("HACK: sleeping before Rescan()")
            intf.Rescan()
            ## HACK!  Rescan() is async.  Need a better solution than a race
            ## condition.
            time.sleep(3)
        except vmkctl.HostCtlException, ex:
            log.debug("iScsiIFs[0].Rescan(): " + str(ex.GetMessage()))
            raise

    # Create /dev/nodes.  (This gets called again in partition.py.)
    log.debug("Creating device nodes...")
    partition.createDeviceNodes()

    log.debug("LUNs after activating iSCSI:")
    showLuns()
Пример #2
0
    def probeDisks(self, diskList=None):
        self.disks = {}  # Need to reset in case of a reprobe.

        if diskList:
            for entry in diskList:
                partedDev = parted.PedDevice.get(entry[1])
                diskDev = DiskDev(name=entry[0],
                                  device=partedDev,
                                  path=entry[1],
                                  model=partedDev.model,
                                  size=partedDev.length,
                                  sectorSize=partedDev.sector_size)

                self.disks[entry[0]] = diskDev
        else:
            log.debug("Querying disks")

            storage = vmkctl.StorageInfoImpl()
            luns = storage.GetDiskLuns()

            for entry in luns:
                path = entry.GetDevfsPath()

                log.debug(" lun -- %s" % entry.GetName())

                # skip anything which isn't a disk
                # XXX - replace this with the correct constant from vmkctl
                #       if vmkctlpy gets fixed
                if entry.GetLunType() != VMKCTL_SCSI_DISK:
                    log.warn("Lun at %s is not a proper disk. Skipping lun." %
                             (path))
                    continue

                if entry.IsPseudoLun():
                    log.warn("Lun at %s is a pseudo lun.  Skipping lun." %
                             (path))
                    continue

                # XXX - Console Device paths are broken for some USB devices.
                try:
                    consoleDevicePath = entry.GetConsoleDevice()
                except vmkctl.HostCtlException, msg:
                    log.warn("No Console Path for %s.  Skipping lun." % (path))
                    continue

                if not consoleDevicePath.startswith("/dev"):
                    log.warn("Got bogus console path for %s.  Skipping lun" %
                             (path))
                    continue

                # XXX - check to see if the disk has been initialized
                # we should probably be prompting the user to initialize it
                if consoleDevicePath:
                    log.debug("  Trying %s" % (consoleDevicePath))
                else:
                    # XXX work around bug 173969 in vmklinux26 that causes
                    # broken luns to be reported
                    log.warn("No Console Path for %s.  Skipping lun." % (path))
                    continue

                # XXX If the mkblkdevs happened in the middle of a scan some of
                # the devices will have been missed so we double check here and
                # run the mkblkdevs on-demand.
                for attempt in range(0, 3):
                    if os.path.exists(consoleDevicePath):
                        break

                    log.debug("console device, '%s', does not exist.  trying "
                              "mkblkdevs again (attempt %d)" %
                              (consoleDevicePath, attempt + 1))
                    time.sleep(3)  # wait for things to settle
                    partition.createDeviceNodes()

                if not os.path.exists(consoleDevicePath):
                    log.warn("console device is missing -- %s" %
                             consoleDevicePath)
                    continue

                # XXX - this needs to be wrapped in a try/except
                # and display a proper warning if the device can't be
                # accessed
                try:
                    partedDev = parted.PedDevice.get(consoleDevicePath)
                except parted.error, msg:
                    log.warn("Parted couldn't open device %s.  Skipping lun." %
                             (consoleDevicePath))
                    continue

                driverName = None
                supportsVmfs = False

                # Set a default path with a large value so it's at the end of
                # the sorted list.
                pathIds = ['z' * 5]

                paths = entry.GetPaths()
                pathStrings = []
                if paths:
                    for vmkctlPath in paths:
                        try:
                            transportMap = vmkctlPath.GetTransportMapping()
                            if transportMap:
                                targetString = transportMap.GetTargetString()
                                log.info("Target String: " + targetString)
                                if targetString not in pathStrings:
                                    pathStrings.append(targetString)
                        except vmkctl.HostCtlException, ex:
                            log.warn("Could not get transport mapping -- %s " %
                                     str(ex.GetMessage()))

                    try:
                        adapter = paths[0].GetAdapter()
                        driverName = adapter.GetDriver()
                        pathIds = [
                            util.splitInts(paths[0].GetAdapterName()),
                            paths[0].GetChannelNumber(),
                            paths[0].GetTargetNumber(), paths[0].GetLun()
                        ]

                        supportsVmfs = self._adapterSupportsVmfs(adapter)
                    except vmkctl.HostCtlException, ex:
                        ## Should be a problem only until iSCSI driver situation is stabilized.
                        log.warn("Could not get driver for path %s -- %s" %
                                 (consoleDevicePath, str(ex.GetMessage())))
Пример #3
0
    log.debug("Rescanning LUNs...")
    iScsiIFs = vmkctl.StorageInfoImpl().GetiScsiInterfaces()
    if len(iScsiIFs) < 1:
        raise SystemError, "No iSCSI interfaces found, or found but their option "\
                           "ROMs are misconfigured.  Cannot configure iSCSI."
        # This could happen if 1) the NIC doesn't support iSCSI or (2) the data
        # in the NIC's option ROM doesn't make sense (in a way that the sanity
        # checks in validateIQN() didn't catch).

    ## TODO: we should scan only on sofware iScsi interfaces, but for the time being
    ## ScsiInterfaceImpl::IsSoftwareiScsi() doesn't work and Prasanna doesn't
    ## know when he'll be able to take care of that.
    for intf in iScsiIFs:
        try:
            log.debug("HACK: sleeping before Rescan()")
            intf.Rescan()
            ## HACK!  Rescan() is async.  Need a better solution than a race
            ## condition.
            time.sleep(3)
        except vmkctl.HostCtlException, ex:
            log.debug("iScsiIFs[0].Rescan(): " + str(ex.GetMessage()))
            raise

    # Create /dev/nodes.  (This gets called again in partition.py.)
    log.debug("Creating device nodes...")
    partition.createDeviceNodes()

    log.debug("LUNs after activating iSCSI:")
    showLuns()
Пример #4
0
    def probeDisks(self, diskList=None):
        self.disks = {} # Need to reset in case of a reprobe.

        if diskList:
            for entry in diskList:
                partedDev = parted.PedDevice.get(entry[1])
                diskDev = DiskDev(name=entry[0], device=partedDev,
                    path=entry[1], model=partedDev.model,
                    size=partedDev.length, sectorSize=partedDev.sector_size)

                self.disks[entry[0]] = diskDev
        else:
            log.debug("Querying disks")

            storage = vmkctl.StorageInfoImpl()
            luns = storage.GetDiskLuns()

            for entry in luns:
                path = entry.GetDevfsPath()

                log.debug(" lun -- %s" % entry.GetName())

                # skip anything which isn't a disk
                # XXX - replace this with the correct constant from vmkctl
                #       if vmkctlpy gets fixed
                if entry.GetLunType() != VMKCTL_SCSI_DISK:
                    log.warn("Lun at %s is not a proper disk. Skipping lun." %
                             (path))
                    continue

                if entry.IsPseudoLun():
                    log.warn("Lun at %s is a pseudo lun.  Skipping lun." %
                             (path))
                    continue

                # XXX - Console Device paths are broken for some USB devices.
                try:
                    consoleDevicePath = entry.GetConsoleDevice()
                except vmkctl.HostCtlException, msg:
                    log.warn("No Console Path for %s.  Skipping lun." % (path))
                    continue

                if not consoleDevicePath.startswith("/dev"):
                    log.warn("Got bogus console path for %s.  Skipping lun" % 
                             (path))
                    continue

                # XXX - check to see if the disk has been initialized
                # we should probably be prompting the user to initialize it 
                if consoleDevicePath:
                    log.debug("  Trying %s" % (consoleDevicePath))
                else:
                    # XXX work around bug 173969 in vmklinux26 that causes
                    # broken luns to be reported
                    log.warn("No Console Path for %s.  Skipping lun." % (path))
                    continue

                # XXX If the mkblkdevs happened in the middle of a scan some of
                # the devices will have been missed so we double check here and
                # run the mkblkdevs on-demand.
                for attempt in range(0, 3):
                    if os.path.exists(consoleDevicePath):
                        break

                    log.debug("console device, '%s', does not exist.  trying "
                              "mkblkdevs again (attempt %d)" %
                              (consoleDevicePath, attempt + 1))
                    time.sleep(3) # wait for things to settle
                    partition.createDeviceNodes()

                if not os.path.exists(consoleDevicePath):
                    log.warn("console device is missing -- %s" %
                             consoleDevicePath)
                    continue
                
                # XXX - this needs to be wrapped in a try/except
                # and display a proper warning if the device can't be
                # accessed
                try:
                    partedDev = parted.PedDevice.get(consoleDevicePath)
                except parted.error, msg:
                    log.warn("Parted couldn't open device %s.  Skipping lun." %
                             (consoleDevicePath))
                    continue

                driverName = None
                supportsVmfs = False

                # Set a default path with a large value so it's at the end of
                # the sorted list.
                pathIds = [ 'z' * 5 ]

                paths = entry.GetPaths()
                pathStrings = []
                if paths:
                    for vmkctlPath in paths:
                        try:
                            transportMap = vmkctlPath.GetTransportMapping()
                            if transportMap:
                                targetString = transportMap.GetTargetString()
                                log.info("Target String: " + targetString)
                                if targetString not in pathStrings:
                                    pathStrings.append(targetString)
                        except vmkctl.HostCtlException, ex:
                            log.warn("Could not get transport mapping -- %s " %
                                     str(ex.GetMessage()))

                    try:
                        adapter = paths[0].GetAdapter()
                        driverName = adapter.GetDriver()
                        pathIds = [
                            util.splitInts(paths[0].GetAdapterName()),
                            paths[0].GetChannelNumber(),
                            paths[0].GetTargetNumber(),
                            paths[0].GetLun()]

                        supportsVmfs = self._adapterSupportsVmfs(adapter)
                    except vmkctl.HostCtlException, ex:
                        ## Should be a problem only until iSCSI driver situation is stabilized.
                        log.warn("Could not get driver for path %s -- %s" %
                                 (consoleDevicePath, str(ex.GetMessage())))
Пример #5
0
def hostActionLoadDrivers(context):
    global DRIVERS_LOADED

    if DRIVERS_LOADED:
        return

    uiHook = context.cb

    # when in rome...
    f = open('/tmp/initscripts.sh', 'w')
    f.write(FIND_INIT_SCRIPTS)
    f.close()

    initScripts = util.execWithCapture('/bin/bash',
                                       ['/bin/bash', '/tmp/initscripts.sh'])
    initScripts = initScripts.split()

    units = len(initScripts)
    uiHook.pushStatusGroup(units)

    criticalFailure = False

    scriptsFailed = []
    log.info("Starting driver load ...")
    for script in initScripts:
        script = os.path.basename(script)

        if _findBaseInitLevel(script) < INIT_START_LEVEL:
            continue

        log.info("Loading %s" % script)
        uiHook.pushStatus("Loading %s" % script)
        rc, stdout, stderr = \
            execCommand("cd / && INSTALLER=1 %s %s" % (INIT_WRAPPER, script))

        if rc == 1:
            warningMessage = "The script %s returned status 1" % script
            log.warning(warningMessage)
        elif rc == 2:
            errorMessage = "A non-critical error has happened in the " + \
                    "script %s.  The installation can continue " % script + \
                    "but you may experience reduced functionality."
            log.error(errorMessage)
            scriptsFailed.append(script)
        elif rc == 3:
            errorMessage = "The script %s failed to execute " % (script) + \
                           "and the installation can not continue."
            criticalFailure = True
            break
        elif rc:
            errorMessage = "An unexpected error occurred in the " + \
                           "script %s." % script
            criticalFailure = True
            break

        uiHook.popStatus()

    if criticalFailure:
        log.error(errorMessage)
        uiHook.popStatus()
        uiHook.popStatusGroup()
        raise CriticalScriptLoadError(errorMessage)

    # XXX should be done by the init scripts...  the device nodes will get
    # created implicitly by devices.DiskSet() but not everything that needs
    # a device node goes through there.
    import partition
    partition.createDeviceNodes()

    DRIVERS_LOADED = True

    uiHook.popStatusGroup()

    if scriptsFailed:
        messageText = SCRIPT_ERROR_MSG % ", ".join(scriptsFailed)
        raise ScriptLoadError(messageText)
Пример #6
0
def hostActionLoadDrivers(context):
    global DRIVERS_LOADED

    if DRIVERS_LOADED:
        return

    uiHook = context.cb

    # when in rome...
    f = open("/tmp/initscripts.sh", "w")
    f.write(FIND_INIT_SCRIPTS)
    f.close()

    initScripts = util.execWithCapture("/bin/bash", ["/bin/bash", "/tmp/initscripts.sh"])
    initScripts = initScripts.split()

    units = len(initScripts)
    uiHook.pushStatusGroup(units)

    criticalFailure = False

    scriptsFailed = []
    log.info("Starting driver load ...")
    for script in initScripts:
        script = os.path.basename(script)

        if _findBaseInitLevel(script) < INIT_START_LEVEL:
            continue

        log.info("Loading %s" % script)
        uiHook.pushStatus("Loading %s" % script)
        rc, stdout, stderr = execCommand("cd / && INSTALLER=1 %s %s" % (INIT_WRAPPER, script))

        if rc == 1:
            warningMessage = "The script %s returned status 1" % script
            log.warning(warningMessage)
        elif rc == 2:
            errorMessage = (
                "A non-critical error has happened in the "
                + "script %s.  The installation can continue " % script
                + "but you may experience reduced functionality."
            )
            log.error(errorMessage)
            scriptsFailed.append(script)
        elif rc == 3:
            errorMessage = "The script %s failed to execute " % (script) + "and the installation can not continue."
            criticalFailure = True
            break
        elif rc:
            errorMessage = "An unexpected error occurred in the " + "script %s." % script
            criticalFailure = True
            break

        uiHook.popStatus()

    if criticalFailure:
        log.error(errorMessage)
        uiHook.popStatus()
        uiHook.popStatusGroup()
        raise CriticalScriptLoadError(errorMessage)

    # XXX should be done by the init scripts...  the device nodes will get
    # created implicitly by devices.DiskSet() but not everything that needs
    # a device node goes through there.
    import partition

    partition.createDeviceNodes()

    DRIVERS_LOADED = True

    uiHook.popStatusGroup()

    if scriptsFailed:
        messageText = SCRIPT_ERROR_MSG % ", ".join(scriptsFailed)
        raise ScriptLoadError(messageText)