com.amazonaws.services.autoscaling.model.DescribeLaunchConfigurationsRequest Java Examples

The following examples show how to use com.amazonaws.services.autoscaling.model.DescribeLaunchConfigurationsRequest. 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: AwsInstanceCloudConnector.java    From titus-control-plane with Apache License 2.0 5 votes vote down vote up
@Override
public Observable<List<InstanceLaunchConfiguration>> getInstanceLaunchConfiguration(List<String> launchConfigurationIds) {
    if (launchConfigurationIds.isEmpty()) {
        return Observable.just(Collections.emptyList());
    }
    DescribeLaunchConfigurationsRequest request = new DescribeLaunchConfigurationsRequest().withLaunchConfigurationNames(launchConfigurationIds);
    Observable<DescribeLaunchConfigurationsResult> observable = toObservable(request, autoScalingClient::describeLaunchConfigurationsAsync);
    return observable.map(
            response -> toInstanceLaunchConfigurations(response.getLaunchConfigurations())
    ).timeout(configuration.getAwsRequestTimeoutMs(), TimeUnit.MILLISECONDS);
}
 
Example #2
Source File: LaunchConfigurationHandlerTest.java    From cloudbreak with Apache License 2.0 5 votes vote down vote up
@Test
public void getLaunchConfigurations() {
    when(autoScalingClient.describeLaunchConfigurations(any(DescribeLaunchConfigurationsRequest.class)))
            .thenReturn(new DescribeLaunchConfigurationsResult());

    Collection<AutoScalingGroup> autoScalingGroups = Lists.newArrayList(new AutoScalingGroup().withLaunchConfigurationName("a"),
            new AutoScalingGroup().withLaunchConfigurationName("b"));
    underTest.getLaunchConfigurations(autoScalingClient, autoScalingGroups);
    ArgumentCaptor<DescribeLaunchConfigurationsRequest> captor = ArgumentCaptor.forClass(DescribeLaunchConfigurationsRequest.class);
    verify(autoScalingClient, times(1)).describeLaunchConfigurations(captor.capture());
    assertEquals(autoScalingGroups.size(), captor.getValue().getLaunchConfigurationNames().size());
}
 
Example #3
Source File: ASGInventoryUtil.java    From pacbot with Apache License 2.0 4 votes vote down vote up
/**
 * Fetch launch configurations.
 *
 * @param temporaryCredentials the temporary credentials
 * @param skipRegions the skip regions
 * @param accountId the accountId
 * @return the map
 */
public static Map<String,List<LaunchConfiguration>> fetchLaunchConfigurations(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName){
	
	AmazonAutoScaling asgClient;
	Map<String,List<LaunchConfiguration>> launchConfigurationList = new LinkedHashMap<>();
	List<String> launchConfigurationNames = new ArrayList<>();
	
	String expPrefix = "{\"errcode\": \"NO_RES_REG\" ,\"accountId\": \""+accountId + "\",\"Message\": \"Exception in fetching info for resource in specific region\" ,\"type\": \"ASG\" , \"region\":\"" ;
	for(Region region : RegionUtils.getRegions()){ 
		try{
			if(!skipRegions.contains(region.getName())){ //!skipRegions
				List<LaunchConfiguration> launchConfigurationListTemp = new ArrayList<>();
				asgClient = AmazonAutoScalingClientBuilder.standard().withCredentials(new AWSStaticCredentialsProvider(temporaryCredentials)).withRegion(region.getName()).build();
				String nextToken = null;
				DescribeAutoScalingGroupsResult  describeResult ;
				do{
					describeResult =  asgClient.describeAutoScalingGroups(new DescribeAutoScalingGroupsRequest().withNextToken(nextToken).withMaxRecords(asgMaxRecord));
					for(AutoScalingGroup _asg : describeResult.getAutoScalingGroups()) {
						launchConfigurationNames.add(_asg.getLaunchConfigurationName());
					}
					nextToken = describeResult.getNextToken();
				}while(nextToken!=null);
				List<String> launchConfigurationNamesTemp = new ArrayList<>();
				
				for(int i =0 ; i<launchConfigurationNames.size();i++){
					launchConfigurationNamesTemp.add(launchConfigurationNames.get(i));
					if((i+1)%50==0 || i == launchConfigurationNames.size()-1){
						launchConfigurationListTemp.addAll(asgClient.describeLaunchConfigurations(new DescribeLaunchConfigurationsRequest().withLaunchConfigurationNames(launchConfigurationNamesTemp)).getLaunchConfigurations());
						launchConfigurationNamesTemp = new ArrayList<>();
					}
					
				}
				
				if(!launchConfigurationListTemp.isEmpty() ){
					log.debug("Account : " + accountId + " Type : ASG Launch Configurations "+region.getName()+" >> " + launchConfigurationListTemp.size());
					launchConfigurationList.put(accountId+delimiter+accountName+delimiter+region.getName(), launchConfigurationListTemp);
				}
		   	}
		}catch(Exception e){
			log.warn(expPrefix+ region.getName()+"\", \"cause\":\"" +e.getMessage()+"\"}");
			ErrorManageUtil.uploadError(accountId,region.getName(),"launchconfig",e.getMessage());
		}
	}
	return launchConfigurationList;
}
 
Example #4
Source File: LaunchConfigurationHandler.java    From cloudbreak with Apache License 2.0 4 votes vote down vote up
public List<LaunchConfiguration> getLaunchConfigurations(AmazonAutoScalingClient autoScalingClient, Collection<AutoScalingGroup> scalingGroups) {
    DescribeLaunchConfigurationsRequest launchConfigurationsRequest = new DescribeLaunchConfigurationsRequest();
    launchConfigurationsRequest.setLaunchConfigurationNames(
            scalingGroups.stream().map(AutoScalingGroup::getLaunchConfigurationName).collect(Collectors.toList()));
    return autoScalingClient.describeLaunchConfigurations(launchConfigurationsRequest).getLaunchConfigurations();
}