com.amazonaws.services.elasticloadbalancing.model.DescribeLoadBalancersResult Java Examples

The following examples show how to use com.amazonaws.services.elasticloadbalancing.model.DescribeLoadBalancersResult. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Ec2Utils.java    From pacbot with Apache License 2.0 6 votes vote down vote up
/**
 * Gets the all elbs desc.
 *
 * @param elbClient the elb client
 * @param region the region
 * @param balancersRequest the balancers request
 * @return the all elbs desc
 */
public static List<LoadBalancerDescription> getAllElbsDesc(AmazonElasticLoadBalancing elbClient,
		Region region, DescribeLoadBalancersRequest balancersRequest) {

	List<LoadBalancerDescription> loadDescriptionList = new ArrayList<LoadBalancerDescription>();
	DescribeLoadBalancersResult balancersResult;
	String marker;
	do {
		balancersResult = elbClient.describeLoadBalancers(balancersRequest);
		
		marker = balancersResult.getNextMarker();
		balancersRequest.setMarker(marker);
		loadDescriptionList.addAll(balancersResult.getLoadBalancerDescriptions());

	} while (null != marker);
	
	return loadDescriptionList;
}
 
Example #2
Source File: AwsCommonProcess.java    From primecloud-controller with GNU General Public License v2.0 6 votes vote down vote up
public LoadBalancerDescription describeLoadBalancer(AwsProcessClient awsProcessClient, String loadBalancerName) {
    // 単一ロードバランサの参照
    DescribeLoadBalancersRequest request = new DescribeLoadBalancersRequest();
    request.withLoadBalancerNames(loadBalancerName);
    DescribeLoadBalancersResult result = awsProcessClient.getElbClient().describeLoadBalancers(request);
    List<LoadBalancerDescription> descriptions = result.getLoadBalancerDescriptions();

    // API実行結果チェック
    if (descriptions.size() == 0) {
        // アドレスが存在しない場合
        throw new AutoException("EPROCESS-000131", loadBalancerName);

    } else if (descriptions.size() > 1) {
        // アドレスを複数参照できた場合
        AutoException exception = new AutoException("EPROCESS-000132", loadBalancerName);
        exception.addDetailInfo("result=" + descriptions);
        throw exception;
    }

    return descriptions.get(0);
}
 
Example #3
Source File: ElbResource.java    From Baragon with Apache License 2.0 6 votes vote down vote up
@GET
@NoAuth
@Path("/{elbName}")
public LoadBalancerDescription getElb(@PathParam("elbName") String elbName) {
  if (config.isPresent()) {
    try {
      DescribeLoadBalancersRequest request = new DescribeLoadBalancersRequest(Arrays.asList(elbName));
      DescribeLoadBalancersResult result = elbClient.describeLoadBalancers(request);
      for (LoadBalancerDescription elb : result.getLoadBalancerDescriptions()) {
        if (elb.getLoadBalancerName().equals(elbName)) {
          return elb;
        }
      }
    } catch (AmazonClientException e) {
      throw new BaragonWebException(String.format("AWS Client Error: %s", e));
    }
    throw new BaragonNotFoundException(String.format("ELB with name %s not found", elbName));
  } else {
    throw new BaragonWebException("ElbSync and related actions are not currently enabled");
  }
}
 
Example #4
Source File: AwsAutoScalingDeployUtils.java    From vertx-deploy-tools with Apache License 2.0 5 votes vote down vote up
private List<ListenerDescription> describeMatchingElbListeners(String loadbalancerName, List<Integer> ports) {
    DescribeLoadBalancersResult loadbalancer = awsElbClient.describeLoadBalancers(new DescribeLoadBalancersRequest().withLoadBalancerNames(loadbalancerName));
    LoadBalancerDescription description = loadbalancer.getLoadBalancerDescriptions().get(0);
    return description.getListenerDescriptions().stream()
            .filter(d -> ports.contains(d.getListener().getLoadBalancerPort()))
            .filter(d -> d.getListener().getProtocol().startsWith("HTTP"))
            .collect(Collectors.toList());
}
 
