Support Questions

Find answers, ask questions, and share your expertise

config.py script - how to disable json file creation

avatar

when we set new values by the config.py script

script created also the file ( example - doSet_version1522153623088712.json )

is it possoible to flag the script in way to disable this file creation ?

/var/lib/ambari-server/resources/scripts/configs.py --user=admin --password=admin  --port=8080 --action=set --host=master02 --cluster=hdp  --config-type=spark2-thrift-sparkconf -k spark.executor.instances -v 8

ls


doSet_version1522153623088712.json
Michael-Bronson
1 ACCEPTED SOLUTION

avatar
Super Guru

@Michael Bronson,

There is no such flag with which the file creation can be disabled. If you want to write to a existing valid file, you can pass the file name using -f option.

.

-Aditya

View solution in original post

5 REPLIES 5

avatar
Super Guru

@Michael Bronson,

There is no such flag with which the file creation can be disabled. If you want to write to a existing valid file, you can pass the file name using -f option.

.

-Aditya

avatar

if we cant block the file creation then is it possible to write this file on other folder as /var/tmp insted my curent folder ?

Michael-Bronson

avatar

just to explain my case , when we run the script more then 100 times then 100 json file created , so we want to avoid the files creation because we run the script under /.../.../sbin folder

Michael-Bronson

avatar
Super Guru

@Michael Bronson,

It is not supported by the script by default. But you can add a line to the script and make it work. Assume you want to store output in /tmp/myconfigs

mkdir /tmp/myconfigs
chmod 777 /tmp/myconfigs

Modify the script as below. Find the function 'output_to_file' and the below line

filename = os.path.join('/tmp','myconfigs',filename)

The function should look like below. Make sure indentation is proper. Python has strict checking for indentation

def output_to_file(filename):
  filename = os.path.join('/tmp','myconfigs',filename)
  def output(config):
    with open(filename, 'w') as out_file:
      json.dump(config, out_file, indent=2)
  return output

avatar
@Michael Bronson

Try commenting the below line in configs.py

    118   #output_to_file(new_file)(new_config)

I did a basic validation and it works. PUT option alone creates output file by default and GET has a flag -f.

We are basically commenting the PUT operations output file.