Orchestrator Function: Create a CName Record in Infoblox

by Simon Sparks · 1 June 2013

To use this function add it to the class library file named InfobloxService.ts

GitHub Repository: https://github.com/SimonSparksUK/Orchestrator

Filename: InfobloxService.ts

Description: Orchestrator Function to create a CName record in Infoblox

Function InfobloxCreateCNameRecord

publicInfobloxCreateCNameRecord(objRESTHost:RESTHost,strARecord:string,strCName:string):void{
letstrJson:string='{"canonical":"'+strCName+'","name":"'+strARecord+'"}';

try{
letobjRESTRequest:RESTRequest=objRESTHost.createRequest("POST","/wapi/v1.1/record:cname",strJson);
objRESTRequest.contentType="application/json";
objRESTRequest.setHeader("Accept","application/json");

letobjRESTResponse:RESTResponse=objRESTRequest.execute();

letintStatusCode:number=objRESTResponse.statusCode;

letobjJSON:any=JSON.parse(objRESTResponse.contentAsString);

if (intStatusCode===201){
this.objLogger.info("Successfully Added a CName Record for : '"+strCName+"' pointing to '"+strARecord+"' into InfoBlox.");
}
else{
letstrError:string=objJSON.Error;
letstrCode:string=objJSON.code;
letstrText:string=objJSON.text;

this.objLogger.info("HTTP Error:"+intStatusCode+","+strText);
}
}
catch (objException){
this.objLogger.info("objException ="+objException);
}
}

Discover more from Cloud Build Tools

Subscribe to get the latest posts sent to your email.

You may also like