當前位置: 首頁>>代碼示例>>Java>>正文


Java DescribeInstances類代碼示例

本文整理匯總了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);
}
 
開發者ID:hazelcast,項目名稱:hazelcast-aws,代碼行數:23,代碼來源:EC2RequestSignerTest.java

示例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"));
}
 
開發者ID:hazelcast,項目名稱:hazelcast-aws,代碼行數:27,代碼來源:CloudyUtilityTest.java

示例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));
}
 
開發者ID:hazelcast,項目名稱:hazelcast-aws,代碼行數:32,代碼來源:EC2RequestSignerTest.java

示例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);
}
 
開發者ID:mdogan,項目名稱:hazelcast-archive,代碼行數:10,代碼來源:EC2RequestSigner.java

示例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();
}
 
開發者ID:hazelcast,項目名稱:hazelcast-aws,代碼行數:5,代碼來源:AWSClient.java

示例6: getAddresses

import com.hazelcast.aws.impl.DescribeInstances; //導入依賴的package包/類
public Map<String, String> getAddresses() throws Exception {
    return new DescribeInstances(awsConfig, endpoint).execute();
}
 
開發者ID:hazelcast,項目名稱:hazelcast-aws,代碼行數:4,代碼來源:AWSClient.java

示例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;
}
 
開發者ID:mdogan,項目名稱:hazelcast-archive,代碼行數:7,代碼來源:EC2RequestSigner.java

示例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;
}
 
開發者ID:mdogan,項目名稱:hazelcast-archive,代碼行數:5,代碼來源:AWSClient.java


注:本文中的com.hazelcast.aws.impl.DescribeInstances類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。