def serialize_pre_provision_tasks(cls, cluster): tasks = [] attrs = objects.Attributes.merged_attrs_values(cluster.attributes) is_build_images = all([ cluster.release.operating_system == consts.RELEASE_OS.ubuntu, attrs['provision']['method'] == consts.PROVISION_METHODS.image ]) if is_build_images: tasks.append( tasks_templates.make_provisioning_images_task( [consts.MASTER_ROLE], attrs['repo_setup']['repos'], attrs['provision'], cluster.id)) # NOTE(kozhukalov): This pre-provision task is going to be # removed by 7.0 because we need this only for classic way of # provision and only until we get rid of it. We are going # to download debian-installer initrd and kernel just before # starting actual provisioning. is_download_debian_installer = all([ cluster.release.operating_system == consts.RELEASE_OS.ubuntu, attrs['provision']['method'] == consts.PROVISION_METHODS.cobbler ]) if is_download_debian_installer: tasks.append( tasks_templates.make_download_debian_installer_task( [consts.MASTER_ROLE], attrs['repo_setup']['repos'], attrs['repo_setup']['installer_kernel'], attrs['repo_setup']['installer_initrd'])) PriorityStrategy().one_by_one(tasks) return tasks
def serialize_pre_provision_tasks(cls, cluster): tasks = [] attrs = objects.Attributes.merged_attrs_values(cluster.attributes) is_build_images = all([ cluster.release.operating_system == consts.RELEASE_OS.ubuntu, attrs['provision']['method'] == consts.PROVISION_METHODS.image]) if is_build_images: tasks.append( tasks_templates.make_provisioning_images_task( [consts.MASTER_ROLE], attrs['repo_setup']['repos'], attrs['provision'], cluster.id)) # NOTE(kozhukalov): This pre-provision task is going to be # removed by 7.0 because we need this only for classic way of # provision and only until we get rid of it. We are going # to download debian-installer initrd and kernel just before # starting actual provisioning. is_download_debian_installer = all([ cluster.release.operating_system == consts.RELEASE_OS.ubuntu, attrs['provision']['method'] == consts.PROVISION_METHODS.cobbler]) if is_download_debian_installer: tasks.append( tasks_templates.make_download_debian_installer_task( [consts.MASTER_ROLE], attrs['repo_setup']['repos'], attrs['repo_setup']['installer_kernel'], attrs['repo_setup']['installer_initrd'])) PriorityStrategy().one_by_one(tasks) return tasks
def test_make_download_debian_installer_task(self): remote_kernel = ('http://some/a/dists/trusty/main/' 'installer-amd64/current/images/' 'netboot/ubuntu-installer/amd64/linux') remote_initrd = ('http://some/a/dists/trusty/main/' 'installer-amd64/current/images/' 'netboot/ubuntu-installer/amd64/initrd.gz') relative_kernel = ('dists/trusty/main/installer-amd64/current/' 'images/netboot/ubuntu-installer/amd64/linux') relative_initrd = ('dists/trusty/main/installer-amd64/current/' 'images/netboot/ubuntu-installer/amd64/initrd.gz') local_kernel = '/var/www/nailgun/ubuntu/x86_64/images/linux' local_initrd = '/var/www/nailgun/ubuntu/x86_64/images/initrd.gz' # we have to be able to handle both cases with trailing slash # and without it for uri in ('http://some/a/', 'http://some/a'): result = tasks_templates.make_download_debian_installer_task( [1, 2, 3], repos=[{ 'name': 'repo', 'uri': uri }], installer_kernel={ 'remote_relative': relative_kernel, 'local': local_kernel }, installer_initrd={ 'remote_relative': relative_initrd, 'local': local_initrd }) self.assertEqual( result, { 'id': None, 'type': 'shell', 'uids': [1, 2, 3], 'parameters': { 'cmd': ('LOCAL_KERNEL_FILE={local_kernel} ' 'LOCAL_INITRD_FILE={local_initrd} ' 'download-debian-installer ' '{remote_kernel} {remote_initrd}').format( local_kernel=local_kernel, local_initrd=local_initrd, remote_kernel=remote_kernel, remote_initrd=remote_initrd), 'timeout': 600, 'retries': 1, 'interval': 1, 'cwd': '/', } })
def test_make_download_debian_installer_task(self): remote_kernel = ( "http://some/a/dists/trusty/main/" "installer-amd64/current/images/" "netboot/ubuntu-installer/amd64/linux" ) remote_initrd = ( "http://some/a/dists/trusty/main/" "installer-amd64/current/images/" "netboot/ubuntu-installer/amd64/initrd.gz" ) relative_kernel = "dists/trusty/main/installer-amd64/current/" "images/netboot/ubuntu-installer/amd64/linux" relative_initrd = "dists/trusty/main/installer-amd64/current/" "images/netboot/ubuntu-installer/amd64/initrd.gz" local_kernel = "/var/www/nailgun/ubuntu/x86_64/images/linux" local_initrd = "/var/www/nailgun/ubuntu/x86_64/images/initrd.gz" # we have to be able to handle both cases with trailing slash # and without it for uri in ("http://some/a/", "http://some/a"): result = tasks_templates.make_download_debian_installer_task( [1, 2, 3], repos=[{"name": "repo", "uri": uri}], installer_kernel={"remote_relative": relative_kernel, "local": local_kernel}, installer_initrd={"remote_relative": relative_initrd, "local": local_initrd}, ) self.assertEqual( result, { "type": "shell", "uids": [1, 2, 3], "parameters": { "cmd": ( "LOCAL_KERNEL_FILE={local_kernel} " "LOCAL_INITRD_FILE={local_initrd} " "download-debian-installer " "{remote_kernel} {remote_initrd}" ).format( local_kernel=local_kernel, local_initrd=local_initrd, remote_kernel=remote_kernel, remote_initrd=remote_initrd, ), "timeout": 600, "retries": 1, "interval": 1, "cwd": "/", }, }, )
def test_make_download_debian_installer_task(self): remote_kernel = ('http://some/a/dists/trusty/main/' 'installer-amd64/current/images/' 'netboot/ubuntu-installer/amd64/linux') remote_initrd = ('http://some/a/dists/trusty/main/' 'installer-amd64/current/images/' 'netboot/ubuntu-installer/amd64/initrd.gz') relative_kernel = ('dists/trusty/main/installer-amd64/current/' 'images/netboot/ubuntu-installer/amd64/linux') relative_initrd = ('dists/trusty/main/installer-amd64/current/' 'images/netboot/ubuntu-installer/amd64/initrd.gz') local_kernel = '/var/www/nailgun/ubuntu/x86_64/images/linux' local_initrd = '/var/www/nailgun/ubuntu/x86_64/images/initrd.gz' # we have to be able to handle both cases with trailing slash # and without it for uri in ('http://some/a/', 'http://some/a'): result = tasks_templates.make_download_debian_installer_task( [1, 2, 3], repos=[{'name': 'repo', 'uri': uri}], installer_kernel={'remote_relative': relative_kernel, 'local': local_kernel}, installer_initrd={'remote_relative': relative_initrd, 'local': local_initrd}) self.assertEqual(result, { 'id': None, 'type': 'shell', 'uids': [1, 2, 3], 'parameters': { 'cmd': ('LOCAL_KERNEL_FILE={local_kernel} ' 'LOCAL_INITRD_FILE={local_initrd} ' 'download-debian-installer ' '{remote_kernel} {remote_initrd}').format( local_kernel=local_kernel, local_initrd=local_initrd, remote_kernel=remote_kernel, remote_initrd=remote_initrd), 'timeout': 600, 'retries': 1, 'interval': 1, 'cwd': '/', }})