Exemple #1
0
def validate_neighbordb():
    # Validating neighbordb
    validator = NeighbordbValidator('N/A')
    neighbordb = neighbordb_path()
    print 'Validating neighbordb (\'%s\')...' % neighbordb
    try:
        validator.validate(load(neighbordb, CONTENT_TYPE_YAML, 'validator'))
        total_patterns = len(validator.valid_patterns) + \
            len(validator.invalid_patterns)

        if validator.invalid_patterns:
            print '\nERROR: Failed to validate neighbordb patterns'
            print '   Invalid Patterns (count: %d/%d)' % \
                (len(validator.invalid_patterns),
                 total_patterns)
            print '   ---------------------------'
            for index, pattern in enumerate(sorted(
                    validator.invalid_patterns)):
                print '   [%d] %s' % (index, pattern[1])
        else:
            print 'Ok!'
    except Exception as exc:  #pylint: disable=W0703
        print 'ERROR: Failed to validate neighbordb\n%s' % exc
Exemple #2
0
def validate_neighbordb():
    # Validating neighbordb
    validator = NeighbordbValidator('N/A')
    neighbordb = neighbordb_path()
    print 'Validating neighbordb (\'%s\')...' % neighbordb
    try:
        validator.validate(load(neighbordb, CONTENT_TYPE_YAML,
                                'validator'))
        total_patterns = len(validator.valid_patterns) + \
            len(validator.invalid_patterns)
            
        if validator.invalid_patterns:
            print '\nERROR: Failed to validate neighbordb patterns'
            print '   Invalid Patterns (count: %d/%d)' % \
                (len(validator.invalid_patterns),
                 total_patterns)
            print '   ---------------------------'
            for index, pattern in enumerate(
                sorted(validator.invalid_patterns)):
                print '   [%d] %s' % (index, pattern[1])
        else:
            print 'Ok!'            
    except Exception as exc:        #pylint: disable=W0703
        print 'ERROR: Failed to validate neighbordb\n%s' % exc
 def test_neighbordb_path(self):
     result = neighbordb_path()
     self.assertEqual(result, '/usr/share/ztpserver/neighbordb')
 def test_neighbordb_path(self):
     result = neighbordb_path()
     self.assertEqual(result, '/usr/share/ztpserver/neighbordb')