mirror of
https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
synced 2025-10-31 18:58:01 +00:00
* We don't need to import LFUtils in lfcli_base
* local_realm in lf_attenmod is unused. * local_realm in attenuator_profile is unused, because I'm switching to inheritance as part of my work eliminating redundancy. Signed-off-by: Matthew Stidham <stidmatt@gmail.com>
This commit is contained in:
@@ -19,7 +19,7 @@ if sys.version_info[0] != 3:
|
|||||||
|
|
||||||
sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../")))
|
sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../")))
|
||||||
|
|
||||||
LFUtils = importlib.import_module("py-json.LANforge.LFUtils")
|
debug_printer = pprint.PrettyPrinter(indent=2)
|
||||||
LFRequest = importlib.import_module("py-json.LANforge.LFRequest")
|
LFRequest = importlib.import_module("py-json.LANforge.LFRequest")
|
||||||
|
|
||||||
|
|
||||||
@@ -205,7 +205,7 @@ class LFCliBase:
|
|||||||
|
|
||||||
lf_r.addPostData(_data)
|
lf_r.addPostData(_data)
|
||||||
if debug_:
|
if debug_:
|
||||||
LFUtils.debug_printer.pprint(_data)
|
debug_printer.pprint(_data)
|
||||||
json_response = lf_r.json_post(show_error=debug_,
|
json_response = lf_r.json_post(show_error=debug_,
|
||||||
debug=debug_,
|
debug=debug_,
|
||||||
response_json_list_=response_json_list_,
|
response_json_list_=response_json_list_,
|
||||||
@@ -243,7 +243,7 @@ class LFCliBase:
|
|||||||
die_on_error_=self.exit_on_error)
|
die_on_error_=self.exit_on_error)
|
||||||
lf_r.addPostData(_data)
|
lf_r.addPostData(_data)
|
||||||
if debug_:
|
if debug_:
|
||||||
LFUtils.debug_printer.pprint(_data)
|
debug_printer.pprint(_data)
|
||||||
json_response = lf_r.json_put(show_error=self.debug,
|
json_response = lf_r.json_put(show_error=self.debug,
|
||||||
debug=debug_,
|
debug=debug_,
|
||||||
response_json_list_=response_json_list_,
|
response_json_list_=response_json_list_,
|
||||||
|
|||||||
@@ -14,9 +14,8 @@ LFUtils = importlib.import_module("py-json.LANforge.LFUtils")
|
|||||||
|
|
||||||
|
|
||||||
class ATTENUATORProfile(LFCliBase):
|
class ATTENUATORProfile(LFCliBase):
|
||||||
def __init__(self, lfclient_host, lfclient_port, local_realm, debug_=False):
|
def __init__(self, lfclient_host, lfclient_port, debug_=False):
|
||||||
super().__init__(lfclient_host, lfclient_port, debug_)
|
super().__init__(lfclient_host, lfclient_port, debug_)
|
||||||
self.local_realm = local_realm
|
|
||||||
self.lfclient_host = lfclient_host
|
self.lfclient_host = lfclient_host
|
||||||
self.COMMANDS = ["show_attenuators", "set_attenuator"]
|
self.COMMANDS = ["show_attenuators", "set_attenuator"]
|
||||||
self.atten_serno = ""
|
self.atten_serno = ""
|
||||||
@@ -34,6 +33,7 @@ class ATTENUATORProfile(LFCliBase):
|
|||||||
"pulse_count": None,
|
"pulse_count": None,
|
||||||
"pulse_time_ms": None
|
"pulse_time_ms": None
|
||||||
}
|
}
|
||||||
|
self.debug = debug_
|
||||||
|
|
||||||
def set_command_param(self, command_name, param_name, param_value):
|
def set_command_param(self, command_name, param_name, param_value):
|
||||||
# we have to check what the param name is
|
# we have to check what the param name is
|
||||||
@@ -46,7 +46,7 @@ class ATTENUATORProfile(LFCliBase):
|
|||||||
if command_name == "set_attenuator":
|
if command_name == "set_attenuator":
|
||||||
self.atten_data[param_name] = param_value
|
self.atten_data[param_name] = param_value
|
||||||
|
|
||||||
def show(self, debug=False):
|
def show(self):
|
||||||
print("Show Attenuators.........")
|
print("Show Attenuators.........")
|
||||||
response = self.json_get("/attenuators/")
|
response = self.json_get("/attenuators/")
|
||||||
time.sleep(0.01)
|
time.sleep(0.01)
|
||||||
@@ -54,25 +54,26 @@ class ATTENUATORProfile(LFCliBase):
|
|||||||
print(response)
|
print(response)
|
||||||
raise ValueError("Cannot find any endpoints")
|
raise ValueError("Cannot find any endpoints")
|
||||||
else:
|
else:
|
||||||
attenuator_resp = response["attenuator"]
|
attenuator_resp = response["attenuators"]
|
||||||
for key, val in attenuator_resp.items():
|
for attenuator in attenuator_resp:
|
||||||
|
for key, val in attenuator.items():
|
||||||
if key == "entity id":
|
if key == "entity id":
|
||||||
serial_num = val.split(".")
|
serial_num = val.split(".")
|
||||||
print("Serial-num : %s" % serial_num[-1])
|
print("Serial-num : %s" % serial_num[-1])
|
||||||
print("%s : %s" % (key, val))
|
print("%s : %s" % (key, val))
|
||||||
print("\n")
|
print("\n")
|
||||||
|
|
||||||
def create(self, debug=False):
|
def create(self):
|
||||||
if len(self.atten_serno) == 0 or len(self.atten_idx) == 0 or len(self.atten_val) == 0:
|
if type(self.atten_serno) == str or len(self.atten_idx) == 0 or type(self.atten_val) == str:
|
||||||
print("ERROR: Must specify atten_serno, atten_idx, and atten_val when setting attenuator.\n")
|
print("ERROR: Must specify atten_serno, atten_idx, and atten_val when setting attenuator.\n")
|
||||||
print("Setting Attenuator...")
|
print("Setting Attenuator...")
|
||||||
self.set_command_param("set_attenuator", "serno", self.atten_serno)
|
self.set_command_param("set_attenuator", "serno", self.atten_serno)
|
||||||
self.set_command_param("set_attenuator", "atten_idx", self.atten_idx)
|
self.set_command_param("set_attenuator", "atten_idx", self.atten_idx)
|
||||||
self.set_command_param("set_attenuator", "val", self.atten_val)
|
self.set_command_param("set_attenuator", "val", self.atten_val)
|
||||||
set_attenuators = LFRequest.LFRequest(self.lfclient_url + "/cli-json/set_attenuator", debug_=debug)
|
set_attenuators = LFRequest.LFRequest(self.lfclient_url + "/cli-json/set_attenuator", debug_=self.debug)
|
||||||
set_attenuators.addPostData(self.atten_data)
|
set_attenuators.addPostData(self.atten_data)
|
||||||
time.sleep(0.01)
|
time.sleep(0.01)
|
||||||
json_response = set_attenuators.jsonPost(debug)
|
json_response = set_attenuators.jsonPost(self.debug)
|
||||||
time.sleep(10)
|
time.sleep(10)
|
||||||
print("\n")
|
print("\n")
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ lfcli_base = importlib.import_module("py-json.LANforge.lfcli_base")
|
|||||||
LFCliBase = lfcli_base.LFCliBase
|
LFCliBase = lfcli_base.LFCliBase
|
||||||
LFRequest = importlib.import_module("py-json.LANforge.LFRequest")
|
LFRequest = importlib.import_module("py-json.LANforge.LFRequest")
|
||||||
LFUtils = importlib.import_module("py-json.LANforge.LFUtils")
|
LFUtils = importlib.import_module("py-json.LANforge.LFUtils")
|
||||||
|
set_port = importlib.import_module("py-json.LANforge.set_port")
|
||||||
|
|
||||||
|
|
||||||
class QVLANProfile(LFCliBase):
|
class QVLANProfile(LFCliBase):
|
||||||
|
|||||||
@@ -447,6 +447,8 @@ class Realm(LFCliBase):
|
|||||||
|
|
||||||
return not wait_more
|
return not wait_more
|
||||||
|
|
||||||
|
#def wait_until_database_loaded(self):
|
||||||
|
|
||||||
# Returns map of all stations with port+type == WIFI-STATION
|
# Returns map of all stations with port+type == WIFI-STATION
|
||||||
# Key is the EID, value is the map of key/values for the port values.
|
# Key is the EID, value is the map of key/values for the port values.
|
||||||
def station_map(self):
|
def station_map(self):
|
||||||
@@ -893,7 +895,7 @@ class Realm(LFCliBase):
|
|||||||
return cx_prof
|
return cx_prof
|
||||||
def new_attenuator_profile(self, ver=1):
|
def new_attenuator_profile(self, ver=1):
|
||||||
if ver == 1:
|
if ver == 1:
|
||||||
atten_prof = ATTENUATORProfile(self.lfclient_host, self.lfclient_port, local_realm=self, debug_=self.debug)
|
atten_prof = ATTENUATORProfile(self.lfclient_host, self.lfclient_port, debug_=self.debug)
|
||||||
return atten_prof
|
return atten_prof
|
||||||
def new_generic_endp_profile(self, ver=1):
|
def new_generic_endp_profile(self, ver=1):
|
||||||
if ver == 1 :
|
if ver == 1 :
|
||||||
|
|||||||
Reference in New Issue
Block a user