def _build_instance_pxe_options(task, pxe_info): pxe_opts = {} node = task.node for label, option in (('kernel', 'aki_path'), ('ramdisk', 'ari_path')): if label in pxe_info: if CONF.pxe.ipxe_enabled: # NOTE(pas-ha) do not use Swift TempURLs for kernel and # ramdisk of user image when boot_option is not local, # as this breaks instance reboot later when temp urls # have timed out. pxe_opts[option] = '/'.join( [CONF.deploy.http_url, node.uuid, label]) else: # It is possible that we don't have kernel/ramdisk or even # image_source to determine if it's a whole disk image or not. # For example, when transitioning to 'available' state # for first time from 'manage' state. pxe_opts[option] = pxe_utils.get_path_relative_to_tftp_root( pxe_info[label][1]) # These are dummy values to satisfy elilo. # image and initrd fields in elilo config cannot be blank. pxe_opts.setdefault('aki_path', 'no_kernel') pxe_opts.setdefault('ari_path', 'no_ramdisk') return pxe_opts
def _build_instance_pxe_options(task, pxe_info): pxe_opts = {} node = task.node for label, option in (('kernel', 'aki_path'), ('ramdisk', 'ari_path')): if label in pxe_info: if CONF.pxe.ipxe_enabled: # NOTE(pas-ha) do not use Swift TempURLs for kernel and # ramdisk of user image when boot_option is not local, # as this breaks instance reboot later when temp urls # have timed out. pxe_opts[option] = '/'.join( [CONF.deploy.http_url, node.uuid, label]) else: # It is possible that we don't have kernel/ramdisk or even # image_source to determine if it's a whole disk image or not. # For example, when transitioning to 'available' state # for first time from 'manage' state. pxe_opts[option] = pxe_utils.get_path_relative_to_tftp_root( pxe_info[label][1]) # These are dummy values to satisfy elilo. # image and initrd fields in elilo config cannot be blank. pxe_opts.setdefault('aki_path', 'no_kernel') pxe_opts.setdefault('ari_path', 'no_ramdisk') return pxe_opts
def _get_pxe_kernel_ramdisk(pxe_info): pxe_opts = {} pxe_opts['deployment_aki_path'] = pxe_utils.get_path_relative_to_tftp_root( pxe_info['deploy_kernel'][1]) pxe_opts['deployment_ari_path'] = pxe_utils.get_path_relative_to_tftp_root( pxe_info['deploy_ramdisk'][1]) # It is possible that we don't have kernel/ramdisk or even # image_source to determine if it's a whole disk image or not. # For example, when transitioning to 'available' state for first # time from 'manage' state. if 'kernel' in pxe_info: pxe_opts['aki_path'] = pxe_utils.get_path_relative_to_tftp_root( pxe_info['kernel'][1]) if 'ramdisk' in pxe_info: pxe_opts['ari_path'] = pxe_utils.get_path_relative_to_tftp_root( pxe_info['ramdisk'][1]) return pxe_opts
def _build_deploy_pxe_options(task, pxe_info): pxe_opts = {} node = task.node for label, option in (('deploy_kernel', 'deployment_aki_path'), ('deploy_ramdisk', 'deployment_ari_path')): if CONF.pxe.ipxe_enabled: image_href = pxe_info[label][0] if (CONF.pxe.ipxe_use_swift and service_utils.is_glance_image(image_href)): pxe_opts[option] = images.get_temp_url_for_glance_image( task.context, image_href) else: pxe_opts[option] = '/'.join( [CONF.deploy.http_url, node.uuid, label]) else: pxe_opts[option] = pxe_utils.get_path_relative_to_tftp_root( pxe_info[label][1]) return pxe_opts
def _build_deploy_pxe_options(task, pxe_info): pxe_opts = {} node = task.node for label, option in (('deploy_kernel', 'deployment_aki_path'), ('deploy_ramdisk', 'deployment_ari_path')): if CONF.pxe.ipxe_enabled: image_href = pxe_info[label][0] if (CONF.pxe.ipxe_use_swift and service_utils.is_glance_image(image_href)): pxe_opts[option] = images.get_temp_url_for_glance_image( task.context, image_href) else: pxe_opts[option] = '/'.join([CONF.deploy.http_url, node.uuid, label]) else: pxe_opts[option] = pxe_utils.get_path_relative_to_tftp_root( pxe_info[label][1]) return pxe_opts
def test_get_path_relative_to_tftp_root_without_trailing_slash(self): self.config(tftp_root='/tftpboot-path', group='pxe') test_file_path = '/tftpboot-path/pxelinux.cfg/test' relpath = pxe_utils.get_path_relative_to_tftp_root(test_file_path) self.assertEqual(relpath, 'pxelinux.cfg/test')
def test_get_path_relative_to_tftp_root_without_trailing_slash(self): self.config(tftp_root='/tftpboot-path', group='pxe') test_file_path = '/tftpboot-path/pxelinux.cfg/test' relpath = pxe_utils.get_path_relative_to_tftp_root(test_file_path) self.assertEqual(relpath, 'pxelinux.cfg/test')