Merge "Added overwrite warning for db_export_metadefs."

This commit is contained in:
Jenkins 2016-11-08 21:27:05 +00:00 committed by Gerrit Code Review
commit 09ca445222
2 changed files with 6 additions and 2 deletions

View File

@ -57,11 +57,13 @@ COMMANDS
Place a database under migration control and upgrade, creating
it first if necessary.
**db_export_metadefs**
**db_export_metadefs [PATH | PREFIX]**
Export the metadata definitions into json format. By default the
definitions are exported to /etc/glance/metadefs directory.
**Note: this command will overwrite existing files in the supplied or
default path.**
**db_load_metadefs**
**db_load_metadefs [PATH]**
Load the metadata definitions into glance database. By default the
definitions are imported from /etc/glance/metadefs directory.

View File

@ -464,6 +464,8 @@ def _export_data_to_file(meta, path):
try:
file_name = ''.join([path, namespace_file_name, '.json'])
if isfile(file_name):
LOG.info(_LI("Overwriting: %s"), file_name)
with open(file_name, 'w') as json_file:
json_file.write(json.dumps(values))
except Exception as e: