@Override public DeployVirtualMachineOptions apply(CloudStackTemplateOptions templateOptions, Map<String, Network> networks, String zoneId, DeployVirtualMachineOptions options) { // security groups not allowed. // at least one network must be given to CloudStack, // but jclouds will try to autodetect an appropriate network if none given. checkArgument(templateOptions.getSecurityGroupIds().isEmpty(), "security groups cannot be specified for locations (zones) that use advanced networking"); if (templateOptions.getNetworkIds().size() > 0) { options.networkIds(templateOptions.getNetworkIds()); } else if (templateOptions.getIpsToNetworks().isEmpty()) { checkArgument(!networks.isEmpty(), "please setup a network for zone: " + zoneId); Network defaultNetworkInZone = Iterables.getFirst(filter(networks.values(), and(defaultNetworkInZone(zoneId), supportsStaticNAT())), null); if(defaultNetworkInZone == null) { defaultNetworkInZone = Iterables.getFirst(filter(networks.values(), isIsolatedNetwork()), null); } if (defaultNetworkInZone == null) { throw new IllegalArgumentException("please choose a specific network in zone " + zoneId + ": " + networks); } else { options.networkId(defaultNetworkInZone.getId()); } } return options; } }
@Override public DeployVirtualMachineOptions apply(CloudStackTemplateOptions templateOptions, Map<String, Network> networks, String zoneId, DeployVirtualMachineOptions options) { // security groups not allowed. // at least one network must be given to CloudStack, // but jclouds will try to autodetect an appropriate network if none given. checkArgument(templateOptions.getSecurityGroupIds().isEmpty(), "security groups cannot be specified for locations (zones) that use advanced networking"); if (templateOptions.getNetworkIds().size() > 0) { options.networkIds(templateOptions.getNetworkIds()); } else if (templateOptions.getIpsToNetworks().isEmpty()) { checkArgument(!networks.isEmpty(), "please setup a network for zone: " + zoneId); Network defaultNetworkInZone = Iterables.getFirst(filter(networks.values(), and(defaultNetworkInZone(zoneId), supportsStaticNAT())), null); if(defaultNetworkInZone == null) { defaultNetworkInZone = Iterables.getFirst(filter(networks.values(), isIsolatedNetwork()), null); } if (defaultNetworkInZone == null) { throw new IllegalArgumentException("please choose a specific network in zone " + zoneId + ": " + networks); } else { options.networkId(defaultNetworkInZone.getId()); } } return options; } }
@Override public DeployVirtualMachineOptions apply(CloudStackTemplateOptions templateOptions, Map<String, Network> networks, String zoneId, DeployVirtualMachineOptions options) { // security groups not allowed. // at least one network must be given to CloudStack, // but jclouds will try to autodetect an appropriate network if none given. checkArgument(templateOptions.getSecurityGroupIds().isEmpty(), "security groups cannot be specified for locations (zones) that use advanced networking"); if (!templateOptions.getNetworks().isEmpty()) { options.networkIds(templateOptions.getNetworks()); } else if (templateOptions.getIpsToNetworks().isEmpty()) { checkArgument(!networks.isEmpty(), "please setup a network for zone: " + zoneId); Network defaultNetworkInZone = Iterables.getFirst(filter(networks.values(), and(defaultNetworkInZone(zoneId), supportsStaticNAT())), null); if (defaultNetworkInZone == null) { defaultNetworkInZone = Iterables.getFirst(filter(networks.values(), isIsolatedNetwork()), null); } if (defaultNetworkInZone == null) { throw new IllegalArgumentException("please choose a specific network in zone " + zoneId + ": " + networks); } else { options.networkId(defaultNetworkInZone.getId()); } } return options; } }