diff --git a/go_cloudshellwrapper/cmdClab.go b/go_cloudshellwrapper/cmdClab.go index ce12d5cd2..0c056ada9 100644 --- a/go_cloudshellwrapper/cmdClab.go +++ b/go_cloudshellwrapper/cmdClab.go @@ -533,30 +533,65 @@ func Clab(_ *cobra.Command, _ []string) error { clabPass := confClab.GetString("clab-pass") log.Infof("clabPass: '%s'", clabPass) - // call function to run SSH commnd - cyTopo.RunSSHCommand(clabUser, clabHost[0], clabPass, command) + if deploymentType == "colocated" { - // Create a response JSON object - responseData := map[string]interface{}{ - "result": "Netem command received", - } + log.Infof("executing exec command, since deployment type is colocated") - // Marshal the response JSON object into a JSON string - jsonResponse, err := json.Marshal(responseData) - if err != nil { - http.Error(w, "Failed to marshal response data", http.StatusInternalServerError) - return - } + returnData, err := cyTopo.RunExecCommand(clabUser, clabHost[0], command) + + // Create a response JSON object + responseData := map[string]interface{}{ + "result": "Netem command received", + "return data": returnData, + "error": err, + } - // Set the response Content-Type header - w.Header().Set("Content-Type", "application/json") + // Marshal the response JSON object into a JSON string + jsonResponse, err := json.Marshal(responseData) + if err != nil { + http.Error(w, "Failed to marshal response data", http.StatusInternalServerError) + return + } - // Write the JSON response to the client - _, err = w.Write(jsonResponse) - if err != nil { - // Handle the error (e.g., log it) - http.Error(w, "Failed to write response", http.StatusInternalServerError) - return + // Set the response Content-Type header + w.Header().Set("Content-Type", "application/json") + + // Write the JSON response to the client + _, err = w.Write(jsonResponse) + if err != nil { + // Handle the error (e.g., log it) + http.Error(w, "Failed to write response", http.StatusInternalServerError) + return + } + + } else { + // call function to run SSH commnd + returnData, err := cyTopo.RunSSHCommand(clabUser, clabHost[0], clabPass, command) + + // Create a response JSON object + responseData := map[string]interface{}{ + "result": "Netem command received", + "return data": returnData, + "error": err, + } + + // Marshal the response JSON object into a JSON string + jsonResponse, err := json.Marshal(responseData) + if err != nil { + http.Error(w, "Failed to marshal response data", http.StatusInternalServerError) + return + } + + // Set the response Content-Type header + w.Header().Set("Content-Type", "application/json") + + // Write the JSON response to the client + _, err = w.Write(jsonResponse) + if err != nil { + // Handle the error (e.g., log it) + http.Error(w, "Failed to write response", http.StatusInternalServerError) + return + } } }).Methods("POST") diff --git a/go_topoengine/adaptorClabv2.go b/go_topoengine/adaptorClabv2.go index 4ddd5d8ed..4b71eafca 100644 --- a/go_topoengine/adaptorClabv2.go +++ b/go_topoengine/adaptorClabv2.go @@ -5,6 +5,7 @@ import ( "context" "encoding/json" "fmt" + "os/exec" "strings" "time" @@ -351,6 +352,30 @@ func (cyTopo *CytoTopology) RunSSHCommand(clabUser string, clabHost string, clab return b.Bytes(), nil } +func (cyTopo *CytoTopology) RunExecCommand(clabUser string, clabHost string, command string) ([]byte, error) { + + log.Infof("RunExecCommand Function: '%s'", command) + + // Split the command into individual arguments + args := strings.Fields(command) + cmd := exec.Command(args[0], args[1:]...) + + output, err := cmd.Output() + + if err != nil { + if err, ok := err.(*exec.ExitError); ok { + // The command exited with a non-zero status code + return nil, err + } + return nil, err + } + + log.Infof("Output of RunExecCommand: %s", output) + log.Errorf("Error of RunExecCommand: %s", err) + + return output, err +} + func (cyTopo *CytoTopology) GetDockerNodeStatus(clabNodeName string, clabUser string, clabHost string, clabPassword string) ([]byte, error) { command := "docker ps --all --format json" output, err := cyTopo.RunSSHCommand(clabUser, clabHost, clabPassword, command) diff --git a/html-static/template/clab/button.tmpl b/html-static/template/clab/button.tmpl index a6ae55d0f..90c994892 100644 --- a/html-static/template/clab/button.tmpl +++ b/html-static/template/clab/button.tmpl @@ -303,7 +303,7 @@ {{rawJSComment " // WebSocket for uptime"}} const socketUptime = initializeWebSocket('/uptime', (msgUptime) => { - const string01 = 'Containerlab Topology: ' + "{{.LabName}}"; + const string01 = 'Containerlab Topology: ' + "{{.LabName}}"; const string02 = ' ::: Uptime: ' + msgUptime.data; const ClabSubtitle = document.getElementById("ClabSubtitle"); @@ -362,11 +362,11 @@ } {{rawJSComment " // Fetch and load element data from a JSON file"}} - console.log("Lab Name: {{.LabName}}") - var deploymentType = {{.DeploymentType}} - console.log ("DeploymentType: ", deploymentType) + console.log ("Lab-Name: {{.LabName}}") + console.log ("DeploymentType: {{.DeploymentType}}") + fetch('dataCytoMarshall-{{.LabName}}.json') @@ -473,7 +473,7 @@ console.log(defaultEdgeColor) {{rawJSComment " // Change the color of the clicked edge (for example, to red)"}} - clickedEdge.style('line-color', '#457800'); + clickedEdge.style('line-color', '#0043BF'); {{rawJSComment " // Revert the color of other edges that were not clicked (e.g., back to their default color)"}} cy.edges().forEach(function(edge) { @@ -1343,11 +1343,10 @@ name: 'blue', iconClass: 'fas fa-play', hoverMessage: 'Click to START the link impairment.', - hrefFunction: 'linkImpairmentSsh', - hrefLink: `/usr/bin/containerlab tools netem set -n ${edge.data('extraData').clabSourceLongName} -i ${edge.data("sourceEndpoint")}`, - hrefLink02: `ssh ${edge.data("extraData").clabServerUsername}@${location.hostname} sudo /usr/bin/containerlab tools netem set -n ${edge.data('extraData').clabSourceLongName} -i ${edge.data("sourceEndpoint")}`, + hrefFunction: 'linkImpairmentManagerExec', + hrefLink: `ssh ${edge.data("extraData").clabServerUsername}@${location.hostname} sudo /usr/bin/containerlab tools netem set -n ${edge.data('extraData').clabSourceLongName} -i ${edge.data("sourceEndpoint")}`, + hrefLink02: `/usr/bin/containerlab tools netem set -n ${edge.data('extraData').clabSourceLongName} -i ${edge.data("sourceEndpoint")}`, hrefFunctionArg: 'start-source', - typeOfTopoviewerDeployment: deploymentType, }, { name: 'green', @@ -1362,11 +1361,10 @@ name: 'blue', iconClass: 'fas fa-stop', hoverMessage: 'Click to STOP the link impairment.', - hrefFunction: 'linkImpairmentSsh', - hrefLink: `/usr/bin/containerlab tools netem set -n ${edge.data('extraData').clabSourceLongName} -i ${edge.data("sourceEndpoint")}`, - hrefLink02: `ssh ${edge.data("extraData").clabServerUsername}@${location.hostname} sudo /usr/bin/containerlab tools netem set -n ${edge.data('extraData').clabSourceLongName} -i ${edge.data("sourceEndpoint")}`, - hrefFunctionArg: 'stop-source', - typeOfTopoviewerDeployment: deploymentType, + hrefFunction: 'linkImpairmentManagerExec', + hrefLink: `ssh ${edge.data("extraData").clabServerUsername}@${location.hostname} sudo /usr/bin/containerlab tools netem set -n ${edge.data('extraData').clabSourceLongName} -i ${edge.data("sourceEndpoint")}`, + hrefLink02: `/usr/bin/containerlab tools netem set -n ${edge.data('extraData').clabSourceLongName} -i ${edge.data("sourceEndpoint")}`, + hrefFunctionArg: 'stop-source' }, { name: 'green', @@ -1511,11 +1509,10 @@ name: 'blue', iconClass: 'fas fa-play', hoverMessage: 'Click to START the link impairment.', - hrefFunction: 'linkImpairmentSsh', - hrefLink: `/usr/bin/containerlab tools netem set -n ${edge.data('extraData').clabTargetLongName} -i ${edge.data("targetEndpoint")}`, - hrefLink02: `ssh ${edge.data("extraData").clabServerUsername}@${location.hostname} sudo /usr/bin/containerlab tools netem set -n ${edge.data('extraData').clabTargetLongName} -i ${edge.data("targetEndpoint")}`, + hrefFunction: 'linkImpairmentManagerExec', + hrefLink: `ssh ${edge.data("extraData").clabServerUsername}@${location.hostname} sudo /usr/bin/containerlab tools netem set -n ${edge.data('extraData').clabTargetLongName} -i ${edge.data("targetEndpoint")}`, + hrefLink02: `/usr/bin/containerlab tools netem set -n ${edge.data('extraData').clabTargetLongName} -i ${edge.data("targetEndpoint")}`, hrefFunctionArg: 'start-target', - typeOfTopoviewerDeployment: deploymentType, }, { name: 'green', @@ -1530,12 +1527,10 @@ name: 'blue', iconClass: 'fas fa-stop', hoverMessage: 'Click to STOP the link impairment.', - hrefFunction: 'linkImpairmentSsh', - hrefLink: `/usr/bin/containerlab tools netem set -n ${edge.data('extraData').clabTargetLongName} -i ${edge.data("targetEndpoint")}`, - hrefLink02: `ssh ${edge.data("extraData").clabServerUsername}@${location.hostname} sudo /usr/bin/containerlab tools netem set -n ${edge.data('extraData').clabTargetLongName} -i ${edge.data("targetEndpoint")}`, - hrefFunctionArg: 'stop-target', - typeOfTopoviewerDeployment: deploymentType, - + hrefFunction: 'linkImpairmentManagerExec', + hrefLink: `ssh ${edge.data("extraData").clabServerUsername}@${location.hostname} sudo /usr/bin/containerlab tools netem set -n ${edge.data('extraData').clabTargetLongName} -i ${edge.data("targetEndpoint")}`, + hrefLink02: `/usr/bin/containerlab tools netem set -n ${edge.data('extraData').clabTargetLongName} -i ${edge.data("targetEndpoint")}`, + hrefFunctionArg: 'stop-target' }, { name: 'green', @@ -2381,7 +2376,7 @@ {{rawJSComment " // { idSuffix: 'labelFindRouteSource', columnLabelTextContent: '', columnLabelClass: 'column is-0 p-0', columnInputType: 'field', columnInputContent: '', columnInputPlaceholder: 'name', columnInputAttribute: 'enabled', columnInputIsInvisible: 'yes',"}} {{rawJSComment " // addonsContent: []"}} {{rawJSComment " // } "}} -{{rawJSComment " // { idSuffix: 'labellinkImpairmentSsh', columnLabelTextContent: 'Link Impairment', columnLabelClass: 'column is-4 p-1', columnInputType: 'field', columnInputContent: 'Apply', columntInputAttribute: 'enabled', // columntInputAttribute default is disabled"}} +{{rawJSComment " // { idSuffix: 'labellinkImpairmentManagerExec', columnLabelTextContent: 'Link Impairment', columnLabelClass: 'column is-4 p-1', columnInputType: 'field', columnInputContent: 'Apply', columntInputAttribute: 'enabled', // columntInputAttribute default is disabled"}} {{rawJSComment " // addonsContent: ["}} {{rawJSComment " // {"}} {{rawJSComment " // name: 'blue',"}} @@ -2719,60 +2714,60 @@ appendMessage(`SSH command is lit 🔥 and copied to your clipboard, ready to drop it in your terminal console like a boss! 🚀💻`) }); } - else if (addon.hrefFunction == 'linkImpairmentSsh') { + else if (addon.hrefFunction == 'linkImpairmentManagerExec') { if (addon.hrefFunctionArg == 'start-source') { - button.classList.add('impairment-start-source-ssh') + button.classList.add('impairment-start-ssh') button.addEventListener('click', () => { console.log('impairmentStartSshButton is clicked') - linkImpairmentManagerSsh('start-source', addon.hrefLink, addon.hrefLink02, addon.typeOfTopoviewerDeployment) + linkImpairmentManagerExec('start-source', addon.hrefLink, addon.hrefLink02) }); } else if (addon.hrefFunctionArg == 'stop-source') { - button.classList.add('impairment-stop-source-ssh') + button.classList.add('impairment-stop-ssh') button.addEventListener('click', () => { console.log('impairmentStopSshButton is clicked') - linkImpairmentManagerSsh('stop-source', addon.hrefLink, addon.hrefLink02, addon.typeOfTopoviewerDeployment) + linkImpairmentManagerExec('stop-source', addon.hrefLink, addon.hrefLink02) }); } else if (addon.hrefFunctionArg == 'start-target') { - button.classList.add('impairment-start-target-ssh') + button.classList.add('impairment-stop-ssh') button.addEventListener('click', () => { console.log('impairmentStopSshButton is clicked') - linkImpairmentManagerSsh('start-target', addon.hrefLink, addon.hrefLink02, addon.typeOfTopoviewerDeployment) + linkImpairmentManagerExec('start-target', addon.hrefLink, addon.hrefLink02) }); } else if (addon.hrefFunctionArg == 'stop-target') { - button.classList.add('impairment-stop-target-ssh') + button.classList.add('impairment-stop-ssh') button.addEventListener('click', () => { console.log('impairmentStopSshButton is clicked') - linkImpairmentManagerSsh('stop-target', addon.hrefLink, addon.hrefLink02, addon.typeOfTopoviewerDeployment) + linkImpairmentManagerExec('stop-target', addon.hrefLink, addon.hrefLink02) }); } } else if (addon.hrefFunction == 'linkImpairmentCopy') { if (addon.hrefFunctionArg == 'start-source') { - button.classList.add('impairment-start-source-copy') + button.classList.add('impairment-start-copy') button.addEventListener('click', () => { console.log('impairmentStartCopyButton is clicked') linkImpairmentManagerCopy('start-source', addon.hrefLink) }); } else if (addon.hrefFunctionArg == 'stop-source') { - button.classList.add('impairment-stop-source-copy') + button.classList.add('impairment-stop-copy') button.addEventListener('click', () => { console.log('impairmentStopCopyButton is clicked') linkImpairmentManagerCopy('stop-source', addon.hrefLink) }); } else if (addon.hrefFunctionArg == 'start-target') { - button.classList.add('impairment-stop-target-copy') + button.classList.add('impairment-stop-copy') button.addEventListener('click', () => { console.log('impairmentStopCopyButton is clicked') linkImpairmentManagerCopy('start-target', addon.hrefLink) }); } else if (addon.hrefFunctionArg == 'stop-target') { - button.classList.add('impairment-stop-target-copy') + button.classList.add('impairment-stop-copy') button.addEventListener('click', () => { console.log('impairmentStopCopyButton is clicked') linkImpairmentManagerCopy('stop-target', addon.hrefLink) @@ -3326,11 +3321,19 @@ } - function linkImpairmentManagerSsh(toggle, baseCommandColocatedDeployment, baseCommandContainerDeployment, type) { + function linkImpairmentManagerExec(toggle, baseCommandSsh, baseCommandExec) { + + console.log("linkImpairmentManagerExec-Function-Called") + + var deploymentType = {{.DeploymentType}} - console.log("linkImpairmentManagerSsh-Function-Called") -{{rawJSComment " // fullCommand = baseCommand"}} + if (deploymentType == 'colocated') { + baseCommand = baseCommandExec + } else { + baseCommand = baseCommandSsh + } + if (toggle == 'start-source') { delayValue = document.getElementById('panelBlock-tabContainer-LinkProperties-divPanelBlock-columnContainerlabelSourceImpairmentDelay-panelContentlabelSourceImpairmentDelay-columnsPanelContentlabelSourceImpairmentDelay-labelColumnlabelSourceImpairmentDelay-inputColumnlabelSourceImpairmentDelay-labellabelSourceImpairmentDelay').value @@ -3343,28 +3346,12 @@ console.log(`rateValue: ${rateValue}`) console.log(`lossValue: ${lossValue}`) - console.log(`type of deployment: ${type}`) - - if (type == 'colocated') { - fullCommand = baseCommandColocatedDeployment + ` --delay ${delayValue}ms --jitter ${jitterValue}ms --rate ${rateValue} --loss ${lossValue}` - alert_msg = `SSH command to start link impairment is lit 🔥, ready to drop it in your terminal console like a boss! 🚀💻` - }else{ - fullCommand = baseCommandContainerDeployment + ` --delay ${delayValue}ms --jitter ${jitterValue}ms --rate ${rateValue} --loss ${lossValue}` - alert_msg = `SSH command to start link impairment is lit 🔥, ready to drop it in your terminal console like a boss! 🚀💻` - } - - + fullCommand = baseCommand + ` --delay ${delayValue}ms --jitter ${jitterValue}ms --rate ${rateValue} --loss ${lossValue}` + alert_msg = `SSH command to start link impairment is lit 🔥 and copied to your clipboard, ready to drop it in your terminal console like a boss! 🚀💻` } else if (toggle == 'stop-source') { -{{rawJSComment " // fullCommand = baseCommand"}} - alert_msg = `SSH command to stop link impairment is lit 🔥, ready to drop it in your terminal console like a boss! 🚀💻` - if (type == 'colocated') { - fullCommand = baseCommandColocatedDeployment - alert_msg = `SSH command to start link impairment is lit 🔥, ready to drop it in your terminal console like a boss! 🚀💻` - }else{ - fullCommand = baseCommandContainerDeployment - alert_msg = `SSH command to start link impairment is lit 🔥, ready to drop it in your terminal console like a boss! 🚀💻` - } + fullCommand = baseCommand + alert_msg = `SSH command to stop link impairment is lit 🔥 and copied to your clipboard, ready to drop it in your terminal console like a boss! 🚀💻` } @@ -3379,30 +3366,16 @@ console.log(`rateValue: ${rateValue}`) console.log(`lossValue: ${lossValue}`) - console.log(`type of deployment: ${type}`) - - if (type == 'colocated') { - fullCommand = baseCommandColocatedDeployment + ` --delay ${delayValue}ms --jitter ${jitterValue}ms --rate ${rateValue} --loss ${lossValue}` - alert_msg = `SSH command to start link impairment is lit 🔥 and copied to your clipboard, ready to drop it in your terminal console like a boss! 🚀💻` - }else{ - fullCommand = baseCommandContainerDeployment + ` --delay ${delayValue}ms --jitter ${jitterValue}ms --rate ${rateValue} --loss ${lossValue}` - alert_msg = `SSH command to start link impairment is lit 🔥 and copied to your clipboard, ready to drop it in your terminal console like a boss! 🚀💻` - } - + fullCommand = baseCommand + ` --delay ${delayValue}ms --jitter ${jitterValue}ms --rate ${rateValue} --loss ${lossValue}` + alert_msg = `SSH command to start link impairment is lit 🔥 and copied to your clipboard, ready to drop it in your terminal console like a boss! 🚀💻` } else if (toggle == 'stop-target') { -{{rawJSComment " // fullCommand = baseCommand"}} - alert_msg = `SSH command to stop link impairment is lit 🔥, ready to drop it in your terminal console like a boss! 🚀💻` - if (type == 'colocated') { - fullCommand = baseCommandColocatedDeployment - alert_msg = `SSH command to start link impairment is lit 🔥, ready to drop it in your terminal console like a boss! 🚀💻` - }else{ - fullCommand = baseCommandContainerDeployment - alert_msg = `SSH command to start link impairment is lit 🔥, ready to drop it in your terminal console like a boss! 🚀💻` - } + fullCommand = baseCommand + alert_msg = `SSH command to stop link impairment is lit 🔥 and copied to your clipboard, ready to drop it in your terminal console like a boss! 🚀💻` } + console.log(`baseCommand: ${baseCommand}`) console.log(`fullCommand: ${fullCommand}`) callGoFunction(fullCommand, 'padding') diff --git a/html-static/template/clab/index.tmpl b/html-static/template/clab/index.tmpl index 2f9e2388f..90c994892 100644 --- a/html-static/template/clab/index.tmpl +++ b/html-static/template/clab/index.tmpl @@ -362,6 +362,12 @@ } {{rawJSComment " // Fetch and load element data from a JSON file"}} + + + console.log ("Lab-Name: {{.LabName}}") + console.log ("DeploymentType: {{.DeploymentType}}") + + fetch('dataCytoMarshall-{{.LabName}}.json') .then(response => response.json()) @@ -467,12 +473,12 @@ console.log(defaultEdgeColor) {{rawJSComment " // Change the color of the clicked edge (for example, to red)"}} - clickedEdge.style('line-color', '#457800'); + clickedEdge.style('line-color', '#0043BF'); {{rawJSComment " // Revert the color of other edges that were not clicked (e.g., back to their default color)"}} cy.edges().forEach(function(edge) { if (edge !== clickedEdge) { - edge.style('line-color', defaultEdgeColor); // Replace 'defaultEdgeColor' with your default color + edge.style('line-color', defaultEdgeColor); } }); @@ -1337,8 +1343,9 @@ name: 'blue', iconClass: 'fas fa-play', hoverMessage: 'Click to START the link impairment.', - hrefFunction: 'linkImpairmentSsh', - hrefLink: `/usr/bin/containerlab tools netem set -n ${edge.data('extraData').clabSourceLongName} -i ${edge.data("sourceEndpoint")}`, + hrefFunction: 'linkImpairmentManagerExec', + hrefLink: `ssh ${edge.data("extraData").clabServerUsername}@${location.hostname} sudo /usr/bin/containerlab tools netem set -n ${edge.data('extraData').clabSourceLongName} -i ${edge.data("sourceEndpoint")}`, + hrefLink02: `/usr/bin/containerlab tools netem set -n ${edge.data('extraData').clabSourceLongName} -i ${edge.data("sourceEndpoint")}`, hrefFunctionArg: 'start-source', }, { @@ -1354,8 +1361,9 @@ name: 'blue', iconClass: 'fas fa-stop', hoverMessage: 'Click to STOP the link impairment.', - hrefFunction: 'linkImpairmentSsh', + hrefFunction: 'linkImpairmentManagerExec', hrefLink: `ssh ${edge.data("extraData").clabServerUsername}@${location.hostname} sudo /usr/bin/containerlab tools netem set -n ${edge.data('extraData').clabSourceLongName} -i ${edge.data("sourceEndpoint")}`, + hrefLink02: `/usr/bin/containerlab tools netem set -n ${edge.data('extraData').clabSourceLongName} -i ${edge.data("sourceEndpoint")}`, hrefFunctionArg: 'stop-source' }, { @@ -1501,8 +1509,9 @@ name: 'blue', iconClass: 'fas fa-play', hoverMessage: 'Click to START the link impairment.', - hrefFunction: 'linkImpairmentSsh', + hrefFunction: 'linkImpairmentManagerExec', hrefLink: `ssh ${edge.data("extraData").clabServerUsername}@${location.hostname} sudo /usr/bin/containerlab tools netem set -n ${edge.data('extraData').clabTargetLongName} -i ${edge.data("targetEndpoint")}`, + hrefLink02: `/usr/bin/containerlab tools netem set -n ${edge.data('extraData').clabTargetLongName} -i ${edge.data("targetEndpoint")}`, hrefFunctionArg: 'start-target', }, { @@ -1518,8 +1527,9 @@ name: 'blue', iconClass: 'fas fa-stop', hoverMessage: 'Click to STOP the link impairment.', - hrefFunction: 'linkImpairmentSsh', + hrefFunction: 'linkImpairmentManagerExec', hrefLink: `ssh ${edge.data("extraData").clabServerUsername}@${location.hostname} sudo /usr/bin/containerlab tools netem set -n ${edge.data('extraData').clabTargetLongName} -i ${edge.data("targetEndpoint")}`, + hrefLink02: `/usr/bin/containerlab tools netem set -n ${edge.data('extraData').clabTargetLongName} -i ${edge.data("targetEndpoint")}`, hrefFunctionArg: 'stop-target' }, { @@ -2366,7 +2376,7 @@ {{rawJSComment " // { idSuffix: 'labelFindRouteSource', columnLabelTextContent: '', columnLabelClass: 'column is-0 p-0', columnInputType: 'field', columnInputContent: '', columnInputPlaceholder: 'name', columnInputAttribute: 'enabled', columnInputIsInvisible: 'yes',"}} {{rawJSComment " // addonsContent: []"}} {{rawJSComment " // } "}} -{{rawJSComment " // { idSuffix: 'labellinkImpairmentSsh', columnLabelTextContent: 'Link Impairment', columnLabelClass: 'column is-4 p-1', columnInputType: 'field', columnInputContent: 'Apply', columntInputAttribute: 'enabled', // columntInputAttribute default is disabled"}} +{{rawJSComment " // { idSuffix: 'labellinkImpairmentManagerExec', columnLabelTextContent: 'Link Impairment', columnLabelClass: 'column is-4 p-1', columnInputType: 'field', columnInputContent: 'Apply', columntInputAttribute: 'enabled', // columntInputAttribute default is disabled"}} {{rawJSComment " // addonsContent: ["}} {{rawJSComment " // {"}} {{rawJSComment " // name: 'blue',"}} @@ -2704,33 +2714,33 @@ appendMessage(`SSH command is lit 🔥 and copied to your clipboard, ready to drop it in your terminal console like a boss! 🚀💻`) }); } - else if (addon.hrefFunction == 'linkImpairmentSsh') { + else if (addon.hrefFunction == 'linkImpairmentManagerExec') { if (addon.hrefFunctionArg == 'start-source') { - button.classList.add('impairment-start-copy') + button.classList.add('impairment-start-ssh') button.addEventListener('click', () => { console.log('impairmentStartSshButton is clicked') - linkImpairmentManagerSsh('start-source', addon.hrefLink) + linkImpairmentManagerExec('start-source', addon.hrefLink, addon.hrefLink02) }); } else if (addon.hrefFunctionArg == 'stop-source') { - button.classList.add('impairment-stop-copy') + button.classList.add('impairment-stop-ssh') button.addEventListener('click', () => { console.log('impairmentStopSshButton is clicked') - linkImpairmentManagerSsh('stop-source', addon.hrefLink) + linkImpairmentManagerExec('stop-source', addon.hrefLink, addon.hrefLink02) }); } else if (addon.hrefFunctionArg == 'start-target') { - button.classList.add('impairment-stop-copy') + button.classList.add('impairment-stop-ssh') button.addEventListener('click', () => { console.log('impairmentStopSshButton is clicked') - linkImpairmentManagerSsh('start-target', addon.hrefLink) + linkImpairmentManagerExec('start-target', addon.hrefLink, addon.hrefLink02) }); } else if (addon.hrefFunctionArg == 'stop-target') { - button.classList.add('impairment-stop-copy') + button.classList.add('impairment-stop-ssh') button.addEventListener('click', () => { console.log('impairmentStopSshButton is clicked') - linkImpairmentManagerSsh('stop-target', addon.hrefLink) + linkImpairmentManagerExec('stop-target', addon.hrefLink, addon.hrefLink02) }); } } @@ -3311,11 +3321,19 @@ } - function linkImpairmentManagerSsh(toggle, baseCommand) { + function linkImpairmentManagerExec(toggle, baseCommandSsh, baseCommandExec) { - console.log("linkImpairmentManagerSsh-Function-Called") + console.log("linkImpairmentManagerExec-Function-Called") + + var deploymentType = {{.DeploymentType}} + + + if (deploymentType == 'colocated') { + baseCommand = baseCommandExec + } else { + baseCommand = baseCommandSsh + } - fullCommand = baseCommand if (toggle == 'start-source') { delayValue = document.getElementById('panelBlock-tabContainer-LinkProperties-divPanelBlock-columnContainerlabelSourceImpairmentDelay-panelContentlabelSourceImpairmentDelay-columnsPanelContentlabelSourceImpairmentDelay-labelColumnlabelSourceImpairmentDelay-inputColumnlabelSourceImpairmentDelay-labellabelSourceImpairmentDelay').value @@ -3335,6 +3353,8 @@ fullCommand = baseCommand alert_msg = `SSH command to stop link impairment is lit 🔥 and copied to your clipboard, ready to drop it in your terminal console like a boss! 🚀💻` } + + else if (toggle == 'start-target') { delayValue = document.getElementById('panelBlock-tabContainer-LinkProperties-divPanelBlock-columnContainerlabelTargetImpairmentDelay-panelContentlabelTargetImpairmentDelay-columnsPanelContentlabelTargetImpairmentDelay-labelColumnlabelTargetImpairmentDelay-inputColumnlabelTargetImpairmentDelay-labellabelTargetImpairmentDelay').value jitterValue = document.getElementById('panelBlock-tabContainer-LinkProperties-divPanelBlock-columnContainerlabelTargetImpairmentJitter-panelContentlabelTargetImpairmentJitter-columnsPanelContentlabelTargetImpairmentJitter-labelColumnlabelTargetImpairmentJitter-inputColumnlabelTargetImpairmentJitter-labellabelTargetImpairmentJitter').value