def main(): # Instantiate config object and get settings from CLI args config = provisioner.ConfigManager() config.set_config_from_args() # Get a list of all CSP accounts managed by Halo halo = provisioner.Halo(config) halo.sanity_check() csp_accounts = halo.get_all_csp_accounts() # Get a list of account IDs and account display names from the CSV csv_consumer = provisioner.CsvConsumer(config) csv_tups = csv_consumer.get_account_metadata() # Get lists of accounts to be provisioned and updated blender = provisioner.Blender(csp_accounts, csv_tups) marching_orders = blender.create_change_set() # Perform provisioning in Halo print("Provisioning CSP accounts into Halo group %s with external ID %s." % (config.target_halo_group_id, config.external_id)) for create_target in marching_orders["create"]: print("Provisioning account %s with display name %s" % create_target) if not config.dry_run: halo.provision_csp_account(create_target[0], create_target[1], config.role_name, config.external_id, config.target_halo_group_id) for update_target in marching_orders["update"]: print("Updating account %s with display name %s." % update_target) if not config.dry_run: halo.update_csp_display_name(update_target[0], update_target[1]) return
def bad_file_config(self): """Return a dummy config object with bad file reference.""" config = provisioner.ConfigManager() config.csv_file_location = os.path.join(fixture_dir, "nonexistent.csv") config.account_id_column = "Account ID" config.account_display_name_column = "Account Name" return config
def bad_col_config(self): """Return a dummy config object with bad column references.""" config = provisioner.ConfigManager() config.csv_file_location = os.path.join(fixture_dir, "lin_accts.csv") config.account_id_column = "noname" config.account_display_name_column = "noname" return config
def good_config_wincr(self): """Return a dummy config object for CsvConsumer. CSV contains Windows-style newlines. """ config = provisioner.ConfigManager() config.csv_file_location = os.path.join(fixture_dir, "win_accts.csv") config.account_id_column = "Account ID" config.account_display_name_column = "Account Name" return config
def main(): start_time = datetime.datetime.now() parser = argparse.ArgumentParser() parser.add_argument("mode", help="(provision|deprovision)") args = parser.parse_args() dyn_config = provisioner.ConfigManager(args.mode) if args.mode == "provision": provision(dyn_config) elif args.mode == "deprovision": deprovision(dyn_config) else: msg_str = "Valid modes: 'provision', 'deprovision'" msg = provisioner.Utility() msg.print_aws_status_message(msg_str) sys.exit(3) end_time = datetime.datetime.now() print_status(start_time, end_time)
def instantiate_config_object_nonworking(self): """Return a dummy, non-working config object.""" conf_obj = provisioner.ConfigManager() conf_obj.halo_api_key = "ABC123" conf_obj.halo_api_secret_key = "DEF456" return conf_obj