To use this function add it to the class library file named OrchestratorService.ts
GitHub Repository: https://github.com/SimonSparksUK/Orchestrator
Filename: OrchestratorService.ts
Description: Orchestrator Function to login to OpsView – Part 2
Function OpsViewLogon2
private OpsViewLogon2(objRESTOperation: RESTOperation, strOpsViewServerName: string, strUsername: string, strToken: string): void {
let objJson: any = {};
this.objLogger.info("===== Attempting to Login to OpsView '" + strOpsViewServerName + "'");
let objRESTRequest: RESTRequest = objRESTOperation.createRequest([], objJson);
objRESTRequest.contentType = "application/json";
objRESTRequest.setHeader("Accept", "application/json");
objRESTRequest.setHeader("X-Opsview-Username", strUsername);
objRESTRequest.setHeader("X-Opsview-Token", strToken);
let objRESTResponse: RESTResponse = objRESTRequest.execute();
let strContentAsString: string = objRESTResponse.contentAsString;
let objJSON: any = JSON.parse(strContentAsString);
if (objRESTResponse.statusCode == 200) {
this.objLogger.info("===== Successfully Logged into OpsView '" + strOpsViewServerName + "'");
if (objJSON.object != null) {
}
else if ((objJSON.summary != null) && (objJSON.list != null)) {
let objSummary: any = objJSON.summary;
let intRows: number = objSummary.rows;
let intPage: number = objSummary.page;
let intTotalRows: number = objSummary.totalrows;
let intTotalPages: number = objSummary.totalpages;
let intAllRows: number = objSummary.allrows;
let arrList: any[] = objJSON.list;
for (let i: number = 0; i < arrList.length; i++) {
let objListItem: any = arrList[i];
let strRef: string = objListItem.ref;
let strName: string = objListItem.name;
let strID: string = objListItem.id;
let strDescription: string = objListItem.description;
}
}
else {
this.objLogger.info("===== Failed to Login to OpsView '" + strOpsViewServerName + "'");
let strMessage: string = objJSON.message;
let strDetail: string = objJSON.detailmessage;
}
}
else {
this.objLogger.info("===== Failed to Login to OpsView '" + strOpsViewServerName + "'");
}
}Discover more from Cloud Build Tools
Subscribe to get the latest posts sent to your email.
