public Set<IPForwardingRule> apply(PublicIPAddress ip, String protocol, Iterable<Integer> ports) { checkState(ip.getVirtualMachineId() != null, "ip %s should be static NATed to a virtual machine before applying rules", ip); if (Iterables.size(ports) == 0) return ImmutableSet.<IPForwardingRule> of(); Builder<AsyncCreateResponse> responses = ImmutableSet.builder(); for (int port : ports) { AsyncCreateResponse response = client.getNATClient().createIPForwardingRule(ip.getId(), protocol, port); logger.debug(">> creating IP forwarding rule IPAddress(%s) for protocol(%s), port(%s); response(%s)", ip.getId(), protocol, port, response); responses.add(response); } Builder<IPForwardingRule> rules = ImmutableSet.builder(); for (AsyncCreateResponse response : responses.build()) { IPForwardingRule rule = blockUntilJobCompletesAndReturnResult.<IPForwardingRule> apply(response); rules.add(rule); getIPForwardingRulesByVirtualMachine.asMap().put(ip.getVirtualMachineId(), ImmutableSet.of(rule)); } return rules.build(); } }
public Set<IPForwardingRule> apply(PublicIPAddress ip, String protocol, Iterable<Integer> ports) { checkState(ip.getVirtualMachineId() != null, "ip %s should be static NATed to a virtual machine before applying rules", ip); if (Iterables.size(ports) == 0) return ImmutableSet.<IPForwardingRule> of(); Builder<AsyncCreateResponse> responses = ImmutableSet.builder(); for (int port : ports) { AsyncCreateResponse response = client.getNATClient().createIPForwardingRule(ip.getId(), protocol, port); logger.debug(">> creating IP forwarding rule IPAddress(%s) for protocol(%s), port(%s); response(%s)", ip.getId(), protocol, port, response); responses.add(response); } Builder<IPForwardingRule> rules = ImmutableSet.builder(); for (AsyncCreateResponse response : responses.build()) { IPForwardingRule rule = blockUntilJobCompletesAndReturnResult.<IPForwardingRule> apply(response); rules.add(rule); getIPForwardingRulesByVirtualMachine.asMap().put(ip.getVirtualMachineId(), ImmutableSet.of(rule)); } return rules.build(); } }
@Override public boolean apply(PublicIPAddress arg0) { return !checkNotNull(arg0, "ipaddress").isSourceNAT() && !arg0.isStaticNAT() && arg0.getVirtualMachineId() == null && arg0.getState() == PublicIPAddress.State.ALLOCATED; }
public Set<IPForwardingRule> apply(PublicIPAddress ip, String protocol, Iterable<Integer> ports) { checkState(ip.getVirtualMachineId() != null, "ip %s should be static NATed to a virtual machine before applying rules", ip); if (Iterables.isEmpty(ports)) return ImmutableSet.<IPForwardingRule> of(); Builder<AsyncCreateResponse> responses = ImmutableSet.builder(); for (int port : ports) { AsyncCreateResponse response = client.getNATApi().createIPForwardingRule(ip.getId(), protocol, port); logger.debug(">> creating IP forwarding rule IPAddress(%s) for protocol(%s), port(%s); response(%s)", ip.getId(), protocol, port, response); responses.add(response); } Builder<IPForwardingRule> rules = ImmutableSet.builder(); for (AsyncCreateResponse response : responses.build()) { IPForwardingRule rule = blockUntilJobCompletesAndReturnResult.<IPForwardingRule> apply(response); rules.add(rule); getIPForwardingRulesByVirtualMachine.asMap().put(ip.getVirtualMachineId(), ImmutableSet.of(rule)); } return rules.build(); } }
@Override public boolean apply(PublicIPAddress arg0) { return !checkNotNull(arg0, "ipaddress").isSourceNAT() && !arg0.isStaticNAT() && arg0.getVirtualMachineId() == null && arg0.getState() == PublicIPAddress.State.ALLOCATED; }
@Override public boolean apply(PublicIPAddress arg0) { return !checkNotNull(arg0, "ipaddress").isSourceNAT() && !arg0.isStaticNAT() && arg0.getVirtualMachineId() == null && arg0.getState() == PublicIPAddress.State.ALLOCATED; }
public Set<FirewallRule> apply(PublicIPAddress ip, String protocol, Iterable<Integer> ports) { checkState(ip.getVirtualMachineId() != null, "ip %s should be static NATed to a virtual machine before applying rules", ip); if (Iterables.size(ports) == 0) return ImmutableSet.<FirewallRule> of(); Builder<AsyncCreateResponse> responses = ImmutableSet.builder(); for (int port : ports) { AsyncCreateResponse response = client.getFirewallClient().createFirewallRuleForIpAndProtocol(ip.getId(), FirewallRule.Protocol.fromValue(protocol), CreateFirewallRuleOptions.Builder.startPort(port).endPort(port)); logger.debug(">> creating firewall rule IPAddress(%s) for protocol(%s), port(%s); response(%s)", ip.getId(), protocol, port, response); responses.add(response); } Builder<FirewallRule> rules = ImmutableSet.builder(); for (AsyncCreateResponse response : responses.build()) { FirewallRule rule = blockUntilJobCompletesAndReturnResult.<FirewallRule> apply(response); rules.add(rule); getFirewallRulesByVirtualMachine.asMap().put(ip.getVirtualMachineId(), ImmutableSet.of(rule)); } return rules.build(); } }
public Set<FirewallRule> apply(PublicIPAddress ip, String protocol, Iterable<Integer> ports) { checkState(ip.getVirtualMachineId() != null, "ip %s should be static NATed to a virtual machine before applying rules", ip); if (Iterables.isEmpty(ports)) return ImmutableSet.<FirewallRule> of(); Builder<AsyncCreateResponse> responses = ImmutableSet.builder(); for (int port : ports) { AsyncCreateResponse response = client.getFirewallApi().createFirewallRuleForIpAndProtocol(ip.getId(), FirewallRule.Protocol.fromValue(protocol), CreateFirewallRuleOptions.Builder.startPort(port).endPort(port)); logger.debug(">> creating firewall rule IPAddress(%s) for protocol(%s), port(%s); response(%s)", ip.getId(), protocol, port, response); responses.add(response); } Builder<FirewallRule> rules = ImmutableSet.builder(); for (AsyncCreateResponse response : responses.build()) { FirewallRule rule = blockUntilJobCompletesAndReturnResult.<FirewallRule> apply(response); rules.add(rule); getFirewallRulesByVirtualMachine.asMap().put(ip.getVirtualMachineId(), ImmutableSet.of(rule)); } return rules.build(); } }
public Set<FirewallRule> apply(PublicIPAddress ip, String protocol, Iterable<Integer> ports) { checkState(ip.getVirtualMachineId() != null, "ip %s should be static NATed to a virtual machine before applying rules", ip); if (Iterables.size(ports) == 0) return ImmutableSet.<FirewallRule> of(); Builder<AsyncCreateResponse> responses = ImmutableSet.builder(); for (int port : ports) { AsyncCreateResponse response = client.getFirewallClient().createFirewallRuleForIpAndProtocol(ip.getId(), FirewallRule.Protocol.fromValue(protocol), CreateFirewallRuleOptions.Builder.startPort(port).endPort(port)); logger.debug(">> creating firewall rule IPAddress(%s) for protocol(%s), port(%s); response(%s)", ip.getId(), protocol, port, response); responses.add(response); } Builder<FirewallRule> rules = ImmutableSet.builder(); for (AsyncCreateResponse response : responses.build()) { FirewallRule rule = blockUntilJobCompletesAndReturnResult.<FirewallRule> apply(response); rules.add(rule); getFirewallRulesByVirtualMachine.asMap().put(ip.getVirtualMachineId(), ImmutableSet.of(rule)); } return rules.build(); } }
public PublicIPAddress apply(VirtualMachine vm) { PublicIPAddress ip; for (ip = reuseOrAssociate.apply(network); !ip.isStaticNAT() || !Objects.equal(ip.getVirtualMachineId(), vm.getId()); ip = reuseOrAssociate .apply(network)) { // check to see if someone already grabbed this ip if (ip.getVirtualMachineId() != null && !ip.getVirtualMachineId().equals(vm.getId())) continue; try { logger.debug(">> static NATing IPAddress(%s) to virtualMachine(%s)", ip.getId(), vm.getId()); client.getNATApi().enableStaticNATForVirtualMachine(vm.getId(), ip.getId()); ip = client.getAddressApi().getPublicIPAddress(ip.getId()); if (ip.isStaticNAT() && ip.getVirtualMachineId().equals(vm.getId())) break; } catch (IllegalStateException e) { // very likely an ip conflict, so retry; } return ip; } return ip; } }
public PublicIPAddress apply(VirtualMachine vm) { PublicIPAddress ip; for (ip = reuseOrAssociate.apply(network); !ip.isStaticNAT() || ip.getVirtualMachineId() != vm.getId(); ip = reuseOrAssociate .apply(network)) { // check to see if someone already grabbed this ip if (ip.getVirtualMachineId() != null && ip.getVirtualMachineId() != vm.getId()) continue; try { logger.debug(">> static NATing IPAddress(%s) to virtualMachine(%s)", ip.getId(), vm.getId()); client.getNATClient().enableStaticNATForVirtualMachine(vm.getId(), ip.getId()); ip = client.getAddressClient().getPublicIPAddress(ip.getId()); if (ip.isStaticNAT() && ip.getVirtualMachineId().equals(vm.getId())) break; } catch (IllegalStateException e) { // very likely an ip conflict, so retry; } return ip; } return ip; } }
public PublicIPAddress apply(VirtualMachine vm) { PublicIPAddress ip; for (ip = reuseOrAssociate.apply(network); !ip.isStaticNAT() || ip.getVirtualMachineId() != vm.getId(); ip = reuseOrAssociate .apply(network)) { // check to see if someone already grabbed this ip if (ip.getVirtualMachineId() != null && ip.getVirtualMachineId() != vm.getId()) continue; try { logger.debug(">> static NATing IPAddress(%s) to virtualMachine(%s)", ip.getId(), vm.getId()); client.getNATClient().enableStaticNATForVirtualMachine(vm.getId(), ip.getId()); ip = client.getAddressClient().getPublicIPAddress(ip.getId()); if (ip.isStaticNAT() && ip.getVirtualMachineId().equals(vm.getId())) break; } catch (IllegalStateException e) { // very likely an ip conflict, so retry; } return ip; } return ip; } }
public T fromPublicIPAddress(PublicIPAddress in) { return this .id(in.getId()) .account(in.getAccount()) .allocated(in.getAllocated()) .associatedNetworkId(in.getAssociatedNetworkId()) .domain(in.getDomain()) .domainId(in.getDomainId()) .usesVirtualNetwork(in.isUsesVirtualNetwork()) .IPAddress(in.getIPAddress()) .isSourceNAT(in.isSourceNAT()) .isStaticNAT(in.isStaticNAT()) .networkId(in.getNetworkId()) .state(in.getState()) .virtualMachineDisplayName(in.getVirtualMachineDisplayName()) .virtualMachineId(in.getVirtualMachineId()) .virtualMachineName(in.getVirtualMachineName()) .VLANId(in.getVLANId()) .VLANName(in.getVLANName()) .zoneId(in.getZoneId()) .zoneName(in.getZoneName()) .jobId(in.getJobId()) .jobStatus(in.getJobStatus()); } }
public T fromPublicIPAddress(PublicIPAddress in) { return this .id(in.getId()) .account(in.getAccount()) .allocated(in.getAllocated()) .associatedNetworkId(in.getAssociatedNetworkId()) .domain(in.getDomain()) .domainId(in.getDomainId()) .usesVirtualNetwork(in.isUsesVirtualNetwork()) .IPAddress(in.getIPAddress()) .isSourceNAT(in.isSourceNAT()) .isStaticNAT(in.isStaticNAT()) .networkId(in.getNetworkId()) .state(in.getState()) .virtualMachineDisplayName(in.getVirtualMachineDisplayName()) .virtualMachineId(in.getVirtualMachineId()) .virtualMachineName(in.getVirtualMachineName()) .VLANId(in.getVLANId()) .VLANName(in.getVLANName()) .zoneId(in.getZoneId()) .zoneName(in.getZoneName()) .jobId(in.getJobId()) .jobStatus(in.getJobStatus()); } }
public T fromPublicIPAddress(PublicIPAddress in) { return this .id(in.getId()) .account(in.getAccount()) .allocated(in.getAllocated()) .associatedNetworkId(in.getAssociatedNetworkId()) .domain(in.getDomain()) .domainId(in.getDomainId()) .usesVirtualNetwork(in.isUsesVirtualNetwork()) .IPAddress(in.getIPAddress()) .isSourceNAT(in.isSourceNAT()) .isStaticNAT(in.isStaticNAT()) .networkId(in.getNetworkId()) .state(in.getState()) .virtualMachineDisplayName(in.getVirtualMachineDisplayName()) .virtualMachineId(in.getVirtualMachineId()) .virtualMachineName(in.getVirtualMachineName()) .VLANId(in.getVLANId()) .VLANName(in.getVLANName()) .zoneId(in.getZoneId()) .zoneName(in.getZoneName()) .jobId(in.getJobId()) .jobStatus(in.getJobStatus()) .tags(in.getTags()); } }