5 ## Nothing to see here, just some housekeeping
8 baseurlnObject
="https://$Infoblox_Server/wapi/v2.2.2/record:txt?name=$fulldomain&text=$txtvalue"
10 _info
"Using Infoblox API"
11 _debug fulldomain
"$fulldomain"
12 _debug txtvalue
"$txtvalue"
14 ## Check for the credentials
15 if [ -z "$Infoblox_Creds" ] ||
[ -z "$Infoblox_Server" ]; then
18 _err
"You didn't specify the credentials or server yet (Infoblox_Creds and Infoblox_Server)."
19 _err
"Please set them via EXPORT ([username:password] and [ip or hostname]) and try again."
23 ## Save the credentials to the account file
24 _saveaccountconf Infoblox_Creds
"$Infoblox_Creds"
25 _saveaccountconf Infoblox_Server
"$Infoblox_Server"
27 ## Base64 encode the credentials
28 Infoblox_CredsEncoded
=$
(echo -n "$Infoblox_Creds" | _base64
)
30 ## Construct the HTTP Authorization header
31 export _H1
="Accept-Language:en-US"
32 export _H2
="Authorization: Basic $Infoblox_CredsEncoded"
34 ## Add the challenge record to the Infoblox grid member
35 result
=$
(_post
"" "$baseurlnObject" "" "POST")
37 ## Let's see if we get something intelligible back from the unit
38 if echo "$result" |
egrep 'record:txt/.*:.*/default'; then
39 _info
"Successfully created the txt record"
42 _err
"Error encountered during record addition"
51 ## Nothing to see here, just some housekeeping
55 _info
"Using Infoblox API"
56 _debug fulldomain
"$fulldomain"
57 _debug txtvalue
"$txtvalue"
59 ## Base64 encode the credentials
60 Infoblox_CredsEncoded
=$
(echo -n "$Infoblox_Creds" | _base64
)
62 ## Construct the HTTP Authorization header
63 export _H1
="Accept-Language:en-US"
64 export _H2
="Authorization: Basic $Infoblox_CredsEncoded"
66 ## Does the record exist? Let's check.
67 baseurlnObject
="https://$Infoblox_Server/wapi/v2.2.2/record:txt?name=$fulldomain&text=$txtvalue&_return_type=xml-pretty"
68 result
=$
(_get
"$baseurlnObject")
70 ## Let's see if we get something intelligible back from the grid
71 if echo "$result" |
egrep 'record:txt/.*:.*/default'; then
72 ## Extract the object reference
73 objRef
=$
(_egrep_o
'record:txt/.*:.*/default' <<<$result)
74 objRmUrl
="https://$Infoblox_Server/wapi/v2.2.2/$objRef"
75 ## Delete them! All the stale records!
76 rmResult
=$
(_post
"" "$objRmUrl" "" "DELETE")
77 ## Let's see if that worked
78 if echo "$rmResult" |
egrep 'record:txt/.*:.*/default'; then
79 _info
"Successfully deleted $objRef"
82 _err
"Error occurred during txt record delete"
87 _err
"Record to delete didn't match an existing record"
93 #################### Private functions below ##################################