2014-04-07 14:23:24 +02:00
|
|
|
from bootstrapvz.base import Task
|
|
|
|
from bootstrapvz.common import phases
|
|
|
|
from bootstrapvz.common.tasks import apt
|
|
|
|
from bootstrapvz.common.tasks.packages import InstallPackages
|
|
|
|
|
|
|
|
|
|
|
|
class DefaultPackages(Task):
|
|
|
|
description = 'Adding image packages required for Azure'
|
|
|
|
phase = phases.preparation
|
|
|
|
predecessors = [apt.AddDefaultSources]
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def run(cls, info):
|
|
|
|
info.packages.add('openssl')
|
|
|
|
info.packages.add('python-openssl')
|
|
|
|
info.packages.add('python-pyasn1')
|
|
|
|
info.packages.add('sudo')
|
2014-04-08 23:29:45 +02:00
|
|
|
|
2014-07-09 21:40:34 +02:00
|
|
|
import os.path
|
|
|
|
kernel_packages_path = os.path.join(os.path.dirname(__file__), 'packages-kernels.yml')
|
|
|
|
from bootstrapvz.common.tools import config_get
|
|
|
|
kernel_package = config_get(kernel_packages_path, [info.release_codename,
|
|
|
|
info.manifest.system['architecture']])
|
|
|
|
info.packages.add(kernel_package)
|
|
|
|
|
2014-04-10 00:27:37 +02:00
|
|
|
|
2014-04-07 14:23:24 +02:00
|
|
|
class Waagent(Task):
|
|
|
|
description = 'Add waagent'
|
|
|
|
phase = phases.package_installation
|
|
|
|
predecessors = [InstallPackages]
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def run(cls, info):
|
2014-04-09 17:32:37 +02:00
|
|
|
from bootstrapvz.common.tools import log_check_call
|
2014-04-07 14:23:24 +02:00
|
|
|
import os
|
2014-07-05 18:14:29 +02:00
|
|
|
waagent_version = info.manifest.provider['waagent']['version']
|
2014-04-09 13:29:14 -03:00
|
|
|
waagent_file = 'WALinuxAgent-' + waagent_version + '.tar.gz'
|
2014-04-09 17:32:37 +02:00
|
|
|
waagent_url = 'https://github.com/Azure/WALinuxAgent/archive/' + waagent_file
|
2014-04-09 13:34:34 -03:00
|
|
|
log_check_call(['wget', '-P', info.root, waagent_url])
|
2014-04-09 17:32:37 +02:00
|
|
|
waagent_directory = os.path.join(info.root, 'root')
|
2014-04-09 13:34:34 -03:00
|
|
|
log_check_call(['tar', 'xaf', os.path.join(info.root, waagent_file), '-C', waagent_directory])
|
2014-04-09 17:32:37 +02:00
|
|
|
os.remove(os.path.join(info.root, waagent_file))
|
2014-04-09 13:29:14 -03:00
|
|
|
waagent_script = '/root/WALinuxAgent-WALinuxAgent-' + waagent_version + '/waagent'
|
|
|
|
log_check_call(['chroot', info.root, 'cp', waagent_script, '/usr/sbin/waagent'])
|
|
|
|
log_check_call(['chroot', info.root, 'chmod', '755', '/usr/sbin/waagent'])
|
2014-04-09 13:34:34 -03:00
|
|
|
log_check_call(['chroot', info.root, 'waagent', '-install'])
|
2014-04-09 17:32:37 +02:00
|
|
|
if info.manifest.system['waagent'].get('conf', False):
|
|
|
|
if os.path.isfile(info.manifest.system['waagent']['conf']):
|
|
|
|
log_check_call(['cp', info.manifest.system['waagent']['conf'],
|
2014-04-10 00:27:37 +02:00
|
|
|
os.path.join(info.root, 'etc/waagent.conf')])
|