Пример #1
0
    def rescanMedia(self, *_args):
        """Do a scan for any attached installation media."""
        selectedMedia = userchoices.getMediaDescriptor()
        
        self.mediaFound = (cdutil.findCdMedia(showAll=True) +
                           usbmedia.findUSBMedia(showAll=True))

        self.model.clear()
        for installMedia in self.mediaFound:
            foreground = "#000000"
            if not installMedia.hasPackages:
                # Mark devices without media as red.  We do not want to make
                # them insensitive since the user needs to be able to select
                # the device they want to eject.
                contents = "No packages"
                foreground = "#ff0000"
            elif installMedia.isoPath:
                contents = installMedia.isoPath
            else:
                contents = "Installation packages"
            mediaIter = self.model.append(None, [
                    util.truncateString(installMedia.getName(),
                                        DEVMODEL_LENGTH),
                    contents,
                    installMedia.version,
                    installMedia,
                    foreground])
            if installMedia.hasPackages and \
                    (not selectedMedia or
                     selectedMedia.diskName == installMedia.diskName):
                self.view.set_cursor(self.model.get_path(mediaIter))
                selectedMedia = installMedia
Пример #2
0
    def addEntry(model, iterType, disk, sensitive=True):
        name = truncateString(disk.name, DEVNAME_LENGTH)

        devModel = truncateString(disk.getVendorModelString(), DEVMODEL_LENGTH)
        devModel +=  " (%s)" % name

        lunId = ''
        if len(disk.pathIds) == 4:
            lunId = disk.pathIds[PATHID_LUN]

        diskIter = model.append(iterType,
            [devModel, lunId, disk.getFormattedSize(), entry, sensitive] )

        for pathString in disk.pathStrings:
            if pathString:
                newIterType = model.insert_before(diskIter, None)
                model.set_value(newIterType, 0, pathString)
Пример #3
0
    def addEntry(model, iterType, disk, sensitive=True):
        name = truncateString(disk.name, DEVNAME_LENGTH)

        devModel = truncateString(disk.getVendorModelString(), DEVMODEL_LENGTH)
        devModel += " (%s)" % name

        lunId = ''
        if len(disk.pathIds) == 4:
            lunId = disk.pathIds[PATHID_LUN]

        diskIter = model.append(
            iterType,
            [devModel, lunId,
             disk.getFormattedSize(), entry, sensitive])

        for pathString in disk.pathStrings:
            if pathString:
                newIterType = model.insert_before(diskIter, None)
                model.set_value(newIterType, 0, pathString)
Пример #4
0
def describeNic(nic):
    "Textual description of NIC - two lines"
    if nic.isLinkUp:
        linkstat = "connected"
    else:
        linkstat = "not connected"
    namePart = util.truncateString(nic.humanReadableName, 42)
    line0 = "%s: %s" % (nic.driverName, namePart)
    line1 = "(%s) [%s]" % (nic.macAddress, linkstat)
    return line0, line1
Пример #5
0
def describeNic(nic):
    "Textual description of NIC - two lines"
    if nic.isLinkUp:
        linkstat = "connected"
    else:
        linkstat = "not connected"
    namePart = util.truncateString(nic.humanReadableName, 42)
    line0 = "%s: %s" % (nic.driverName, namePart)
    line1 = "(%s) [%s]" % (nic.macAddress, linkstat)
    return line0, line1
Пример #6
0
def getStorageList(diskSet, vmfsSupport=True, esxAndCos=True):
    ''' diskSet can be an instance of devices.DiskSet, or it can be a
    function that, when evaluated, returns a devices.DiskSet.  This is
    to support both static and dynamic usage of this function.
    This is a counterpart to populateStorageModel() in
    gui/storage_widgets.py.
    '''
    try:
        disks = diskSet()
    except TypeError:
        disks = diskSet
    # TODO: may have to handle "remote" later.  Check gui/storage_widgets.py.

    eligible = partition.getEligibleDisks(vmfsSupport=vmfsSupport,
                                          esxAndCos=esxAndCos)

    storageList = []
    for lun in disks.values():
        if lun not in eligible:
            continue

        name = truncateString(lun.name, DEVNAME_LENGTH)
        vendModName = "%s %s" % (lun.vendor, lun.model)
        vendorModel = truncateString(vendModName, VENDMODNAME_LENGTH)
        deviceName = "%s (%s)" % (vendorModel, name)
        try:
            path0 = lun.vmkLun.GetPaths()[0]
            targetid = str(path0.GetTargetNumber())
        except IndexError:
            targetid = "n/a"
        lunid = '0'
        if len(lun.pathIds) == 4:
            lunid = lun.pathIds[PATHID_LUN]
        diskSize = lun.getFormattedSize()
        storageList.append(
            [deviceName, lunid, diskSize, lun.name, lun.pathStrings, targetid])

    return storageList
