public void testCreateIPForwardingRule() throws Exception { if (networksDisabled) return; BlockUntilJobCompletesAndReturnResult blocker = new BlockUntilJobCompletesAndReturnResult(client, jobComplete); StaticNATVirtualMachineInNetwork fn = new StaticNATVirtualMachineInNetwork(client, reuseOrAssociate, network); CreatePortForwardingRulesForIP createPortForwardingRulesForIP = new CreatePortForwardingRulesForIP(client, blocker, CacheBuilder.newBuilder().<String, Set<IPForwardingRule>> build( new GetIPForwardingRulesByVirtualMachine(client))); // logger injector.injectMembers(blocker); injector.injectMembers(fn); injector.injectMembers(createPortForwardingRulesForIP); ip = fn.apply(vm); createPortForwardingRulesForIP.apply(ip, ImmutableSet.of(22)); rule = getOnlyElement(filter(client.getNATApi().getIPForwardingRulesForIPAddress(ip.getId()), new Predicate<IPForwardingRule>() { @Override public boolean apply(IPForwardingRule rule) { return rule != null && rule.getStartPort() == 22; } })); assertEquals(rule.getIPAddressId(), ip.getId()); assertEquals(rule.getVirtualMachineId(), vm.getId()); assertEquals(rule.getStartPort(), 22); assertEquals(rule.getProtocol(), "tcp"); checkRule(rule); HostAndPort socket = HostAndPort.fromParts(ip.getIPAddress(), 22); checkSSH(socket); }
PublicIPAddress ip = staticNATVMInNetwork.create(networks.get(networkId)).apply(vm); logger.trace("<< static NATed IPAddress(%s) to virtualMachine(%s)", ip.getId(), vm.getId()); vm = client.getVirtualMachineClient().getVirtualMachine(vm.getId());
PublicIPAddress ip = staticNATVMInNetwork.create(networks.get(networkId)).apply(vm); logger.trace("<< static NATed IPAddress(%s) to virtualMachine(%s)", ip.getId(), vm.getId()); vm = client.getVirtualMachineClient().getVirtualMachine(vm.getId());
public void testCreateIPForwardingRule() throws Exception { if (networksDisabled) return; BlockUntilJobCompletesAndReturnResult blocker = new BlockUntilJobCompletesAndReturnResult(client, jobComplete); StaticNATVirtualMachineInNetwork fn = new StaticNATVirtualMachineInNetwork(client, reuseOrAssociate, network); CreatePortForwardingRulesForIP createPortForwardingRulesForIP = new CreatePortForwardingRulesForIP(client, blocker, CacheBuilder.newBuilder().<String, Set<IPForwardingRule>> build( new GetIPForwardingRulesByVirtualMachine(client))); // logger injector.injectMembers(blocker); injector.injectMembers(fn); injector.injectMembers(createPortForwardingRulesForIP); ip = fn.apply(vm); createPortForwardingRulesForIP.apply(ip, ImmutableSet.of(22)); rule = getOnlyElement(filter(client.getNATClient().getIPForwardingRulesForIPAddress(ip.getId()), new Predicate<IPForwardingRule>() { @Override public boolean apply(IPForwardingRule rule) { return rule != null && rule.getStartPort() == 22; } })); assertEquals(rule.getIPAddressId(), ip.getId()); assertEquals(rule.getVirtualMachineId(), vm.getId()); assertEquals(rule.getStartPort(), 22); assertEquals(rule.getProtocol(), "tcp"); checkRule(rule); HostAndPort socket = HostAndPort.fromParts(ip.getIPAddress(), 22); checkSSH(socket); }
PublicIPAddress ip = staticNATVMInNetwork.create(networks.get(networkId)).apply(vm); logger.trace("<< static NATed IPAddress(%s) to virtualMachine(%s)", ip.getId(), vm.getId()); vm = client.getVirtualMachineApi().getVirtualMachine(vm.getId());