Esempio n. 1
0
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
Esempio n. 2
0
File: run.py Progetto: uho/cftpl
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
Esempio n. 3
0
 def test_create(self):
     stack = CFStack(self.test_config, self.test_password)
     result = stack.create()
     self.boto_mock.return_value.create_stack.assert_called_with(self.test_config['STACK_NAME'],
                                                                 template_body=ANY,
                                                                 capabilities=self.test_config['CAPABILITIES'],
                                                                 tags=self.test_config['TAGS'])
Esempio n. 4
0
 def test_create(self):
     stack = CFStack(self.test_config, self.test_password)
     result = stack.create()
     self.boto_mock.return_value.create_stack.assert_called_with(
         self.test_config['STACK_NAME'],
         template_body=ANY,
         capabilities=self.test_config['CAPABILITIES'],
         tags=self.test_config['TAGS'])