Forum Discussion
tmsh-tcl newbie help - How to user tmsh-tcl to change the APM Policy on virtual servers
Hi All,
So i'm a tmsh-tcl newbie, but from what i can see i think its what i need but i'm also a open book if someone can suggest a better way of doing it.
So i have 30 virtual servers all using the same APM policy, to make a update i am taking a copy of the live policy, renaming it making my changes and then going through all of my virtual servers to apply the changes. So in the thinking of there must be a better way of doing this i have found tmsh-tcl.
So what i'd like to do is to task the code to
Get a list of all virtual servers
Check if the virtual server has APM Policy A assigned to it.
If it does then change this to Policy B
Can anyone show me any examples of how i can piece this together please? Or if there is a better way of doing this?
Thanks
Pete
- AlexBCTCumulonimbus
Mornin' sir!
I've got part of an answer for you - hope it helps to get the full thing to work.
The command
tmsh list ltm virtual one-line | grep apm_policy_old | awk '{print $3}'
should give you a full list of all virtual servers that contain the specific APM policy. If you then put this in a "for" loop or something similar, together with the following two commands, it should do the trick.
modify ltm virtual vs1 profiles del { apm_policy_old }
modify ltm virtual vs1 profiles add { apm_policy_new }
Be careful not to use the "replace" command in the modify option as it replaces ALL profiles, rather than just the APM profile ("replace" is short for "replace-all-with").
Alternatively, if you are unlikely to make big mistakes in your APM policy (but still want to take a policy backup in case you do), you can also make a copy of the policy before you start, and then work on the original, rather than work on the copy. This will save you the hassle of changing them over.
Hope this helps.
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