def deploy(name, tasks, noinput, args): print_header() if tasks: fab.display_fabric_tasks() sys.exit(0) else: print("Generating fab deploy command...") cmd = ['fab', 'setup:config={0}'.format(name)] if args: cmd.extend(args) else: config = load_config(name) dvcs_type = config.get('dvcs') if dvcs_type.lower() == 'git': default_branch = 'master' elif dvcs_type.lower() == 'hg': default_branch = 'default' else: print("Unsupported or missing DVCS") sys.exit(1) cmd.append('deploy:branch={0}'.format(default_branch)) print('Executing: {0}'.format(' '.join(cmd))) if noinput or query_yes_no("Do you want to continue?", default="no"): subprocess.call(cmd)
def init(name): print_header() if os.path.exists(name): print('File already exists, exiting...') sys.exit(1) app_type = query_options('Type of application', 'python', 'javascript') dvcs = query_options('Source Control version', 'git', 'hg') profile_name = raw_input('AWS Profile to use: ') profile_exists = AWSProfile.exists(profile_name) if not profile_exists: should_create_profile = query_yes_no('Do you want to create this profile?: ') if not should_create_profile: sys.exit(1) access_key_id = raw_input('AWS Access Key Id: ') access_secret_key = raw_input('AWS Secret Access Key: ') AWSProfile.save(profile_name, access_key_id, access_secret_key) config_values = {} config_template = Config.load_from_template() for key, components in config_template.iteritems(): if key in ['bifrost', 'application', 'dvcs']: continue if key == 'roles': print('Roles...') config_values['roles'] = {} number_of_roles = raw_input('Number required: ') for i in range(0, int(number_of_roles)): builder = ConfigBuilder('role {0}'.format(i), {'name': '', 'tag-key': 'my-role'}) values = builder.prompt_user() role_name = values.pop('name') config_values['roles'][role_name] = values else: builder = ConfigBuilder(key, components) if key == 'connection': builder.change_question('aws_profile', skip=True) elif key == 'deployment': builder.change_question('base_dir', required=True) elif key == 'repository': builder.change_question('repository', required=True) config_values[key] = builder.prompt_user() if key == 'repository': config_values[key] = config_values[key][key] if config_values: Config.save(name=name, application_type=app_type, dvcs=dvcs, **config_values) if not os.path.exists(FABRIC_FILE_NAME): Fabric.save(FABRIC_FILE_NAME, roles=list(config_values['roles'].iterkeys())) else: print('No configuration loaded')
def deploy(name, tasks, args): print_header() if tasks: fab.display_fabric_tasks() sys.exit(0) else: print("Generating fab deploy command...") cmd = ['fab'] cmd.append('setup:config={0}'.format(name)) if args: cmd.extend(args) else: cmd.append('deploy:branch=default') print('Executing: {0}'.format(' '.join(cmd))) if query_yes_no("Do you want to continue?", default="no"): subprocess.call(cmd)