SteveBamford
Neophyte
8 days agoTrouble with setHTTPProxy creating discovery script.
For background I am currently working on onboarding Arista AP's that are managed from the Arista CUE platform, to build the discovery script at least I am using Groovy however when testing the Login element I am getting "setHTTPProxy MissingMethodException" the problem I have is that following the documentation presented here, I do not see what the issue is. I have tried single and double quotes for the string of the proxy and even though the port is documented as an Integer I have even tried string to no avail.
The script is below:
/*******************************************************************************
* Arista WIFI Integration with CUE for discovery of the AP's
******************************************************************************/
import com.santaba.agent.groovyapi.http.*
import com.santaba.agent.groovy.utils.GroovyScriptHelper as GSH
import com.logicmonitor.mod.Snippets
import com.santaba.agent.AgentVersion
import java.text.DecimalFormat
import groovy.json.JsonOutput
import groovy.json.JsonSlurper
// To run in debug mode, set to true
Boolean debug = false
// To enable logging, set to true
Boolean log = false
// Set props object based on whether or not we are running inside a netscan or debug console
def props
try {
hostProps.get("system.hostname")
props = hostProps
debug = true // set debug to true so that we can ensure we do not print sensitive properties
}
catch (MissingPropertyException) {
props = netscanProps
}
//String key = props.get("AristaWIFI.api.key")
//String token = props.get("AristaWIFI.api.token")
//String clientId = props.get("AristaWIFI.api.clientId")
//Temp lines for testing
String key = [KEY]
String token = [token]
String clientId = "logicmonitor"
Integer collectorVersion = AgentVersion.AGENT_VERSION.toInteger()
// Bail out early if we don't have the correct minimum collector version to ensure netscan runs properly
if (collectorVersion < 32400) {
def formattedVer = new DecimalFormat("00.000").format(collectorVersion / 1000)
throw new Exception("Upgrade collector running netscan to 32.400 or higher to run full featured enhanced netscan. Currently running version ${formattedVer}.")
}
externalHost= [host dns record];
setHTTPProxy("proxy name",8080);
httpClient = HTTP.open(externalHost,443);
// Log in to arista
loginurl = "https://[Our Instance].wifi.arista.com/wifi/api/session"
payloadstring = '{}"type":"apiKeycredentials","keyId":'+key+',"keyValue":'+token+',"timeout":3600,"clientIdentifier": '+clientId+'}';
def payload = payloadstring;
def loginResponse = httpClient.post(loginurl,payload,["Content-Type":"application/json"]);
if ( !(httpClient.getStatusCode() =~ /200/) )
{
// Error has occured
println "Authentication Failure";
return(1);
}
println loginResponse;
def LMDebugPrint(message) {
if (debug) {
println(message.toString())
}
}
Had a dive through the community and documentation and found nothing.