From b04bda220a14805e7073c613995e9861cd928464 Mon Sep 17 00:00:00 2001 From: Olivier Sallou Date: Wed, 9 Apr 2014 17:32:37 +0200 Subject: [PATCH] Download Waagent archive instead of using git repo. Specify the version in the manifest (system/waagent section) Add possibility to specify waagent conf file in manifest (system/waagent section) Update documentation to match changes Use log_check_call instead of log_call refactor test on dictionary key --- bootstrapvz/providers/azure/README.md | 12 +++++- .../providers/azure/manifest-schema.json | 23 ++++++----- bootstrapvz/providers/azure/tasks/packages.py | 38 ++++++++++++------- manifests/azure.manifest.json | 9 +++-- 4 files changed, 54 insertions(+), 28 deletions(-) diff --git a/bootstrapvz/providers/azure/README.md b/bootstrapvz/providers/azure/README.md index b428f00..c03009e 100644 --- a/bootstrapvz/providers/azure/README.md +++ b/bootstrapvz/providers/azure/README.md @@ -2,7 +2,6 @@ Azure provider =========== This provider generates raw images for Microsoft Azure computing platform. -It also supports an optional virtio integration. Setup ===== @@ -10,6 +9,8 @@ Setup qemu-img >= 1.7.0 required to convert raw image to vhd fixed size disk. This release is available in wheezy-backports. +*wget* must be installed on local computer. + Manifest must use the *raw* format, provider will automatically transform the disk to a vhd disk format. @@ -25,4 +26,11 @@ The Windows Azure Linux Agent can automatically configure swap space using the l You can specify a waagent.conf file to replace the default one in the manifest in the azure/waagent section of the provider: - "azure" : { "waagent" : "path_to_my_conf_file" }, ... + "system" : { + "waagent" : { + "conf": "path_to_my_conf_file", # optional + "version" : "2.0.4" # mandatory + } + }, ... + +Waagent versions are available at: https://github.com/Azure/WALinuxAgent/releases diff --git a/bootstrapvz/providers/azure/manifest-schema.json b/bootstrapvz/providers/azure/manifest-schema.json index e2e274c..97b4330 100644 --- a/bootstrapvz/providers/azure/manifest-schema.json +++ b/bootstrapvz/providers/azure/manifest-schema.json @@ -3,22 +3,27 @@ "title": "Azure manifest", "type": "object", "properties": { - "azure": { - "type": "object", - "properties": { - "waagent": { - "type": "string" - } - } - }, "system": { "type": "object", "properties": { "bootloader": { "type": "string", "enum": ["grub", "extlinux"] + }, + "waagent": { + "type": "object", + "properties": { + "conf": { + "type": "string" + }, + "version": { + "type": "string" + } + }, + "required": ["version"] } - } + }, + "required": ["waagent"] }, "volume": { "type": "object", diff --git a/bootstrapvz/providers/azure/tasks/packages.py b/bootstrapvz/providers/azure/tasks/packages.py index b856f5b..10ceb70 100644 --- a/bootstrapvz/providers/azure/tasks/packages.py +++ b/bootstrapvz/providers/azure/tasks/packages.py @@ -18,10 +18,8 @@ class DefaultPackages(Task): info.packages.add('python-openssl') info.packages.add('openssh-server') info.packages.add('python-pyasn1') - info.packages.add('git') info.packages.add('sudo') - class Waagent(Task): description = 'Add waagent' phase = phases.package_installation @@ -29,17 +27,29 @@ class Waagent(Task): @classmethod def run(cls, info): - from bootstrapvz.common.tools import log_call + from bootstrapvz.common.tools import log_check_call import os - env = os.environ.copy() - env['GIT_SSL_NO_VERIFY'] = 'true' - log_call(['chroot', info.root, - 'git', 'clone', 'https://github.com/WindowsAzure/WALinuxAgent.git', - '/root/WALinuxAgent'], env=env) - log_call(['chroot', info.root, 'cp', '/root/WALinuxAgent/waagent', '/usr/sbin/waagent']) - log_call(['chmod', '755', '/usr/sbin/waagent']) - log_call(['chroot', info.root, 'waagent', '-install']) + waagent_version = info.manifest.system['waagent']['version'] + waagent_file = 'WALinuxAgent-'+waagent_version+'.tar.gz' + waagent_url = 'https://github.com/Azure/WALinuxAgent/archive/' + waagent_file + log_check_call(['/usr/bin/wget', '-P', info.root, waagent_url]) import os.path - if hasattr(info.manifest, 'azure') and info.manifest.azure['waagent']: - if os.path.isfile(info.manifest.azure['waagent']): - log_call(['cp', info.manifest.azure['waagent'], os.path.join(info.root, 'etc/waagent.conf')]) + waagent_directory = os.path.join(info.root, 'root') + log_check_call(['/bin/tar', 'xaf', + os.path.join(info.root, waagent_file), + '-C', waagent_directory]) + os.remove(os.path.join(info.root, waagent_file)) + 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']) + log_check_call(['chroot', info.root, + '/usr/sbin/waagent','-install']) + import os.path + 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'], + os.path.join(info.root,'etc/waagent.conf')]) + diff --git a/manifests/azure.manifest.json b/manifests/azure.manifest.json index 7475c84..4007691 100644 --- a/manifests/azure.manifest.json +++ b/manifests/azure.manifest.json @@ -1,8 +1,8 @@ { "provider": "azure", "bootstrapper": { - "workspace": "/target", - "mirror": "http://ftp.fr.debian.org/debian/" + "workspace": "/target", + "mirror": "http://ftp.fr.debian.org/debian/" }, "image": { "name": "debian-{system.release}-{system.architecture}-{%y}{%m}{%d}", @@ -14,7 +14,10 @@ "bootloader": "grub", "timezone": "UTC", "locale": "en_US", - "charmap": "UTF-8" + "charmap": "UTF-8", + "waagent": { + "version": "2.0.4" + } }, "packages": { },