コード例 #1
0
ファイル: EC2Iaas.java プロジェクト: R-Rajkumar/stratos
  @Override
  public boolean isValidZone(String region, String zone) throws InvalidZoneException {
    IaasProvider iaasInfo = getIaasProvider();
    if (zone == null || iaasInfo == null) {
      String msg = "Zone or IaaSProvider is null: zone: " + zone + " - IaaSProvider: " + iaasInfo;
      log.error(msg);
      throw new InvalidZoneException(msg);
    }
    ComputeServiceContext context = iaasInfo.getComputeService().getContext();
    AvailabilityZoneAndRegionApi zoneRegionApi =
        context.unwrapApi(AWSEC2Api.class).getAvailabilityZoneAndRegionApiForRegion(region).get();

    Set<AvailabilityZoneInfo> availabilityZones =
        zoneRegionApi.describeAvailabilityZonesInRegion(region);
    for (AvailabilityZoneInfo zoneInfo : availabilityZones) {
      String configuredZone = zoneInfo.getZone();
      if (zone.equalsIgnoreCase(configuredZone)) {
        if (log.isDebugEnabled()) {
          log.debug("Found a matching zone: " + zone);
        }
        return true;
      }
    }

    String msg =
        "Invalid zone: "
            + zone
            + " in the region: "
            + region
            + " and of the iaas: "
            + iaasInfo.getType();
    log.error(msg);
    throw new InvalidZoneException(msg);
  }
コード例 #2
0
ファイル: EC2Iaas.java プロジェクト: R-Rajkumar/stratos
  @Override
  public boolean isValidHost(String zone, String host) throws InvalidHostException {
    IaasProvider iaasInfo = getIaasProvider();

    // there's no such concept in EC2
    String msg =
        "Invalid host: "
            + host
            + " in the zone: "
            + zone
            + " and of the iaas: "
            + iaasInfo.getType();
    log.error(msg);
    throw new InvalidHostException(msg);
  }
コード例 #3
0
ファイル: EC2Iaas.java プロジェクト: R-Rajkumar/stratos
  @Override
  public boolean isValidRegion(String region) throws InvalidRegionException {
    IaasProvider iaasInfo = getIaasProvider();
    if (region == null || iaasInfo == null) {
      String msg =
          "Region or IaaSProvider is null: region: " + region + " - IaaSProvider: " + iaasInfo;
      log.error(msg);
      throw new InvalidRegionException(msg);
    }

    ComputeServiceContext context = iaasInfo.getComputeService().getContext();
    Set<String> regions = context.unwrapApi(AWSEC2Api.class).getConfiguredRegions();
    for (String configuredRegion : regions) {
      if (region.equalsIgnoreCase(configuredRegion)) {
        if (log.isDebugEnabled()) {
          log.debug("Found a matching region: " + region);
        }
        return true;
      }
    }
    String msg = "Invalid region: " + region + " in the iaas: " + iaasInfo.getType();
    log.error(msg);
    throw new InvalidRegionException(msg);
  }