Skip to content

Commit

Permalink
Debughtmlfix (#595)
Browse files Browse the repository at this point in the history
* Fix HTTP UI and calls for debug actions

* Debug history show logs of actions and process out
  • Loading branch information
juztas authored Jul 17, 2024
1 parent c5df9dd commit 736acd6
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 30 deletions.
12 changes: 8 additions & 4 deletions src/html/debughistory.html
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,17 @@
if (myObject['exitCode']){
model.append('<div class="row"><b>Runtime Exit Code: <\/b>' + myObject['exitCode'] + '<\/div>');
}
if (myObject['err']){
if (myObject['stderr']){
model.append('<div class="row"><b>Debug Err:<\/b><\/div>');
tableAddKeyLine(myObject['err'], ['LineNum', 'Value'], model);
tableAddKeyLine(myObject['stderr'], ['LineNum', 'Value'], model);
}
if (myObject['out']){
if (myObject['stdout']){
model.append('<div class="row"><b>Debug Output:<\/b><\/div>');
tableAddKeyLine(myObject['out'], ['LineNum', 'Value'], model);
tableAddKeyLine(myObject['stdout'], ['LineNum', 'Value'], model);
}
if (myObject['processOut']){
model.append('<div class="row"><b>Process Output:<\/b><\/div>');
tableAddKeyLine(myObject['processOut'], ['LineNum', 'Value'], model);
}
}
$('#v-pills-' + debugID).empty();
Expand Down
50 changes: 26 additions & 24 deletions src/html/newdebug.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@
}
$.post("/"+params['sitename']+"/sitefe/json/frontend/submitdebug/NEW", params, function(result){
newAlert("New debug action submit state:" + JSON.stringify(result), params);
});
}
})}


function doSiteUpdate(ids) {
Expand All @@ -39,22 +38,18 @@
success: function(json){
for (j=0; j < json.length; j++){
addDropDown(json[j]['hostname'], $("#" + ids + "hostname"));
}
}
});
}
}}})}

function doSiteUpdateN(ids) {
strSite = document.getElementById(ids + "sitename").value;
$.get('/MAIN/sitefe/json/frontend/configuration', function(data){
for (i=0; i < data['general']['sites'].length; i++){
sitename = data['general']['sites'][i];
if (strSite === sitename) {
for (const [switchname] of Object.entries(data[sitename]['switch'])) {
addDropDown(switchname, $("#" + ids + "hostname"))
}}}})}


const switchArray = data[sitename]['switch'];
switchArray.forEach((name, index) => {
addDropDown(name, $("#" + ids + "hostname"))
})}}})}

