def test_valid_contact(self): """ Test functionality of valid_contact to make sure that it rejects incorrect contact strings and accepts correct ones """ jobmanagers = ['pbs', 'lsf', 'sge', 'condor', 'slurm'] domain_port = 'example.net:8888' ipv4addr_port = '12.34.56.78:8888' for jobmanager in jobmanagers: for test_manager in jobmanagers: contact = "%s/jobmanager-%s" % (domain_port, test_manager) if test_manager == jobmanager: self.assertTrue(validation.valid_contact(contact, jobmanager), "%s labeled as invalid contact" % contact) else: self.assertFalse(validation.valid_contact(contact, jobmanager), "%s labeled as valid contact" % contact) contact = "%s/jobmanager-condor" % (ipv4addr_port) self.assertTrue(validation.valid_contact(contact, 'condor'), "%s labeled as invalid contact" % contact) domain_port = 'example.net:234a' for jobmanager in jobmanagers: contact = "%s/jobmanager-%s" % (domain_port, jobmanager) self.assertFalse(validation.valid_contact(contact, jobmanager), "%s labeled as valid contact" % contact) domain_port = 'fdf%34@!:8888' for jobmanager in jobmanagers: contact = "%s/jobmanager-%s" % (domain_port, jobmanager) self.assertFalse(validation.valid_contact(contact, jobmanager), "%s labeled as valid contact" % contact)
def test_valid_contact(self): """ Test functionality of valid_contact to make sure that it rejects incorrect contact strings and accepts correct ones """ jobmanagers = ["pbs", "lsf", "sge", "condor", "slurm"] domain_port = "example.net:8888" ipv4addr_port = "12.34.56.78:8888" for jobmanager in jobmanagers: for test_manager in jobmanagers: contact = "%s/jobmanager-%s" % (domain_port, test_manager) if test_manager == jobmanager: self.assertTrue( validation.valid_contact(contact, jobmanager), "%s labeled as invalid contact" % contact ) else: self.assertFalse( validation.valid_contact(contact, jobmanager), "%s labeled as valid contact" % contact ) contact = "%s/jobmanager-condor" % (ipv4addr_port) self.assertTrue(validation.valid_contact(contact, "condor"), "%s labeled as invalid contact" % contact) domain_port = "example.net:234a" for jobmanager in jobmanagers: contact = "%s/jobmanager-%s" % (domain_port, jobmanager) self.assertFalse(validation.valid_contact(contact, jobmanager), "%s labeled as valid contact" % contact) domain_port = "fdf%34@!:8888" for jobmanager in jobmanagers: contact = "%s/jobmanager-%s" % (domain_port, jobmanager) self.assertFalse(validation.valid_contact(contact, jobmanager), "%s labeled as valid contact" % contact)
def check_attributes(self, attributes): """Check attributes currently stored and make sure that they are consistent""" self.log('SlurmConfiguration.check_attributes started') attributes_ok = True if not self.enabled: self.log('SLURM not enabled, returning True') self.log('SlurmConfiguration.check_attributes completed') return attributes_ok if self.ignored: self.log('Ignored, returning True') self.log('SlurmConfiguration.check_attributes completed') return attributes_ok # make sure locations exist if not validation.valid_location(self.options['slurm_location'].value): attributes_ok = False self.log("Non-existent location given: %s" % (self.options['slurm_location'].value), option='slurm_location', section=self.config_section, level=logging.ERROR) if not validation.valid_directory(self.slurm_bin_location): attributes_ok = False self.log("Given slurm_location %r has no bin/ directory" % self.options['slurm_location'].value, option='slurm_location', section=self.config_section, level=logging.ERROR) if not validation.valid_contact(self.options['job_contact'].value, 'pbs'): attributes_ok = False self.log("Invalid job contact: %s" % (self.options['job_contact'].value), option='job_contact', section=self.config_section, level=logging.ERROR) if not validation.valid_contact(self.options['util_contact'].value, 'pbs'): attributes_ok = False self.log("Invalid util contact: %s" % (self.options['util_contact'].value), option='util_contact', section=self.config_section, level=logging.ERROR) self.log('SlurmConfiguration.check_attributes completed') return attributes_ok
def test_valid_contact_ipv6(self): valid_hosts = [ "[1234:5678:9abc:def::01]:8888", # ipv6 addr with port "1234:5678:9abc:def::01", # ipv6 addr with no port "[1234:5678:9abc:def::01]", # ipv6 addr with brackets but no port ] invalid_hosts = ["fghi::01", "[[::ff]]"] # not hex # too many brackets for testval in valid_hosts: contact = testval + "/jobmanager" self.assertTrue(validation.valid_contact(contact, ""), "%s labeled as invalid contact" % contact) for testval in invalid_hosts: contact = testval + "/jobmanager" self.assertFalse(validation.valid_contact(contact, ""), "%s labeled as valid contact" % contact)
def test_valid_contact_ipv6(self): valid_hosts = [ '[1234:5678:9abc:def::01]:8888', # ipv6 addr with port '1234:5678:9abc:def::01', # ipv6 addr with no port '[1234:5678:9abc:def::01]', # ipv6 addr with brackets but no port ] invalid_hosts = [ 'fghi::01', # not hex '[[::ff]]', # too many brackets ] for testval in valid_hosts: contact = testval + "/jobmanager" self.assertTrue(validation.valid_contact(contact, ''), "%s labeled as invalid contact" % contact) for testval in invalid_hosts: contact = testval + "/jobmanager" self.assertFalse(validation.valid_contact(contact, ''), "%s labeled as valid contact" % contact)
def check_attributes(self, attributes): """Check attributes currently stored and make sure that they are consistent""" self.log('CondorConfiguration.check_attributes started') if not self.enabled: self.log('CondorConfiguration.check_attributes completed returning True') return True if self.ignored: self.log('CondorConfiguration.check_attributes completed returning True') return True attributes_ok = True # make sure locations exist self.log('checking condor_location') if not validation.valid_location(self.options['condor_location'].value): attributes_ok = False self.log("Non-existent location given: %s" % (self.options['condor_location'].value), option='condor_location', section=self.config_section, level=logging.ERROR) if not validation.valid_directory(self.condor_bin_location): attributes_ok = False self.log("Given condor_location %r has no bin/ directory" % self.options['condor_location'].value, option='condor_location', section=self.config_section, level=logging.ERROR) self.log('checking condor_config') if not validation.valid_file(self.options['condor_config'].value): attributes_ok = False self.log("Non-existent location given: %s" % (self.options['condor_config'].value), option='condor_config', section=self.config_section, level=logging.ERROR) if not validation.valid_contact(self.options['job_contact'].value, 'condor'): attributes_ok = False self.log("Invalid job contact: %s" % (self.options['job_contact'].value), option='job_contact', section=self.config_section, level=logging.ERROR) if not validation.valid_contact(self.options['util_contact'].value, 'condor'): attributes_ok = False self.log("Invalid util contact: %s" % (self.options['util_contact'].value), option='util_contact', section=self.config_section, level=logging.ERROR) self.log('CondorConfiguration.check_attributes completed returning %s' \ % attributes_ok) return attributes_ok
def check_attributes(self, attributes): """Check attributes currently stored and make sure that they are consistent""" self.log('CondorConfiguration.check_attributes started') if not self.enabled: self.log( 'CondorConfiguration.check_attributes completed returning True' ) return True if self.ignored: self.log( 'CondorConfiguration.check_attributes completed returning True' ) return True attributes_ok = True # make sure locations exist self.log('checking condor_location') if not validation.valid_location( self.options['condor_location'].value): attributes_ok = False self.log("Non-existent location given: %s" % (self.options['condor_location'].value), option='condor_location', section=self.config_section, level=logging.ERROR) if not validation.valid_directory(self.condor_bin_location): attributes_ok = False self.log("Given condor_location %r has no bin/ directory" % self.options['condor_location'].value, option='condor_location', section=self.config_section, level=logging.ERROR) self.log('checking condor_config') if not validation.valid_file(self.options['condor_config'].value): attributes_ok = False self.log("Non-existent location given: %s" % (self.options['condor_config'].value), option='condor_config', section=self.config_section, level=logging.ERROR) if not validation.valid_contact(self.options['job_contact'].value, 'condor'): attributes_ok = False self.log("Invalid job contact: %s" % (self.options['job_contact'].value), option='job_contact', section=self.config_section, level=logging.ERROR) if not validation.valid_contact(self.options['util_contact'].value, 'condor'): attributes_ok = False self.log("Invalid util contact: %s" % (self.options['util_contact'].value), option='util_contact', section=self.config_section, level=logging.ERROR) self.log('CondorConfiguration.check_attributes completed returning %s' \ % attributes_ok) return attributes_ok
def check_attributes(self, attributes): """Check attributes currently stored and make sure that they are consistent""" self.log('SGEConfiguration.check_attributes started') attributes_ok = True if not self.enabled: self.log('SGE not enabled, returning True') self.log('SGEConfiguration.check_attributes completed') return attributes_ok if self.ignored: self.log('Ignored, returning True') self.log('SGEConfiguration.check_attributes completed') return attributes_ok # make sure locations exist if not validation.valid_location(self.options['sge_root'].value): attributes_ok = False self.log("Non-existent location given: %s" % (self.options['sge_root'].value), option='sge_root', section=self.config_section, level=logging.ERROR) settings_file = os.path.join(self.options['sge_root'].value, self.options['sge_cell'].value, 'common', 'settings.sh') if not validation.valid_file(settings_file): attributes_ok = False self.log("$SGE_ROOT/$SGE_CELL/common/settings.sh not present: %s" % settings_file, option='sge_cell', section=self.config_section, level=logging.ERROR) if not validation.valid_directory(self.options['sge_bin_location'].value): attributes_ok = False self.log("sge_bin_location not valid: %s" % self.options['sge_bin_location'].value, option='sge_bin_location', section=self.config_section, level=logging.ERROR) if not validation.valid_contact(self.options['job_contact'].value, 'sge'): attributes_ok = False self.log("Invalid job contact: %s" % (self.options['job_contact'].value), option='job_contact', section=self.config_section, level=logging.ERROR) if not validation.valid_contact(self.options['util_contact'].value, 'sge'): attributes_ok = False self.log("Invalid util contact: %s" % (self.options['util_contact'].value), option='util_contact', section=self.config_section, level=logging.ERROR) if self.options['seg_enabled'].value: if (self.options['log_file'].value is None or not validation.valid_file(self.options['log_file'].value)): mesg = "%s is not a valid file path " % self.options['log_file'].value mesg += "for sge log files" self.log(mesg, section=self.config_section, option='log_file', level=logging.ERROR) attributes_ok = False key = 'sge_config' if (not self.options[key].value or not validation.valid_file(self.options[key].value)): attributes_ok = False self.log("%s is not a valid file: %s" % (key, self.options[key].value), section=self.config_section, option=key, level=logging.ERROR) self.log('SGEConfiguration.check_attributes completed') return attributes_ok
def check_attributes(self, attributes): """Check attributes currently stored and make sure that they are consistent""" self.log('SGEConfiguration.check_attributes started') attributes_ok = True if not self.enabled: self.log('SGE not enabled, returning True') self.log('SGEConfiguration.check_attributes completed') return attributes_ok if self.ignored: self.log('Ignored, returning True') self.log('SGEConfiguration.check_attributes completed') return attributes_ok # make sure locations exist if not validation.valid_location(self.options['sge_root'].value): attributes_ok = False self.log("Non-existent location given: %s" % (self.options['sge_root'].value), option='sge_root', section=self.config_section, level=logging.ERROR) settings_file = os.path.join(self.options['sge_root'].value, self.options['sge_cell'].value, 'common', 'settings.sh') if not validation.valid_file(settings_file): attributes_ok = False self.log("$SGE_ROOT/$SGE_CELL/common/settings.sh not present: %s" % settings_file, option='sge_cell', section=self.config_section, level=logging.ERROR) if not validation.valid_directory( self.options['sge_bin_location'].value): attributes_ok = False self.log("sge_bin_location not valid: %s" % self.options['sge_bin_location'].value, option='sge_bin_location', section=self.config_section, level=logging.ERROR) if not validation.valid_contact(self.options['job_contact'].value, 'sge'): attributes_ok = False self.log("Invalid job contact: %s" % (self.options['job_contact'].value), option='job_contact', section=self.config_section, level=logging.ERROR) if not validation.valid_contact(self.options['util_contact'].value, 'sge'): attributes_ok = False self.log("Invalid util contact: %s" % (self.options['util_contact'].value), option='util_contact', section=self.config_section, level=logging.ERROR) if self.options['seg_enabled'].value: if (self.options['log_file'].value is None or not validation.valid_file(self.options['log_file'].value)): mesg = "%s is not a valid file path " % self.options[ 'log_file'].value mesg += "for sge log files" self.log(mesg, section=self.config_section, option='log_file', level=logging.ERROR) attributes_ok = False key = 'sge_config' if (not self.options[key].value or not validation.valid_file(self.options[key].value)): attributes_ok = False self.log("%s is not a valid file: %s" % (key, self.options[key].value), section=self.config_section, option=key, level=logging.ERROR) self.log('SGEConfiguration.check_attributes completed') return attributes_ok