def run(cls, info): registration_params = {"name": info._ec2["ami_name"], "description": info._ec2["ami_description"]} registration_params["architecture"] = {"i386": "i386", "amd64": "x86_64"}.get( info.manifest.system["architecture"] ) if info.manifest.volume["backing"] == "s3": registration_params["image_location"] = info._ec2["manifest_location"] else: root_dev_name = {"pvm": "/dev/sda", "hvm": "/dev/xvda"}.get(info.manifest.data["virtualization"]) registration_params["root_device_name"] = root_dev_name from boto.ec2.blockdevicemapping import BlockDeviceType from boto.ec2.blockdevicemapping import BlockDeviceMapping block_device = BlockDeviceType( snapshot_id=info._ec2["snapshot"].id, delete_on_termination=True, size=info.volume.size.get_qty_in("GiB"), ) registration_params["block_device_map"] = BlockDeviceMapping() registration_params["block_device_map"][root_dev_name] = block_device if info.manifest.data["virtualization"] == "hvm": registration_params["virtualization_type"] = "hvm" else: registration_params["virtualization_type"] = "paravirtual" akis_path = os.path.join(os.path.dirname(__file__), "ami-akis.json") from bootstrapvz.common.tools import config_get registration_params["kernel_id"] = config_get( akis_path, [info._ec2["host"]["region"], info.manifest.system["architecture"]] ) info._ec2["image"] = info._ec2["connection"].register_image(**registration_params)
def run(cls, info): 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.manifest.release.codename, info.manifest.system['architecture']]) info.packages.add(kernel_package)
def run(cls, info): kernel_packages_path = rel_path(__file__, 'packages-kernels.yml') kernel_package = config_get(kernel_packages_path, [ info.manifest.release.codename, info.manifest.system['architecture'] ]) info.packages.add(kernel_package)
def run(cls, info): info.packages.add('acpi-support-base') info.packages.add('busybox') info.packages.add('ca-certificates') info.packages.add('curl') info.packages.add('ethtool') info.packages.add('gdisk') info.packages.add('kpartx') info.packages.add('isc-dhcp-client') info.packages.add('lsb-release') info.packages.add('ntp') info.packages.add('parted') info.packages.add('python') info.packages.add('openssh-client') info.packages.add('openssh-server') info.packages.add('sudo') info.packages.add('uuid-runtime') kernel_packages_path = os.path.join(os.path.dirname(__file__), 'packages-kernels.yml') kernel_package = config_get(kernel_packages_path, [ info.manifest.release.codename, info.manifest.system['architecture'] ]) info.packages.add(kernel_package)
def run(cls, info): registration_params = {'name': info._ec2['ami_name'], 'description': info._ec2['ami_description']} registration_params['architecture'] = {'i386': 'i386', 'amd64': 'x86_64'}.get(info.manifest.system['architecture']) if info.manifest.volume['backing'] == 's3': registration_params['image_location'] = info._ec2['manifest_location'] else: root_dev_name = {'pvm': '/dev/sda', 'hvm': '/dev/xvda'}.get(info.manifest.provider['virtualization']) registration_params['root_device_name'] = root_dev_name from boto.ec2.blockdevicemapping import BlockDeviceType from boto.ec2.blockdevicemapping import BlockDeviceMapping block_device = BlockDeviceType(snapshot_id=info._ec2['snapshot'].id, delete_on_termination=True, size=info.volume.size.bytes.get_qty_in('GiB'), volume_type='gp2') registration_params['block_device_map'] = BlockDeviceMapping() registration_params['block_device_map'][root_dev_name] = block_device if info.manifest.provider['virtualization'] == 'hvm': registration_params['virtualization_type'] = 'hvm' else: registration_params['virtualization_type'] = 'paravirtual' akis_path = os.path.join(os.path.dirname(__file__), 'ami-akis.yml') from bootstrapvz.common.tools import config_get registration_params['kernel_id'] = config_get(akis_path, [info._ec2['region'], info.manifest.system['architecture']]) if info.manifest.provider.get('enhanced_networking', None) == 'simple': registration_params['sriov_net_support'] = 'simple' info._ec2['image'] = info._ec2['connection'].register_image(**registration_params)
def run(cls, info): registration_params = {'name': info.ami_name, 'description': info.ami_description} registration_params['architecture'] = {'i386': 'i386', 'amd64': 'x86_64'}.get(info.manifest.system['architecture']) if info.manifest.volume['backing'] == 's3': registration_params['image_location'] = info.manifest.manifest_location else: root_dev_name = {'pvm': '/dev/sda', 'hvm': '/dev/xvda'}.get(info.manifest.data['virtualization']) registration_params['root_device_name'] = root_dev_name from boto.ec2.blockdevicemapping import BlockDeviceType from boto.ec2.blockdevicemapping import BlockDeviceMapping block_device = BlockDeviceType(snapshot_id=info.snapshot.id, delete_on_termination=True, size=info.volume.size.get_qty_in('GiB')) registration_params['block_device_map'] = BlockDeviceMapping() registration_params['block_device_map'][root_dev_name] = block_device if info.manifest.data['virtualization'] == 'hvm': registration_params['virtualization_type'] = 'hvm' else: registration_params['virtualization_type'] = 'paravirtual' akis_path = os.path.join(os.path.dirname(__file__), 'ami-akis.json') from bootstrapvz.common.tools import config_get registration_params['kernel_id'] = config_get(akis_path, [info.host['region'], info.manifest.system['architecture']]) info.image = info.connection.register_image(**registration_params)
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 run(cls, info): from bootstrapvz.common.tools import config_get, rel_path kernel_packages_path = rel_path(__file__, 'packages-kernels.yml') kernel_package = config_get(kernel_packages_path, [ info.manifest.release.codename, info.manifest.system['architecture'] ]) info.packages.add(kernel_package)
def run(cls, info): registration_params = { 'Name': info._ec2['ami_name'], 'Description': info._ec2['ami_description'] } registration_params['Architecture'] = { 'i386': 'i386', 'amd64': 'x86_64' }.get(info.manifest.system['architecture']) if info.manifest.volume['backing'] == 's3': registration_params['ImageLocation'] = info._ec2[ 'manifest_location'] else: root_dev_name = { 'pvm': '/dev/sda', 'hvm': '/dev/xvda' }.get(info.manifest.provider['virtualization']) registration_params['RootDeviceName'] = root_dev_name block_device = [{ 'DeviceName': root_dev_name, 'Ebs': { 'SnapshotId': info._ec2['snapshot'], 'VolumeSize': info.volume.size.bytes.get_qty_in('GiB'), 'VolumeType': 'gp2', 'DeleteOnTermination': True } }] registration_params['BlockDeviceMappings'] = block_device if info.manifest.provider['virtualization'] == 'hvm': registration_params['VirtualizationType'] = 'hvm' else: registration_params['VirtualizationType'] = 'paravirtual' akis_path = rel_path(__file__, 'ami-akis.yml') from bootstrapvz.common.tools import config_get registration_params['kernel_id'] = config_get( akis_path, [info._ec2['region'], info.manifest.system['architecture']]) if info.manifest.provider.get('enhanced_networking', None) == 'simple': registration_params['SriovNetSupport'] = 'simple' registration_params['EnaSupport'] = True info._ec2['image'] = info._ec2['connection'].register_image( **registration_params) # Setting up tags on the AMI if 'tags' in info.manifest.data: raw_tags = info.manifest.data['tags'] formatted_tags = { k: v.format(**info.manifest_vars) for k, v in raw_tags.items() } tags = [{'Key': k, 'Value': v} for k, v in formatted_tags.items()] info._ec2['connection'].create_tags( Resources=[info._ec2['image']['ImageId']], Tags=tags)
def run(cls, info): from bootstrapvz.common.tools import rel_path info.packages.add('file') # Needed for the init scripts kernel_packages_path = rel_path(__file__, 'packages-kernels.yml') from bootstrapvz.common.tools import config_get kernel_package = config_get(kernel_packages_path, [info.manifest.release.codename, info.manifest.system['architecture']]) info.packages.add(kernel_package)
def run(cls, info): info.packages.add('openssl') info.packages.add('python-openssl') info.packages.add('python-pyasn1') info.packages.add('sudo') info.packages.add('parted') from bootstrapvz.common.tools import config_get, rel_path kernel_packages_path = rel_path(__file__, 'packages-kernels.yml') kernel_package = config_get(kernel_packages_path, [info.manifest.release.codename, info.manifest.system['architecture']]) info.packages.add(kernel_package)
def run(cls, info): info.packages.add('file') # Needed for the init scripts info.packages.add('dhcpcd') # isc-dhcp-client doesn't work properly with ec2 info.exclude_packages.add('isc-dhcp-client') info.exclude_packages.add('isc-dhcp-common') import os.path kernel_packages_path = os.path.join(os.path.dirname(__file__), 'packages-kernels.json') 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)
def run(cls, info): info.packages.add('openssl') info.packages.add('python-openssl') info.packages.add('python-pyasn1') info.packages.add('sudo') info.packages.add('parted') from bootstrapvz.common.tools import config_get, rel_path kernel_packages_path = rel_path(__file__, 'packages-kernels.yml') kernel_package = config_get(kernel_packages_path, [ info.manifest.release.codename, info.manifest.system['architecture'] ]) info.packages.add(kernel_package)
def run(cls, info): info.packages.add('python') info.packages.add('sudo') info.packages.add('ntp') info.packages.add('lsb-release') info.packages.add('acpi-support-base') info.packages.add('openssh-client') info.packages.add('openssh-server') info.packages.add('dhcpd') info.packages.add('ca-certificates') kernel_packages_path = os.path.join(os.path.dirname(__file__), 'packages-kernels.yml') kernel_package = config_get(kernel_packages_path, [info.manifest.release.codename, info.manifest.system['architecture']]) info.packages.add(kernel_package)
def run(cls, info): info.packages.add('file') # Needed for the init scripts # isc-dhcp-client before jessie doesn't work properly with ec2 from bootstrapvz.common.releases import jessie if info.manifest.release < jessie: info.packages.add('dhcpcd') info.exclude_packages.add('isc-dhcp-client') info.exclude_packages.add('isc-dhcp-common') 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.manifest.release.codename, info.manifest.system['architecture']]) info.packages.add(kernel_package)
def run(cls, info): info.packages.add("python") info.packages.add("sudo") info.packages.add("ntp") info.packages.add("lsb-release") info.packages.add("acpi-support-base") info.packages.add("openssh-client") info.packages.add("openssh-server") info.packages.add("dhcpd") info.packages.add("ca-certificates") kernel_packages_path = os.path.join(os.path.dirname(__file__), "packages-kernels.yml") kernel_package = config_get( kernel_packages_path, [info.manifest.release.codename, info.manifest.system["architecture"]] ) info.packages.add(kernel_package)
def run(cls, info): registration_params = {'Name': info._ec2['ami_name'], 'Description': info._ec2['ami_description']} registration_params['Architecture'] = {'i386': 'i386', 'amd64': 'x86_64'}.get(info.manifest.system['architecture']) if info.manifest.volume['backing'] == 's3': registration_params['ImageLocation'] = info._ec2['manifest_location'] else: root_dev_name = {'pvm': '/dev/sda', 'hvm': '/dev/xvda'}.get(info.manifest.provider['virtualization']) registration_params['RootDeviceName'] = root_dev_name block_device = [{'DeviceName': root_dev_name, 'Ebs': { 'SnapshotId': info._ec2['snapshot'], 'VolumeSize': info.volume.size.bytes.get_qty_in('GiB'), 'VolumeType': 'gp2', 'DeleteOnTermination': True}}] registration_params['BlockDeviceMappings'] = block_device if info.manifest.provider['virtualization'] == 'hvm': registration_params['VirtualizationType'] = 'hvm' else: registration_params['VirtualizationType'] = 'paravirtual' akis_path = rel_path(__file__, 'ami-akis.yml') from bootstrapvz.common.tools import config_get registration_params['kernel_id'] = config_get(akis_path, [info._ec2['region'], info.manifest.system['architecture']]) if info.manifest.provider.get('enhanced_networking', None) == 'simple': registration_params['SriovNetSupport'] = 'simple' registration_params['EnaSupport'] = True info._ec2['image'] = info._ec2['connection'].register_image(**registration_params) # Setting up tags on the AMI if 'tags' in info.manifest.data: raw_tags = info.manifest.data['tags'] formatted_tags = {k: v.format(**info.manifest_vars) for k, v in raw_tags.items()} tags = [{'Key': k, 'Value': v} for k, v in formatted_tags.items()] info._ec2['connection'].create_tags(Resources=[info._ec2['image']['ImageId']], Tags=tags)
def run(cls, info): info.packages.add('python') info.packages.add('sudo') info.packages.add('ntp') info.packages.add('lsb-release') info.packages.add('acpi-support-base') info.packages.add('openssh-client') info.packages.add('openssh-server') info.packages.add('dhcpd') info.packages.add('ca-certificates') 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.manifest.release.codename, info.manifest.system['architecture'] ]) info.packages.add(kernel_package)
def run(cls, info): info.packages.add('acpi-support-base') info.packages.add('busybox') info.packages.add('ca-certificates') info.packages.add('curl') info.packages.add('ethtool') info.packages.add('gdisk') info.packages.add('kpartx') info.packages.add('isc-dhcp-client') info.packages.add('lsb-release') info.packages.add('ntp') info.packages.add('parted') info.packages.add('python') info.packages.add('openssh-client') info.packages.add('openssh-server') info.packages.add('sudo') info.packages.add('uuid-runtime') kernel_packages_path = rel_path(__file__, 'packages-kernels.yml') kernel_package = config_get(kernel_packages_path, [info.manifest.release.codename, info.manifest.system['architecture']]) info.packages.add(kernel_package)
def __init__(self, manifest=None, debug=False): """Instantiates a new bootstrap info object. Args: manifest (Manifest): The manifest debug (bool): Whether debugging is turned on """ # Set the manifest attribute. self.manifest = manifest self.debug = debug # Create a run_id. This id may be used to uniquely identify the currrent bootstrapping process import random self.run_id = '{id:08x}'.format(id=random.randrange(16 ** 8)) # Define the path to our workspace import os.path self.workspace = os.path.join(manifest.bootstrapper['workspace'], self.run_id) # Load all the volume information from fs import load_volume self.volume = load_volume(self.manifest.volume, manifest.system['bootloader']) # 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.json') from bootstrapvz.common.tools import config_get self.release_codename = config_get(release_codenames_path, [self.manifest.system['release']]) # Create the manifest_vars dictionary self.manifest_vars = self.__create_manifest_vars(self.manifest, {'apt_mirror': self.apt_mirror}) # Keep a list of apt sources, # so that tasks may add to that list without having to fiddle with apt source list files. from pkg.sourceslist import SourceLists self.source_lists = SourceLists(self.manifest_vars) # Keep a list of apt preferences from pkg.preferenceslist import PreferenceLists self.preference_lists = PreferenceLists(self.manifest_vars) # Keep a list of packages that should be installed, tasks can add and remove things from this list from pkg.packagelist import PackageList self.packages = PackageList(self.manifest_vars, self.source_lists) # These sets should rarely be used and specify which packages the debootstrap invocation # should be called with. self.include_packages = set() self.exclude_packages = set() # Dictionary to specify which commands are required on the host. # The keys are commands, while the values are either package names or urls # that hint at how a command may be made available. self.host_dependencies = {} # Lists of startup scripts that should be installed and disabled self.initd = {'install': {}, 'disable': []} # Add a dictionary that can be accessed via info._pluginname for the provider and every plugin # Information specific to the module can be added to that 'namespace', this avoids clutter. providername = manifest.modules['provider'].__name__.split('.')[-1] setattr(self, '_' + providername, {}) for plugin in manifest.modules['plugins']: pluginname = plugin.__name__.split('.')[-1] setattr(self, '_' + pluginname, {})
def run(cls, info): kernel_packages_path = os.path.join(os.path.dirname(__file__), "packages-kernels.yml") kernel_package = config_get( kernel_packages_path, [info.manifest.release.codename, info.manifest.system["architecture"]] ) info.packages.add(kernel_package)
def __init__(self, manifest=None, debug=False): """Instantiates a new bootstrap info object. :param Manifest manifest: The manifest :param bool debug: Whether debugging is turned on """ # Set the manifest attribute. self.manifest = manifest self.debug = debug # Create a run_id. This id may be used to uniquely identify the currrent bootstrapping process import random self.run_id = '{id:08x}'.format(id=random.randrange(16**8)) # Define the path to our workspace import os.path self.workspace = os.path.join(manifest.bootstrapper['workspace'], self.run_id) # Load all the volume information from fs import load_volume self.volume = load_volume(self.manifest.volume, manifest.system['bootloader']) # 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.json') from bootstrapvz.common.tools import config_get self.release_codename = config_get(release_codenames_path, [self.manifest.system['release']]) # Create the manifest_vars dictionary self.manifest_vars = self.__create_manifest_vars( self.manifest, {'apt_mirror': self.apt_mirror}) # Keep a list of apt sources, # so that tasks may add to that list without having to fiddle with apt source list files. from pkg.sourceslist import SourceLists self.source_lists = SourceLists(self.manifest_vars) # Keep a list of apt preferences from pkg.preferenceslist import PreferenceLists self.preference_lists = PreferenceLists(self.manifest_vars) # Keep a list of packages that should be installed, tasks can add and remove things from this list from pkg.packagelist import PackageList self.packages = PackageList(self.manifest_vars, self.source_lists) # These sets should rarely be used and specify which packages the debootstrap invocation # should be called with. self.include_packages = set() self.exclude_packages = set() # Dictionary to specify which commands are required on the host. # The keys are commands, while the values are either package names or urls # that hint at how a command may be made available. self.host_dependencies = {} # Lists of startup scripts that should be installed and disabled self.initd = {'install': {}, 'disable': []} # Add a dictionary that can be accessed via info._pluginname for the provider and every plugin # Information specific to the module can be added to that 'namespace', this avoids clutter. providername = manifest.modules['provider'].__name__.split('.')[-1] setattr(self, '_' + providername, {}) for plugin in manifest.modules['plugins']: pluginname = plugin.__name__.split('.')[-1] setattr(self, '_' + pluginname, {})
def run(cls, info): kernel_packages_path = rel_path(__file__, 'packages-kernels.yml') kernel_package = config_get(kernel_packages_path, [info.manifest.release.codename, info.manifest.system['architecture']]) info.packages.add(kernel_package)
def run(cls, info): from bootstrapvz.common.tools import config_get, rel_path kernel_packages_path = rel_path(__file__, 'packages-kernels.yml') kernel_package = config_get(kernel_packages_path, [info.manifest.release.codename, info.manifest.system['architecture']]) info.packages.add(kernel_package)