Exemplo n.º 1
0
def run():
    helptext = """
    {} <command> <config>

    Where <command> is one of:

        list:   list all stacks in AWS
        create: create or update the stack (same as 'update')
        update: create or update the stack (same as 'create')
        show:   displays the generated template in the base format (usually YAML) without converting it to JSON
        test:   builds, tests and displays the generated stack template (JSON), does not change any resources
        delete: delete the stack on AWS
        convert: convert a JSON file to YAML syntax

    And <config> it the path of a config.py file.
    """.format(get_args(0))
    if len(sys.argv) == 1:
        print(helptext)
        sys.exit(1)
    operation = get_args(1)
    config_file = get_args(2)
    config = get_settings(config_file)

    try:
        if not operation:
            print(helptext)
            sys.exit(0)
        elif operation in ('convert'):
            convert_json_to_yaml(config)
            sys.exit(0)
        elif operation in ('show', 'display'):
            display_yaml(config)
            sys.exit(0)

        password = get_password(config)
        if operation == 'list':
            list_stacks(config, password)
            sys.exit(0)
        elif operation in ('create', 'make', 'update', 'run', 'start'):
            create_or_update(config, password)
            sys.exit(0)
        elif operation in ('norun', 'test'):
            create_or_update(config, password, run=False)
            sys.exit(0)
        elif operation in ('kill', 'destroy', 'eradicate', 'delete', 'erase',
                           'inhume'):
            delete_stack(config, password)
            sys.exit(0)
        else:
            print(helptext)
            sys.exit(1)
    except boto.exception.BotoServerError, e:
        print("\nERROR:\n\t{}".format(e.error_message))
        sys.exit(42)
Exemplo n.º 2
0
Arquivo: run.py Projeto: hinnerk/cftpl
def run():
    helptext = """
    {} <command> <config>

    Where <command> is one of:

        list:   list all stacks in AWS
        create: create or update the stack (same as 'update')
        update: create or update the stack (same as 'create')
        show:   displays the generated template in the base format (usually YAML) without converting it to JSON
        test:   builds, tests and displays the generated stack template (JSON), does not change any resources
        delete: delete the stack on AWS
        convert: convert a JSON file to YAML syntax

    And <config> it the path of a config.py file.
    """.format(get_args(0))
    if len(sys.argv) == 1:
        print(helptext)
        sys.exit(1)
    operation = get_args(1)
    config_file = get_args(2)
    config = get_settings(config_file)

    try:
        if not operation :
            print(helptext)
            sys.exit(0)
        elif operation in ('convert'):
            convert_json_to_yaml(config)
            sys.exit(0)
        elif operation in ('show', 'display'):
            display_yaml(config)
            sys.exit(0)

        password = get_password(config)
        if operation == 'list':
            list_stacks(config, password)
            sys.exit(0)
        elif operation in ('create', 'make', 'update', 'run', 'start'):
            create_or_update(config, password)
            sys.exit(0)
        elif operation in ('norun', 'test'):
            create_or_update(config, password, run=False)
            sys.exit(0)
        elif operation in ('kill', 'destroy', 'eradicate', 'delete', 'erase', 'inhume'):
            delete_stack(config, password)
            sys.exit(0)
        else:
            print(helptext)
            sys.exit(1)
    except boto.exception.BotoServerError, e:
        print("\nERROR:\n\t{}".format(e.error_message))
        sys.exit(42)
Exemplo n.º 3
0
 def setUp(self):
     self.boto_patch = patch('boto.connect_cloudformation')
     self.boto_mock = self.boto_patch.start()
     self.test_config = get_settings('testdata/config.py')
     self.test_password = '******'
Exemplo n.º 4
0
 def setUp(self):
     self.boto_patch = patch('boto.connect_cloudformation')
     self.boto_mock = self.boto_patch.start()
     self.test_config = get_settings('testdata/config.py')
     self.test_password = '******'
Exemplo n.º 5
0
 def setUp(self):
     self.example_config = get_settings('testdata/config.py')
     self.test_result_json = open(os.path.join(self.example_config['TEMPLATE_PATH'], 'output.json')).read()
     self.test_result = json.loads(self.test_result_json)
Exemplo n.º 6
0
 def setUp(self):
     self.cfstack_patch = patch('cftpl.run.CFStack')
     self.cfstack_mock = self.cfstack_patch.start()
     self.test_config = get_settings('testdata/config.py')
     self.test_password = '******'
Exemplo n.º 7
0
 def setUp(self):
     self.example_config = get_settings("testdata/config.py")
     self.test_result_json = open(os.path.join(self.example_config["TEMPLATE_PATH"], "output.json")).read()
     self.test_result = json.loads(self.test_result_json)
Exemplo n.º 8
0
 def setUp(self):
     self.cfstack_patch = patch('cftpl.run.CFStack')
     self.cfstack_mock = self.cfstack_patch.start()
     self.test_config = get_settings('testdata/config.py')
     self.test_password = '******'