def __init__(self, controlState, xml): controlState.displayHeaderBar = True controlState.windowIcon = 'networkadapter.png' controlState.windowTitle = "Network Configuration" controlState.windowText = "Select an adapter for ESX" self.controlState = controlState self.thisWindow = controlState.gui.getWindow() self.xml = xml networking.init() def queryCurrentCosNic(): cosNics = userchoices.getCosNICs() if not cosNics: return None return cosNics[0]['device'] try: self.nicSetup = nic_setup.NicSetup( xml, controlState.gui.getWindow(), comboBoxName="CosnetworkadapterComboBox", vlanCheckButtonName="CosnetworkadapterVlanCheckButton", vlanEntryName="CosnetworkadapterVlanIDEntry", vlanIDHBoxName="CosnetworkadapterVlanIDHBox", queryCurrentFn=queryCurrentCosNic) except RuntimeError, msg: self.desensitizeEverything() self.noNicHandlerID = self.thisWindow.connect('enter-notify-event', self.showNoNicError) # We do it like this, rather than call MessageWindow right here, # so as to give this screen a chance to render itself. (If not, # we see the MessageWindow on top of a totally blank, grey, window.) self.nicSetup = None
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
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
def __init__(self): super(CosNetworkAdapterWindow, self).__init__() networking.init() self.substep = self.start self.nic = {} # device, ip, netmask, bootProto, vlanID self.net = {} # gateway, nameserver[12], hostname
import iam import networking iam.init() networking.init()
def checkNICsDetected(self): networking.init() pnics = networking.getPhysicalNics() return len(pnics) > 0