本文整理匯總了Java中com.hazelcast.aws.impl.DescribeInstances類的典型用法代碼示例。如果您正苦於以下問題:Java DescribeInstances類的具體用法?Java DescribeInstances怎麽用?Java DescribeInstances使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
DescribeInstances類屬於com.hazelcast.aws.impl包,在下文中一共展示了DescribeInstances類的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testSigning
import com.hazelcast.aws.impl.DescribeInstances; //導入依賴的package包/類
@Test
public void testSigning() throws NoSuchFieldException, IllegalAccessException, IOException {
AwsConfig awsConfig = new AwsConfig();
awsConfig.setRegion(TEST_REGION).
setHostHeader(TEST_HOST).
setAccessKey(TEST_ACCESS_KEY).
setSecretKey(TEST_SECRET_KEY);
DescribeInstances di = new DescribeInstances(awsConfig, TEST_HOST);
di.getRequestSigner();
Field attributesField = di.getClass().getDeclaredField("attributes");
attributesField.setAccessible(true);
Map<String, String> attributes = (Map<String, String>) attributesField.get(di);
attributes.put("X-Amz-Date", TEST_REQUEST_DATE);
EC2RequestSigner actual = new EC2RequestSigner(awsConfig, TEST_REQUEST_DATE, TEST_HOST);
attributes.put("X-Amz-Credential", actual.createFormattedCredential());
String signature = actual.sign(TEST_SERVICE, attributes);
assertEquals(TEST_SIGNATURE_EXPECTED, signature);
}
示例2: testIamRole
import com.hazelcast.aws.impl.DescribeInstances; //導入依賴的package包/類
@Test
public void testIamRole() throws IOException {
String s = "{\n"
+ " \"Code\" : \"Success\",\n"
+ " \"LastUpdated\" : \"2015-09-06T21:17:26Z\",\n"
+ " \"Type\" : \"AWS-HMAC\",\n"
+ " \"AccessKeyId\" : \"ASIAIEXAMPLEOXYDA\",\n"
+ " \"SecretAccessKey\" : \"hOCVge3EXAMPLExSJ+B\",\n"
+ " \"Token\" : \"AQoDYXdzEE4EXAMPLE2UGAFshkTsyw7gojLdiEXAMPLE+1SfSRTfLR\",\n"
+ " \"Expiration\" : \"2015-09-07T03:19:56Z\"\n}";
StringReader sr = new StringReader(s);
BufferedReader br = new BufferedReader(sr);
AwsConfig awsConfig1 = new AwsConfig();
awsConfig1.setAccessKey("some-access-key");
awsConfig1.setSecretKey("some-secret-key");
awsConfig1.setSecurityGroupName("hazelcast");
DescribeInstances describeInstances = new DescribeInstances(awsConfig, "");
Map map = describeInstances.parseIamRole(br);
assertEquals("Success", map.get("Code"));
assertEquals("2015-09-06T21:17:26Z", map.get("LastUpdated"));
assertEquals("AWS-HMAC", map.get("Type"));
assertEquals("ASIAIEXAMPLEOXYDA", map.get("AccessKeyId"));
assertEquals("hOCVge3EXAMPLExSJ+B", map.get("SecretAccessKey"));
assertEquals("AQoDYXdzEE4EXAMPLE2UGAFshkTsyw7gojLdiEXAMPLE+1SfSRTfLR", map.get("Token"));
}
示例3: deriveSigningKeyTest
import com.hazelcast.aws.impl.DescribeInstances; //導入依賴的package包/類
@Test
public void deriveSigningKeyTest() throws Exception {
// this is from http://docs.aws.amazon.com/general/latest/gr/signature-v4-examples.html
AwsConfig awsConfig = new AwsConfig();
awsConfig.setRegion(TEST_REGION).
setHostHeader(TEST_HOST).
setAccessKey(TEST_ACCESS_KEY).
setSecretKey(TEST_SECRET_KEY);
DescribeInstances di = new DescribeInstances(awsConfig, TEST_HOST);
// Override the attributes map. We need to change values. Not pretty, but
// no real alternative, and in this case : testing only
Field field = di.getClass().getDeclaredField("attributes");
field.setAccessible(true);
Map<String, String> attributes = (Map<String, String>) field.get(di);
attributes.put("X-Amz-Date", TEST_REQUEST_DATE);
field.set(di, attributes);
// Override private method
EC2RequestSigner rs = new EC2RequestSigner(awsConfig, TEST_REQUEST_DATE, TEST_HOST);
field = rs.getClass().getDeclaredField("service");
field.setAccessible(true);
field.set(rs, "ec2");
Method method = rs.getClass().getDeclaredMethod("deriveSigningKey", null);
method.setAccessible(true);
byte[] derivedKey = (byte[]) method.invoke(rs);
assertEquals(TEST_DERIVED_EXPECTED, bytesToHex(derivedKey));
}
示例4: sign
import com.hazelcast.aws.impl.DescribeInstances; //導入依賴的package包/類
public void sign(DescribeInstances request, String endpoint) {
String canonicalizedQueryString = getCanonicalizedQueryString(request);
String stringToSign = new StringBuilder().append(HTTP_VERB)
.append(endpoint).append("\n")
.append(HTTP_REQUEST_URI)
.append(canonicalizedQueryString).toString();
String signature = signTheString(stringToSign);
request.putSignature(signature);
}
示例5: getPrivateIpAddresses
import com.hazelcast.aws.impl.DescribeInstances; //導入依賴的package包/類
public Collection<String> getPrivateIpAddresses() throws Exception {
Map<String, String> result = new DescribeInstances(awsConfig, endpoint).execute();
return result.keySet();
}
示例6: getAddresses
import com.hazelcast.aws.impl.DescribeInstances; //導入依賴的package包/類
public Map<String, String> getAddresses() throws Exception {
return new DescribeInstances(awsConfig, endpoint).execute();
}
示例7: getCanonicalizedQueryString
import com.hazelcast.aws.impl.DescribeInstances; //導入依賴的package包/類
private String getCanonicalizedQueryString(DescribeInstances request) {
List<String> componentz = getListOfEntries(request.getAttributes());
Collections.sort(componentz);
String canonicalizedQueryString = getCanonicalizedQueryString(componentz);
return canonicalizedQueryString;
}
示例8: getPrivateIpAddresses
import com.hazelcast.aws.impl.DescribeInstances; //導入依賴的package包/類
public List<String> getPrivateIpAddresses(AwsConfig groupName) throws Exception {
List<String> list = new DescribeInstances(awsConfig).execute(endpoint);
return list;
}