Add tool to merge passwords during release upgrade

Typical usage:
   cp /etc/kolla/passwords.yml /etc/kolla/passwords.yml.old
   kolla-genpwd
   kolla-mergepwd --old /etc/kolla/passwords.yml.old \
                  --new /etc/kolla/passwords.yml     \
                  --final /etc/kolla/passwords.yml

Change-Id: Ibbc598909e28e096145841aec929d0cfcf8f7cab
Implements: blueprint kolla-merge-passwords
This commit is contained in:
Vladislav Belogrudov 2016-11-25 15:52:03 +03:00
parent 4aa693f2fd
commit 14f9246fcd
3 changed files with 41 additions and 0 deletions

39
kolla/cmd/mergepwd.py Executable file
View File

@ -0,0 +1,39 @@
#!/usr/bin/env python
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import argparse
import yaml
def main():
parser = argparse.ArgumentParser()
parser.add_argument("--old", help="old password file", required=True)
parser.add_argument("--new", help="new password file", required=True)
parser.add_argument("--final", help="merged password file", required=True)
args = parser.parse_args()
with open(args.old, "r") as old_file:
old_passwords = yaml.safe_load(old_file)
with open(args.new, "r") as new_file:
new_passwords = yaml.safe_load(new_file)
new_passwords.update(old_passwords)
with open(args.final, "w") as destination:
yaml.dump(new_passwords, destination)
if __name__ == '__main__':
main()

View File

@ -43,6 +43,7 @@ scripts =
console_scripts = console_scripts =
kolla-build = kolla.cmd.build:main kolla-build = kolla.cmd.build:main
kolla-genpwd = kolla.cmd.genpwd:main kolla-genpwd = kolla.cmd.genpwd:main
kolla-mergepwd = kolla.cmd.mergepwd:main
oslo.config.opts = oslo.config.opts =
kolla = kolla.opts:list_opts kolla = kolla.opts:list_opts

1
tools/merge_passwords.py Symbolic link
View File

@ -0,0 +1 @@
../kolla/cmd/mergepwd.py