Unprotect VMs from Protection Domain NCLI | Nutanix Community
Skip to main content
Solved

Unprotect VMs from Protection Domain NCLI


a-a-ron
Forum|alt.badge.img+1

Hi there,

I have many PDs and inside these PDs I have many VMs. I want to be able to run NCLI (or the like) to unprotect VM’s using a wildcard if possible. Example:

ncli pd unprotect name=ProtectionDomain vm_name=VM*

Anyone have an idea on how to do this to unprotect machines by wildcard to remove a mass amount at once?

Best answer by Sergei Ivanov

Hi Aaron,

unfortunately, the traditional wildcard will not work there. You can use the following for-loop as a workaround:

for i in $(ncli pd list name=<PD-NAME> | grep "VM Name" | grep "<PART-OF-VM-NAME>" | awk {'print $NF'}); do ncli pd unprotect name=<PD-NAME> vm-names=$i; done

Just replace the <PD-NAME> from in the command above with the name of the Protection Domain and replace <PART-OF-VM-NAME> with what you would write before the * as if you used the wildcard. For example, if you want to remove only the VMs from the PD that have “accounting” in their name, put “accounting” there.

I know it is not a beautiful solution and it is rather slow, but it works.

View original
Did this topic help you find an answer to your question?
This topic has been closed for comments

3 replies

Sergei Ivanov
Nutanix Employee
Forum|alt.badge.img+5
  • Nutanix Employee
  • 108 replies
  • Answer
  • June 23, 2020

Hi Aaron,

unfortunately, the traditional wildcard will not work there. You can use the following for-loop as a workaround:

for i in $(ncli pd list name=<PD-NAME> | grep "VM Name" | grep "<PART-OF-VM-NAME>" | awk {'print $NF'}); do ncli pd unprotect name=<PD-NAME> vm-names=$i; done

Just replace the <PD-NAME> from in the command above with the name of the Protection Domain and replace <PART-OF-VM-NAME> with what you would write before the * as if you used the wildcard. For example, if you want to remove only the VMs from the PD that have “accounting” in their name, put “accounting” there.

I know it is not a beautiful solution and it is rather slow, but it works.


a-a-ron
Forum|alt.badge.img+1
  • Author
  • Trailblazer
  • 10 replies
  • June 23, 2020

I think that is exactly what I am looking for actually...i will test this out. thank you!


a-a-ron
Forum|alt.badge.img+1
  • Author
  • Trailblazer
  • 10 replies
  • June 23, 2020

works like a charm...you’re right, a bit slow, but it does what i want! thanks!!