Changing Virtual Server's Access Profile with TMSH w/o Knowing Its Current Value

I am trying to use tmsh to change the Access Profile that is assigned to a given virtual server without knowing its current value. In the f5 Console GUI this is straightforward. When you navigate to Local traffic → Virtual Servers → Virtual Server List and click on a given virtual server, you can then scroll down and change the Access Profile assigned to that virtual server in the dropdown next to “Access Profile”, click update, and you’re done … no need to know what the access profile was set to beforehang, you can just change the dropdown next to the “Access Profile” label. However, when I’m performing the same action using a tmsh command, I seem to have to know the value that assigned Access Profile is currently set to in order to be able to delete the profile out of that virtual server’s properties and add in my new one. Here is the tmsh command I’m using …

modify ltm virtual MY_VIRTUAL_SERVER profiles add {ACCESS_PROFILE_NEW} profiles delete {ACCESS_PROFILE_ORIG}

My point is that I need to know that the access profile is set to

ACCESS_PROFILE_ORIG

before issuing this command to reassign the access profile value. Is there any way to just have tmsh somehow detect what the access profile is set to and then delete it?

You should be able to just use

modify ltm virtual MY_VIRTUAL_SERVER profiles replace-all-with {ACCESS_PROFILE_NEW}

You should be able to just use

modify ltm virtual MY_VIRTUAL_SERVER profiles replace-all-with {ACCESS_PROFILE_NEW}

Probably best to list ltm virtual one-line first so you know all the other profile you have attached as well if you replace-all-with.

Probably best to list ltm virtual one-line first so you know all the other profile you have attached as well if you replace-all-with.

Ok so how would I preserve all those other profiles and just replace the Access Profile specifically?

Ok so how would I preserve all those other profiles and just replace the Access Profile specifically?

Well, you would have to put them all into the curlies with the new profile. Its actually probably much easier to “list ltm virtual VS_name profiles” to gather the list of profiles and just use your original add/delete tmsh since you are querying what the original profile was anyway.

Well, you would have to put them all into the curlies with the new profile. Its actually probably much easier to “list ltm virtual VS_name profiles” to gather the list of profiles and just use your original add/delete tmsh since you are querying what the original profile was anyway.

This isn’t that easy because some of the profiles have dependencies on iRules and other configuration objects. I would suggest that you explicit remove the old one with a known name.

This isn’t that easy because some of the profiles have dependencies on iRules and other configuration objects. I would suggest that you explicit remove the old one with a known name.

I’m still not understanding how you propose to discover which profile is the Access Profile exactly. If I list out the profiles it gives me all profiles, not just Access Profiles. So if I were to get a list of all profiles, then replace them all with the new Access Profile, then add back all the original profiles, would I not still be adding back the original Access Profile in addition to the new one?

I’m still not understanding how you propose to discover which profile is the Access Profile exactly. If I list out the profiles it gives me all profiles, not just Access Profiles. So if I were to get a list of all profiles, then replace them all with the new Access Profile, then add back all the original profiles, would I not still be adding back the original Access Profile in addition to the new one?

@Walter Kacynski So if the question instead were, “How do I get the value a Virtual Server’s Access Profile property is set to?” would this just not be doable?

@Walter Kacynski So if the question instead were, “How do I get the value a Virtual Server’s Access Profile property is set to?” would this just not be doable?

Try using a well structured naming convention. In my environment I name all of my Access profiles with “Access”. Since you can only have one applied then when doing a list you know what is what.

Try using a well structured naming convention. In my environment I name all of my Access profiles with “Access”. Since you can only have one applied then when doing a list you know what is what.

good reason for naming convention that help with this like _access or _ap when you create profiles and other objects.

good reason for naming convention that help with this like _access or _ap when you create profiles and other objects.

Unfortunately, I don’t have control over the Access Profile naming conventions my tmsh scripts my encounter. If there’s no easier way, I may just list out all the Access Profiles and compare them against profiles listed for the VS and delete any that match before doing my add.