/** * Validates the configured placement group. * * @param client the EC2 client * @param configuration the configuration to be validated * @param accumulator the exception condition accumulator * @param localizationContext the localization context */ @VisibleForTesting void checkPlacementGroup(AmazonEC2Client client, Configured configuration, PluginExceptionConditionAccumulator accumulator, LocalizationContext localizationContext) { String placementGroup = configuration.getConfigurationValue(PLACEMENT_GROUP, localizationContext); if (placementGroup != null) { LOG.info(">> Describing placement group '{}'", placementGroup); try { DescribePlacementGroupsResult result = client.describePlacementGroups( new DescribePlacementGroupsRequest().withGroupNames(placementGroup)); checkCount(accumulator, PLACEMENT_GROUP, localizationContext, "Placement group", result.getPlacementGroups()); } catch (AmazonServiceException e) { if (e.getErrorCode().startsWith(INVALID_PLACEMENT_GROUP_ID)) { addError(accumulator, PLACEMENT_GROUP, localizationContext, null, INVALID_PLACEMENT_GROUP_MSG, placementGroup); } else { throw Throwables.propagate(e); } } } }
@Override public List<AbstractResource<?>> describePlacementGroups(Account account, Region region, DateTime dt, Ec2Filter... filters) { AmazonEC2 ec2 = findClient(account, region); DescribePlacementGroupsRequest req = new DescribePlacementGroupsRequest(); for (Ec2Filter filter : filters) { Filter f = new Filter().withName(filter.getName()).withValues(filter.getValues()); req.withFilters(f); } log.debug("start describing placement groups for account:{} in region:{} via api", account.getId() + "=>" + account.getName(), region); DescribePlacementGroupsResult res = ec2.describePlacementGroups(req); return converter.toEc2PlacementGroups(res.getPlacementGroups(), account.getId(), region, dt); }
@Override public DescribePlacementGroupsResult describePlacementGroups(DescribePlacementGroupsRequest describePlacementGroupsRequest) throws AmazonServiceException, AmazonClientException { throw new UnsupportedOperationException("Not supported in mock"); }
@Override public DescribePlacementGroupsResult describePlacementGroups() throws AmazonServiceException, AmazonClientException { throw new UnsupportedOperationException("Not supported in mock"); }
@Override public boolean load(DescribePlacementGroupsRequest request, ResultCapture<DescribePlacementGroupsResult> extractor) { return resource.load(request, extractor); }
/** * Makes a call to the service to load this resource's attributes if they * are not loaded yet, and use a ResultCapture to retrieve the low-level * client response * The following request parameters will be populated from the data of this * <code>PlacementGroup</code> resource, and any conflicting parameter value * set in the request will be overridden: * <ul> * <li> * <b><code>GroupNames.0</code></b> * - mapped from the <code>Name</code> identifier. * </li> * </ul> * * <p> * * @return Returns {@code true} if the resource is not yet loaded when this * method was invoked, which indicates that a service call has been * made to retrieve the attributes. * @see DescribePlacementGroupsRequest */ boolean load(DescribePlacementGroupsRequest request, ResultCapture<DescribePlacementGroupsResult> extractor);