LFUtils: updates name_to_eid() to allow for qvlan names

This commit is contained in:
Jed Reynolds
2020-11-13 15:36:37 -08:00
parent 9f6e6d45fe
commit e07e5e3a9c

View File

@@ -464,22 +464,43 @@ def waitUntilPortsAppear(base_url="http://localhost:8080", port_list=(), debug=F
"""
return wait_until_ports_appear(base_url, port_list, debug=debug)
def name_to_eid(eid):
def name_to_eid(input):
rv = [1, 1, ""];
info = []
if (eid is None) or (eid == ""):
raise ValueError("name_to_eid wants eid like 1.1.sta0 but given[%s]" % eid)
if (input is None) or (input == ""):
raise ValueError("name_to_eid wants eid like 1.1.sta0 but given[%s]" % input)
info = eid.split('.')
if (len(info) == 1):
info = input.split('.')
if len(info) == 1:
rv[2] = info[0]; # just port name
if len(info) == 2: # resource.port-name
return rv
if (len(info) == 2) and info[0].isnumeric() and not info[1].isnumeric(): # resource.port-name
print("ZZZZZZZZZZZZZZZZZZZZZZZZZZZZ")
rv[1] = int(info[0])
rv[2] = info[1]
if len(info) == 3: # shelf.resource.port-name
return rv
elif (len(info) == 2) and not info[0].isnumeric(): # port-name.qvlan
print("YYYYYYYYYYYYYYYYYYYYYYYYYYYY")
rv[2] = info[0]+"."+info[1]
return rv
if (len(info) == 3) and info[0].isnumeric() and info[1].isnumeric(): # shelf.resource.port-name
rv[0] = int(info[0])
rv[1] = int(info[1])
rv[2] = info[2]
return rv
elif (len(info) == 3) and info[0].isnumeric() and not info[1].isnumeric(): # resource.port-name.qvlan
rv[1] = int(info[0])
rv[2] = info[1]+"."+info[2]
return rv
if len(info) == 4: # shelf.resource.port-name.qvlan
rv[0] = int(info[0])
rv[1] = int(info[1])
rv[2] = info[2]+"."+info[3]
return rv;