diff --git a/doc/source/man/glancemanage.rst b/doc/source/man/glancemanage.rst index 921c645ea4..621bfcad71 100644 --- a/doc/source/man/glancemanage.rst +++ b/doc/source/man/glancemanage.rst @@ -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. diff --git a/glance/db/sqlalchemy/metadata.py b/glance/db/sqlalchemy/metadata.py index dd84f88e80..d5ef53cbaf 100644 --- a/glance/db/sqlalchemy/metadata.py +++ b/glance/db/sqlalchemy/metadata.py @@ -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: