Skip to content

Commit

Permalink
CR changes
Browse files Browse the repository at this point in the history
Signed-off-by: shirady <57721533+shirady@users.noreply.github.com>
  • Loading branch information
shirady committed Feb 18, 2024
1 parent 3127b3e commit 03df133
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 17 deletions.
4 changes: 2 additions & 2 deletions docs/non_containerized_NSFS.md
Original file line number Diff line number Diff line change
Expand Up @@ -467,11 +467,11 @@ sudo node src/cmd/manage_nsfs bucket delete --config_root ../standalon/config_ro
sudo node src/cmd/manage_nsfs bucket list --config_root ../standalon/config_root 2>/dev/null
```
NSFS management CLI command will create both account and bucket dir if it's missing in the config_root path.
NSFS management CLI run will create both accounts, access_keys, and buckets directories if they are missing under the config_root directory.
**Important**: All the Account/Bucket commands end with `2>/dev/null` to make sure there are no unwanted logs.

Using `from_file` flag:
- Users can also pass account or bucket values in JSON file (hereinafter referred to as "options JSON file") instead of passing them in CLI as arguments using flags.
- For account and bucket creation users can also pass account or bucket values in JSON file (hereinafter referred to as "options JSON file") instead of passing them in CLI as arguments using flags.
- General use:
```
sudo node src/cmd/manage_nsfs account add --config_root ../standalon/config_root --from_file <options_JSON_file_path>
Expand Down
7 changes: 4 additions & 3 deletions src/cmd/manage_nsfs.js
Original file line number Diff line number Diff line change
Expand Up @@ -684,8 +684,7 @@ async function get_config_data(config_file_path, show_secrets = false) {
async function get_options_from_file(type, action, file_path) {
const fs_context = native_fs_utils.get_process_fs_context();
try {
const raw_data = (await nb_native().fs.readFile(fs_context, file_path)).data;
const input_options_with_data = JSON.parse(raw_data.toString());
const input_options_with_data = await native_fs_utils.read_file(fs_context, file_path);
const input_options = Object.keys(input_options_with_data);
if (input_options.includes(FROM_FILE)) {
const details = `${FROM_FILE} should not be passed inside json options`;
Expand Down Expand Up @@ -713,7 +712,9 @@ function get_access_keys(action, user_input) {
secret_key: undefined,
}];
let new_access_key;
if (action !== ACTIONS.LIST && action !== ACTIONS.STATUS) _validate_access_keys(user_input.access_key, user_input.secret_key);
if (action === ACTIONS.ADD || action === ACTIONS.UPDATE || action === ACTIONS.DELETE) {
_validate_access_keys(user_input.access_key, user_input.secret_key);
}
if (action === ACTIONS.ADD || action === ACTIONS.STATUS) {
const regenerate = action === ACTIONS.ADD;
access_keys = set_access_keys(user_input.access_key, user_input.secret_key, regenerate);
Expand Down
4 changes: 2 additions & 2 deletions src/manage_nsfs/manage_nsfs_help_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ Flags:
--access_key <string> (optional) Set the access key for the account (default is generated)
--secret_key <string> (optional) Set the secret key for the account (default is generated)
--fs_backend <none | GPFS | CEPH_FS | NFSv4> (optional) Set the filesystem type of new_buckets_path (default config.NSFS_NC_STORAGE_BACKEND)
--from_file <string> (optional) Use details from the JSON file, there is no need to mention all the properties individually in the CLI
--from_file <string> (optional) Use details from the JSON file, other account properties will be ignored
--config_root <string> (optional) Use configuration files path (default config.NSFS_NC_DEFAULT_CONF_DIR)
--config_root_backend <none | GPFS | CEPH_FS | NFSv4> (optional) Use the filesystem type in the configuration (default config.NSFS_NC_CONFIG_DIR_BACKEND)
`;
Expand Down Expand Up @@ -142,7 +142,7 @@ Flags:
--path <string> Set the bucket path
--bucket_policy <string> (optional) Set the bucket policy, type is a string of valid JSON policy
--fs_backend <none | GPFS | CEPH_FS | NFSv4> (optional) Set the filesystem type (default config.NSFS_NC_STORAGE_BACKEND)
--from_file <string> (optional) Use details from the JSON file, there is no need to mention all the properties individually in the CLI
--from_file <string> (optional) Use details from the JSON file, other account properties will be ignored
--config_root <string> (optional) Use configuration files path (default config.NSFS_NC_DEFAULT_CONF_DIR)
--config_root_backend <none | GPFS | CEPH_FS | NFSv4> (optional) Use the filesystem type in the configuration (default config.NSFS_NC_CONFIG_DIR_BACKEND)
`;
Expand Down
6 changes: 3 additions & 3 deletions src/test/unit_tests/test_bucketspace_fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const assert = require('assert');
const P = require('../../util/promise');
const config = require('../../../config');
const fs_utils = require('../../util/fs_utils');
const { get_process_fs_context, read_config_file, get_user_by_distinguished_name} = require('../../util/native_fs_utils');
const { get_process_fs_context, read_file, get_user_by_distinguished_name} = require('../../util/native_fs_utils');
const os_utils = require('../../util/os_utils');

const BucketSpaceFS = require('../../sdk/bucketspace_fs');
Expand Down Expand Up @@ -315,7 +315,7 @@ mocha.describe('bucketspace_fs', function() {
assert.equal(objects.buckets.length, 1);
assert.equal(objects.buckets[0].name.unwrap(), expected_bucket_name);
const bucket_config_path = get_config_file_path(buckets, expected_bucket_name);
const bucket_data = await read_config_file(process_fs_context, bucket_config_path);
const bucket_data = await read_file(process_fs_context, bucket_config_path);
assert.equal(objects.buckets[0].creation_date, bucket_data.creation_date);
});
});
Expand Down Expand Up @@ -392,7 +392,7 @@ mocha.describe('bucketspace_fs', function() {
const param = {name: test_bucket, versioning: 'ENABLED'};
await bucketspace_fs.set_bucket_versioning(param, dummy_object_sdk);
const bucket_config_path = get_config_file_path(buckets, param.name);
const bucket = await read_config_file(process_fs_context, bucket_config_path);
const bucket = await read_file(process_fs_context, bucket_config_path);
assert.equal(bucket.versioning, 'ENABLED');

});
Expand Down
14 changes: 7 additions & 7 deletions src/util/native_fs_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -548,15 +548,15 @@ async function folder_delete(dir, fs_context, is_temp = false) {
}

/**
* read_config_file reads and returns the parsed config file data
* read_config_file reads file and returns the parsed file data as object
* @param {nb.NativeFSContext} fs_context
* @param {string} config_path
* @param {string} _path
* @return {Promise<object>}
*/
async function read_config_file(fs_context, config_path) {
const { data } = await nb_native().fs.readFile(fs_context, config_path);
const config_data = JSON.parse(data.toString());
return config_data;
async function read_file(fs_context, _path) {
const { data } = await nb_native().fs.readFile(fs_context, _path);
const data_parsed = JSON.parse(data.toString());
return data_parsed;
}

exports.get_umasked_mode = get_umasked_mode;
Expand Down Expand Up @@ -584,7 +584,7 @@ exports.gpfs_unlink_retry_catch = gpfs_unlink_retry_catch;
exports.create_config_file = create_config_file;
exports.delete_config_file = delete_config_file;
exports.update_config_file = update_config_file;
exports.read_config_file = read_config_file;
exports.read_file = read_file;
exports.isDirectory = isDirectory;
exports.get_process_fs_context = get_process_fs_context;
exports.get_fs_context = get_fs_context;
Expand Down

0 comments on commit 03df133

Please sign in to comment.