Added info grabbing for ports

This commit is contained in:
Logan Lipke
2020-05-27 14:17:14 -07:00
parent eec145eec5
commit 79447e967d

View File

@@ -7,7 +7,7 @@ import json
import pprint
from LANforge import LFRequest
from LANforge import LFUtils
import re
def jsonPost(mgrURL, reqURL, data, debug=False):
lf_r = LFRequest.LFRequest(mgrURL + reqURL)
@@ -15,11 +15,6 @@ def jsonPost(mgrURL, reqURL, data, debug=False):
json_response = lf_r.jsonPost(debug)
LFUtils.debug_printer.pprint(json_response)
sys.exit(1)
def getJsonReq(mgrURL, reqURL):
lf_r = LFRequest.LFRequest(mgrURL + reqURL)
json_response = lf_r.getAsJson(debugOn)
return json_response
class Realm:
@@ -28,18 +23,68 @@ class Realm:
self.mgrURL = mgrURL
def cxList(self):
print("Not yet Implemented")
#Returns json response from webpage of all layer 3 cross connects
lf_r = LFRequest.LFRequest(self.mgrURL + "/cx")
response = lf_r.getAsJson(True)
return response
def stationList(self):
#Returns list of all stations with "sta" in their name
list = []
lf_r = LFRequest.LFRequest(self.mgrURL + "/port/list?fields=_links,alias")
response = lf_r.getAsJson(False)
print(response)
response = lf_r.getAsJson(True)
for x in range(len(response['interfaces'])):
for k,v in response['interfaces'][x].items():
if "sta" in v['alias']:
list.append(response['interfaces'][x])
return list
def vapList(self):
print("Not yet Implemented")
#Returns list of all VAPs with "vap" in their name
list = []
lf_r = LFRequest.LFRequest(self.mgrURL + "/port/list?fields=_links,alias")
response = lf_r.getAsJson(True)
for x in range(len(response['interfaces'])):
for k,v in response['interfaces'][x].items():
if "vap" in v['alias']:
list.append(response['interfaces'][x])
return list
def findPortsLike(self, pattern=""):
print("Not yet Implemented")
#Searches for ports that match a given pattern and returns a list of names
list = []
lf_r = LFRequest.LFRequest(self.mgrURL + "/port/list?fields=_links,alias")
response = lf_r.getAsJson(True)
for x in range(len(response['interfaces'])):
for k,v in response['interfaces'][x].items():
if v['alias'] != "NA":
list.append(v['alias'])
matchedList = []
for name in list:
if (pattern.index("+") > 0):
match1 = re.search(r"^[^+]+[+]$", name)
if match1:
print(match1)
matchedList.append(name)
elif (pattern.index("*") > 0):
match2 = re.search(r"^[^\*]+[\*]$", name)
if match2:
print(match2)
matchedList.append(name)
if (pattern.index("[") > 0):
match3 = re.search(r"^[\[]+\[\d+\.\.\d+\]$", name)
if match3:
print(match3)
matchedList.append(name)
return matchedList
class CxProfile:
@@ -60,4 +105,4 @@ class StationProfile:
self.dhcp = dhcp
def build(self, resourceRadio, numStations):
print("Not yet Implemented")
print("Not yet implemented")