def setup(self): log.debug('Setting network options for media downloads') nicChoices = userchoices.getDownloadNic() nic = nicChoices.get('device', None) if nic and not nic.isLinkUp: failWithLog(('The specified network interface card (Name: %s' ' MAC Address: %s) is not plugged in.' ' Installation cannot continue as requested') %\ (nic.name, nic.macAddress)) elif not nic and not networking.getPluggedInAvailableNIC(None): # Check for an available NIC before we go further. # It's best to fail early and provide a descriptive error failWithLog('This system does not have a network interface' ' card that is plugged in, or all network' ' interface cards are already claimed. ' ' Installation cannot continue as requested') # Create a netmask if it was left out ip = nicChoices.get('ip', None) netmask = nicChoices.get('netmask', None) if netmask and not ip: failWithLog('Netmask specified, but no IP given.') if ip and not netmask: log.warn('IP specified, but no netmask given. Guessing netmask.') try: netmask = networking.utils.calculateNetmask(ip) except ValueError, ex: msg = ((genericErr + ' A netmask could not be created.') % ('IP Address', str(ex))) failWithLog(msg) nicChoices.update(netmask=netmask) userchoices.setDownloadNic(**nicChoices)
def updateNicChoices(self, **kwargs): self.needed = True nicChoices = userchoices.getDownloadNic() if not nicChoices: # was empty - this is the first time populating it. newArgs = dict(device='', vlanID='') #set defaults else: newArgs = nicChoices newArgs.update(kwargs) userchoices.setDownloadNic(**newArgs)