def list_users_for_group(ctx, from_json, compartment_id, group_id, page, limit, all_pages, page_size): cli_util.load_context_obj_values_from_defaults(ctx) if all_pages and limit: raise click.UsageError( 'If you provide the --all option you cannot provide the --limit option' ) client = cli_util.build_client('identity', 'identity', ctx) args = {} args['group_id'] = group_id if page is not None: args['page'] = page if limit is not None: args['limit'] = limit if all_pages: if page_size: args['limit'] = page_size result = cli_util.list_call_get_all_results( client.list_user_group_memberships, compartment_id=compartment_id, **args) elif limit is not None: result = cli_util.list_call_get_up_to_limit( client.list_user_group_memberships, limit, page_size, compartment_id=compartment_id, **args) else: result = client.list_user_group_memberships( compartment_id=compartment_id, **args) users = [] for membership in result.data: users.append(client.get_user(membership.user_id).data) cli_util.render(users, result.headers, ctx)
def nfs_dataset_seal(ctx, from_json, wait, name, appliance_profile): """ 1. Get the datasets. Since there is only one dataset, deactivate it if present, else throw a not found error 2. If the dataset is ACTIVE, deactivate it 3. Seal the dataset """ nfs_dataset_client = create_nfs_dataset_client(ctx, appliance_profile) click.echo( "Initiating Seal .... \n(Track progress using 'oci dts nfs-dataset seal-status' command)" ) click.echo("Fetching all the datasets ...\n") nfs_datasets = nfs_dataset_client.list_nfs_datasets().data if len(nfs_datasets) < 1: raise exceptions.ClientError( "No datasets exist. Create a Dataset first") nfs_dataset = nfs_datasets[0] if name is not None: if name != nfs_dataset['name']: raise exceptions.ClientError( "The dataset {} does not exist".format(name)) name = nfs_dataset['name'] if nfs_dataset['state'] == NfsDatasetInfo.STATE_ACTIVE: click.echo("Deactivating the dataset {}".format(name)) nfs_dataset_client.deactivate_nfs_dataset(name) click.echo("Triggering seal on dataset {}".format(name)) click.echo( "This performs a pre-walk of the file system to check for invalid files before walking again " "to do the actual seal. This process can be time consuming depending on the size and number of files. " "Progress will be displayed once the pre-walk is done.") nfs_dataset_client.initiate_seal_on_nfs_dataset(name) seal_status = nfs_dataset_client.get_nfs_dataset_seal_status(name).data if wait: _seal_progress_display(seal_status) while seal_status['completed'] is None or not seal_status['completed']: time.sleep(0.5) seal_status = nfs_dataset_client.get_nfs_dataset_seal_status( name).data _seal_progress_display(seal_status) cli_util.render(seal_status, None, ctx)
def patch_database(ctx, **kwargs): client = cli_util.build_client('database', ctx) response = client.get_database(kwargs['database_id']) db_home_id = response.data.db_home_id patch_details = oci.database.models.PatchDetails() patch_details.action = kwargs['patch_action'] patch_details.patch_id = kwargs['patch_id'] update_db_home_details = oci.database.models.UpdateDbHomeDetails() update_db_home_details.db_version = patch_details client.update_db_home(db_home_id, update_db_home_details) # update_db_home returns the DbHome, so we need to get the # corresponding database and print that out for the user result = client.get_database(kwargs['database_id']) database = result.data cli_util.render(database, None, ctx)