Showing
1 changed file
with
14 additions
and
7 deletions
1 | package com.monitor.cmdb.ctrl; | 1 | package com.monitor.cmdb.ctrl; |
2 | 2 | ||
3 | +import com.amazonaws.regions.Regions; | ||
4 | +import com.amazonaws.services.autoscaling.AmazonAutoScaling; | ||
5 | +import com.amazonaws.services.autoscaling.AmazonAutoScalingClient; | ||
6 | +import com.amazonaws.services.elasticloadbalancingv2.model.SetSecurityGroupsRequest; | ||
7 | +import com.yoho.ops.cmdb.aws.AwsClientFactory; | ||
3 | import com.yoho.ops.cmdb.aws.lb.AwsApplicationLoadBalanceFetcher; | 8 | import com.yoho.ops.cmdb.aws.lb.AwsApplicationLoadBalanceFetcher; |
4 | import com.yoho.ops.cmdb.domain.BaseResponse; | 9 | import com.yoho.ops.cmdb.domain.BaseResponse; |
5 | import com.yoho.ops.cmdb.models.LoadBalance; | 10 | import com.yoho.ops.cmdb.models.LoadBalance; |
@@ -22,8 +27,9 @@ import java.util.List; | @@ -22,8 +27,9 @@ import java.util.List; | ||
22 | public class NwtmCtrl { | 27 | public class NwtmCtrl { |
23 | @Autowired | 28 | @Autowired |
24 | private AwsApplicationLoadBalanceFetcher awsApplicationLoadBalanceFetcher; | 29 | private AwsApplicationLoadBalanceFetcher awsApplicationLoadBalanceFetcher; |
25 | - /*@Autowired | ||
26 | - AWSClientComp awsClientComp;*/ | 30 | + |
31 | + @Autowired | ||
32 | + private AwsClientFactory awsClientFactory; | ||
27 | 33 | ||
28 | //运行外网访问的安全组id | 34 | //运行外网访问的安全组id |
29 | private String YOHO_ELB_ID="XXXXX"; | 35 | private String YOHO_ELB_ID="XXXXX"; |
@@ -82,11 +88,12 @@ public class NwtmCtrl { | @@ -82,11 +88,12 @@ public class NwtmCtrl { | ||
82 | resetFlag=true; | 88 | resetFlag=true; |
83 | } | 89 | } |
84 | } | 90 | } |
85 | - /* if(resetFlag){ | ||
86 | - AmazonAutoScaling client = new AmazonAutoScalingClient(awsClientComp.getAWSCredentials()); | ||
87 | - client.setRegion(awsClientComp.getRegion(Regions.CN_NORTH_1)); | ||
88 | - SetSecurityGroupsRequest request=new SetSecurityGroupsRequest(); | ||
89 | - }*/ | 91 | + if(resetFlag){ |
92 | + SetSecurityGroupsRequest request=new SetSecurityGroupsRequest(); | ||
93 | + request.setSecurityGroups(securityGroups); | ||
94 | + awsClientFactory.getALBClient().setSecurityGroups(request); | ||
95 | + | ||
96 | + } | ||
90 | return new BaseResponse(); | 97 | return new BaseResponse(); |
91 | } | 98 | } |
92 | } | 99 | } |
-
Please register or login to post a comment