function doDTNUpdate(ids) {
strDTN = document.getElementById(ids + "hostname").value;
Expand Down Expand Up @@ -148,7 +143,7 @@ <h1 class="h2">Request New Debug Action</h1>
<div class="row col-md-12">
<h3 class="h3">Rapid Ping (from Host)</h3>
</div>
<div class="col-md-12" id="alertsrapidping"></div>
<div class="col-md-12" id="alertsrapid-ping"></div>
<div class="col">
Rapid ping - very similar to Flood ping implemented in FreeBSD. where a minimum of 100 packets are sent in one second or as soon as a reply to the request has come. <br/>
It will execute the following command on selected hostname: <b>ping -i &lt;interval&gt; -w &lt;runtime&gt; &lt;ip&gt; -s &lt;packetsize&gt; -I &lt;Interface&gt;</b><br/><br/>
Expand Down Expand Up @@ -177,7 +172,7 @@ <h3 class="h3">Rapid Ping (from Host)</h3>
</select>
</div>
<div class="form-group">
<label for="exampleFormControlSelect1">Hostname</label> <select class="form-control" id="f1_switchname" name="switchname" onchange="doDTNUpdate('f1_');" required="">
<label for="exampleFormControlSelect1">Hostname</label> <select class="form-control" id="f1_hostname" name="hostname" onchange="doDTNUpdate('f1_');" required="">
<option value="">
Choose Hostname
</option>
Expand Down Expand Up @@ -254,7 +249,7 @@ <h3 class="h3">TCPDump (from Host)</h3>
<div class="row col-md-12">
<h3 class="h3">ARP Table</h3>
</div>
<div class="col-md-12" id="alertsarptable"></div>
<div class="col-md-12" id="alertsarp-table"></div>
<div class="col">
The ip neigh command manipulates neighbour objects that establish bindings between protocol addresses and link layer addresses for hosts sharing the same link. Neighbour entries are organized into tables. The IPv4 neighbour table is also known by another name - the ARP table.<br/>
The corresponding commands display neighbour bindings and their properties.
Expand Down Expand Up @@ -288,9 +283,9 @@ <h3 class="h3">ARP Table</h3>
</div>
<div class="row col-md-12 border border-danger">
<div class="row col-md-12">
<h3 class="h3">IPerf Client (from Host)</h3>
<h3 class="h3">IPerf Server (from Host)</h3>
</div>
<div class="col-md-12" id="alertsiperf"></div>
<div class="col-md-12" id="alertsiperf-server"></div>
<div class="col">
<span class="border" style="width:100%">
iPerf3 is a tool for active measurements of the maximum achievable bandwidth on IP networks. It supports tuning of various parameters related to timing, buffers and protocols (TCP, UDP, SCTP with IPv4 and IPv6). For each test it reports the bandwidth, loss, and other parameters.<br/>
Expand Down Expand Up @@ -320,13 +315,13 @@ <h3 class="h3">IPerf Client (from Host)</h3>
</select>
</div>
<div class="form-group">
<label for="exampleFormControlSelect1">IP to ping</label> <input class="form-control" type="text" placeholder="IP to ping" id="f4_ip" name="ip" required="">
<label for="exampleFormControlSelect1">IP to listen</label> <input class="form-control" type="text" placeholder="IP to listen" id="f4_ip" name="ip" required="">
</div>
<div class="form-group">
<label for="exampleFormControlSelect1">Port</label> <input class="form-control" type="text" placeholder="Port" id="f4_port" name="port" required="">
<label for="exampleFormControlSelect1">Port to listen</label> <input class="form-control" type="text" placeholder="Port to listen" id="f4_port" name="port" required="">
</div>
<div class="form-group">
<label for="exampleFormControlSelect1">Interface</label> <select class="form-control" id="f4_interface" name="interface" required="">
<label for="exampleFormControlSelect1">Interface to attach</label> <select class="form-control" id="f4_interface" name="interface" required="">
<option value="">
Choose Interface
</option>
Expand All @@ -353,9 +348,9 @@ <h3 class="h3">IPerf Client (from Host)</h3>
</div>
<div class="row col-md-12 border border-warning">
<div class="row col-md-12">
<h3 class="h3">IPerf Server (from Host)</h3>
<h3 class="h3">IPerf Client (from Host)</h3>
</div>
<div class="col-md-12" id="alertsiperfserver"></div>
<div class="col-md-12" id="alertsiperf-client"></div>
<div class="col">
<span class="border" style="width:100%">
iPerf3 is a tool for active measurements of the maximum achievable bandwidth on IP networks. It supports tuning of various parameters related to timing, buffers and protocols (TCP, UDP, SCTP with IPv4 and IPv6). For each test it reports the bandwidth, loss, and other parameters.<br/>
Expand Down Expand Up @@ -393,6 +388,13 @@ <h3 class="h3">IPerf Server (from Host)</h3>
</option>
</select>
</div>
<div class="form-group">
<label for="exampleFormControlSelect1">Interface to attach</label> <select class="form-control" id="f5_interface" name="interface" required="">
<option value="">
Choose Interface
</option>
</select>
</div>
<div class="form-group">
<label for="exampleFormControlSelect1">Runtime</label> <select class="form-control" id="f5_time" name="time" required="">
<option value="">
Expand Down Expand Up @@ -450,10 +452,10 @@ <h3 class="h3">Traceroute (from Host)</h3>
</select>
</div>
<div class="form-group">
<label for="exampleFormControlSelect1">From Interface:</label> <input class="form-control" type="text" placeholder="IP to ping" id="f6_from_interface" name="from_interface">
<label for="exampleFormControlSelect1">From Interface:</label> <input class="form-control" type="text" placeholder="From interface" id="f6_from_interface" name="from_interface">
</div>
<div class="form-group">
<label for="exampleFormControlSelect1">From IP:</label> <input class="form-control" type="text" placeholder="Port" id="f6_from_ip" name="from_ip">
<label for="exampleFormControlSelect1">From IP:</label> <input class="form-control" type="text" placeholder="From IP" id="f6_from_ip" name="from_ip">
</div>
<div class="form-group">
<label for="exampleFormControlSelect1">To IP:</label> <select class="form-control" id="f6_ip" name="ip" required="">
Expand All @@ -470,7 +472,7 @@ <h3 class="h3">Traceroute (from Host)</h3>
<div class="row col-md-12">
<h3 class="h3">Ping (from Network Device)</h3>
</div>
<div class="col-md-12" id="alertsrapidpingnet"></div>
<div class="col-md-12" id="alertsrapid-pingnet"></div>
<div class="col">
It will execute the following command on selected network device: ping ipaddress -c count -i interval<br/><br/>
Descriptions:<br/>
Expand Down
2 changes: 1 addition & 1 deletion src/python/SiteFE/REST/Modules/DebugCalls.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def __validateRapidpingnet(self, inputDict):
self.__validateKeys(inputDict, ["ip", "count", "timeout"])
if int(inputDict["count"]) > 100:
raise BadRequestError("Count request is more than 100. Maximum allowed is 100")
if int(inputDict["timeout"] > 30):
if int(inputDict["timeout"]) > 30:
raise BadRequestError("Timeout request is more than 30 seconds. Maximum allowed is 30")
if ipVersion(inputDict['ip']) == -1:
raise BadRequestError(f"IP {inputDict['ip']} does not appear to be an IPv4 or IPv6")
Expand Down
2 changes: 1 addition & 1 deletion src/python/SiteRMLibs/BaseDebugAction.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def __init__(self):
self.diragent = contentDB()
self.flightcheck()

def logMessage(self, message, level):
def logMessage(self, message, level="info"):
"""Log Message to logger process and also processout"""
if level == "warning":
self.logger.warning(message)
Expand Down

0 comments on commit 736acd6

Please sign in to comment.