* @param vOptions
* options to override defaults with
* @return
*/
public NetworkConfig apply(Network networkToConnect, VCloudTemplateOptions vOptions) {
NetworkConfig config;
URI userDefinedParentNetwork = vOptions.getParentNetwork();
FenceMode fenceMode = vOptions.getFenceMode() != null ? vOptions.getFenceMode() : defaultFenceMode;
if (userDefinedParentNetwork != null) {
config = NetworkConfig.builder().networkName("jclouds").fenceMode(fenceMode)
.parentNetwork(userDefinedParentNetwork).build();
} else {
config = defaultNetworkConfig.get().toBuilder().fenceMode(fenceMode).build();
}
// if we only have a disconnected network, we are adding a new section
// for the upstream
if (InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOn.networkWithNoIpAllocation
.apply(networkToConnect)) {
// TODO: remove the disconnected entry
} else {
config = config.toBuilder().networkName(networkToConnect.getName()).build();
}
return config;
}