Пример #7
0
def getStorageList(diskSet, vmfsSupport=True, esxAndCos=True):
    ''' diskSet can be an instance of devices.DiskSet, or it can be a
    function that, when evaluated, returns a devices.DiskSet.  This is
    to support both static and dynamic usage of this function.
    This is a counterpart to populateStorageModel() in
    gui/storage_widgets.py.
    '''
    try:
        disks = diskSet()
    except TypeError:
        disks = diskSet
    # TODO: may have to handle "remote" later.  Check gui/storage_widgets.py.

    eligible = partition.getEligibleDisks(vmfsSupport=vmfsSupport,
                                          esxAndCos=esxAndCos)

    storageList = []
    for lun in disks.values():
        if lun not in eligible:
            continue

        name = truncateString(lun.name, DEVNAME_LENGTH)
        vendModName = "%s %s" % (lun.vendor, lun.model)
        vendorModel = truncateString(vendModName, VENDMODNAME_LENGTH)
        deviceName = "%s (%s)" % (vendorModel, name)
        try:
            path0 = lun.vmkLun.GetPaths()[0]
            targetid = str(path0.GetTargetNumber())
        except IndexError:
            targetid = "n/a"
        lunid = '0'
        if len(lun.pathIds) == 4:
            lunid = lun.pathIds[PATHID_LUN]
        diskSize = lun.getFormattedSize()
        storageList.append([deviceName, lunid, diskSize, lun.name, lun.pathStrings, targetid])

    return storageList
Пример #8
0
    def populateComboBox(self):
        self.comboBox.clear()

        # Find available NICs and put them in the liststore
        nics = networking.getPhysicalNics()
        if not nics:
            raise RuntimeError, 'No network interfaces detected'
        if self.wantedMacAddresses:
            nics = [nic for nic in nics
                    if nic.macAddress in self.wantedMacAddresses]
            if not nics:
                log.error('No NICs passed MAC address filter')
                raise RuntimeError, 'No appropriate NICs detected'
        nics.sort(lambda x,y: cmp(y.isLinkUp, x.isLinkUp))

        liststore = gtk.ListStore(object, str, bool)
        for nic in nics:
            namePart = util.truncateString(nic.humanReadableName, 24)
            identifier = '%s (MAC: %s)' % (namePart, nic.macAddress)
            liststore.append([nic, identifier, nic.isLinkUp])
        self.comboBox.set_model(liststore)

        # Three cells: nic name, toggle, connected/disconnected
        nicNameCell = gtk.CellRendererText()
        self.comboBox.pack_start(nicNameCell, expand=True)
        self.comboBox.add_attribute(nicNameCell, 'text', 1)

        crp = gtk.CellRendererPixbuf()
        self.comboBox.pack_start(crp, expand=False)
        self.comboBox.set_cell_data_func(crp,
                                         self._connectedPixmapGenerator)

        connectedTextCell = gtk.CellRendererText()
        connectedTextCell.set_property('family', 'monospace')
        connectedTextCell.set_property('width-chars', 15)
        self.comboBox.pack_start(connectedTextCell, expand=False)
        self.comboBox.set_cell_data_func(connectedTextCell,
                                         self._connectedTextGenerator)

        # Now figure out which row should be active
        currentNic = self.queryCurrentFn()
        if currentNic:
            # If there's one that has already been selected, activate that
            for i, nic in enumerate(nics):
                if nic == currentNic:
                    self.comboBox.set_active(i)
                    break
        else:
            # Set-active the first NIC that hasn't been claimed already (e.g. 
            # we might be configuring iSCSI, having already configured COS 
            # networking) and which is connected ("isLinkUp").
            claimedNics = userchoices.getClaimedNICDevices()
            suggestedNic = None
            for i, nic in enumerate(nics):
                if nic not in claimedNics and nic.isLinkUp:
                    suggestedNic = i
                    self.comboBox.set_active(suggestedNic)
                    break
            if suggestedNic == None:
                if claimedNics:
                    MessageWindow(self.thisWindow, 'NICs',
                                  ('All the connected network adapters are'
                                   'claimed. Proceed with caution.'),
                                  'warning')
                self.comboBox.set_active(0)
