Example #1
0
    def start(self):

        self.nics = networking.getPhysicalNics()  # all of them
        if not self.nics:
            raise RuntimeError, 'No network adapters detected.'
        try:
            nic = networking.getPluggedInAvailableNIC(self.nics[0])
        except networking.ConnectException, ex:
            # with argument to getPluggedInAvailableNIC(), we should NEVER
            # get here.  If we do, something is seriously wrong.
            raise RuntimeError, 'NIC setup failure.'
Example #2
0
    def start(self):

        self.nics = networking.getPhysicalNics()  # all of them
        if not self.nics:
            raise RuntimeError, 'No network adapters detected.'
        try:
            nic = networking.getPluggedInAvailableNIC(self.nics[0])
        except networking.ConnectException, ex:
            # with argument to getPluggedInAvailableNIC(), we should NEVER
            # get here.  If we do, something is seriously wrong.
            raise RuntimeError, 'NIC setup failure.'
Example #3
0
 def getDetails(self):
     # sometimes this is due to no NICs being detected.  In that case
     # getDetails will return a friendly, verbose message
     try:
         import networking
         networking.init()
         pnics = networking.getPhysicalNics()
         # GUI has its own way to handle this prettily
         notGUI = userchoices.getRunMode() != userchoices.RUNMODE_GUI
         if len(pnics) == 0 and notGUI:
             paras = NO_NIC_MSG.split('\n')
             paras = ['\n'.join(textwrap.wrap(x, 70)) for x in paras]
             return '\n'.join(paras)
     except (Exception, networking.HostCtlException), ex:
         pass
Example #4
0
    def getDetails(self):
        # sometimes this is due to no NICs being detected.  In that case
        # getDetails will return a friendly, verbose message
        try:
            import networking

            networking.init()
            pnics = networking.getPhysicalNics()
            # GUI has its own way to handle this prettily
            notGUI = userchoices.getRunMode() != userchoices.RUNMODE_GUI
            if len(pnics) == 0 and notGUI:
                paras = NO_NIC_MSG.split("\n")
                paras = ["\n".join(textwrap.wrap(x, 70)) for x in paras]
                return "\n".join(paras)
        except (Exception, networking.HostCtlException), ex:
            pass
Example #5
0
def prepare_cosnetwork():
    import userchoices
    import networking
    device = networking.getPhysicalNics()[0]
    userchoices.addCosNIC(device, 0, None, None)
Example #6
0
def prepare_cosnetwork():
    import userchoices
    import networking
    device = networking.getPhysicalNics()[0]
    userchoices.addCosNIC(device, 0, None, None)
Example #7
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)
Example #8
0
 def checkNICsDetected(self):
     networking.init()
     pnics = networking.getPhysicalNics()
     return len(pnics) > 0
Example #9
0
 def checkNICsDetected(self):
     networking.init()
     pnics = networking.getPhysicalNics()
     return len(pnics) > 0
Example #10
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)