com.amazonaws.services.elasticloadbalancing.AmazonElasticLoadBalancing Java Examples
The following examples show how to use
com.amazonaws.services.elasticloadbalancing.AmazonElasticLoadBalancing.
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: AmazonAwsClientFactory.java From primecloud-controller with GNU General Public License v2.0 | 6 votes |
/** * {@inheritDoc} */ @Override public AmazonElasticLoadBalancing createElbClient(String awsAccessId, String awsSecretKey) { AWSCredentials credentials = new BasicAWSCredentials(awsAccessId, awsSecretKey); ClientConfiguration configuration = createConfiguration(); AmazonElasticLoadBalancing client = new AmazonElasticLoadBalancingClient(credentials, configuration); if (host != null) { client.setEndpoint(AmazonElasticLoadBalancing.ENDPOINT_PREFIX + "." + host); } client = new ExceptionHandleAwsClientWrapper().wrap(client); return client; }
Example #2
Source File: AbstractAwsClientWrapper.java From primecloud-controller with GNU General Public License v2.0 | 6 votes |
/** * TODO: メソッドコメント * * @param client * @return */ public AmazonElasticLoadBalancing wrap(final AmazonElasticLoadBalancing client) { InvocationHandler handler = new InvocationHandler() { @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { if (!AmazonWebServiceResult.class.isAssignableFrom(method.getReturnType())) { return method.invoke(client, args); } return doInvoke(client, proxy, method, args); } }; return (AmazonElasticLoadBalancing) Proxy.newProxyInstance(LoggingAwsClientWrapper.class.getClassLoader(), new Class[] { AmazonElasticLoadBalancing.class }, handler); }
Example #3
Source File: Ec2Utils.java From pacbot with Apache License 2.0 | 6 votes |
/** * 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 #4
Source File: InventoryUtilTest.java From pacbot with Apache License 2.0 | 5 votes |
/** * Fetch target groups test. * * @throws Exception the exception */ @SuppressWarnings("static-access") @Test public void fetchTargetGroupsTest() throws Exception { mockStatic(com.amazonaws.services.elasticloadbalancingv2.AmazonElasticLoadBalancingClientBuilder.class); com.amazonaws.services.elasticloadbalancingv2.AmazonElasticLoadBalancing elbClient = PowerMockito.mock(com.amazonaws.services.elasticloadbalancingv2.AmazonElasticLoadBalancing.class); com.amazonaws.services.elasticloadbalancingv2.AmazonElasticLoadBalancingClientBuilder amazonElasticLoadBalancingClientBuilder = PowerMockito.mock(com.amazonaws.services.elasticloadbalancingv2.AmazonElasticLoadBalancingClientBuilder.class); AWSStaticCredentialsProvider awsStaticCredentialsProvider = PowerMockito.mock(AWSStaticCredentialsProvider.class); PowerMockito.whenNew(AWSStaticCredentialsProvider.class).withAnyArguments().thenReturn(awsStaticCredentialsProvider); when(amazonElasticLoadBalancingClientBuilder.standard()).thenReturn(amazonElasticLoadBalancingClientBuilder); when(amazonElasticLoadBalancingClientBuilder.withCredentials(anyObject())).thenReturn(amazonElasticLoadBalancingClientBuilder); when(amazonElasticLoadBalancingClientBuilder.withRegion(anyString())).thenReturn(amazonElasticLoadBalancingClientBuilder); when(amazonElasticLoadBalancingClientBuilder.build()).thenReturn(elbClient); DescribeTargetGroupsResult trgtGrpRslt = new DescribeTargetGroupsResult(); List<TargetGroup> targetGrpList = new ArrayList<>(); TargetGroup targetGroup = new TargetGroup(); targetGroup.setTargetGroupArn("targetGroupArn"); targetGrpList.add(targetGroup); trgtGrpRslt.setTargetGroups(targetGrpList); when(elbClient.describeTargetGroups(anyObject())).thenReturn(trgtGrpRslt); DescribeTargetHealthResult describeTargetHealthResult = new DescribeTargetHealthResult(); describeTargetHealthResult.setTargetHealthDescriptions(new ArrayList<>()); when(elbClient.describeTargetHealth(anyObject())).thenReturn(describeTargetHealthResult); assertThat(inventoryUtil.fetchTargetGroups(new BasicSessionCredentials("awsAccessKey", "awsSecretKey", "sessionToken"), "skipRegions", "account","accountName").size(), is(1)); }
Example #5
Source File: ServerInstanceContext.java From chassis with Apache License 2.0 | 5 votes |
public ServerInstanceContext(Ec2MetadataClient ec2MetadataClient, AmazonEC2 amazonEC2, AmazonElasticLoadBalancing amazonElasticLoadBalancing){ this.ec2MetadataClient = ec2MetadataClient; this.amazonEC2 = amazonEC2; this.amazonElasticLoadBalancing = amazonElasticLoadBalancing; init(); }
Example #6
Source File: AwsUtils.java From chassis with Apache License 2.0 | 5 votes |
/** * Fetches and filters a Region's ELBs * @param amazonElasticLoadBalancing * @param filter * @return */ public static List<LoadBalancerDescription> findLoadBalancers(AmazonElasticLoadBalancing amazonElasticLoadBalancing, ELBFilter filter) { List<LoadBalancerDescription> loadBalancers = amazonElasticLoadBalancing.describeLoadBalancers().getLoadBalancerDescriptions(); List<LoadBalancerDescription> result = new ArrayList<>(loadBalancers.size()); for(LoadBalancerDescription loadBalancer:loadBalancers){ if(filter.accept(loadBalancer)){ result.add(loadBalancer); } } return result; }
Example #7
Source File: InventoryUtilTest.java From pacbot with Apache License 2.0 | 5 votes |
/** * Fetch elb info test. * * @throws Exception the exception */ @SuppressWarnings("static-access") @Test public void fetchElbInfoTest() throws Exception { mockStatic(com.amazonaws.services.elasticloadbalancingv2.AmazonElasticLoadBalancingClientBuilder.class); com.amazonaws.services.elasticloadbalancingv2.AmazonElasticLoadBalancing elbClient = PowerMockito.mock(com.amazonaws.services.elasticloadbalancingv2.AmazonElasticLoadBalancing.class); com.amazonaws.services.elasticloadbalancingv2.AmazonElasticLoadBalancingClientBuilder amazonElasticLoadBalancingClientBuilder = PowerMockito.mock(com.amazonaws.services.elasticloadbalancingv2.AmazonElasticLoadBalancingClientBuilder.class); AWSStaticCredentialsProvider awsStaticCredentialsProvider = PowerMockito.mock(AWSStaticCredentialsProvider.class); PowerMockito.whenNew(AWSStaticCredentialsProvider.class).withAnyArguments().thenReturn(awsStaticCredentialsProvider); when(amazonElasticLoadBalancingClientBuilder.standard()).thenReturn(amazonElasticLoadBalancingClientBuilder); when(amazonElasticLoadBalancingClientBuilder.withCredentials(anyObject())).thenReturn(amazonElasticLoadBalancingClientBuilder); when(amazonElasticLoadBalancingClientBuilder.withRegion(anyString())).thenReturn(amazonElasticLoadBalancingClientBuilder); when(amazonElasticLoadBalancingClientBuilder.build()).thenReturn(elbClient); DescribeLoadBalancersResult elbDescResult = new DescribeLoadBalancersResult(); List<LoadBalancer> elbList = new ArrayList<>(); LoadBalancer loadBalancer = new LoadBalancer(); loadBalancer.setLoadBalancerArn("loadBalancerArn"); elbList.add(loadBalancer); elbDescResult.setLoadBalancers(elbList); when(elbClient.describeLoadBalancers(anyObject())).thenReturn(elbDescResult); com.amazonaws.services.elasticloadbalancingv2.model.DescribeTagsResult describeTagsResult = new com.amazonaws.services.elasticloadbalancingv2.model.DescribeTagsResult(); List<com.amazonaws.services.elasticloadbalancingv2.model.TagDescription> tagsList = new ArrayList<>(); com.amazonaws.services.elasticloadbalancingv2.model.TagDescription tagDescription = new com.amazonaws.services.elasticloadbalancingv2.model.TagDescription(); tagDescription.setResourceArn("loadBalancerArn"); tagDescription.setTags(new ArrayList<com.amazonaws.services.elasticloadbalancingv2.model.Tag>()); tagsList.add(tagDescription); describeTagsResult.setTagDescriptions(tagsList); when(elbClient.describeTags(anyObject())).thenReturn(describeTagsResult); assertThat(inventoryUtil.fetchElbInfo(new BasicSessionCredentials("awsAccessKey", "awsSecretKey", "sessionToken"), "skipRegions", "account","accountName").size(), is(1)); }
Example #8
Source File: InventoryUtilTest.java From pacbot with Apache License 2.0 | 5 votes |
/** * Fetch classic elb info test. * * @throws Exception the exception */ @SuppressWarnings("static-access") @Test public void fetchClassicElbInfoTest() throws Exception { mockStatic(AmazonElasticLoadBalancingClientBuilder.class); AmazonElasticLoadBalancing elbClient = PowerMockito.mock(AmazonElasticLoadBalancing.class); AmazonElasticLoadBalancingClientBuilder amazonElasticLoadBalancingClientBuilder = PowerMockito.mock(AmazonElasticLoadBalancingClientBuilder.class); AWSStaticCredentialsProvider awsStaticCredentialsProvider = PowerMockito.mock(AWSStaticCredentialsProvider.class); PowerMockito.whenNew(AWSStaticCredentialsProvider.class).withAnyArguments().thenReturn(awsStaticCredentialsProvider); when(amazonElasticLoadBalancingClientBuilder.standard()).thenReturn(amazonElasticLoadBalancingClientBuilder); when(amazonElasticLoadBalancingClientBuilder.withCredentials(anyObject())).thenReturn(amazonElasticLoadBalancingClientBuilder); when(amazonElasticLoadBalancingClientBuilder.withRegion(anyString())).thenReturn(amazonElasticLoadBalancingClientBuilder); when(amazonElasticLoadBalancingClientBuilder.build()).thenReturn(elbClient); com.amazonaws.services.elasticloadbalancing.model.DescribeLoadBalancersResult elbDescResult = new com.amazonaws.services.elasticloadbalancing.model.DescribeLoadBalancersResult(); List<LoadBalancerDescription> elbList = new ArrayList<>(); LoadBalancerDescription loadBalancerDescription = new LoadBalancerDescription(); loadBalancerDescription.setLoadBalancerName("loadBalancerName"); elbList.add(loadBalancerDescription); elbDescResult.setLoadBalancerDescriptions(elbList); when(elbClient.describeLoadBalancers(anyObject())).thenReturn(elbDescResult); com.amazonaws.services.elasticloadbalancing.model.DescribeTagsResult describeTagsResult = new com.amazonaws.services.elasticloadbalancing.model.DescribeTagsResult(); List<TagDescription> tagsList = new ArrayList<TagDescription>(); TagDescription tagDescription = new TagDescription(); tagDescription.setLoadBalancerName("loadBalancerName"); tagDescription.setTags(new ArrayList<com.amazonaws.services.elasticloadbalancing.model.Tag>()); tagsList.add(tagDescription); describeTagsResult.setTagDescriptions(tagsList); when(elbClient.describeTags(anyObject())).thenReturn(describeTagsResult); assertThat(inventoryUtil.fetchClassicElbInfo(new BasicSessionCredentials("awsAccessKey", "awsSecretKey", "sessionToken"), "skipRegions", "account","accountName").size(), is(1)); }
Example #9
Source File: InventoryUtil.java From pacbot with Apache License 2.0 | 5 votes |
/** * Fetch target groups. * * @param temporaryCredentials the temporary credentials * @param skipRegions the skip regions * @param accountId the accountId * @param accountName the account name * @return the map */ public static Map<String,List<TargetGroupVH>> fetchTargetGroups(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName){ com.amazonaws.services.elasticloadbalancingv2.AmazonElasticLoadBalancing elbClient ; Map<String,List<TargetGroupVH>> targetGrpMap = new LinkedHashMap<>(); String expPrefix = InventoryConstants.ERROR_PREFIX_CODE+accountId + "\",\"Message\": \"Exception in fetching info for resource in specific region\" ,\"type\": \"Target Group\" , \"region\":\"" ; for(Region region : RegionUtils.getRegions()){ try{ if(!skipRegions.contains(region.getName())){ elbClient = com.amazonaws.services.elasticloadbalancingv2.AmazonElasticLoadBalancingClientBuilder.standard(). withCredentials(new AWSStaticCredentialsProvider(temporaryCredentials)).withRegion(region.getName()).build(); String nextMarker = null; List<TargetGroupVH> targetGrpList = new ArrayList<>(); do{ DescribeTargetGroupsResult trgtGrpRslt = elbClient.describeTargetGroups(new DescribeTargetGroupsRequest().withMarker(nextMarker)); List<TargetGroup> targetGrpListTemp = trgtGrpRslt.getTargetGroups(); for(TargetGroup tg : targetGrpListTemp) { DescribeTargetHealthResult rslt = elbClient.describeTargetHealth(new DescribeTargetHealthRequest().withTargetGroupArn(tg.getTargetGroupArn())); targetGrpList.add(new TargetGroupVH(tg, rslt.getTargetHealthDescriptions())); } nextMarker = trgtGrpRslt.getNextMarker(); }while(nextMarker!=null); if( !targetGrpList.isEmpty() ) { log.debug(InventoryConstants.ACCOUNT + accountId +" Type : Target Group " +region.getName() + "-"+targetGrpList.size()); targetGrpMap.put(accountId+delimiter+accountName+delimiter+region.getName(), targetGrpList); } } }catch(Exception e){ log.warn(expPrefix+ region.getName()+InventoryConstants.ERROR_CAUSE +e.getMessage()+"\"}"); ErrorManageUtil.uploadError(accountId,region.getName(),"targetgroup",e.getMessage()); } } return targetGrpMap; }
Example #10
Source File: PublicAccessAutoFix.java From pacbot with Apache License 2.0 | 5 votes |
/** * Apply security groups to app ELB. * * @param amazonApplicationElasticLoadBalancing the amazon application elastic load balancing * @param sgIdToBeAttached the sg id to be attached * @param resourceId the resource id * @return true, if successful * @throws Exception the exception */ public static boolean applySecurityGroupsToAppELB(com.amazonaws.services.elasticloadbalancingv2.AmazonElasticLoadBalancing amazonApplicationElasticLoadBalancing,Set<String> sgIdToBeAttached, String resourceId) throws Exception { boolean applysgFlg = false; try { SetSecurityGroupsRequest groupsRequest = new SetSecurityGroupsRequest(); groupsRequest.setSecurityGroups(sgIdToBeAttached); groupsRequest.setLoadBalancerArn(resourceId); amazonApplicationElasticLoadBalancing.setSecurityGroups(groupsRequest); applysgFlg = true; } catch (Exception e) { logger.error("Apply Security Group operation failed for app ELB {}", resourceId); throw new Exception(e); } return applysgFlg; }
Example #11
Source File: PublicAccessAutoFix.java From pacbot with Apache License 2.0 | 5 votes |
/** * Apply security groups to classic ELB. * * @param amazonClassicElasticLoadBalancing the amazon classic elastic load balancing * @param sgIdToBeAttached the sg id to be attached * @param resourceId the resource id * @return true, if successful * @throws Exception the exception */ public static boolean applySecurityGroupsToClassicELB(AmazonElasticLoadBalancing amazonClassicElasticLoadBalancing, List<String> sgIdToBeAttached, String resourceId) throws Exception { boolean applysgFlg = false; try { ApplySecurityGroupsToLoadBalancerRequest groupsRequest = new ApplySecurityGroupsToLoadBalancerRequest(); groupsRequest.setSecurityGroups(sgIdToBeAttached); groupsRequest.setLoadBalancerName(resourceId); amazonClassicElasticLoadBalancing.applySecurityGroupsToLoadBalancer(groupsRequest); applysgFlg = true; } catch (Exception e) { logger.error("Apply Security Group operation failed for classic ELB {}",resourceId); return applysgFlg; } return applysgFlg; }
Example #12
Source File: PublicAccessAutoFix.java From pacbot with Apache License 2.0 | 5 votes |
/** * Gets the sg list for classic elb resource. * * @param clientMap the client map * @param resourceId the resource id * @return the sg list for classic elb resource * @throws Exception the exception */ public static List<String> getSgListForClassicElbResource(Map<String,Object> clientMap,String resourceId) throws Exception { AmazonElasticLoadBalancing amazonApplicationElasticLoadBalancing = (AmazonElasticLoadBalancing) clientMap.get("client"); com.amazonaws.services.elasticloadbalancing.model.DescribeLoadBalancersRequest describeLoadBalancersRequest = new com.amazonaws.services.elasticloadbalancing.model.DescribeLoadBalancersRequest(); describeLoadBalancersRequest.setLoadBalancerNames(Arrays.asList(resourceId)); com.amazonaws.services.elasticloadbalancing.model.DescribeLoadBalancersResult balancersResult = amazonApplicationElasticLoadBalancing.describeLoadBalancers(describeLoadBalancersRequest); List<LoadBalancerDescription> balancers = balancersResult.getLoadBalancerDescriptions(); return balancers.get(0).getSecurityGroups(); }
Example #13
Source File: PublicAccessAutoFix.java From pacbot with Apache License 2.0 | 5 votes |
/** * Gets the sg list for app elb resource. * * @param clientMap the client map * @param resourceId the resource id * @return the sg list for app elb resource * @throws Exception the exception */ public static List<String> getSgListForAppElbResource(Map<String,Object> clientMap,String resourceId) throws Exception { com.amazonaws.services.elasticloadbalancingv2.AmazonElasticLoadBalancing amazonApplicationElasticLoadBalancing = (com.amazonaws.services.elasticloadbalancingv2.AmazonElasticLoadBalancing) clientMap.get("client"); DescribeLoadBalancersRequest describeLoadBalancersRequest = new DescribeLoadBalancersRequest(); describeLoadBalancersRequest.setLoadBalancerArns(Arrays.asList(resourceId)); DescribeLoadBalancersResult balancersResult = amazonApplicationElasticLoadBalancing.describeLoadBalancers(describeLoadBalancersRequest); List<LoadBalancer> balancers = balancersResult.getLoadBalancers(); return balancers.get(0).getSecurityGroups(); }
Example #14
Source File: InventoryUtil.java From pacbot with Apache License 2.0 | 4 votes |
/** * Fetch elb info. * * @param temporaryCredentials the temporary credentials * @param skipRegions the skip regions * @param accountId the accountId * @param accountName the account name * @return the map */ public static Map<String,List<LoadBalancerVH>> fetchElbInfo(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName){ com.amazonaws.services.elasticloadbalancingv2.AmazonElasticLoadBalancing elbClient ; Map<String,List<LoadBalancerVH>> elbMap = new LinkedHashMap<>(); String expPrefix = InventoryConstants.ERROR_PREFIX_CODE+accountId + "\",\"Message\": \"Exception in fetching info for resource in specific region\" ,\"type\": \"Application ELB\" , \"region\":\"" ; for(Region region : RegionUtils.getRegions()){ try{ if(!skipRegions.contains(region.getName())){ elbClient = com.amazonaws.services.elasticloadbalancingv2.AmazonElasticLoadBalancingClientBuilder.standard(). withCredentials(new AWSStaticCredentialsProvider(temporaryCredentials)).withRegion(region.getName()).build(); String nextMarker = null; DescribeLoadBalancersResult descElbRslt ; List<LoadBalancer> elbList = new ArrayList<>(); do{ descElbRslt = elbClient.describeLoadBalancers(new com.amazonaws.services.elasticloadbalancingv2.model.DescribeLoadBalancersRequest().withMarker(nextMarker)); elbList.addAll(descElbRslt.getLoadBalancers()); nextMarker = descElbRslt.getNextMarker(); }while(nextMarker!=null); if(! elbList.isEmpty() ) { List<LoadBalancerVH> elbListTemp = new ArrayList<>(); List<String> elbArns = elbList.stream().map(LoadBalancer::getLoadBalancerArn).collect(Collectors.toList()); List<com.amazonaws.services.elasticloadbalancingv2.model.TagDescription> tagDescriptions = new ArrayList<>(); int i = 0; List<String> elbArnsTemp = new ArrayList<>(); for(String elbArn : elbArns){ i++; elbArnsTemp.add(elbArn); if(i%20 == 0){ tagDescriptions.addAll(elbClient.describeTags(new com.amazonaws.services.elasticloadbalancingv2.model.DescribeTagsRequest().withResourceArns(elbArnsTemp)).getTagDescriptions()); elbArnsTemp = new ArrayList<>(); } } if(!elbArnsTemp.isEmpty()) tagDescriptions.addAll(elbClient.describeTags(new com.amazonaws.services.elasticloadbalancingv2.model.DescribeTagsRequest().withResourceArns(elbArnsTemp)).getTagDescriptions()); elbList.parallelStream().forEach(elb-> { List<List<com.amazonaws.services.elasticloadbalancingv2.model.Tag>> tagsInfo = tagDescriptions.stream().filter(tag -> tag.getResourceArn().equals( elb.getLoadBalancerArn())).map(x-> x.getTags()).collect(Collectors.toList()); List<com.amazonaws.services.elasticloadbalancingv2.model.Tag> tags = new ArrayList<>(); //****** Changes For Federated Rules Start ****** String name = elb.getLoadBalancerArn(); String accessLogBucketName = ""; boolean accessLog = false; if (name != null) { com.amazonaws.services.elasticloadbalancingv2.AmazonElasticLoadBalancing appElbClient = com.amazonaws.services.elasticloadbalancingv2.AmazonElasticLoadBalancingClientBuilder .standard() .withCredentials(new AWSStaticCredentialsProvider(temporaryCredentials)) .withRegion(region.getName()).build(); com.amazonaws.services.elasticloadbalancingv2.model.DescribeLoadBalancerAttributesRequest request1 = new com.amazonaws.services.elasticloadbalancingv2.model.DescribeLoadBalancerAttributesRequest() .withLoadBalancerArn(name); List<LoadBalancerAttribute> listAccessLogBucketAttri = appElbClient .describeLoadBalancerAttributes(request1).getAttributes(); for (LoadBalancerAttribute help : listAccessLogBucketAttri) { String attributeBucketKey = help.getKey(); String attributeBucketValue = help.getValue(); if (attributeBucketKey.equalsIgnoreCase("access_logs.s3.enabled") && attributeBucketValue.equalsIgnoreCase("true")) { accessLog = true; } if ((attributeBucketKey.equalsIgnoreCase("access_logs.s3.bucket") && attributeBucketValue != null)) { accessLogBucketName = attributeBucketValue; } } //****** Changes For Federated Rules End ****** if(!tagsInfo.isEmpty()) tags = tagsInfo.get(0); LoadBalancerVH elbTemp = new LoadBalancerVH(elb, tags, accessLogBucketName, accessLog); synchronized(elbListTemp){ elbListTemp.add(elbTemp); } } }); log.debug(InventoryConstants.ACCOUNT + accountId +" Type : Application ELB " +region.getName() + " >> "+elbListTemp.size()); elbMap.put(accountId+delimiter+accountName+delimiter+region.getName(),elbListTemp); } } }catch(Exception e){ log.warn(expPrefix+ region.getName()+InventoryConstants.ERROR_CAUSE +e.getMessage()+"\"}"); ErrorManageUtil.uploadError(accountId,region.getName(),"appelb",e.getMessage()); } } return elbMap; }
Example #15
Source File: EucaAwsClientFactory.java From primecloud-controller with GNU General Public License v2.0 | 4 votes |
/** * {@inheritDoc} */ @Override public AmazonElasticLoadBalancing createElbClient(String awsAccessId, String awsSecretKey) { return elbClient; }
Example #16
Source File: AwsProcessClientFactory.java From primecloud-controller with GNU General Public License v2.0 | 4 votes |
protected AwsProcessClient createAwsClient(Platform platform, PlatformAws platformAws, AwsCertificate awsCertificate) { AwsClientFactory factory; if (BooleanUtils.isTrue(platformAws.getEuca())) { factory = new EucaAwsClientFactory(); } else { factory = new AmazonAwsClientFactory(); } factory.setHost(platformAws.getHost()); factory.setPort(platformAws.getPort()); factory.setSecure(platformAws.getSecure()); if (BooleanUtils.isTrue(platform.getProxy())) { Proxy proxy = proxyDao.read(); factory.setProxyHost(proxy.getHost()); factory.setProxyPort(proxy.getPort()); factory.setProxyUser(proxy.getUser()); factory.setProxyPassword(proxy.getPassword()); } // Clientの作成 AmazonEC2 ec2Client = factory.createEc2Client(awsCertificate.getAwsAccessId(), awsCertificate.getAwsSecretKey()); AmazonElasticLoadBalancing elbClient = factory.createElbClient(awsCertificate.getAwsAccessId(), awsCertificate.getAwsSecretKey()); // ログ出力用Clientでラップ String logging = StringUtils.defaultIfEmpty(Config.getProperty("aws.logging"), "false"); if (BooleanUtils.toBoolean(logging)) { LoggingAwsClientWrapper loggingAwsClientWrapper = new LoggingAwsClientWrapper(); ec2Client = loggingAwsClientWrapper.wrap(ec2Client); elbClient = loggingAwsClientWrapper.wrap(elbClient); } // 同期実行用Clientでラップ String sync = StringUtils.defaultIfEmpty(Config.getProperty("aws.synchronized"), "true"); if (BooleanUtils.toBoolean(sync)) { SynchronizedAwsClientWrapper synchronizedAwsClientWrapper = new SynchronizedAwsClientWrapper(); ec2Client = synchronizedAwsClientWrapper.wrap(ec2Client); elbClient = synchronizedAwsClientWrapper.wrap(elbClient); } AwsProcessClient client = new AwsProcessClient(awsCertificate.getUserNo(), platform, platformAws, ec2Client, elbClient); String describeInterval = Config.getProperty("aws.describeInterval"); client.setDescribeInterval(NumberUtils.toInt(describeInterval, 15)); return client; }
Example #17
Source File: AwsProcessClient.java From primecloud-controller with GNU General Public License v2.0 | 4 votes |
public AmazonElasticLoadBalancing getElbClient() { return elbClient; }
Example #18
Source File: AwsProcessClient.java From primecloud-controller with GNU General Public License v2.0 | 3 votes |
/** * TODO: コンストラクタコメント * * @param userNo * @param platform * @param platformAws * @param ec2Client * @param elbClient */ public AwsProcessClient(Long userNo, Platform platform, PlatformAws platformAws, AmazonEC2 ec2Client, AmazonElasticLoadBalancing elbClient) { this.userNo = userNo; this.platform = platform; this.platformAws = platformAws; this.ec2Client = ec2Client; this.elbClient = elbClient; }
Example #19
Source File: AwsClientFactory.java From primecloud-controller with GNU General Public License v2.0 | votes |
public abstract AmazonElasticLoadBalancing createElbClient(String awsAccessId, String awsSecretKey);