Пример #9
0
 def pushXORRead(self, offset, data, callback, *args):
     assert offset + len(
         data) < self.size, "pushXORRead exceeds upper bound of filesize"
     log.msg("pushXORRead(%d, %s)" % (offset, truncateString(repr(data))))
     self.work_queue.put(
         (self._handleXORRead, offset, data, callback, args))
Пример #10
0
 def pushXORWrite(self, offset, data):
     assert offset + len(
         data) < self.size, "pushXORWrite exceeds upper bound of filesize"
     log.msg("pushXORWrite(%d, %s)" % (offset, truncateString(repr(data))))
     self.work_queue.put((self._handleXORWrite, offset, data))
Пример #11
0
    def populateComboBox(self):
        self.comboBox.clear()

        # Find available NICs and put them in the liststore
        nics = networking.getPhysicalNics()
        if not nics:
            raise RuntimeError, 'No network interfaces detected'
        if self.wantedMacAddresses:
            nics = [
                nic for nic in nics
                if nic.macAddress in self.wantedMacAddresses
            ]
            if not nics:
                log.error('No NICs passed MAC address filter')
                raise RuntimeError, 'No appropriate NICs detected'
        nics.sort(lambda x, y: cmp(y.isLinkUp, x.isLinkUp))

        liststore = gtk.ListStore(object, str, bool)
        for nic in nics:
            namePart = util.truncateString(nic.humanReadableName, 24)
            identifier = '%s (MAC: %s)' % (namePart, nic.macAddress)
            liststore.append([nic, identifier, nic.isLinkUp])
        self.comboBox.set_model(liststore)

        # Three cells: nic name, toggle, connected/disconnected
        nicNameCell = gtk.CellRendererText()
        self.comboBox.pack_start(nicNameCell, expand=True)
        self.comboBox.add_attribute(nicNameCell, 'text', 1)

        crp = gtk.CellRendererPixbuf()
        self.comboBox.pack_start(crp, expand=False)
        self.comboBox.set_cell_data_func(crp, self._connectedPixmapGenerator)

        connectedTextCell = gtk.CellRendererText()
        connectedTextCell.set_property('family', 'monospace')
        connectedTextCell.set_property('width-chars', 15)
        self.comboBox.pack_start(connectedTextCell, expand=False)
        self.comboBox.set_cell_data_func(connectedTextCell,
                                         self._connectedTextGenerator)

        # Now figure out which row should be active
        currentNic = self.queryCurrentFn()
        if currentNic:
            # If there's one that has already been selected, activate that
            for i, nic in enumerate(nics):
                if nic == currentNic:
                    self.comboBox.set_active(i)
                    break
        else:
            # Set-active the first NIC that hasn't been claimed already (e.g.
            # we might be configuring iSCSI, having already configured COS
            # networking) and which is connected ("isLinkUp").
            claimedNics = userchoices.getClaimedNICDevices()
            suggestedNic = None
            for i, nic in enumerate(nics):
                if nic not in claimedNics and nic.isLinkUp:
                    suggestedNic = i
                    self.comboBox.set_active(suggestedNic)
                    break
            if suggestedNic == None:
                if claimedNics:
                    MessageWindow(self.thisWindow, 'NICs',
                                  ('All the connected network adapters are'
                                   'claimed. Proceed with caution.'),
                                  'warning')
                self.comboBox.set_active(0)