Moved endpoint and cx creation to specific classes

This commit is contained in:
Logan Lipke
2020-06-09 13:08:24 -07:00
parent dfc6929924
commit c3e48e4ed5

View File

@@ -154,32 +154,27 @@ class Realm(LFCliBase):
station_prof = StationProfile(self.lfclient_url, debug=self.debugOn)
return station_prof
def new_l3_cx_profile(self, cx_type):
cx_prof = CXProfile(lfclient_host=self.lfjson_host, lfclient_port=self.lfjson_port, cx_type=cx_type,
debug=self.debugOn)
def new_l3_cx_profile(self):
return cx_prof
def new_l4_cx_profile(self):
cx_prof = CXProfile(lfclient_host=self.lfjson_host, lfclient_port=self.lfjson_port, cx_type="l4_generic",
debug=self.debugOn)
return cx_prof
def new_generic_cx_profile(self):
cx_prof = CXProfile(lfclient_host=self.lfjson_host, lfclient_port=self.lfjson_port, cx_type="gen_generic",
debug=self.debugOn)
return cx_prof
class CXProfile:
def __init__(self, lfclient_host, lfclient_port, cx_type, debug=False):
class L3CXProfile:
def __init__(self, lfclient_host, lfclient_port, debug=False):
self.lfclient_url = "http://%s:%s/" % (lfclient_host, lfclient_port)
self.cx_type = cx_type
self.debug = debug
# Creates cross-connect for each port specified in the addPorts function
def create(self, endp_type, side="a", ports=[], sleep_time=.5):
post_data = []
if endp_type == "lf_udp" or endp_type == "lf_tcp":
side = side.upper()
endp_side_a = {
"alias": "",
@@ -228,8 +223,20 @@ class CXProfile:
"rx_endp": port_name + "CX-B"
}
post_data.append(data)
for data in post_data:
url = self.lfclient_url + "/cli-json/add_cx"
LFCliBase.json_post(url, data)
time.sleep(sleep_time)
elif endp_type == "l4_generic":
class L4CXProfile:
def __init__(self, lfclient_host, lfclient_port, debug=False):
self.lfclient_url = "http://%s:%s/" % (lfclient_host, lfclient_port)
self.debug = debug
# Creates cross-connect for each port specified in the addPorts function
def create(self, endp_type, ports=[], sleep_time=.5):
post_data = []
for port_name in ports:
data = {
"alias": port_name + "_l4",
@@ -253,7 +260,20 @@ class CXProfile:
}
post_data.append(data)
elif endp_type == "gen_generic":
for data in post_data:
url = self.lfclient_url + "/cli-json/add_cx"
LFCliBase.json_post(url, data)
time.sleep(sleep_time)
class GenCXProfile:
def __init__(self, lfclient_host, lfclient_port, debug=False):
self.lfclient_url = "http://%s:%s/" % (lfclient_host, lfclient_port)
self.debug = debug
# Creates cross-connect for each port specified in the addPorts function
def create(self, endp_type, ports=[], sleep_time=.5):
post_data = []
for port_name in ports:
genl = GenericCx(lfclient_host=self.lfjson_host, lfclient_port=self.lfjson_port)
genl.createGenEndp(port_name + "_gen", 1, 1, port_name, endp_type)