Added overwrite warning for db_export_metadefs.
The bug in [1] proposed to always require a directory option for glance-manage db_export_metadefs command. The rationale being that silently overwriting the default path /etc/glance/metadefs can be undesired. However, the feedback was that this command should stay silent in case it's called from cron jobs or automated tasks, and that it's better to simply log a warning and proceed, as well as update the documentation with a cautionary note. This patch addresses that request. [1] https://bugs.launchpad.net/glance/+bug/1367011 Change-Id: Ie8cc4bb3769a6347fd25e2235a72c6358af70d42 Closes-Bug: #1367011
This commit is contained in:
parent
b50cd90f65
commit
9968b0993f
@ -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.
|
||||
|
||||
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user