Hi,
I'm trying to dev. a workflow which will remove a network portgroup on a standard virtual switch., when I'm tring to use the method : destroyNetwork() on a PG, i'm receiving an error that it is in use. I've double checked that there is no more VM on it.
bellow is my script in a Script task
ListTestPG is an Array of VC:Network
for each (var pg in ListTestPG) {
if (pg.vm.length == 0) { //Check that no vm is on this PG
var task = pg.destroyNetwork();
};
}
Any idea, or does someone already done an action or workflow to remove a PG on stargard vSwitch ??
Thanks for your help.
Regards
Hi Remi,
You should definitely use Onyx to see what happens when the PG is removed. You may be missing an operation.
Christophe.
Thanks Christophe,
Onyx is a very cool tools and very quick to install and run.
Onyx show me that it is unsing the method : removePortGroup instead of destroyNetwork.
So with this script, my PG is well removed.
var netConf = ESX.configManager.networkSystem;
for each (var pg in ListTestPG) {
if (pg.vm.length == 0) { //Check that no vm is on this PG
netConf.removePortGroup(pg.name);
};
}
Thanks
Rémi