Example #5
Source File: ClassicLoadBalancer.java    From Baragon with Apache License 2.0 5 votes vote down vote up
private Optional<LoadBalancerDescription> getElb(String elbName) {
  DescribeLoadBalancersRequest request = new DescribeLoadBalancersRequest(Arrays.asList(elbName));
  DescribeLoadBalancersResult result = elbClient.describeLoadBalancers(request);
  if (!result.getLoadBalancerDescriptions().isEmpty()) {
    return Optional.of(result.getLoadBalancerDescriptions().get(0));
  } else {
    return Optional.absent();
  }
}
 
Example #6
Source File: FetchElasticLoadBalancersJobTest.java    From fullstop with Apache License 2.0 4 votes vote down vote up
@Before
public void setUp() throws Exception {
    this.violationSinkMock = mock(ViolationSink.class);
    this.clientProviderMock = mock(ClientProvider.class);
    this.accountIdSupplierMock = mock(AccountIdSupplier.class);
    this.jobsPropertiesMock = mock(JobsProperties.class);
    this.portsChecker = mock(PortsChecker.class);
    this.securityGroupsChecker = mock(SecurityGroupsChecker.class);
    this.mockAwsELBClient = mock(AmazonElasticLoadBalancingClient.class);
    this.mockAwsApplications = mock(AwsApplications.class);
    this.mockViolationService = mock(ViolationService.class);
    this.fetchTaupageYamlMock = mock(FetchTaupageYaml.class);
    this.mockAmiDetailsProvider = mock(AmiDetailsProvider.class);
    this.mockEC2InstanceProvider = mock(EC2InstanceProvider.class);

    final Listener listener = new Listener("HTTPS", 80, 80);

    final ListenerDescription listenerDescription = new ListenerDescription();
    listenerDescription.setListener(listener);

    final ArrayList<LoadBalancerDescription> elbs = newArrayList();
    final ArrayList<TagDescription> tagDescriptions = newArrayList();

    final LoadBalancerDescription publicELB = new LoadBalancerDescription();
    publicELB.setScheme("internet-facing");
    publicELB.setListenerDescriptions(newArrayList(listenerDescription));
    publicELB.setCanonicalHostedZoneName("test.com");
    publicELB.setInstances(asList(new Instance("i1"), new Instance("i2")));
    publicELB.setLoadBalancerName("publicELB");
    elbs.add(publicELB);
    tagDescriptions.add(
            new TagDescription()
                    .withLoadBalancerName("publicELB")
                    .withTags(newArrayList(
                            new Tag().withKey("someTag").withValue("someValue"))));

    final LoadBalancerDescription privateELB = new LoadBalancerDescription();
    privateELB.setScheme("internal");
    privateELB.setCanonicalHostedZoneName("internal.org");
    privateELB.setLoadBalancerName("privateELB");
    elbs.add(privateELB);

    for (int i = 1; i <= 20; i++) {
        final String loadBalancerName = "kubeELB" + i;
        final LoadBalancerDescription kubeELB = new LoadBalancerDescription();
        kubeELB.setScheme("internet-facing");
        kubeELB.setCanonicalHostedZoneName("test" + i + ".com");
        kubeELB.setLoadBalancerName(loadBalancerName);
        elbs.add(kubeELB);

        tagDescriptions.add(
                new TagDescription()
                        .withLoadBalancerName(loadBalancerName)
                        .withTags(newArrayList(
                                new Tag().withKey("someTag").withValue("someValue"),
                                new Tag().withKey("kubernetes.io/cluster/").withValue("owned"))));
    }

    mockDescribeELBResult = new DescribeLoadBalancersResult();
    mockDescribeELBResult.setLoadBalancerDescriptions(elbs);

    mockDescribeTagsResult = new DescribeTagsResult();
    mockDescribeTagsResult.setTagDescriptions(tagDescriptions);

    regions.add(REGION1);

    when(clientProviderMock.getClient(any(), any(String.class), any(Region.class))).thenReturn(mockAwsELBClient);

    when(mockEC2InstanceProvider.getById(anyString(), any(Region.class), anyString()))
            .thenReturn(Optional.of(new com.amazonaws.services.ec2.model.Instance().withInstanceId("foo").withImageId("bar")));
    when(mockAmiDetailsProvider.getAmiDetails(anyString(), any(Region.class), anyString()))
            .thenReturn(ImmutableMap.of("ami_id", "bar"));
}