VLAN tidying time

master
Marek Isalski 3 years ago
parent 804417481a
commit 4a36c97449

@ -10,7 +10,7 @@ import json
import re
resolver = dns.resolver.Resolver()
vlan_re = re.compile( r"([:\.][0-9]+)" )
vlan_re = re.compile( r"([:\.]?[0-9]+)" )
THINGTYPE_VM = "/api/v2/thingtype/4/"
USER_MAREK = "/api/v2/user/1/"
@ -69,9 +69,16 @@ def fulcrm_get_thing( uuid = None, source_str = None, source = None, name = None
return ( thing, False )
def ganeti_vlan( val ):
vlans = { "untagged": None, "tagged": [] }
if val:
return [ x for ( i, x ) in enumerate( vlan_re.split( val ) ) if i % 2 ]
return None
for vid in [ x for ( i, x ) in enumerate( vlan_re.split( val ) ) if i % 2 ]:
if vid.startswith( ":" ):
vlans[ 'tagged' ].append( int( vid[ 1: ] ) )
elif vid.startswith( "." ):
vlans[ 'untagged' ] = int( vid[ 1: ] )
else:
vlans[ 'untagged' ] = int( vid )
return vlans
def unix_to_8601( t ):
if t:

Loading…
Cancel
Save