mirror of
https://github.com/ceph/ceph
synced 2025-02-07 19:03:18 +00:00
No need to be passing ctx to update_lock()
... or update_keys() or scan_for_locks() Signed-off-by: Zack Cerza <zack.cerza@inktank.com>
This commit is contained in:
parent
8048dc348c
commit
5e5c32ef79
@ -90,7 +90,7 @@ def main(ctx):
|
|||||||
# Avoid ssh-keyscans for everybody when listing all machines
|
# Avoid ssh-keyscans for everybody when listing all machines
|
||||||
# Listing specific machines will update the keys.
|
# Listing specific machines will update the keys.
|
||||||
if machines:
|
if machines:
|
||||||
scan_for_locks(ctx, vmachines)
|
scan_for_locks(vmachines)
|
||||||
statuses = [get_status(machine)
|
statuses = [get_status(machine)
|
||||||
for machine in machines]
|
for machine in machines]
|
||||||
else:
|
else:
|
||||||
@ -196,7 +196,7 @@ def main(ctx):
|
|||||||
|
|
||||||
if ctx.desc is not None or ctx.status is not None:
|
if ctx.desc is not None or ctx.status is not None:
|
||||||
for machine in machines_to_update:
|
for machine in machines_to_update:
|
||||||
update_lock(ctx, machine, ctx.desc, ctx.status)
|
update_lock(machine, ctx.desc, ctx.status)
|
||||||
|
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
@ -296,7 +296,7 @@ def list_locks(machine_type=None):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def update_lock(ctx, name, description=None, status=None, ssh_pub_key=None):
|
def update_lock(name, description=None, status=None, ssh_pub_key=None):
|
||||||
status_info = get_status(name)
|
status_info = get_status(name)
|
||||||
phys_host = status_info['vpshost']
|
phys_host = status_info['vpshost']
|
||||||
if phys_host:
|
if phys_host:
|
||||||
@ -389,15 +389,15 @@ def updatekeys(ctx):
|
|||||||
except IOError as e:
|
except IOError as e:
|
||||||
raise argparse.ArgumentTypeError(str(e))
|
raise argparse.ArgumentTypeError(str(e))
|
||||||
|
|
||||||
return scan_for_locks(ctx, machines)
|
return scan_for_locks(machines)
|
||||||
|
|
||||||
|
|
||||||
def scan_for_locks(ctx, machines):
|
def scan_for_locks(machines):
|
||||||
out, current_locks = keyscan_check(machines)
|
out, current_locks = keyscan_check(machines)
|
||||||
return update_keys(ctx, out, current_locks)
|
return update_keys(out, current_locks)
|
||||||
|
|
||||||
|
|
||||||
def update_keys(ctx, out, current_locks):
|
def update_keys(out, current_locks):
|
||||||
ret = 0
|
ret = 0
|
||||||
for key_entry in out.splitlines():
|
for key_entry in out.splitlines():
|
||||||
hostname, pubkey = key_entry.split(' ', 1)
|
hostname, pubkey = key_entry.split(' ', 1)
|
||||||
@ -407,7 +407,7 @@ def update_keys(ctx, out, current_locks):
|
|||||||
assert full_name in current_locks, 'host is not in the database!'
|
assert full_name in current_locks, 'host is not in the database!'
|
||||||
if current_locks[full_name]['ssh_pub_key'] != pubkey:
|
if current_locks[full_name]['ssh_pub_key'] != pubkey:
|
||||||
log.info('New key found. Updating...')
|
log.info('New key found. Updating...')
|
||||||
if not update_lock(ctx, full_name, ssh_pub_key=pubkey):
|
if not update_lock(full_name, ssh_pub_key=pubkey):
|
||||||
log.error('failed to update %s!', full_name)
|
log.error('failed to update %s!', full_name)
|
||||||
ret = 1
|
ret = 1
|
||||||
return ret
|
return ret
|
||||||
|
@ -125,7 +125,7 @@ def lock_machines(ctx, config):
|
|||||||
log.info('recreating: ' + guest)
|
log.info('recreating: ' + guest)
|
||||||
provision.destroy_if_vm(ctx, 'ubuntu@' + guest)
|
provision.destroy_if_vm(ctx, 'ubuntu@' + guest)
|
||||||
provision.create_if_vm(ctx, 'ubuntu@' + guest)
|
provision.create_if_vm(ctx, 'ubuntu@' + guest)
|
||||||
if lock.update_keys(ctx, keyscan_out, current_locks):
|
if lock.update_keys(keyscan_out, current_locks):
|
||||||
log.info("Error in virtual machine keys")
|
log.info("Error in virtual machine keys")
|
||||||
newscandict = {}
|
newscandict = {}
|
||||||
for dkey in newly_locked.iterkeys():
|
for dkey in newly_locked.iterkeys():
|
||||||
|
Loading…
Reference in New Issue
Block a user