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
- Brent_West_7733Historic F5 Account
Tony,
The appropriate interfaces are
LocalLB.classI think that it wouldn't be too difficult to do what your asking. Are you writing the scripts yourself?
- ANL_158394
Nimbostratus
Yes, I have also been looking at the libraries in .NET if that would make it any easier... What do you suggest?
- Brent_West_7733Historic F5 Account
The Zonerunner (BIND) code is the more difficult of the two in my opinion. The datagroup manipulation is pretty straight forward.
The only scripts I could find for manipulating BIND on GTM and datagroup manipulation were in pyControl, but this may get you started at least as a pseudocode.
I'll be honest, my development expertise in iControl is in PHP, Perl, and Python.
pyControl Datagroups - ANL_158394
Nimbostratus
Thanks, I will review these and see if I can make this work.
- ANL_158394
Nimbostratus
FYI, I am proceeding with .NET development for this as I do not see a way to do this with PowerShell. Although I am now running into issues with the add_cname method as referenced by this question: https://devcentral.f5.com/questions/net-add_cname-method
Thanks for the help! Tony
- ANL_158394
Nimbostratus
FYI, I am proceeding with .NET development for this as I do not see a way to do this with PowerShell. Although I am now running into issues with the add_cname method as referenced by this question: https://devcentral.f5.com/questions/net-add_cname-method
Thanks for the help! Tony
- Brent_West_7733Historic F5 Account
What error are you given?
- ANL_158394
Nimbostratus
Error1The best overloaded method match for 'iControl.ManagementResourceRecord.add_cname(iControl.ManagementViewZone[], iControl.ManagementCNAMERecord[][])' has some invalid arguments
I get that the ViewZone would be an array, but it looks like it wants a a multi-dimensional array for the records? Reviewing this:
https://devcentral.f5.com/wiki/iControl.Create-CNAME-Resource-Record-in-Zone-Runner.ashx
It appears there should be some kind of sequence method, but only shows to be an alias in .NET. I'm confused...
- Brent_West_7733Historic F5 Account
I find that the correct format of the arrays is the most difficult aspect of any iControl interface. I'll take a look at this a bit later today and see if I can find the correct format.
The pyControl script seems like it's using libraries that make it difficult to determine how the code is working under the hood.If I was to guess, it looks like the view array expects the view name and the zone name, and I'm unsure about how those are keyed.
You might try various 'get_' methods to see how the arrays are constructed.
- ANL_158394
Nimbostratus
I'll keep looking at it. I've been experimenting for a couple days now and can't seem to get it right. I've tried loading it into a List, I've paused the execution to view the data structures and it's all really confusing... Actually, here's the code I posted in the other forum (thought it was already here...):
Interfaces interfaces = new Interfaces();
string[] view = { "external" };
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;
interfaces.ManagementResourceRecord.add_cname(viewZones, record);
Thanks! 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