mirror of
https://github.com/kevingruesser/bootstrap-vz.git
synced 2025-08-24 07:26:29 +00:00
[admin_user]: More cleanups. Remove uneeded tests.
Signed-off-by: Manoj Srivastava <srivasta@golden-gryphon.com>
This commit is contained in:
parent
efeddc43a8
commit
32ef6fc571
2 changed files with 11 additions and 14 deletions
|
@ -7,10 +7,11 @@ def validate_manifest(data, validator, error):
|
|||
if ('password' in data['plugins']['admin_user'] and 'pubkey' in data['plugins']['admin_user']):
|
||||
msg = 'passwd and pubkey are mutually exclusive.'
|
||||
error(msg, ['plugins', 'admin_user'])
|
||||
full_path = data['plugins']['admin_user']['pubkey']
|
||||
if not os.path.exists(full_path):
|
||||
msg = 'Could not find public key at %s' % full_path
|
||||
error(msg, ['plugins', 'admin_user'])
|
||||
if 'pubkey' in data['plugins']['admin_user']:
|
||||
full_path = data['plugins']['admin_user']['pubkey']
|
||||
if not os.path.exists(full_path):
|
||||
msg = 'Could not find public key at %s' % full_path
|
||||
error(msg, ['plugins', 'admin_user'])
|
||||
|
||||
|
||||
def resolve_tasks(taskset, manifest):
|
||||
|
|
|
@ -90,10 +90,10 @@ class AdminUserCredentialsPublicKey(Task):
|
|||
username = info.manifest.plugins['admin_user']['username']
|
||||
|
||||
ssh_file = os.path.join('/home/', username, '.ssh/authorized_keys')
|
||||
rel_ssh_file = os.path.realpath(info.root + '/%s' % ssh_file)
|
||||
rel_ssh_file = os.path.join(info.root, ssh_file)
|
||||
|
||||
ssh_dir = os.path.dirname(ssh_file)
|
||||
rel_ssh_dir = os.path.realpath(info.root + '/%s' % ssh_dir)
|
||||
rel_ssh_dir = os.path.join(info.root, ssh_dir)
|
||||
if not os.path.exists(rel_ssh_dir):
|
||||
log.debug('Creating %s.' % rel_ssh_dir)
|
||||
os.mkdir(rel_ssh_dir)
|
||||
|
@ -118,15 +118,11 @@ class AdminUserCredentialsEC2(Task):
|
|||
|
||||
@classmethod
|
||||
def run(cls, info):
|
||||
from bootstrapvz.common.exceptions import TaskError
|
||||
from bootstrapvz.common.tools import sed_i
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
getcreds_path = os.path.join(info.root, 'etc/init.d/ec2-get-credentials')
|
||||
if os.path.exists(getcreds_path):
|
||||
log.debug('Updating EC2 get credentials script.')
|
||||
username = info.manifest.plugins['admin_user']['username']
|
||||
sed_i(getcreds_path, "username='root'",
|
||||
"username='{username}'".format(username=username))
|
||||
else:
|
||||
raise TaskError('Could not find EC2 get credentials script.')
|
||||
log.debug('Updating EC2 get credentials script.')
|
||||
username = info.manifest.plugins['admin_user']['username']
|
||||
sed_i(getcreds_path, "username='root'",
|
||||
"username='{username}'".format(username=username))
|
||||
|
|
Loading…
Add table
Reference in a new issue