Quantcast
Channel: CodeSection,代码区,网络安全 - CodeSec
Viewing all articles
Browse latest Browse all 12749

VRO code to apply a NSX security tag

$
0
0

I recently created an environment that had a VRA XaaS to apply a security tag to individual virtual machines. I wanted to share the code I wrote to speed up your adoption. In this case we have a scriptable task to do the work. We have one parameter:


VRO code to apply a NSX security tag
Parameters (it’s the string name of the server)

We have two attributes:


VRO code to apply a NSX security tag
tag ( array of names selected because you have VRO integrated with NSX endpoint) RestAPI endpoint for NSX

Here is the code:


VRO code to apply a NSX security tag
Here is the scriptable task and code

Here is the code for cut and paste usage:

//name = ‘dev-214’;

vms = VcPlugin.getAllVirtualMachines();

for each (vm in vms) {

if (vm.Name == name) {

System.log(“VM name: ” + vm.name + ” MOID: ” + vm.id);

machineMOID = vm.id;

}

}

// Apply the tag

NSXSecurityTagManager.applySecurityTagOnVMs(connection, machineMOID, tag);


Viewing all articles
Browse latest Browse all 12749

Latest Images

Trending Articles





Latest Images