@Override public boolean apply(Network network) { return network.getZoneId().equals(zoneId) && network.isDefault(); } }
@Override public boolean apply(Network network) { return network.getZoneId().equals(zoneId) && network.isDefault(); } }
@Override public boolean apply(Network network) { return network.getZoneId().equals(zoneId) && network.isDefault(); } }
public static PublicIPAddress associateIPAddressInNetwork(Network network, CloudStackApi client, BlockUntilJobCompletesAndReturnResult blockUntilJobCompletesAndReturnResult) { AsyncCreateResponse job = client.getAddressApi().associateIPAddressInZone(network.getZoneId(), networkId(network.getId())); PublicIPAddress ip = blockUntilJobCompletesAndReturnResult.<PublicIPAddress> apply(job); assert ip.getZoneId().equals(network.getZoneId()); return ip; }
public static PublicIPAddress associateIPAddressInNetwork(Network network, CloudStackClient client, BlockUntilJobCompletesAndReturnResult blockUntilJobCompletesAndReturnResult) { AsyncCreateResponse job = client.getAddressClient().associateIPAddressInZone(network.getZoneId(), networkId(network.getId())); PublicIPAddress ip = blockUntilJobCompletesAndReturnResult.<PublicIPAddress> apply(job); assert ip.getZoneId().equals(network.getZoneId()); return ip; }
public static PublicIPAddress associateIPAddressInNetwork(Network network, CloudStackClient client, BlockUntilJobCompletesAndReturnResult blockUntilJobCompletesAndReturnResult) { AsyncCreateResponse job = client.getAddressClient().associateIPAddressInZone(network.getZoneId(), networkId(network.getId())); PublicIPAddress ip = blockUntilJobCompletesAndReturnResult.<PublicIPAddress> apply(job); assert ip.getZoneId().equals(network.getZoneId()); return ip; }
public static VirtualMachine createVirtualMachineInNetworkWithIp( CloudStackClient client, String templateId, Set<Network> networks, Map<String, String> ipToNetwork, Predicate<String> jobComplete, Predicate<VirtualMachine> virtualMachineRunning) { DeployVirtualMachineOptions options = new DeployVirtualMachineOptions(); String zoneId = getFirst(networks, null).getZoneId(); options.networkIds(Iterables.transform(networks, new Function<Network, String>() { @Override public String apply(Network network) { return network.getId(); } })); options.ipsToNetworks(ipToNetwork); return createVirtualMachineWithOptionsInZone(options, zoneId, templateId, client, jobComplete, virtualMachineRunning); }
public static VirtualMachine createVirtualMachineInNetworkWithIp( CloudStackApi client, String templateId, Set<Network> networks, Map<String, String> ipToNetwork, Predicate<String> jobComplete, Predicate<VirtualMachine> virtualMachineRunning) { DeployVirtualMachineOptions options = new DeployVirtualMachineOptions(); String zoneId = getFirst(networks, null).getZoneId(); options.networkIds(Iterables.transform(networks, new Function<Network, String>() { @Override public String apply(Network network) { return network.getId(); } })); options.ipsToNetworks(ipToNetwork); return createVirtualMachineWithOptionsInZone(options, zoneId, templateId, client, jobComplete, virtualMachineRunning); }
public static VirtualMachine createVirtualMachineInNetwork(Network network, String templateId, CloudStackClient client, Predicate<String> jobComplete, Predicate<VirtualMachine> virtualMachineRunning) { DeployVirtualMachineOptions options = new DeployVirtualMachineOptions(); String zoneId = network.getZoneId(); options.networkId(network.getId()); return createVirtualMachineWithOptionsInZone(options, zoneId, templateId, client, jobComplete, virtualMachineRunning); }
public static VirtualMachine createVirtualMachineInNetwork(Network network, String templateId, CloudStackApi client, Predicate<String> jobComplete, Predicate<VirtualMachine> virtualMachineRunning) { DeployVirtualMachineOptions options = new DeployVirtualMachineOptions(); String zoneId = network.getZoneId(); options.networkId(network.getId()); return createVirtualMachineWithOptionsInZone(options, zoneId, templateId, client, jobComplete, virtualMachineRunning); }
public void testAssociateDisassociatePublicIPAddress() throws Exception { if (!networksEnabled) return; AsyncCreateResponse job = client.getAddressClient().associateIPAddressInZone( Iterables.get(client.getNetworkClient().listNetworks(), 0).getZoneId()); checkState(jobComplete.apply(job.getJobId()), "job %s failed to complete", job.getJobId()); ip = client.getAsyncJobClient().<PublicIPAddress> getAsyncJob(job.getJobId()).getResult(); checkIP(ip); }
public void testAssociateDisassociatePublicIPAddress() throws Exception { if (!networksEnabled) return; AsyncCreateResponse job = client.getAddressApi().associateIPAddressInZone( Iterables.get(client.getNetworkApi().listNetworks(), 0).getZoneId()); checkState(jobComplete.apply(job.getJobId()), "job %s failed to complete", job.getJobId()); ip = client.getAsyncJobApi().<PublicIPAddress> getAsyncJob(job.getJobId()).getResult(); checkIP(ip); }
public void testCreateVm() { if (networksDisabled) return; String defaultTemplate = templateBuilderSpec != null ? templateBuilderSpec.getImageId() : null; vm = VirtualMachineApiLiveTest.createVirtualMachineInNetwork(network, defaultTemplateOrPreferredInZone(defaultTemplate, client, network.getZoneId()), client, jobComplete, virtualMachineRunning); if (vm.getPassword() != null && !loginCredentials.getOptionalPassword().isPresent()) loginCredentials = loginCredentials.toBuilder().password(vm.getPassword()).build(); }
public static VirtualMachine createVirtualMachine(CloudStackClient client, String defaultTemplate, Predicate<String> jobComplete, Predicate<VirtualMachine> virtualMachineRunning) { Set<Network> networks = client.getNetworkClient().listNetworks(isDefault(true)); if (networks.size() > 0) { Network network = get(filter(networks, new Predicate<Network>() { @Override public boolean apply(Network network) { return network != null && network.getState().equals("Implemented"); } }), 0); return createVirtualMachineInNetwork(network, defaultTemplateOrPreferredInZone(defaultTemplate, client, network.getZoneId()), client, jobComplete, virtualMachineRunning); } else { String zoneId = find(client.getZoneClient().listZones(), new Predicate<Zone>() { @Override public boolean apply(Zone arg0) { return arg0.isSecurityGroupsEnabled(); } }).getId(); return createVirtualMachineWithSecurityGroupInZone(zoneId, defaultTemplateOrPreferredInZone(defaultTemplate, client, zoneId), get(client.getSecurityGroupClient().listSecurityGroups(), 0).getId(), client, jobComplete, virtualMachineRunning); } }
public static VirtualMachine createVirtualMachine(CloudStackApi client, String defaultTemplate, Predicate<String> jobComplete, Predicate<VirtualMachine> virtualMachineRunning) { Set<Network> networks = client.getNetworkApi().listNetworks(isDefault(true)); if (!networks.isEmpty()) { Network network = get(filter(networks, new Predicate<Network>() { @Override public boolean apply(Network network) { return network != null && network.getState().equals("Implemented"); } }), 0); return createVirtualMachineInNetwork(network, defaultTemplateOrPreferredInZone(defaultTemplate, client, network.getZoneId()), client, jobComplete, virtualMachineRunning); } else { String zoneId = find(client.getZoneApi().listZones(), new Predicate<Zone>() { @Override public boolean apply(Zone arg0) { return arg0.isSecurityGroupsEnabled(); } }).getId(); return createVirtualMachineWithSecurityGroupInZone(zoneId, defaultTemplateOrPreferredInZone(defaultTemplate, client, zoneId), get(client.getSecurityGroupApi().listSecurityGroups(), 0).getId(), client, jobComplete, virtualMachineRunning); } }
@BeforeGroups(groups = "live") public void setupContext() { super.setupContext(); prefix += "rule"; try { network = find(client.getNetworkApi().listNetworks(), Predicates.and(supportsPortForwarding(), new Predicate<Network>() { @Override public boolean apply(Network network) { return network.isDefault() && !network.isSecurityGroupEnabled() && network.getAccount().equals(user.getAccount()); } })); String defaultTemplate = templateBuilderSpec != null ? templateBuilderSpec.getImageId() : null; vm = VirtualMachineApiLiveTest.createVirtualMachineInNetwork(network, defaultTemplateOrPreferredInZone(defaultTemplate, client, network.getZoneId()), client, jobComplete, virtualMachineRunning); if (vm.getPassword() != null && !loginCredentials.getOptionalPassword().isPresent()) loginCredentials = loginCredentials.toBuilder().password(vm.getPassword()).build(); } catch (NoSuchElementException e) { networksDisabled = true; } }
public void testCreateVm() { if (networksDisabled) return; String defaultTemplate = template != null ? template.getImageId() : null; vm = VirtualMachineClientLiveTest.createVirtualMachineInNetwork(network, defaultTemplateOrPreferredInZone(defaultTemplate, client, network.getZoneId()), client, jobComplete, virtualMachineRunning); if (vm.getPassword() != null && loginCredentials.getOptionalPassword() == null) loginCredentials = loginCredentials.toBuilder().password(vm.getPassword()).build(); }
@BeforeGroups(groups = "live") public void setupClient() { super.setupContext(); prefix += "nat"; try { network = find(client.getNetworkApi().listNetworks(), NetworkPredicates.supportsStaticNAT()); String defaultTemplate = templateBuilderSpec != null ? templateBuilderSpec.getImageId() : null; vm = VirtualMachineApiLiveTest.createVirtualMachineInNetwork(network, defaultTemplateOrPreferredInZone(defaultTemplate, client, network.getZoneId()), client, jobComplete, virtualMachineRunning); if (vm.getPassword() != null && !loginCredentials.getOptionalPassword().isPresent()) loginCredentials = loginCredentials.toBuilder().password(vm.getPassword()).build(); } catch (NoSuchElementException e) { networksDisabled = true; } }
@BeforeGroups(groups = "live") public void setupContext() { super.setupContext(); prefix += "rule"; try { network = find(client.getNetworkClient().listNetworks(), Predicates.and(supportsPortForwarding(), new Predicate<Network>() { @Override public boolean apply(Network network) { return network.isDefault() && !network.isSecurityGroupEnabled() && network.getAccount().equals(user.getAccount()); } })); String defaultTemplate = template != null ? template.getImageId() : null; vm = VirtualMachineClientLiveTest.createVirtualMachineInNetwork(network, defaultTemplateOrPreferredInZone(defaultTemplate, client, network.getZoneId()), client, jobComplete, virtualMachineRunning); if (vm.getPassword() != null && loginCredentials.getOptionalPassword() == null) loginCredentials = loginCredentials.toBuilder().password(vm.getPassword()).build(); } catch (NoSuchElementException e) { networksDisabled = true; } }
@BeforeGroups(groups = "live") public void setupClient() { super.setupContext(); prefix += "nat"; try { network = find(client.getNetworkClient().listNetworks(), NetworkPredicates.supportsStaticNAT()); String defaultTemplate = template != null ? template.getImageId() : null; vm = VirtualMachineClientLiveTest.createVirtualMachineInNetwork(network, defaultTemplateOrPreferredInZone(defaultTemplate, client, network.getZoneId()), client, jobComplete, virtualMachineRunning); if (vm.getPassword() != null && loginCredentials.getOptionalPassword() == null) loginCredentials = loginCredentials.toBuilder().password(vm.getPassword()).build(); } catch (NoSuchElementException e) { networksDisabled = true; } }