def configure_step(self): """ Handle license file. """ default_lic_env_var = 'PGROUPD_LICENSE_FILE' license_specs = ensure_iterable_license_specs(self.cfg['license_file']) lic_specs, self.license_env_var = find_flexlm_license( custom_env_vars=[default_lic_env_var], lic_specs=license_specs) if lic_specs: if self.license_env_var is None: self.log.info( "Using PGI license specifications from 'license_file': %s", lic_specs) self.license_env_var = default_lic_env_var else: self.log.info("Using PGI license specifications from %s: %s", self.license_env_var, lic_specs) self.license_file = os.pathsep.join(lic_specs) env.setvar(self.license_env_var, self.license_file) else: self.log.info( "No viable license specifications found, assuming PGI Community Edition..." )
def configure_step(self): """ Handle license file. """ default_lic_env_var = 'PGROUPD_LICENSE_FILE' lic_specs, self.license_env_var = find_flexlm_license( custom_env_vars=[default_lic_env_var], lic_specs=[self.cfg['license_file']]) if lic_specs: if self.license_env_var is None: self.log.info( "Using PGI license specifications from 'license_file': %s", lic_specs) self.license_env_var = default_lic_env_var else: self.log.info("Using PGI license specifications from %s: %s", self.license_env_var, lic_specs) self.license_file = os.pathsep.join(lic_specs) env.setvar(self.license_env_var, self.license_file) else: raise EasyBuildError( "No viable license specifications found; specify 'license_file' or " + "define $PGROUPD_LICENSE_FILE or $LM_LICENSE_FILE")
def prepare_step(self): """Custom prepare step for IntelBase. Set up the license""" super(IntelBase, self).prepare_step() default_lic_env_var = 'INTEL_LICENSE_FILE' lic_specs, self.license_env_var = find_flexlm_license(custom_env_vars=[default_lic_env_var], lic_specs=[self.cfg['license_file']]) if lic_specs: if self.license_env_var is None: self.log.info("Using Intel license specifications from 'license_file': %s", lic_specs) self.license_env_var = default_lic_env_var else: self.log.info("Using Intel license specifications from $%s: %s", self.license_env_var, lic_specs) self.license_file = os.pathsep.join(lic_specs) env.setvar(self.license_env_var, self.license_file) # if we have multiple retained lic specs, specify to 'use a license which exists on the system' if len(lic_specs) > 1: self.log.debug("More than one license specs found, using '%s' license activation instead of '%s'", ACTIVATION_EXIST_LIC, self.cfg['license_activation']) self.cfg['license_activation'] = ACTIVATION_EXIST_LIC # $INTEL_LICENSE_FILE should always be set during installation with existing license env.setvar(default_lic_env_var, self.license_file) else: msg = "No viable license specifications found; " msg += "specify 'license_file', or define $INTEL_LICENSE_FILE or $LM_LICENSE_FILE" raise EasyBuildError(msg)
def configure_step(self): """Configure COMSOL installation: create license file.""" # The tar file comes from the DVD and has 0444 as permission at the top dir. adjust_permissions(self.start_dir, stat.S_IWUSR) default_lic_env_var = 'LMCOMSOL_LICENSE_FILE' lic_specs, self.license_env_var = find_flexlm_license( custom_env_vars=[default_lic_env_var], lic_specs=[self.cfg['license_file']]) if lic_specs: if self.license_env_var is None: self.log.info( "Using COMSOL license specifications from 'license_file': %s", lic_specs) self.license_env_var = default_lic_env_var else: self.log.info( "Using COMSOL license specifications from $%s: %s", self.license_env_var, lic_specs) self.license_file = os.pathsep.join(lic_specs) env.setvar(self.license_env_var, self.license_file) else: msg = "No viable license specifications found; " msg += "specify 'license_file', or define $%s" % default_lic_env_var raise EasyBuildError(msg) copy_file(os.path.join(self.start_dir, 'setupconfig.ini'), self.configfile) config = read_file(self.configfile) config_vars = { 'agree': '1', 'desktopshortcuts': '0', 'fileassoc': '0', 'firewall': '0', 'installdir': self.installdir, 'license': self.license_file, 'licmanager': '0', 'linuxlauncher': '0', 'showgui': '0', 'startmenushortcuts': '0', 'symlinks': '0', } matlab_root = get_software_root("MATLAB") if matlab_root: config_vars.update({'matlabdir': matlab_root}) for key, val in config_vars.items(): regex = re.compile(r"^%s\s*=.*" % key, re.M) config = regex.sub("%s=%s" % (key, val), config) write_file(self.configfile, config) self.log.debug('configuration file written to %s:\n %s', self.configfile, config)
def prepare_step(self, *args, **kwargs): """Custom prepare step for IntelBase. Set up the license""" requires_runtime_license = kwargs.pop('requires_runtime_license', True) super(IntelBase, self).prepare_step(*args, **kwargs) # Decide if we need a license or not (default is True because of defaults of individual Booleans) self.requires_runtime_license = self.cfg[ 'requires_runtime_license'] and requires_runtime_license self.serial_number = self.cfg['serial_number'] if self.serial_number: self.log.info( "Using provided serial number (%s) and ignoring other licenses", self.serial_number) else: if self.requires_runtime_license: default_lic_env_var = 'INTEL_LICENSE_FILE' license_specs = ensure_iterable_license_specs( self.cfg['license_file']) lic_specs, self.license_env_var = find_flexlm_license( custom_env_vars=[default_lic_env_var], lic_specs=license_specs) if lic_specs: if self.license_env_var is None: self.log.info( "Using Intel license specifications from 'license_file': %s", lic_specs) self.license_env_var = default_lic_env_var else: self.log.info( "Using Intel license specifications from $%s: %s", self.license_env_var, lic_specs) self.license_file = os.pathsep.join(lic_specs) env.setvar(self.license_env_var, self.license_file) # if we have multiple retained lic specs, specify to 'use a license which exists on the system' if len(lic_specs) > 1: self.log.debug( "More than one license specs found, using '%s' license activation instead of '%s'", ACTIVATION_EXIST_LIC, self.cfg['license_activation']) self.cfg['license_activation'] = ACTIVATION_EXIST_LIC # $INTEL_LICENSE_FILE should always be set during installation with existing license env.setvar(default_lic_env_var, self.license_file) else: msg = "No viable license specifications found; " msg += "specify 'license_file', or define $INTEL_LICENSE_FILE or $LM_LICENSE_FILE" raise EasyBuildError(msg)
def configure_step(self): """Configure COMSOL installation: create license file.""" # The tar file comes from the DVD and has 0444 as permission at the top dir. adjust_permissions(self.start_dir, stat.S_IWUSR) default_lic_env_var = 'LMCOMSOL_LICENSE_FILE' lic_specs, self.license_env_var = find_flexlm_license(custom_env_vars=[default_lic_env_var], lic_specs=[self.cfg['license_file']]) if lic_specs: if self.license_env_var is None: self.log.info("Using COMSOL license specifications from 'license_file': %s", lic_specs) self.license_env_var = default_lic_env_var else: self.log.info("Using COMSOL license specifications from $%s: %s", self.license_env_var, lic_specs) self.license_file = os.pathsep.join(lic_specs) env.setvar(self.license_env_var, self.license_file) else: msg = "No viable license specifications found; " msg += "specify 'license_file', or define $%s" % default_lic_env_var raise EasyBuildError(msg) copy_file(os.path.join(self.start_dir, 'setupconfig.ini'), self.configfile) config = read_file(self.configfile) config_vars = { 'agree': '1', 'desktopshortcuts': '0', 'fileassoc': '0', 'firewall': '0', 'installdir': self.installdir, 'license': self.license_file, 'licmanager': '0', 'linuxlauncher': '0', 'showgui': '0', 'startmenushortcuts': '0', 'symlinks': '0', } matlab_root = get_software_root("MATLAB") if matlab_root: config_vars.update({'matlabdir': matlab_root}) for key, val in config_vars.items(): regex = re.compile(r"^%s\s*=.*" % key, re.M) config = regex.sub("%s=%s" % (key, val), config) write_file(self.configfile, config) self.log.debug('configuration file written to %s:\n %s', self.configfile, config)
def configure_step(self): """Configure: handle license file and clean home dir.""" # prepare (local) 'intel' home subdir self.setup_local_home_subdir() self.clean_home_subdir() default_lic_env_var = 'INTEL_LICENSE_FILE' lic_specs, self.license_env_var = find_flexlm_license( custom_env_vars=[default_lic_env_var], lic_specs=[self.cfg['license_file']]) if lic_specs: if self.license_env_var is None: self.log.info( "Using Intel license specifications from 'license_file': %s", lic_specs) self.license_env_var = default_lic_env_var else: self.log.info( "Using Intel license specifications from $%s: %s", self.license_env_var, lic_specs) self.license_file = os.pathsep.join(lic_specs) env.setvar(self.license_env_var, self.license_file) # if we have multiple retained lic specs, specify to 'use a license which exists on the system' if len(lic_specs) > 1: self.log.debug( "More than one license specs found, using '%s' license activation instead of '%s'", ACTIVATION_EXIST_LIC, self.cfg['license_activation']) self.cfg['license_activation'] = ACTIVATION_EXIST_LIC # $INTEL_LICENSE_FILE should always be set during installation with existing license env.setvar(default_lic_env_var, self.license_file) else: msg = "No viable license specifications found; " msg += "specify 'license_file', or define $INTEL_LICENSE_FILE or $LM_LICENSE_FILE" raise EasyBuildError(msg) # clean home directory self.clean_home_subdir() # determine list of components, based on 'components' easyconfig parameter (if specified) if self.cfg['components']: self.parse_components_list() else: self.log.debug("No components specified")
def configure_step(self): """Configure: handle license file and clean home dir.""" # prepare (local) 'intel' home subdir self.setup_local_home_subdir() self.clean_home_subdir() default_lic_env_var = 'INTEL_LICENSE_FILE' lic_specs, self.license_env_var = find_flexlm_license(custom_env_vars=[default_lic_env_var], lic_specs=[self.cfg['license_file']]) if lic_specs: if self.license_env_var is None: self.log.info("Using Intel license specifications from 'license_file': %s", lic_specs) self.license_env_var = default_lic_env_var else: self.log.info("Using Intel license specifications from $%s: %s", self.license_env_var, lic_specs) self.license_file = os.pathsep.join(lic_specs) env.setvar(self.license_env_var, self.license_file) # if we have multiple retained lic specs, specify to 'use a license which exists on the system' if len(lic_specs) > 1: self.log.debug("More than one license specs found, using '%s' license activation instead of '%s'", ACTIVATION_EXIST_LIC, self.cfg['license_activation']) self.cfg['license_activation'] = ACTIVATION_EXIST_LIC # $INTEL_LICENSE_FILE should always be set during installation with existing license env.setvar(default_lic_env_var, self.license_file) else: msg = "No viable license specifications found; " msg += "specify 'license_file', or define $INTEL_LICENSE_FILE or $LM_LICENSE_FILE" raise EasyBuildError(msg) # clean home directory self.clean_home_subdir() # determine list of components, based on 'components' easyconfig parameter (if specified) if self.cfg['components']: self.parse_components_list() else: self.log.debug("No components specified")
def configure_step(self): """ Handle of license """ default_lic_env_var = 'LM_LICENSE_FILE' lic_specs, self.license_env_var = find_flexlm_license(custom_env_vars=[default_lic_env_var], lic_specs=[self.cfg['license_file']]) if lic_specs: if self.license_env_var is None: self.log.info("Using Totalview license specifications from 'license_file': %s", lic_specs) self.license_env_var = default_lic_env_var else: self.log.info("Using Totalview license specifications from %s: %s", self.license_env_var, lic_specs) self.license_file = os.pathsep.join(lic_specs) env.setvar(self.license_env_var, self.license_file) else: raise EasyBuildError("No viable license specifications found; specify 'license_file' or "+ "define $LM_LICENSE_FILE")
def configure_step(self): """ Handle license file. """ default_lic_env_var = 'PGROUPD_LICENSE_FILE' license_specs = ensure_iterable_license_specs(self.cfg['license_file']) lic_specs, self.license_env_var = find_flexlm_license(custom_env_vars=[default_lic_env_var], lic_specs=license_specs) if lic_specs: if self.license_env_var is None: self.log.info("Using PGI license specifications from 'license_file': %s", lic_specs) self.license_env_var = default_lic_env_var else: self.log.info("Using PGI license specifications from %s: %s", self.license_env_var, lic_specs) self.license_file = os.pathsep.join(lic_specs) env.setvar(self.license_env_var, self.license_file) else: self.log.info("No viable license specifications found, assuming PGI Community Edition...")
def prepare_step(self, *args, **kwargs): """Custom prepare step for IntelBase. Set up the license""" requires_runtime_license = kwargs.pop('requires_runtime_license', True) super(IntelBase, self).prepare_step(*args, **kwargs) # Decide if we need a license or not (default is True because of defaults of individual Booleans) self.requires_runtime_license = self.cfg['requires_runtime_license'] and requires_runtime_license self.serial_number = self.cfg['serial_number'] if self.serial_number: self.log.info("Using provided serial number (%s) and ignoring other licenses", self.serial_number) elif self.requires_runtime_license: default_lic_env_var = 'INTEL_LICENSE_FILE' license_specs = ensure_iterable_license_specs(self.cfg['license_file']) lic_specs, self.license_env_var = find_flexlm_license(custom_env_vars=[default_lic_env_var], lic_specs=license_specs) if lic_specs: if self.license_env_var is None: self.log.info("Using Intel license specifications from 'license_file': %s", lic_specs) self.license_env_var = default_lic_env_var else: self.log.info("Using Intel license specifications from $%s: %s", self.license_env_var, lic_specs) self.license_file = os.pathsep.join(lic_specs) env.setvar(self.license_env_var, self.license_file) # if we have multiple retained lic specs, specify to 'use a license which exists on the system' if len(lic_specs) > 1: self.log.debug("More than one license specs found, using '%s' license activation instead of " "'%s'", ACTIVATION_EXIST_LIC, self.cfg['license_activation']) self.cfg['license_activation'] = ACTIVATION_EXIST_LIC # $INTEL_LICENSE_FILE should always be set during installation with existing license env.setvar(default_lic_env_var, self.license_file) else: msg = "No viable license specifications found; " msg += "specify 'license_file', or define $INTEL_LICENSE_FILE or $LM_LICENSE_FILE" raise EasyBuildError(msg)
def test_find_flexlm_license(self): """Test find_flexlm_license function.""" lic_file1 = os.path.join(self.test_prefix, 'one.lic') ft.write_file(lic_file1, "This is a license file (no, really!)") lic_file2 = os.path.join(self.test_prefix, 'two.dat') ft.write_file(lic_file2, "This is another license file (sure it is!)") lic_server = '*****@*****.**' # make test robust against environment in which $LM_LICENSE_FILE is defined if 'LM_LICENSE_FILE' in os.environ: del os.environ['LM_LICENSE_FILE'] # default return value self.assertEqual(ft.find_flexlm_license(), ([], None)) # provided license spec self.assertEqual(ft.find_flexlm_license(lic_specs=[lic_file1]), ([lic_file1], None)) self.assertEqual( ft.find_flexlm_license(lic_specs=[lic_server, lic_file2]), ([lic_server, lic_file2], None)) # non-existing license file os.environ[ 'LM_LICENSE_FILE'] = '/no/such/file/unless/you/aim/to/break/this/check' self.assertEqual(ft.find_flexlm_license(), ([], None)) # existing license file os.environ['LM_LICENSE_FILE'] = lic_file2 self.assertEqual(ft.find_flexlm_license(), ([lic_file2], 'LM_LICENSE_FILE')) # directory with existing license files os.environ['LM_LICENSE_FILE'] = self.test_prefix self.assertEqual(ft.find_flexlm_license(), ([lic_file1, lic_file2], 'LM_LICENSE_FILE')) # server spec os.environ['LM_LICENSE_FILE'] = lic_server self.assertEqual(ft.find_flexlm_license(), ([lic_server], 'LM_LICENSE_FILE')) # duplicates are filtered out, order is maintained os.environ['LM_LICENSE_FILE'] = ':'.join( [lic_file1, lic_server, self.test_prefix, lic_file2, lic_file1]) self.assertEqual( ft.find_flexlm_license(), ([lic_file1, lic_server, lic_file2], 'LM_LICENSE_FILE')) # invalid server spec (missing port) os.environ['LM_LICENSE_FILE'] = 'test.license.server' self.assertEqual(ft.find_flexlm_license(), ([], None)) # env var wins of provided lic spec os.environ['LM_LICENSE_FILE'] = lic_file2 self.assertEqual(ft.find_flexlm_license(lic_specs=[lic_server]), ([lic_file2], 'LM_LICENSE_FILE')) # custom env var wins over $LM_LICENSE_FILE os.environ['INTEL_LICENSE_FILE'] = lic_file1 expected = ([lic_file1], 'INTEL_LICENSE_FILE') self.assertEqual( ft.find_flexlm_license(custom_env_vars='INTEL_LICENSE_FILE'), expected) self.assertEqual( ft.find_flexlm_license(custom_env_vars=['INTEL_LICENSE_FILE']), expected) self.assertEqual( ft.find_flexlm_license( custom_env_vars=['NOSUCHENVVAR', 'INTEL_LICENSE_FILE']), expected) # $LM_LICENSE_FILE is always considered os.environ['LM_LICENSE_FILE'] = lic_server os.environ[ 'INTEL_LICENSE_FILE'] = '/no/such/file/unless/you/aim/to/break/this/check' expected = ([lic_server], 'LM_LICENSE_FILE') self.assertEqual( ft.find_flexlm_license(custom_env_vars=['INTEL_LICENSE_FILE']), expected) # license server *and* file spec; order is preserved os.environ['LM_LICENSE_FILE'] = ':'.join( [lic_file2, lic_server, lic_file1]) self.assertEqual( ft.find_flexlm_license(), ([lic_file2, lic_server, lic_file1], 'LM_LICENSE_FILE')) # typical usage os.environ['LM_LICENSE_FILE'] = lic_server os.environ[ 'INTEL_LICENSE_FILE'] = '/not/a/valid/license/path:%s:/another/bogus/license/file' % lic_file2 expected = ([lic_file2], 'INTEL_LICENSE_FILE') self.assertEqual( ft.find_flexlm_license(custom_env_vars='INTEL_LICENSE_FILE'), expected) os.environ[ 'INTEL_LICENSE_FILE'] = '[email protected]:[email protected]:[email protected]' expected = (['*****@*****.**', '*****@*****.**', '*****@*****.**'], 'INTEL_LICENSE_FILE') self.assertEqual( ft.find_flexlm_license(custom_env_vars=['INTEL_LICENSE_FILE']), expected) # make sure find_flexlm_license is robust against None input; # this occurs if license_file is left unspecified del os.environ['INTEL_LICENSE_FILE'] del os.environ['LM_LICENSE_FILE'] self.assertEqual(ft.find_flexlm_license(lic_specs=[None]), ([], None))
def test_find_flexlm_license(self): """Test find_flexlm_license function.""" lic_file1 = os.path.join(self.test_prefix, 'one.lic') ft.write_file(lic_file1, "This is a license file (no, really!)") lic_file2 = os.path.join(self.test_prefix, 'two.dat') ft.write_file(lic_file2, "This is another license file (sure it is!)") lic_server = '*****@*****.**' # make test robust against environment in which $LM_LICENSE_FILE is defined if 'LM_LICENSE_FILE' in os.environ: del os.environ['LM_LICENSE_FILE'] # default return value self.assertEqual(ft.find_flexlm_license(), ([], None)) # provided license spec self.assertEqual(ft.find_flexlm_license(lic_specs=[lic_file1]), ([lic_file1], None)) self.assertEqual(ft.find_flexlm_license(lic_specs=[lic_server, lic_file2]), ([lic_server, lic_file2], None)) # non-existing license file os.environ['LM_LICENSE_FILE'] = '/no/such/file/unless/you/aim/to/break/this/check' self.assertEqual(ft.find_flexlm_license(), ([], None)) # existing license file os.environ['LM_LICENSE_FILE'] = lic_file2 self.assertEqual(ft.find_flexlm_license(), ([lic_file2], 'LM_LICENSE_FILE')) # directory with existing license files os.environ['LM_LICENSE_FILE'] = self.test_prefix self.assertEqual(ft.find_flexlm_license(), ([lic_file1, lic_file2], 'LM_LICENSE_FILE')) # server spec os.environ['LM_LICENSE_FILE'] = lic_server self.assertEqual(ft.find_flexlm_license(), ([lic_server], 'LM_LICENSE_FILE')) # invalid server spec (missing port) os.environ['LM_LICENSE_FILE'] = 'test.license.server' self.assertEqual(ft.find_flexlm_license(), ([], None)) # env var wins of provided lic spec os.environ['LM_LICENSE_FILE'] = lic_file2 self.assertEqual(ft.find_flexlm_license(lic_specs=[lic_server]), ([lic_file2], 'LM_LICENSE_FILE')) # custom env var wins over $LM_LICENSE_FILE os.environ['INTEL_LICENSE_FILE'] = lic_file1 expected = ([lic_file1], 'INTEL_LICENSE_FILE') self.assertEqual(ft.find_flexlm_license(custom_env_vars='INTEL_LICENSE_FILE'), expected) self.assertEqual(ft.find_flexlm_license(custom_env_vars=['INTEL_LICENSE_FILE']), expected) self.assertEqual(ft.find_flexlm_license(custom_env_vars=['NOSUCHENVVAR', 'INTEL_LICENSE_FILE']), expected) # $LM_LICENSE_FILE is always considered os.environ['LM_LICENSE_FILE'] = lic_server os.environ['INTEL_LICENSE_FILE'] = '/no/such/file/unless/you/aim/to/break/this/check' expected = ([lic_server], 'LM_LICENSE_FILE') self.assertEqual(ft.find_flexlm_license(custom_env_vars=['INTEL_LICENSE_FILE']), expected) # license server *and* file spec; order is preserved os.environ['LM_LICENSE_FILE'] = ':'.join([lic_file2, lic_server, lic_file1]) self.assertEqual(ft.find_flexlm_license(), ([lic_file2, lic_server, lic_file1], 'LM_LICENSE_FILE')) # typical usage os.environ['LM_LICENSE_FILE'] = lic_server os.environ['INTEL_LICENSE_FILE'] = '/not/a/valid/license/path:%s:/another/bogus/license/file' % lic_file2 expected = ([lic_file2], 'INTEL_LICENSE_FILE') self.assertEqual(ft.find_flexlm_license(custom_env_vars='INTEL_LICENSE_FILE'), expected) os.environ['INTEL_LICENSE_FILE'] = '[email protected]:[email protected]:[email protected]' expected = (['*****@*****.**', '*****@*****.**', '*****@*****.**'], 'INTEL_LICENSE_FILE') self.assertEqual(ft.find_flexlm_license(custom_env_vars=['INTEL_LICENSE_FILE']), expected) # make sure find_flexlm_license is robust against None input; # this occurs if license_file is left unspecified del os.environ['INTEL_LICENSE_FILE'] del os.environ['LM_LICENSE_FILE'] self.assertEqual(ft.find_flexlm_license(lic_specs=[None]), ([], None))