public DescribeLaunchConfigurationsResult unmarshall(Node node) throws Exception {
    if (node == null) return null;

    DescribeLaunchConfigurationsResult describeLaunchConfigurationsResult =
        new DescribeLaunchConfigurationsResult();

    NodeList launchConfigurationsNodes = XpathUtils.asNodeList("LaunchConfigurations/member", node);
    for (int launchConfigurationsIndex = 0;
        launchConfigurationsIndex < XpathUtils.nodeLength(launchConfigurationsNodes);
        ++launchConfigurationsIndex) {
      Node launchConfigurationsNode = launchConfigurationsNodes.item(launchConfigurationsIndex);
      describeLaunchConfigurationsResult
          .getLaunchConfigurations()
          .add(new LaunchConfigurationUnmarshaller().unmarshall(launchConfigurationsNode));
      launchConfigurationsNode.getParentNode().removeChild(launchConfigurationsNode);
    }

    Node nextTokenNode = XpathUtils.asNode("NextToken", node);
    describeLaunchConfigurationsResult.setNextToken(
        new StringUnmarshaller().unmarshall(nextTokenNode));

    return describeLaunchConfigurationsResult;
  }
示例#2
0
  /**
   * Describe a set of specific launch configurations.
   *
   * @param names the launch configuration names
   * @return the launch configurations
   */
  public List<LaunchConfiguration> describeLaunchConfigurations(String... names) {
    if (names == null || names.length == 0) {
      LOGGER.info("Getting all launch configurations.");
    } else {
      LOGGER.info(String.format("Getting launch configurations for %d names.", names.length));
    }

    List<LaunchConfiguration> lcs = new LinkedList<LaunchConfiguration>();

    AmazonAutoScalingClient asgClient = asgClient();
    DescribeLaunchConfigurationsRequest request =
        new DescribeLaunchConfigurationsRequest().withLaunchConfigurationNames(names);
    DescribeLaunchConfigurationsResult result = asgClient.describeLaunchConfigurations(request);

    lcs.addAll(result.getLaunchConfigurations());
    while (result.getNextToken() != null) {
      request.setNextToken(result.getNextToken());
      result = asgClient.describeLaunchConfigurations(request);
      lcs.addAll(result.getLaunchConfigurations());
    }

    LOGGER.info(String.format("Got %d launch configurations.", lcs.size()));
    return lcs;
  }