Forum Discussion
Adding and Deleting data group records and ZoneRunner records via PowerShell
What I would like to do is script the creation of Data Group Records and ZoneRunner records across our various F5s. What I would need is to list all the records within a specific data group and ZoneRunner to make sure the record does not already exist and then create it or delete it, and in turn do the opposite for deleting records... Is there an easy way to do this with PowerShell?
Thanks! Tony
15 Replies
- ANL_158394
Nimbostratus
So I am trying to just list the resource records get_rrs and get_rrs_detailed and I am getting the following error:
An unhandled exception of type 'System.Net.WebException' occurred in System.dll
Here's the code:
Interfaces interfaces = new Interfaces();
string[] view = { "external" };
ManagementViewInfo[] views = interfaces.ManagementView.get_list();
ManagementViewZone[] viewZones = interfaces.ManagementZone.get_zone_name(view);
ManagementZoneInfo[] zoneInfo = interfaces.ManagementZone.get_zone(viewZones);
ManagementResourceRecord rr = new ManagementResourceRecord();
string[][] resourceRecords = rr.get_rrs(viewZones);
ManagementRRList[] resourceRecordsDetailed = rr.get_rrs_detailed(viewZones);
Thanks!
- Brent_West_7733Historic F5 Account
Unless I am mistakien, your arrays should be constructed like this...
[[view_name][zone_name]],[[[domain_name][cname][ttl]]]And for your gets, which call is generating the error?
- ANL_158394
Nimbostratus
The get_rrs and get_rrs_detailed.
Let me take a crack at constructing these arrays.
Thanks!
- ANL_158394
Nimbostratus
I'm lost. Maybe I just don't know enough about the data structure nut this seems like overkill... I am getting a null reference exception at this line: recordseqseq[0][0] = recordseq[0]; This does appear to fix the issues with add_cname but the code doesn't get to that point so I am not sure if it really is fixed... At least Visual Studio is not underlining the add_cname line anymore because the overloads are to correct data structure it is looking for.
Interfaces interfaces = new Interfaces(); string[] view = { "external" }; ManagementViewInfo[] views = interfaces.ManagementView.get_list(); ManagementViewZone[] viewZones = interfaces.ManagementZone.get_zone_name(view); ManagementZoneInfo[] zoneInfo = interfaces.ManagementZone.get_zone(viewZones); ManagementCNAMERecord record = new ManagementCNAMERecord(); record.cname = "test"; record.domain_name = "st.int"; record.ttl = 3600; ManagementCNAMERecord[] recordseq = new ManagementCNAMERecord[1]; ManagementCNAMERecord[][] recordseqseq = new ManagementCNAMERecord[1][]; recordseq[0] = record; recordseqseq[0][0] = recordseq[0]; interfaces.ManagementResourceRecord.add_cname(viewZones, recordseqseq);Any ideas what the deal is?
- ANL_158394
Nimbostratus
I figured it out! Code below:
Interfaces interfaces = new Interfaces(); string[] view = { "external" }; ManagementViewInfo[] views = interfaces.ManagementView.get_list(); ManagementViewZone[] viewZones = interfaces.ManagementZone.get_zone_name(view); ManagementZoneInfo[] zoneInfo = interfaces.ManagementZone.get_zone(viewZones); ManagementCNAMERecord record = new ManagementCNAMERecord(); record.cname = "test"; record.domain_name = "st.int"; record.ttl = 3600; ManagementCNAMERecord[][] recordseqseq = new ManagementCNAMERecord[][] { new ManagementCNAMERecord[] {record} }; try { interfaces.ManagementResourceRecord.add_cname(viewZones, recordseqseq); } catch (Exception e) { Console.WriteLine(e.ToString()); }Now in all reality, this code will NOT work as it is because you need to have FQDNs for both the cname and the domain_name field. Funny thing also is that the catch does not catch the error... It does catch exceptions on some configurations but if you have a domain name only and a cname only, it will not catch the exception.
I am creating a custom REST API to automate some of the tasks that need to be done so I should be able to take care of error handling via Model Validation.
Thanks for all the help!
Tony
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com