mirror of
https://github.com/kevingruesser/bootstrap-vz.git
synced 2025-08-22 09:50:37 +00:00
Factor release codename fetching out into common.tools
This allows code that runs before the bootstrapinformation object has been created to also figure out the release codename
This commit is contained in:
parent
376baae583
commit
34bb45bb00
10 changed files with 23 additions and 15 deletions
|
@ -31,11 +31,8 @@ class BootstrapInformation(object):
|
|||
# The default apt mirror
|
||||
self.apt_mirror = self.manifest.packages.get('mirror', 'http://http.debian.net/debian')
|
||||
|
||||
# Normalize the release codenames so that tasks may query for release codenames rather than
|
||||
# 'stable', 'unstable' etc. This is useful when handling cases that are specific to a release.
|
||||
release_codenames_path = os.path.join(os.path.dirname(__file__), 'release-codenames.yml')
|
||||
from bootstrapvz.common.tools import config_get
|
||||
self.release_codename = config_get(release_codenames_path, [self.manifest.system['release']])
|
||||
from bootstrapvz.common.tools import get_codename
|
||||
self.release_codename = get_codename(self.manifest.system['release'])
|
||||
|
||||
# Create the manifest_vars dictionary
|
||||
self.manifest_vars = self.__create_manifest_vars(self.manifest, {'apt_mirror': self.apt_mirror})
|
||||
|
|
|
@ -45,7 +45,7 @@ class RemoveHWClock(Task):
|
|||
@classmethod
|
||||
def run(cls, info):
|
||||
info.initd['disable'].append('hwclock.sh')
|
||||
if info.manifest.system['release'] == 'squeeze':
|
||||
if info.release_codename == 'squeeze':
|
||||
info.initd['disable'].append('hwclockfirst.sh')
|
||||
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ class AddSSHKeyGeneration(Task):
|
|||
try:
|
||||
log_check_call(['chroot', info.root,
|
||||
'dpkg-query', '-W', 'openssh-server'])
|
||||
if info.manifest.system['release'] == 'squeeze':
|
||||
if info.release_codename == 'squeeze':
|
||||
install['generate-ssh-hostkeys'] = os.path.join(init_scripts_dir, 'squeeze/generate-ssh-hostkeys')
|
||||
else:
|
||||
install['generate-ssh-hostkeys'] = os.path.join(init_scripts_dir, 'generate-ssh-hostkeys')
|
||||
|
@ -70,7 +70,7 @@ class ShredHostkeys(Task):
|
|||
def run(cls, info):
|
||||
ssh_hostkeys = ['ssh_host_dsa_key',
|
||||
'ssh_host_rsa_key']
|
||||
if info.manifest.system['release'] != 'squeeze':
|
||||
if info.release_codename != 'squeeze':
|
||||
ssh_hostkeys.append('ssh_host_ecdsa_key')
|
||||
|
||||
private = [os.path.join(info.root, 'etc/ssh', name) for name in ssh_hostkeys]
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import os
|
||||
|
||||
|
||||
def log_check_call(command, stdin=None, env=None, shell=False, cwd=None):
|
||||
|
@ -76,7 +77,6 @@ def load_yaml(path):
|
|||
|
||||
|
||||
def load_data(path):
|
||||
import os.path
|
||||
filename, extension = os.path.splitext(path)
|
||||
if not os.path.isfile(path):
|
||||
raise Exception('The path {path} does not point to a file.'.format(path=path))
|
||||
|
@ -95,9 +95,17 @@ def config_get(path, config_path):
|
|||
return config
|
||||
|
||||
|
||||
def get_codename(release):
|
||||
"""Normalizes the release codenames
|
||||
This allows tasks to query for release codenames rather than 'stable', 'unstable' etc.
|
||||
"""
|
||||
release_codenames_path = os.path.join(os.path.dirname(__file__), 'release-codenames.yml')
|
||||
from bootstrapvz.common.tools import config_get
|
||||
return config_get(release_codenames_path, [release])
|
||||
|
||||
|
||||
def copy_tree(from_path, to_path):
|
||||
from shutil import copy
|
||||
import os
|
||||
for abs_prefix, dirs, files in os.walk(from_path):
|
||||
prefix = os.path.normpath(os.path.relpath(abs_prefix, from_path))
|
||||
for path in dirs:
|
||||
|
|
|
@ -12,7 +12,8 @@ def resolve_tasks(taskset, manifest):
|
|||
from bootstrapvz.common.tasks import initd
|
||||
from bootstrapvz.common.tasks import ssh
|
||||
|
||||
if manifest.system['release'] in ['wheezy', 'stable']:
|
||||
from bootstrapvz.common.tools import get_codename
|
||||
if get_codename(manifest.system['release']) == 'wheezy':
|
||||
taskset.add(tasks.AddBackports)
|
||||
|
||||
taskset.update([tasks.SetMetadataSource,
|
||||
|
|
|
@ -29,7 +29,7 @@ class AddCloudInitPackages(Task):
|
|||
@classmethod
|
||||
def run(cls, info):
|
||||
target = None
|
||||
if info.manifest.system['release'] in ['wheezy', 'stable']:
|
||||
if info.release_codename == 'wheezy':
|
||||
target = '{system.release}-backports'
|
||||
info.packages.add('cloud-init', target)
|
||||
info.packages.add('sudo')
|
||||
|
|
|
@ -5,7 +5,8 @@ import os.path
|
|||
def validate_manifest(data, validator, error):
|
||||
schema_path = os.path.normpath(os.path.join(os.path.dirname(__file__), 'manifest-schema.yml'))
|
||||
validator(data, schema_path)
|
||||
if data.get('system', {}).get('release', None) in ['wheezy', 'stable']:
|
||||
from bootstrapvz.common.tools import get_codename
|
||||
if get_codename(data['system']['release']) == 'wheezy':
|
||||
# prefs is a generator of apt preferences across files in the manifest
|
||||
prefs = (item for vals in data.get('packages', {}).get('preferences', {}).values() for item in vals)
|
||||
if not any('linux-image' in item['package'] and 'wheezy-backports' in item['pin'] for item in prefs):
|
||||
|
|
|
@ -2,6 +2,7 @@ import tasks
|
|||
|
||||
|
||||
def resolve_tasks(taskset, manifest):
|
||||
if manifest.system['release'] in ['wheezy', 'stable']:
|
||||
from bootstrapvz.common.tools import get_codename
|
||||
if get_codename(manifest.system['release']) == 'wheezy':
|
||||
taskset.add(tasks.AddBackports)
|
||||
taskset.update([tasks.AddONEContextPackage])
|
||||
|
|
|
@ -26,6 +26,6 @@ class AddONEContextPackage(Task):
|
|||
@classmethod
|
||||
def run(cls, info):
|
||||
target = None
|
||||
if info.manifest.system['release'] in ['wheezy', 'stable']:
|
||||
if info.release_codename == 'wheezy':
|
||||
target = '{system.release}-backports'
|
||||
info.packages.add('opennebula-context', target)
|
||||
|
|
Loading…
Add table
Reference in a new issue