def hostname (tokeniser): value = string(tokeniser) if not value[0].isalnum() or value[0].isdigit(): raise ValueError('bad host-name (alphanumeric)') if not value[-1].isalnum() or value[-1].isdigit(): raise ValueError('bad host-name (alphanumeric)') if '..' in value: raise ValueError('bad host-name (double colon)') if not all(True if c in ascii_letters + digits + '.-' else False for c in value): raise ValueError('bad host-name (charset)') if len(value) > 255: raise ValueError('bad host-name (length)') return value
def hostname (tokeniser): value = string(tokeniser) if not value[0].isalnum(): raise ValueError('bad host-name (alphanumeric)') if not value[-1].isalnum() or value[-1].isdigit(): raise ValueError('bad host-name (alphanumeric)') if '..' in value: raise ValueError('bad host-name (double period)') if not all(True if c in ascii_letters + digits + '.-' else False for c in value): raise ValueError('bad host-name (charset)') if len(value) > 255: raise ValueError('bad host-name (length)') return value
def domainname (tokeniser): value = string(tokeniser) if not value: raise ValueError('bad domain-name') if not value[0].isalnum() or value[0].isdigit(): raise ValueError('bad domain-name') if not value[-1].isalnum() or value[-1].isdigit(): raise ValueError('bad domain-name') if '..' in value: raise ValueError('bad domain-name') if not all(True if c in ascii_letters + digits + '.-' else False for c in value): raise ValueError('bad domain-name') if len(value) > 255: raise ValueError('bad domain-name (length)') return value
def gracefulrestart (tokeniser, default): if len(tokeniser.tokens) == 1: return default state = string(tokeniser) if state in ('disable','disabled'): return False try: grace = int(state) except ValueError: raise ValueError('"%s" is an invalid graceful-restart time' % state) if grace < 0: raise ValueError('graceful-restart can not be negative') if grace > Graceful.MAX: raise ValueError('graceful-restart must be smaller or equal to %d' % Graceful.MAX) return grace
def addpath (tokeniser): if not tokeniser.tokens: raise ValueError('add-path must be one of send, receive, send/receive, disable') ap = string(tokeniser).lower() match = { 'disable': 0, 'disabled': 0, 'receive': 1, 'send': 2, 'send/receive': 3, } if ap in match: return match[ap] if ap == 'receive/send': # was allowed with the previous parser raise ValueError('the option is send/receive') raise ValueError('"%s" is an invalid add-path, options are send, receive, send/receive' % ap)
def addpath (tokeniser): if not tokeniser.tokens: raise ValueError('add-path must be one of send, receive, send/receive, disable') ap = string(tokeniser).lower() match = { 'disable': 0, 'disabled': 0, 'receive': 1, 'send': 2, 'send/receive': 3, } if ap in match: return match[ap] if ap == 'receive/send': # was allowed with the previous parser raise ValueError('the option is send/receive') raise ValueError('"%s" is an invalid add-path, options are: send, receive, send/receive' % ap)
def description (tokeniser): try: return string(tokeniser) except: raise ValueError('bad neighbor description')
def description(tokeniser): try: return string(tokeniser) except: raise ValueError('bad neighbor description')
def bgpsec_crypto_init(tokeniser): value = string(tokeniser) return value
def bgpsec_openssl_lib(tokeniser): value = string(tokeniser) return value