public DescribeInstances(AwsConfig awsConfig) { rs = new EC2RequestSigner(awsConfig.getSecretKey()); attributes.put("Action", this.getClass().getSimpleName()); attributes.put("Version", DOC_VERSION); attributes.put("SignatureVersion", SIGNATURE_VERSION); attributes.put("SignatureMethod", SIGNATURE_METHOD); attributes.put("AWSAccessKeyId", awsConfig.getAccessKey()); attributes.put("Timestamp", getFormattedTimestamp()); this.awsConfig = awsConfig; }
@Test public void testNetworkConfig() { NetworkConfig networkConfig = config.getNetworkConfig(); assertNotNull(networkConfig); assertEquals(5700, networkConfig.getPort()); assertFalse(networkConfig.isPortAutoIncrement()); final Collection<String> allowedPorts = networkConfig.getOutboundPortDefinitions(); assertEquals(2, allowedPorts.size()); Iterator portIter = allowedPorts.iterator(); assertEquals("35000-35100", portIter.next()); assertEquals("36000,36100", portIter.next()); assertFalse(networkConfig.getJoin().getMulticastConfig().isEnabled()); assertEquals(networkConfig.getJoin().getMulticastConfig().getMulticastTimeoutSeconds(), 8); assertEquals(networkConfig.getJoin().getMulticastConfig().getMulticastTimeToLive(), 16); assertFalse(networkConfig.getInterfaces().isEnabled()); assertEquals(1, networkConfig.getInterfaces().getInterfaces().size()); assertEquals("10.10.1.*", networkConfig.getInterfaces().getInterfaces().iterator().next()); TcpIpConfig tcp = networkConfig.getJoin().getTcpIpConfig(); assertNotNull(tcp); assertTrue(tcp.isEnabled()); assertTrue(networkConfig.getSymmetricEncryptionConfig().isEnabled()); final List<String> members = tcp.getMembers(); assertEquals(members.toString(), 2, members.size()); assertEquals("127.0.0.1:5700", members.get(0)); assertEquals("127.0.0.1:5701", members.get(1)); assertEquals("127.0.0.1:5700", tcp.getRequiredMember()); AwsConfig aws = networkConfig.getJoin().getAwsConfig(); assertFalse(aws.isEnabled()); assertEquals("sample-access-key", aws.getAccessKey()); assertEquals("sample-secret-key", aws.getSecretKey()); assertEquals("sample-region", aws.getRegion()); assertEquals("sample-group", aws.getSecurityGroupName()); assertEquals("sample-tag-key", aws.getTagKey()); assertEquals("sample-tag-value", aws.getTagValue()); }
public AWSClient(AwsConfig awsConfig) { if (awsConfig == null) { throw new IllegalArgumentException("AwsConfig is required!"); } if (awsConfig.getAccessKey() == null) { throw new IllegalArgumentException("AWS access key is required!"); } if (awsConfig.getSecretKey() == null) { throw new IllegalArgumentException("AWS secret key is required!"); } this.awsConfig = awsConfig; endpoint = awsConfig.getHostHeader(); if (awsConfig.getRegion() != null && awsConfig.getRegion().length() > 0) { setEndpoint("ec2." + awsConfig.getRegion() + ".amazonaws.com"); } }
@Override protected int getConnTimeoutSeconds() { AwsConfig awsConfig = node.getConfig().getNetworkConfig().getJoin().getAwsConfig(); return awsConfig.getConnectionTimeoutSeconds(); }
private boolean applyFilter(AwsConfig awsConfig, Node node) { boolean inGroup = applyFilter(node, awsConfig.getSecurityGroupName(), "groupset", "groupname"); return inGroup && applyTagFilter(node, awsConfig.getTagKey(), awsConfig.getTagValue()); }