Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ceph-create-keys: fix existing-but-different case #10415

Merged
merged 1 commit into from Sep 15, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
31 changes: 24 additions & 7 deletions src/ceph-create-keys
Expand Up @@ -92,24 +92,41 @@ def get_key(cluster, mon_id):
os.fchmod(f.fileno(), 0600)
os.fchown(f.fileno(), get_ceph_uid(), get_ceph_gid())
LOG.info('Talking to monitor...')
returncode = subprocess.call(
args=[
'ceph',

args_prefix = [
"ceph",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit, s/"/'/ for consistency.

'--cluster={cluster}'.format(cluster=cluster),
'--name=mon.',
'--keyring=/var/lib/ceph/mon/{cluster}-{mon_id}/keyring'.format(
cluster=cluster,
mon_id=mon_id,
),
]

# First try getting the key if it already exists, to handle
# the case where it exists but doesn't match the caps
# we would pass into get-or-create.
returncode = subprocess.call(
args=args_prefix + [
'auth',
'get-or-create',
'get'
'client.admin',
'mon', 'allow *',
'osd', 'allow *',
'mds', 'allow *',
],
stdout=f,
)
if returncode == errno.ENOENT:
returncode = subprocess.call(
args=args_prefix + [
'auth',
'get-or-create',
'client.admin',
'mon', 'allow *',
'osd', 'allow *',
'mds', 'allow *',
],
stdout=f,
)

if returncode != 0:
if returncode == errno.EPERM or returncode == errno.EACCES:
LOG.info('Cannot get or create admin key, permission denied')
Expand Down