mirror of
https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
synced 2025-11-20 12:04:52 +00:00
Moved endpoint and cx creation to specific classes
This commit is contained in:
188
py-json/realm.py
188
py-json/realm.py
@@ -154,106 +154,126 @@ class Realm(LFCliBase):
|
|||||||
station_prof = StationProfile(self.lfclient_url, debug=self.debugOn)
|
station_prof = StationProfile(self.lfclient_url, debug=self.debugOn)
|
||||||
return station_prof
|
return station_prof
|
||||||
|
|
||||||
def new_l3_cx_profile(self, cx_type):
|
def new_l3_cx_profile(self):
|
||||||
cx_prof = CXProfile(lfclient_host=self.lfjson_host, lfclient_port=self.lfjson_port, cx_type=cx_type,
|
|
||||||
debug=self.debugOn)
|
|
||||||
return cx_prof
|
return cx_prof
|
||||||
|
|
||||||
def new_l4_cx_profile(self):
|
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
|
return cx_prof
|
||||||
|
|
||||||
def new_generic_cx_profile(self):
|
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
|
return cx_prof
|
||||||
|
|
||||||
|
|
||||||
class CXProfile:
|
class L3CXProfile:
|
||||||
def __init__(self, lfclient_host, lfclient_port, cx_type, debug=False):
|
def __init__(self, lfclient_host, lfclient_port, debug=False):
|
||||||
self.lfclient_url = "http://%s:%s/" % (lfclient_host, lfclient_port)
|
self.lfclient_url = "http://%s:%s/" % (lfclient_host, lfclient_port)
|
||||||
self.cx_type = cx_type
|
|
||||||
self.debug = debug
|
self.debug = debug
|
||||||
|
|
||||||
# Creates cross-connect for each port specified in the addPorts function
|
# Creates cross-connect for each port specified in the addPorts function
|
||||||
def create(self, endp_type, side="a", ports=[], sleep_time=.5):
|
def create(self, endp_type, side="a", ports=[], sleep_time=.5):
|
||||||
post_data = []
|
post_data = []
|
||||||
if endp_type == "lf_udp" or endp_type == "lf_tcp":
|
side = side.upper()
|
||||||
side = side.upper()
|
endp_side_a = {
|
||||||
endp_side_a = {
|
"alias": "",
|
||||||
"alias": "",
|
"shelf": 1,
|
||||||
"shelf": 1,
|
"resource": 1,
|
||||||
"resource": 1,
|
"port": "",
|
||||||
"port": "",
|
"type": endp_type,
|
||||||
"type": endp_type,
|
"min_rate": 0,
|
||||||
"min_rate": 0,
|
"max_rate": 0,
|
||||||
"max_rate": 0,
|
"min_pkt": -1,
|
||||||
"min_pkt": -1,
|
"max_pkt": 0
|
||||||
"max_pkt": 0
|
}
|
||||||
|
endp_side_b = {
|
||||||
|
"alias": "",
|
||||||
|
"shelf": 1,
|
||||||
|
"resource": 1,
|
||||||
|
"port": "",
|
||||||
|
"type": endp_type,
|
||||||
|
"min_rate": 0,
|
||||||
|
"max_rate": 0,
|
||||||
|
"min_pkt": -1,
|
||||||
|
"max_pkt": 0
|
||||||
|
}
|
||||||
|
|
||||||
|
for port_name in ports:
|
||||||
|
if side == "A":
|
||||||
|
endp_side_a["alias"] = port_name + "CX-A"
|
||||||
|
endp_side_a["port"] = port_name
|
||||||
|
endp_side_b["alias"] = port_name + "CX-B"
|
||||||
|
endp_side_b["port"] = "eth1"
|
||||||
|
elif side == "B":
|
||||||
|
endp_side_a["alias"] = port_name + "CX-A"
|
||||||
|
endp_side_a["port"] = "eth1"
|
||||||
|
endp_side_b["alias"] = port_name + "CX-B"
|
||||||
|
endp_side_b["port"] = port_name
|
||||||
|
|
||||||
|
url = self.lfclient_url + "/cli-json/add_endp"
|
||||||
|
LFCliBase.json_post(url, endp_side_a)
|
||||||
|
LFCliBase.json_post(url, endp_side_b)
|
||||||
|
time.sleep(sleep_time)
|
||||||
|
|
||||||
|
data = {
|
||||||
|
"alias": port_name + "CX",
|
||||||
|
"test_mgr": "default_tm",
|
||||||
|
"tx_endp": port_name + "CX-A",
|
||||||
|
"rx_endp": port_name + "CX-B"
|
||||||
}
|
}
|
||||||
endp_side_b = {
|
post_data.append(data)
|
||||||
"alias": "",
|
for data in post_data:
|
||||||
"shelf": 1,
|
url = self.lfclient_url + "/cli-json/add_cx"
|
||||||
"resource": 1,
|
|
||||||
"port": "",
|
|
||||||
"type": endp_type,
|
|
||||||
"min_rate": 0,
|
|
||||||
"max_rate": 0,
|
|
||||||
"min_pkt": -1,
|
|
||||||
"max_pkt": 0
|
|
||||||
}
|
|
||||||
|
|
||||||
for port_name in ports:
|
|
||||||
if side == "A":
|
|
||||||
endp_side_a["alias"] = port_name + "CX-A"
|
|
||||||
endp_side_a["port"] = port_name
|
|
||||||
endp_side_b["alias"] = port_name + "CX-B"
|
|
||||||
endp_side_b["port"] = "eth1"
|
|
||||||
elif side == "B":
|
|
||||||
endp_side_a["alias"] = port_name + "CX-A"
|
|
||||||
endp_side_a["port"] = "eth1"
|
|
||||||
endp_side_b["alias"] = port_name + "CX-B"
|
|
||||||
endp_side_b["port"] = port_name
|
|
||||||
|
|
||||||
url = self.lfclient_url + "/cli-json/add_endp"
|
|
||||||
LFCliBase.json_post(url, endp_side_a)
|
|
||||||
LFCliBase.json_post(url, endp_side_b)
|
|
||||||
time.sleep(sleep_time)
|
|
||||||
|
|
||||||
data = {
|
|
||||||
"alias": port_name + "CX",
|
|
||||||
"test_mgr": "default_tm",
|
|
||||||
"tx_endp": port_name + "CX-A",
|
|
||||||
"rx_endp": port_name + "CX-B"
|
|
||||||
}
|
|
||||||
post_data.append(data)
|
|
||||||
|
|
||||||
elif endp_type == "l4_generic":
|
|
||||||
for port_name in ports:
|
|
||||||
data = {
|
|
||||||
"alias": port_name + "_l4",
|
|
||||||
"shelf": 1,
|
|
||||||
"resource": 1,
|
|
||||||
"port": port_name,
|
|
||||||
"type": endp_type,
|
|
||||||
"timeout": 1000,
|
|
||||||
"url_rate": 600,
|
|
||||||
"url": "http://localhost/"
|
|
||||||
}
|
|
||||||
url = self.lfclient_url + "cli-json/add_l4_endp"
|
|
||||||
LFCliBase.json_post(url, data)
|
LFCliBase.json_post(url, data)
|
||||||
time.sleep(sleep_time)
|
time.sleep(sleep_time)
|
||||||
|
|
||||||
data = {
|
|
||||||
"alias": port_name + "_l4CX",
|
|
||||||
"test_mgr": "default_tm",
|
|
||||||
"tx_endp": port_name + "_l4",
|
|
||||||
"rx_endp": "NA"
|
|
||||||
}
|
|
||||||
post_data.append(data)
|
|
||||||
|
|
||||||
elif endp_type == "gen_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",
|
||||||
|
"shelf": 1,
|
||||||
|
"resource": 1,
|
||||||
|
"port": port_name,
|
||||||
|
"type": endp_type,
|
||||||
|
"timeout": 1000,
|
||||||
|
"url_rate": 600,
|
||||||
|
"url": "http://localhost/"
|
||||||
|
}
|
||||||
|
url = self.lfclient_url + "cli-json/add_l4_endp"
|
||||||
|
LFCliBase.json_post(url, data)
|
||||||
|
time.sleep(sleep_time)
|
||||||
|
|
||||||
|
data = {
|
||||||
|
"alias": port_name + "_l4CX",
|
||||||
|
"test_mgr": "default_tm",
|
||||||
|
"tx_endp": port_name + "_l4",
|
||||||
|
"rx_endp": "NA"
|
||||||
|
}
|
||||||
|
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)
|
||||||
|
|
||||||
|
|
||||||
|
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:
|
for port_name in ports:
|
||||||
genl = GenericCx(lfclient_host=self.lfjson_host, lfclient_port=self.lfjson_port)
|
genl = GenericCx(lfclient_host=self.lfjson_host, lfclient_port=self.lfjson_port)
|
||||||
genl.createGenEndp(port_name + "_gen", 1, 1, port_name, endp_type)
|
genl.createGenEndp(port_name + "_gen", 1, 1, port_name, endp_type)
|
||||||
@@ -272,10 +292,10 @@ class CXProfile:
|
|||||||
}
|
}
|
||||||
post_data.append(data)
|
post_data.append(data)
|
||||||
|
|
||||||
for data in post_data:
|
for data in post_data:
|
||||||
url = self.lfclient_url + "/cli-json/add_cx"
|
url = self.lfclient_url + "/cli-json/add_cx"
|
||||||
LFCliBase.json_post(url, data)
|
LFCliBase.json_post(url, data)
|
||||||
time.sleep(sleep_time)
|
time.sleep(sleep_time)
|
||||||
|
|
||||||
|
|
||||||
# use the station profile to set the combination of features you want on your stations
|
# use the station profile to set the combination of features you want on your stations
|
||||||
|
|||||||
Reference in New Issue
Block a user