Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def all_instances(self, **kwargs):
"""
Returns all instances associated with the project (including stopped)
"""
# Looks across all AWS regions, in parallel using a thread pool.
pool = Pool(8)
regions = kwargs.get('regions', REGIONS.keys())
results = pool.map(self.__instances_by_region, regions)
pool.close()
pool.join()
instances = []
for result in results:
for boto_instance in result['instances']:
uuid = boto_instance.tags['uuid']
instance = Instance(
host=self,
uuid=uuid,
project_name=self.project.name,
boto_instance=boto_instance,
size=boto_instance.instance_type,
region=result['region'],
)
instances.append(instance)
def valid_region(self, region):
if region in REGIONS.keys():
self.region = region
else:
raise TypeError("%s is not a valid region" % self.region)