summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPete Vander Giessen <pete.vandergiessen@canonical.com>2019-01-17 17:45:41 -0500
committerPete Vander Giessen <pete.vandergiessen@canonical.com>2019-01-17 17:45:50 -0500
commit98a5f35b1d7f9fb417ca148cedb32d4e574417fc (patch)
tree826f775bacfe254224c2cf96636c550ef754c030
parent57531582996f2bbf39df999608b581e14baf62e4 (diff)
charmhelpers-sync
Pull in fix for call to ceph-authtool when updating keys. Change-Id: I472cfa91e682d662cae9db4006bdc8b25174a24b Closes-Bug: #1810917
Notes
Notes (review): Verified-1: Canonical CI <uosci-testing-bot@ubuntu.com> Code-Review+2: David Ames <david.ames@canonical.com> Workflow+1: David Ames <david.ames@canonical.com> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Fri, 18 Jan 2019 21:51:42 +0000 Reviewed-on: https://review.openstack.org/631673 Project: openstack/charm-cinder-backup Branch: refs/heads/master
-rw-r--r--hooks/charmhelpers/contrib/storage/linux/ceph.py27
1 files changed, 21 insertions, 6 deletions
diff --git a/hooks/charmhelpers/contrib/storage/linux/ceph.py b/hooks/charmhelpers/contrib/storage/linux/ceph.py
index 7682820..63c9304 100644
--- a/hooks/charmhelpers/contrib/storage/linux/ceph.py
+++ b/hooks/charmhelpers/contrib/storage/linux/ceph.py
@@ -856,12 +856,22 @@ def _keyring_path(service):
856 return KEYRING.format(service) 856 return KEYRING.format(service)
857 857
858 858
859def create_keyring(service, key): 859def add_key(service, key):
860 """Create a new Ceph keyring containing key.""" 860 """
861 Add a key to a keyring.
862
863 Creates the keyring if it doesn't already exist.
864
865 Logs and returns if the key is already in the keyring.
866 """
861 keyring = _keyring_path(service) 867 keyring = _keyring_path(service)
862 if os.path.exists(keyring): 868 if os.path.exists(keyring):
863 log('Ceph keyring exists at %s.' % keyring, level=WARNING) 869 with open(keyring, 'r') as ring:
864 return 870 if key in ring.read():
871 log('Ceph keyring exists at %s and has not changed.' % keyring,
872 level=DEBUG)
873 return
874 log('Updating existing keyring %s.' % keyring, level=DEBUG)
865 875
866 cmd = ['ceph-authtool', keyring, '--create-keyring', 876 cmd = ['ceph-authtool', keyring, '--create-keyring',
867 '--name=client.{}'.format(service), '--add-key={}'.format(key)] 877 '--name=client.{}'.format(service), '--add-key={}'.format(key)]
@@ -869,6 +879,11 @@ def create_keyring(service, key):
869 log('Created new ceph keyring at %s.' % keyring, level=DEBUG) 879 log('Created new ceph keyring at %s.' % keyring, level=DEBUG)
870 880
871 881
882def create_keyring(service, key):
883 """Deprecated. Please use the more accurately named 'add_key'"""
884 return add_key(service, key)
885
886
872def delete_keyring(service): 887def delete_keyring(service):
873 """Delete an existing Ceph keyring.""" 888 """Delete an existing Ceph keyring."""
874 keyring = _keyring_path(service) 889 keyring = _keyring_path(service)
@@ -905,7 +920,7 @@ def get_ceph_nodes(relation='ceph'):
905 920
906def configure(service, key, auth, use_syslog): 921def configure(service, key, auth, use_syslog):
907 """Perform basic configuration of Ceph.""" 922 """Perform basic configuration of Ceph."""
908 create_keyring(service, key) 923 add_key(service, key)
909 create_key_file(service, key) 924 create_key_file(service, key)
910 hosts = get_ceph_nodes() 925 hosts = get_ceph_nodes()
911 with open('/etc/ceph/ceph.conf', 'w') as ceph_conf: 926 with open('/etc/ceph/ceph.conf', 'w') as ceph_conf:
@@ -1068,7 +1083,7 @@ def ensure_ceph_keyring(service, user=None, group=None,
1068 if not key: 1083 if not key:
1069 return False 1084 return False
1070 1085
1071 create_keyring(service=service, key=key) 1086 add_key(service=service, key=key)
1072 keyring = _keyring_path(service) 1087 keyring = _keyring_path(service)
1073 if user and group: 1088 if user and group:
1074 check_call(['chown', '%s.%s' % (user, group), keyring]) 1089 check_call(['chown', '%s.%s' % (user, group), keyring])