david - 2015-01-16

I'm in need of some help. I have tried several things, but I can't seem to be able to update/copy the network settings from one HostSystem to another HostSystem.

Say I have one HostSystem with the following settings:
HostSystemA
-Network Configuration Standard Switch: virtual_switch1
-Virtual Machine Port Groups for virtual_switch1:
network_1: this network group contains VLAN ID 11
network_2: this network group contains VLAN ID 20

HostSystemB
-Network Configuration Standard Switch: virtual_switch1
-Virtual Machine Port Groups for virtual_switch1:
network_1: this network group contains VLAN ID 13

I want to take the network configuration settings from HostSystemA and make them the same in HostSystemB. Yes, that is right, I want the network configuration from HostSystemB to be exactly like the network configuration from HostSystemB.

I attempt to do the following as such:

// Get host system A
HostSystem hsA = (HostSystem) new InventoryNavigator(rootFolder).searchManagedEntity("HostSystem", "HostSystemA");

// Get host system B
HostSystem hsB = (HostSystem) new InventoryNavigator(rootFolder).searchManagedEntity("HostSystem", "HostSystemB");

// Get the network configuration of host system A
HostNetworkConfig netConfHostA = hsA.getHostNetworkSystem().getNetworkConfig();

// Attempt to update the network configurations of host system B with host system A.
hsB.getHostNetworkSystem().updateNetworkConfig(netConfHostA, "replace");

When I execute the code above, I get the following error logs:\ java.rmi.RemoteException: VI SDK invoke exception:com.vmware.vim25.InvalidArgument
at com.vmware.vim25.ws.WSClient.invoke(WSClient.java:122)
at com.vmware.vim25.ws.VimStub.updateNetworkConfig(VimStub.java:2813)
at com.vmware.vim25.mo.HostNetworkSystem.updateNetworkConfig(testmain.java:161)
at com.testapp.updateNetFunction(updateNet.java:413)

I looked at the API and I think I followed the instructions specified on how to use updateNetworkConfig(), but I could be wrong. That's why I'm reaching out to anyone who can help me out. Thank you.

Link to updateNetworkConfig(): http://pubs.vmware.com/vi30/sdk/ReferenceGuide/vim.host.NetworkSystem.html#updateNetworkConfig