##// END OF EJS Templates
automation: don't create resources when deleting things...
Gregory Szorc -
r42463:dd6a9723 default
parent child Browse files
Show More
@@ -53,7 +53,7 class HGAutomation:
53
53
54 return password
54 return password
55
55
56 def aws_connection(self, region: str):
56 def aws_connection(self, region: str, ensure_ec2_state: bool=True):
57 """Obtain an AWSConnection instance bound to a specific region."""
57 """Obtain an AWSConnection instance bound to a specific region."""
58
58
59 return AWSConnection(self, region)
59 return AWSConnection(self, region, ensure_ec2_state=ensure_ec2_state)
@@ -180,7 +180,7 Install-WindowsFeature -Name Net-Framewo
180 class AWSConnection:
180 class AWSConnection:
181 """Manages the state of a connection with AWS."""
181 """Manages the state of a connection with AWS."""
182
182
183 def __init__(self, automation, region: str):
183 def __init__(self, automation, region: str, ensure_ec2_state: bool=True):
184 self.automation = automation
184 self.automation = automation
185 self.local_state_path = automation.state_path
185 self.local_state_path = automation.state_path
186
186
@@ -191,9 +191,10 class AWSConnection:
191 self.ec2resource = self.session.resource('ec2')
191 self.ec2resource = self.session.resource('ec2')
192 self.iamclient = self.session.client('iam')
192 self.iamclient = self.session.client('iam')
193 self.iamresource = self.session.resource('iam')
193 self.iamresource = self.session.resource('iam')
194 self.security_groups = {}
194
195
196 if ensure_ec2_state:
195 ensure_key_pairs(automation.state_path, self.ec2resource)
197 ensure_key_pairs(automation.state_path, self.ec2resource)
196
197 self.security_groups = ensure_security_groups(self.ec2resource)
198 self.security_groups = ensure_security_groups(self.ec2resource)
198 ensure_iam_state(self.iamresource)
199 ensure_iam_state(self.iamresource)
199
200
@@ -95,12 +95,12 def build_all_windows_packages(hga: HGAu
95
95
96
96
97 def terminate_ec2_instances(hga: HGAutomation, aws_region):
97 def terminate_ec2_instances(hga: HGAutomation, aws_region):
98 c = hga.aws_connection(aws_region)
98 c = hga.aws_connection(aws_region, ensure_ec2_state=False)
99 aws.terminate_ec2_instances(c.ec2resource)
99 aws.terminate_ec2_instances(c.ec2resource)
100
100
101
101
102 def purge_ec2_resources(hga: HGAutomation, aws_region):
102 def purge_ec2_resources(hga: HGAutomation, aws_region):
103 c = hga.aws_connection(aws_region)
103 c = hga.aws_connection(aws_region, ensure_ec2_state=False)
104 aws.remove_resources(c)
104 aws.remove_resources(c)
105
105
106
106
General Comments 0
You need to be logged in to leave comments. Login now