Skip to content

Commit

Permalink
Fixes #35 Create accounts in serial rather than parallel
Browse files Browse the repository at this point in the history
  • Loading branch information
rmc3 committed May 30, 2018
1 parent 881364f commit b912bb9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
6 changes: 5 additions & 1 deletion cumulogenesis/models/aws_entities/organization.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,8 @@ def load(self):
if self.source != "aws":
raise exceptions.NotAwsModelException('load()')
self._load_organization()
self._load_stacksets()
# Not yet implemented
#self._load_stacksets()

def _initialize_session_builder(self):
session_builder_params = {}
Expand Down Expand Up @@ -744,6 +745,9 @@ def _load_organization(self):
organization_service.load_policies(organization=self)

def _load_stacksets(self):
'''
Not yet fully implemented
'''
session_builder = self._get_session_builder()
cloudformation_service = CloudformationService(session_builder=session_builder)
cloudformation_service.load_stacksets(organization=self)
Expand Down
26 changes: 13 additions & 13 deletions cumulogenesis/services/organization.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,26 +205,26 @@ def create_accounts(self, organization, accounts):
is asynchronous, it waits until each account finishes creating, then
returns a changes dict for the report.
'''
creation_statuses = {}
changes = {}
for account in accounts:
creation_statuses = {}
logger.info('Creating account %s', account)
create_account_params = {
'Email': organization.accounts[account]['owner'],
'AccountName': organization.accounts[account]['name']}
create_res = self.client.create_account(**create_account_params)
creation_statuses[account] = create_res['CreateAccountStatus']
self._wait_on_account_creation(creation_statuses)
changes = {}
for account, status in creation_statuses.items():
if status['State'] == 'SUCCEEDED':
change = 'created'
elif status['State'] == 'FAILED':
change = 'failed'
else:
change = 'unknown'
changes[account] = {"change": change}
if status == 'failed':
changes[account]['reason'] = status['FailureReason']
self._wait_on_account_creation(creation_statuses)
for account_name, status in creation_statuses.items():
if status['State'] == 'SUCCEEDED':
change = 'created'
elif status['State'] == 'FAILED':
change = 'failed'
else:
change = 'unknown'
changes[account_name] = {"change": change}
if status == 'failed':
changes[account_name]['reason'] = status['FailureReason']
return changes

def move_account(self, organization, account_name, parent_name):
Expand Down

0 comments on commit b912bb9

Please sign in to comment.