解决了

保护域NCLI的无保护VM


徽章 +1

你好呀,

我有很多PD,在这些PD中,我有很多VM。如果可能的话,我希望能够运行NCLI(或类似)的VM使用通配符。例子:

NCLI PD UNPROTECT名称= protectionDomain vm_name = vm*

任何人都对如何通过通配符毫无保护的机器来一次删除批量量?

图标

最好的答案谢尔盖·伊万诺夫(Sergei Ivanov)2020年6月23日,15:12

Hi Aaron,<\/p>

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

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<\/p>

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 \u201caccounting\u201d in their name, put \u201caccounting\u201d there.<\/p>

I know it is not a beautiful solution and it is rather slow, but it works.<\/p>","className":"post__content__best_answer"}">

查看原件

该主题已关闭以供评论

3个答复

UserLevel 4
徽章 +5

嗨,亚伦,

不幸的是,传统的通配符不会在那里工作。您可以将以下循环用作解决方法:

for i in $(ncli pd List name = | grep“ vm name” | grep“ <部分vm-name>” | awk {'print $ nf'});do ncli pd unprotect name = vm-names = $ i;完毕

只需从上面的命令中用保护域的名称替换,然后用 *在使用通配符之前将其替换为<-of-of-of-of-name>。例如,如果您只想从具有其名称“会计”的PD中删除VM,请在此处放置“会计”。

我知道这不是一个美丽的解决方案,而且相当慢,但是它起作用。

徽章 +1

我认为这正是我实际上在寻找的……我会测试这一点。谢谢你!

徽章 +1

像魅力一样的工作……您是对的,有点慢,但是它可以做我想要的!谢谢!!

Learn more about our cookies.<\/a>","cookiepolicy.button":"Accept cookies","cookiepolicy.button.deny":"Deny all","cookiepolicy.link":"Cookie settings","cookiepolicy.modal.title":"Cookie settings","cookiepolicy.modal.content":"We use 3 different kinds of cookies. You can choose which cookies you want to accept. We need basic cookies to make this site work, therefore these are the minimum you can select. Learn more about our cookies.<\/a>","cookiepolicy.modal.level1":"Basic
Functional","cookiepolicy.modal.level2":"Normal
Functional + analytics","cookiepolicy.modal.level3":"Complete
Functional + analytics + social media + embedded videos"}}}">
Baidu