def commit(self): if not checkMediaRootIsValid(self.url): log.error('FTP textui failed on %s' % self.url) body = "%s\n%s" % (errNetConnectText, TransMenu.Back) self.errorPushPop(self.title, body) return userchoices.setMediaDescriptor(None) userchoices.setMediaLocation(self.url) self.setSubstepEnv({'next': self.stepForward})
def commit(self): url = 'nfs://%s%s' % (self.serverName, self.serverDir) if not checkMediaRootIsValid(url): log.error('NFS textui failed on %s' % url) body = "%s\n%s" % (errNetConnectText, TransMenu.Back) self.errorPushPop(self.title, body) return userchoices.setMediaDescriptor(None) userchoices.setMediaLocation(url) self.setSubstepEnv({'next': self.stepForward})
def _sourceOption(match): '''Handle the "source=<path>" option.''' path = match.group(1) # If the CD is in a drive that is only detected after all the drivers are # loaded then we need to rerun the script that finds the install CD. if not os.path.exists(path): media.runtimeActionMountMedia() if not os.path.exists(path): failWithLog("error: cannot find source -- %s\n" % path) if path == CDROM_DEVICE_PATH: pass else: userchoices.setMediaDescriptor(media.MediaDescriptor( partPath=path, partFsName="iso9660")) return []
class NFSInstallMediaWindow: SCREEN_NAME = 'nfsmedia' def __init__(self, controlState, xml): controlState.displayHeaderBar = True controlState.windowIcon = 'network_media.png' controlState.windowTitle = "Network Filesystem (NFS) Installation" controlState.windowText = \ "Enter the Network File System (NFS) server and path of the " + \ "ESX installation media" self.xml = xml self._setupUrl() def _setupUrl(self): if not userchoices.getMediaLocation(): return url = userchoices.getMediaLocation()['mediaLocation'] protocol, user, passwd, host, port, path =\ networking.utils.parseFileResourceURL(url) self.xml.get_widget('NfsServerEntry').set_text(host) self.xml.get_widget('NfsDirectoryEntry').set_text(path) def getNext(self): serverName = self.xml.get_widget('NfsServerEntry').get_text().strip() serverDir = self.xml.get_widget('NfsDirectoryEntry').get_text().strip() if not serverDir: MessageWindow(None, 'NFS Server Directory Error', 'NFS server directory must not be empty') raise exception.StayOnScreen if not serverDir.startswith('/'): serverDir = '/' + serverDir try: networking.utils.sanityCheckIPorHostname(serverName) except ValueError, msg: MessageWindow(None, 'NFS Server Name Error', msg[0]) raise exception.StayOnScreen url = 'nfs://%s%s' % (serverName, serverDir) if not checkMediaRootIsValid(url): MessageWindow(None, 'Network Error', 'There was an error trying to connect to the network server.') raise exception.StayOnScreen userchoices.setMediaDescriptor(None) userchoices.setMediaLocation(url)
def getNext(self): selectedMedia = self._getSelectedMedia() if not selectedMedia or not selectedMedia.hasPackages: MessageWindow(None, "Media Selection Error", "Select a valid installation medium.") raise exception.StayOnScreen if selectedMedia.diskName: userchoices.addDriveUse(selectedMedia.diskName, 'media') userchoices.setMediaDescriptor(selectedMedia) userchoices.clearMediaLocation() try: # Mount the media in case it is needed later on. selectedMedia.mount() except Exception, e: log.exception("unable to mount media") MessageWindow(None, "Media Error", "Unable to mount media. Rescan and select " "the media again.") raise exception.StayOnScreen
class HTTPInstallMediaWindow: SCREEN_NAME = 'httpmedia' def __init__(self, controlState, xml): controlState.displayHeaderBar = True controlState.windowIcon = 'network_media.png' controlState.windowTitle = "World Wide Web (HTTP) Installation" controlState.windowText = "Enter the URL for the ESX installation media" self.xml = xml connectSignalHandlerByDict(self, HTTPInstallMediaWindow, self.xml, { ('HttpProxyCheckButton', 'toggled'): 'toggleProxy', ('HttpProxyUserCheckButton', 'toggled'): 'toggleUserProxy', }) def getNext(self): url = self.xml.get_widget('HttpUrlEntry').get_text().strip() try: networking.utils.sanityCheckUrl(url, expectedProtocols=['http','https']) except ValueError, msg: MessageWindow(None, 'Invalid Url', msg[0]) raise exception.StayOnScreen if self.xml.get_widget('HttpProxyCheckButton').get_active(): errors, proxy, port, proxyUser, proxyPass = self.getProxyValues() if errors: title, details = errors[0] MessageWindow(None, title, details) raise exception.StayOnScreen # Note: if a user clicks Next, Back, Back, the proxy will still be # set, but that should be OK, because they'll have to come # through either the HTTP or FTP screen again userchoices.setMediaProxy(proxy, port, proxyUser, proxyPass) else: userchoices.unsetMediaProxy() if not checkMediaRootIsValid(url): MessageWindow(None, 'Network Error', 'There was an error trying to connect to the network server.') raise exception.StayOnScreen userchoices.setMediaDescriptor(None) userchoices.setMediaLocation(url)
class FTPInstallMediaWindow: SCREEN_NAME = 'ftpmedia' def __init__(self, controlState, xml): controlState.displayHeaderBar = True controlState.windowIcon = 'network_media.png' controlState.windowTitle = "File System (FTP) Installation" controlState.windowText = "Enter the FTP settings for the ESX " + \ "installation media" self.xml = xml connectSignalHandlerByDict( self, FTPInstallMediaWindow, self.xml, { ('FtpProxyCheckButton', 'toggled'): 'toggleProxy', ('FtpProxyUserCheckButton', 'toggled'): 'toggleUserProxy', ('FtpNonAnonLoginCheckButton', 'toggled'): 'toggleNonAnonLogin', }) self._setupUrl() def _setupUrl(self): # since the user name / password are encoded in the url, we # need to remove them here to set them up in the widgets correctly if not userchoices.getMediaLocation(): return mediaURL = userchoices.getMediaLocation()['mediaLocation'] username, password, host, port, path = parseFTPURL(mediaURL) displayURL = unparseFTPURL('', '', host, port, path) self.xml.get_widget('FtpUrlEntry').set_text(displayURL) self.xml.get_widget('FtpNonAnonLoginUserEntry').set_text(username) self.xml.get_widget('FtpNonAnonPasswordEntry').set_text(password) def getNext(self): url = self.xml.get_widget('FtpUrlEntry').get_text().strip() try: networking.utils.sanityCheckUrl(url, expectedProtocols=['ftp']) except ValueError, msg: MessageWindow(None, 'Invalid URL', msg[0]) raise exception.StayOnScreen if self.xml.get_widget('FtpNonAnonLoginCheckButton').get_active(): # encode the username and password into the url ftpUser = self.xml.get_widget( 'FtpNonAnonLoginUserEntry').get_text() ftpUser = ftpUser.strip() ftpPass = self.xml.get_widget('FtpNonAnonPasswordEntry').get_text() if not ftpUser or not ftpPass: MessageWindow(None, 'Invalid User name or Password', 'You need to specify a User name and password') raise exception.StayOnScreen urlUser, urlPass, host, port, path = parseFTPURL(url) if urlUser or urlPass: MessageWindow(None, 'Duplicate User name or Password', 'User name or password was specified twice') raise exception.StayOnScreen url = unparseFTPURL(ftpUser, ftpPass, host, port, path) if self.xml.get_widget('FtpProxyCheckButton').get_active(): errors, proxy, port, proxyUser, proxyPass = self.getProxyValues() if errors: title, detail = errors[0] MessageWindow(None, title, detail) raise exception.StayOnScreen userchoices.setMediaProxy(proxy, port, proxyUser, proxyPass) else: userchoices.unsetMediaProxy() if not checkMediaRootIsValid(url): MessageWindow( None, 'Network Error', 'There was an error trying to connect to the network server.') raise exception.StayOnScreen userchoices.setMediaDescriptor(None) userchoices.setMediaLocation(url)