From 17876070a5c227cb85f33653f855551440b2d539 Mon Sep 17 00:00:00 2001 From: Olivier Sallou Date: Wed, 10 Jul 2013 15:43:39 +0200 Subject: [PATCH] add mirror attribute --- base/manifest-schema.json | 3 ++- providers/one/__init__.py | 3 ++- providers/one/tasks/apt.py | 5 ++++- providers/one/tasks/bootstrap.py | 6 +++++- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/base/manifest-schema.json b/base/manifest-schema.json index cc723a4..21eb276 100644 --- a/base/manifest-schema.json +++ b/base/manifest-schema.json @@ -30,7 +30,8 @@ }, "timezone": { "type": "string" }, "locale": { "type": "string" }, - "charmap": { "type": "string" } + "charmap": { "type": "string" }, + "mirror": { "type": "string" } }, "required": ["release", "architecture", "timezone", "locale", "charmap"] }, diff --git a/providers/one/__init__.py b/providers/one/__init__.py index 3372c1f..426607f 100644 --- a/providers/one/__init__.py +++ b/providers/one/__init__.py @@ -41,7 +41,8 @@ def tasks(tasklist, manifest): locale.SetTimezone(), apt.DisableDaemonAutostart(), apt.AptSources(), - apt.AptUpgrade(), + #No network for the moment, skip + #apt.AptUpgrade(), boot.ConfigureGrub(), filesystem.ModifyFstab(), boot.BlackListModules(), diff --git a/providers/one/tasks/apt.py b/providers/one/tasks/apt.py index e039df4..d2d86d3 100644 --- a/providers/one/tasks/apt.py +++ b/providers/one/tasks/apt.py @@ -10,11 +10,14 @@ class AptSources(Task): phase = phases.system_modification def run(self, info): + mirror = 'http://http.debian.net/debian' + if info.manifest.system['mirror']: + mirror = info.manifest.system['mirror'] sources_path = os.path.join(info.root, 'etc/apt/sources.list') with open(sources_path, 'w') as apt_sources: apt_sources.write(('deb {apt_mirror} {release} main\n' 'deb-src {apt_mirror} {release} main\n' - .format(apt_mirror='http://http.debian.net/debian', + .format(apt_mirror=mirror, release=info.manifest.system['release']))) apt_sources.write(('deb {apt_mirror} {release}/updates main\n' 'deb-src {apt_mirror} {release}/updates main\n' diff --git a/providers/one/tasks/bootstrap.py b/providers/one/tasks/bootstrap.py index 9e27f36..9b405b0 100644 --- a/providers/one/tasks/bootstrap.py +++ b/providers/one/tasks/bootstrap.py @@ -6,6 +6,10 @@ log = logging.getLogger(__name__) def get_bootstrap_args(info): + mirror = 'http://http.debian.net/debian' + if info.manifest.system['mirror']: + mirror = info.manifest.system['mirror'] + executable = ['/usr/sbin/debootstrap'] options = ['--arch=' + info.manifest.system['architecture']] include, exclude = info.img_packages @@ -13,7 +17,7 @@ def get_bootstrap_args(info): options.append('--include=' + ','.join(include)) if len(exclude) > 0: options.append('--exclude=' + ','.join(exclude)) - arguments = [info.manifest.system['release'], info.root, 'http://http.debian.net/debian'] + arguments = [info.manifest.system['release'], info.root, mirror] return executable, options, arguments