def create_or_update(config, password, run=True): stack = CFStack(config, password) print('Validating template... ', end='', file=sys.stderr) stack.validate() # raises if defect print('successfull.', file=sys.stderr) if run: if stack.active: print("Updating Stack {}...".format(stack.name), end='', file=sys.stderr) stack.update() print(' done.') else: print("Creating Stack {}...".format(stack.name), end='', file=sys.stderr) stack.create() print(' done.', file=sys.stderr) print_stack_events(stack) return stack # IF WE'RE NOT ACTIVELY CREATING OR UPDATING A STACK, WE'RE SHOWING THE CONFIG INSTEAD: print("This is the configuration we'd use if this was for real:\n\n", file=sys.stderr) if not config['JSON_INDENT']: config['JSON_INDENT'] = 4 template = CFTemplate(config) print(template.create_json()) if config['FILES']: print("\n\nHere are all the files you can use:", file=sys.stderr) for name, path in config['FILES'].iteritems(): print('\t"{}":\t"{}"'.format(name, path), file=sys.stderr) return None
def create_or_update(config, password, run=True): stack = CFStack(config, password) print('Validating template... ', end='', file=sys.stderr) stack.validate() # raises if defect print('successfull.', file=sys.stderr) if run: if stack.active: print("Updating Stack {}...".format(stack.name), end='', file=sys.stderr) stack.update() print(' done.') else: print("Creating Stack {}...".format(stack.name), end='', file=sys.stderr) stack.create() print(' done.', file=sys.stderr) print_stack_events(stack) return stack # IF WE'RE NOT ACTIVELY CREATING OR UPDATING A STACK, WE'RE SHOWING THE CONFIG INSTEAD: print("This is the configuration we'd use if this was for real:\n\n", file=sys.stderr) if not config['JSON_INDENT']: config['JSON_INDENT'] = 4 template = CFTemplate(config) print(template.create_json()) if config['FILES']: print("\n\nHere are all the files you can use:", file=sys.stderr) for name, path in config['FILES'].iteritems(): print('\t"{}":\t"{}"'.format(name, path), file=sys.stderr) return None
def test_update(self): stack = CFStack(self.test_config, self.test_password) result = stack.update() test_result_json = open(os.path.join(self.test_config['TEMPLATE_PATH'], 'output.json')).read() self.boto_mock.return_value.update_stack.assert_called_with(self.test_config['STACK_NAME'], # TODO: Check if equal to test_result_json: template_body=ANY, capabilities=self.test_config['CAPABILITIES'], tags=self.test_config['TAGS'])
def test_update(self): stack = CFStack(self.test_config, self.test_password) result = stack.update() test_result_json = open( os.path.join(self.test_config['TEMPLATE_PATH'], 'output.json')).read() self.boto_mock.return_value.update_stack.assert_called_with( self.test_config['STACK_NAME'], # TODO: Check if equal to test_result_json: template_body=ANY, capabilities=self.test_config['CAPABILITIES'], tags=self.test_config['TAGS'])