~ibm-charms/charms/trusty/nova-compute-power/trunk

« back to all changes in this revision

Viewing changes to hooks/nova_compute_utils.py

  • Committer: James Page
  • Date: 2014-01-24 15:21:15 UTC
  • mfrom: (51.2.7 nova-compute)
  • Revision ID: james.page@canonical.com-20140124152115-wh94p063fxc699th
[james-page] Add support for optional resize support
[r,gandelman-a]

Show diffs side-by-side

added added

removed removed

Lines of Context:
315
315
    check_output(['chown', '-R', user, ssh_dir])
316
316
 
317
317
 
318
 
def import_authorized_keys(user='root'):
 
318
def import_authorized_keys(user='root', prefix=None):
319
319
    """Import SSH authorized_keys + known_hosts from a cloud-compute relation
320
320
    and store in user's $HOME/.ssh.
321
321
    """
322
 
    # XXX: Should this be managed via templates + contexts?
323
 
    hosts = relation_get('known_hosts')
324
 
    auth_keys = relation_get('authorized_keys')
 
322
    if prefix:
 
323
        hosts = relation_get('{}_known_hosts'.format(prefix))
 
324
        auth_keys = relation_get('{}_authorized_keys'.format(prefix))
 
325
    else:
 
326
        # XXX: Should this be managed via templates + contexts?
 
327
        hosts = relation_get('known_hosts')
 
328
        auth_keys = relation_get('authorized_keys')
 
329
 
325
330
    # XXX: Need to fix charm-helpers to return None for empty settings,
326
331
    #      in all cases.
327
332
    if not hosts or not auth_keys:
380
385
    cmd = ['virsh', 'secret-set-value', '--secret', secret_uuid,
381
386
           '--base64', key]
382
387
    check_call(cmd)
 
388
 
 
389
 
 
390
def enable_shell(user):
 
391
    cmd = ['usermod', '-s', '/bin/bash', user]
 
392
    check_call(cmd)
 
393
 
 
394
 
 
395
def disable_shell(user):
 
396
    cmd = ['usermod', '-s', '/bin/false', user]
 
397
    check_call(cmd)