def _customization(self): interactive = self.environment[ohostedcons.VMEnv.OVF] is None if interactive: if self._appliances: directlyOVA = str(len(self._appliances) + 1) app_list = '' for entry in self._appliances: app_list += _( '\t[{i}] - {description} - {version}\n').format( i=entry['index'], description=entry['description'], version=entry['version'], ) app_list += ( _('\t[{i}] - Directly select an OVA file\n').format( i=directlyOVA, )) valid = False while not valid: appliance_ver = None if not interactive: ova_path = self.environment[ohostedcons.VMEnv.OVF] else: ova_path = '' if self._appliances: self.dialog.note( _('The following appliance have been ' 'found on your system:\n' '{app_list}').format(app_list=app_list, )) sapp = self.dialog.queryString( name='OVEHOSTED_BOOT_DISK_APPLIANCE', note=_('Please select an appliance ' '(@VALUES@) [@DEFAULT@]: '), prompt=True, caseSensitive=True, default='1', validValues=[ str(i + 1) for i in range(len(self._appliances) + 1) ], ) if sapp != directlyOVA: ova_path = self._appliances[int(sapp) - 1]['path'] appliance_ver = self._appliances[int(sapp) - 1]['version'] self.logger.info(_('Verifying its sha1sum')) if (self._file_hash(ova_path) != self._appliances[int(sapp) - 1]['sha1sum']): self.logger.error( _("The selected appliance is invalid: the " "sha1sum of the selected file ('{p}') " "doesn't match the expected value.").format( p=ova_path)) continue if not ova_path: ova_path = self.dialog.queryString( name='OVEHOSTED_VMENV_OVF', note=_('Please specify path to OVF archive ' 'you would like to use [@DEFAULT@]: '), prompt=True, caseSensitive=True, default=str(self.environment[ohostedcons.VMEnv.OVF]), ) valid = self._check_ovf(ova_path) if valid: self.environment[ohostedcons.VMEnv.OVF] = ova_path self.environment[ ohostedcons.VMEnv.APPLIANCE_VERSION] = appliance_ver else: if interactive: self.logger.error( _('The specified OVF archive is not a valid OVF ' 'archive.')) else: raise RuntimeError( _('The specified OVF archive is not ' 'readable. Please ensure that {filepath} ' 'could be read').format(filepath=self.environment[ ohostedcons.VMEnv.OVF])) valid = False checker = ohosteddomains.DomainChecker() while not valid: vdsmPermissionsErrorMessage = None spaceErrorMessage = None tempDirCheck = ohostedutil.checkUserPermissions( self, 'vdsm', 'ls %s' % self.environment[ohostedcons.CoreEnv.TEMPDIR]) if tempDirCheck is not True: vdsmPermissionsErrorMessage = _( 'vdsm user has no read permissions on' ' {tmpdir}, please choose another. {errmsg}').format( tmpdir=self.environment[ohostedcons.CoreEnv.TEMPDIR], errmsg=tempDirCheck, ) spaceCheck = False try: checker.check_available_space( self.environment[ohostedcons.CoreEnv.TEMPDIR], int(self.environment[ohostedcons.StorageEnv.QCOW_SIZE_GB]) * 1024) spaceCheck = True except ohosteddomains.InsufficientSpaceError as e: self.logger.debug( 'Error checking TMPDIR space', exc_info=True, ) self.logger.debug(e) valid = False spaceErrorMessage = _( 'Not enough space in the temporary directory [{tmpdir}]' ).format( tmpdir=self.environment[ohostedcons.CoreEnv.TEMPDIR], ) if not interactive: if not spaceCheck: raise RuntimeError(spaceErrorMessage) if tempDirCheck is not True: raise RuntimeError(vdsmPermissionsErrorMessage) else: if not spaceCheck: self.logger.error(spaceErrorMessage) if tempDirCheck is not True: self.logger.error(vdsmPermissionsErrorMessage) if not spaceCheck or tempDirCheck is not True: self.environment[ ohostedcons.CoreEnv.TEMPDIR] = self.dialog.queryString( name='OVEHOSTED_COREENV_TEMPDIR', note=_( 'Please specify path to a temporary directory ' 'with at least {size} GB [@DEFAULT@]: '). format(size=self.environment[ ohostedcons.StorageEnv.QCOW_SIZE_GB], ), prompt=True, caseSensitive=True, default=str( self.environment[ohostedcons.CoreEnv.TEMPDIR]), ) valid = True if tempDirCheck is True and spaceCheck else False
def __init__(self, context): super(Plugin, self).__init__(context=context) self._checker = ohosteddomains.DomainChecker()
def _customization(self): interactive = self.environment[ohostedcons.VMEnv.OVF] is None valid = False while not valid: if interactive: self.environment[ ohostedcons.VMEnv.OVF] = self.dialog.queryString( name='OVEHOSTED_VMENV_OVF', note=_('Please specify path to OVF archive ' 'you would like to use [@DEFAULT@]: '), prompt=True, caseSensitive=True, default=str(self.environment[ohostedcons.VMEnv.OVF]), ) valid = self._check_ovf(self.environment[ohostedcons.VMEnv.OVF]) if not valid: if interactive: self.logger.error( _('The specified OVF archive is not a valid OVF ' 'archive.')) else: raise RuntimeError( _('The specified OVF archive is not ' 'readable. Please ensure that {filepath} ' 'could be read').format(filepath=self.environment[ ohostedcons.VMEnv.OVF])) valid = False checker = ohosteddomains.DomainChecker() while not valid: try: checker.check_available_space( self.environment[ohostedcons.CoreEnv.TEMPDIR], int(self.environment[ohostedcons.StorageEnv.IMAGE_SIZE_GB]) * 1024) valid = True except ohosteddomains.InsufficientSpaceError as e: self.logger.debug( 'Error checking TMPDIR space', exc_info=True, ) self.logger.debug(e) valid = False if not interactive: raise RuntimeError( _('Not enough space in the temporary directory')) else: self.logger.error( _('Not enough space in the temporary directory')) self.environment[ ohostedcons.CoreEnv.TEMPDIR] = self.dialog.queryString( name='OVEHOSTED_COREENV_TEMPDIR', note=_( 'Please specify path to a temporary directory ' 'with at least {size} GB [@DEFAULT@]: '). format(size=self.environment[ ohostedcons.StorageEnv.IMAGE_SIZE_GB], ), prompt=True, caseSensitive=True, default=str( self.environment[ohostedcons.CoreEnv.TEMPDIR]), )
def __init__(self, context): super(Plugin, self).__init__(context=context) self._checker = ohosteddomains.DomainChecker() # TODO: remove once the engine is able to handle this self.query_for_additional_mnt_options = False