def activateNetwork2(self, dialogOnSuccess=True): failMsg = None try: networking.cosConnectForInstaller() except Exception, ex: failMsg = networkBringupFailureMessage %\ dict(exceptionClass=ex.__class__, exceptionRepr=repr(ex), exceptionStr=str(ex) )
def _runtimeActions(self): errors = [] warnings = [] if userchoices.getActivateNetwork() and userchoices.getCosNICs() and \ not networking.connected() and not userchoices.getUpgrade(): try: networking.cosConnectForInstaller() except Exception, ex: log.exception(str(ex)) warnings.append("warning: could not bring up network -- %s\n" % str(ex))
def checkNetworkUp(): if networking.connected(): return True try: networking.cosConnectForInstaller(failOnWarnings=False, onlyConfiguredNics=False) except networking.WrappedVmkctlException, ex: log.info('got WrappedVmkctlException (%s %s)' % (ex, ex.msg)) #TODO: this needs to be fixed in vmkctl if 'returned with non-zero status' in ex.msg: log.warn('harmless exception ' + ex.msg) else: log.error('not a harmless exception ' + ex.msg) raise
def checkNetworkUp(): if networking.connected(): return True try: networking.cosConnectForInstaller(failOnWarnings=False, onlyConfiguredNics=False) except networking.WrappedVmkctlException, ex: log.info('got WrappedVmkctlException (%s %s)' % (ex, ex.msg)) #TODO: this needs to be fixed in vmkctl if 'returned with non-zero status' in ex.msg: log.warn('harmless exception '+ ex.msg) else: log.error('not a harmless exception '+ ex.msg) raise
def attemptSynchronize(self): "Contact NTP server, synchronize time." errMsg = None try: # Note: ntpQueryStart() may get error 107: ENOTCONN # It seems to be harmless but results in console message. if not networking.connected(): print 'Connecting to the network...' networking.cosConnectForInstaller() timedate.ntpQueryStart(self.ntpServer) textengine.render_status('Attempting to contact server.') for _attempt in range(timedate.NTP_TIMEOUT): if timedate.ntpReady(): break textengine.render_status('.') textengine.render_status('\n') if timedate.ntpReady(timeout=0): year, month, day, hours, mins, secs = timedate.ntpQueryFinish() else: raise timedate.NTPError("Timeout: Destination is unreachable") except timedate.NTPError, ex: errMsg = 'Got an NTP error (%s)' % str(ex)
def done(self): "set up network NOW" try: networking.cosConnectForInstaller() except Exception, ex: log.exception(str(ex))