#NEWLINE# def _get_boot_iso( task , root_uuid ) : #NEWLINE# #INDENT# "This method returns a boot ISO to boot the node.\n\n    It chooses one of the three options in the order as below:\n    1. Does nothing if 'ilo_boot_iso' is present in node's instance_info and\n       'boot_iso_created_in_web_server' is not set in 'driver_internal_info'.\n    2. Image deployed has a meta-property 'boot_iso' in Glance. This should\n       refer to the UUID of the boot_iso which exists in Glance.\n    3. Generates a boot ISO on the fly using kernel and ramdisk mentioned in\n       the image deployed. It uploads the generated boot ISO to Swift.\n\n    :param task: a TaskManager instance containing the node to act on.\n    :param root_uuid: the uuid of the root partition.\n    :returns: boot ISO URL. Should be either of below:\n        * A Swift object - It should be of format 'swift:<object-name>'. It is\n          assumed that the image object is present in\n          CONF.ilo.swift_ilo_container;\n        * A Glance image - It should be format 'glance://<glance-image-uuid>'\n          or just <glance-image-uuid>;\n        * An HTTP URL.\n        On error finding the boot iso, it returns None.\n    :raises: MissingParameterValue, if any of the required parameters are\n        missing in the node's driver_info or instance_info.\n    :raises: InvalidParameterValue, if any of the parameters have invalid\n        value in the node's driver_info or instance_info.\n    :raises: SwiftOperationError, if operation with Swift fails.\n    :raises: ImageCreationFailed, if creation of boot ISO failed.\n    :raises: exception.ImageRefValidationFailed if ilo_boot_iso is not\n        HTTP(S) URL.\n    " #NEWLINE# LOG . debug ( 'Trying to get a boot ISO to boot the baremetal node' ) #NEWLINE# driver_internal_info = task . node . driver_internal_info #NEWLINE# boot_iso_created_in_web_server = driver_internal_info . get ( 'boot_iso_created_in_web_server' ) #NEWLINE# if ( task . node . instance_info . get ( 'ilo_boot_iso' ) and ( not boot_iso_created_in_web_server ) ) : #NEWLINE# #INDENT# LOG . debug ( "Using ilo_boot_iso provided in node's instance_info" ) #NEWLINE# boot_iso = task . node . instance_info [ 'ilo_boot_iso' ] #NEWLINE# if ( not service_utils . is_glance_image ( boot_iso ) ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# image_service . HttpImageService ( ) . validate_href ( boot_iso ) #NEWLINE# #UNINDENT# except exception . ImageRefValidationFailed : #NEWLINE# #INDENT# with excutils . save_and_reraise_exception ( ) : #NEWLINE# #INDENT# LOG . error ( _LE ( "Virtual media deploy accepts only Glance images or HTTP(S) URLs as instance_info['ilo_boot_iso']. Either %s is not a valid HTTP(S) URL or is not reachable." ) , boot_iso ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return task . node . instance_info [ 'ilo_boot_iso' ] #NEWLINE# #UNINDENT# deploy_info = _parse_deploy_info ( task . node ) #NEWLINE# image_href = deploy_info [ 'image_source' ] #NEWLINE# image_properties = images . get_image_properties ( task . context , image_href , [ 'boot_iso' , 'kernel_id' , 'ramdisk_id' ] ) #NEWLINE# boot_iso_uuid = image_properties . get ( 'boot_iso' ) #NEWLINE# kernel_href = ( task . node . instance_info . get ( 'kernel' ) or image_properties . get ( 'kernel_id' ) ) #NEWLINE# ramdisk_href = ( task . node . instance_info . get ( 'ramdisk' ) or image_properties . get ( 'ramdisk_id' ) ) #NEWLINE# if boot_iso_uuid : #NEWLINE# #INDENT# LOG . debug ( 'Found boot_iso %s in Glance' , boot_iso_uuid ) #NEWLINE# return boot_iso_uuid #NEWLINE# #UNINDENT# if ( ( not kernel_href ) or ( not ramdisk_href ) ) : #NEWLINE# #INDENT# LOG . error ( _LE ( 'Unable to find kernel or ramdisk for image %(image)s to generate boot ISO for %(node)s' ) , { #NEWLINE# #INDENT# 'image' : image_href , #NEWLINE# 'node' : task . node . uuid , #NEWLINE# #UNINDENT# } ) #NEWLINE# return #NEWLINE# #UNINDENT# deploy_iso_uuid = deploy_info [ 'ilo_deploy_iso' ] #NEWLINE# boot_mode = deploy_utils . get_boot_mode_for_deploy ( task . node ) #NEWLINE# boot_iso_object_name = _get_boot_iso_object_name ( task . node ) #NEWLINE# kernel_params = CONF . pxe . pxe_append_params #NEWLINE# with tempfile . NamedTemporaryFile ( dir = CONF . tempdir ) as fileobj : #NEWLINE# #INDENT# boot_iso_tmp_file = fileobj . name #NEWLINE# images . create_boot_iso ( task . context , boot_iso_tmp_file , kernel_href , ramdisk_href , deploy_iso_uuid , root_uuid , kernel_params , boot_mode ) #NEWLINE# if CONF . ilo . use_web_server_for_images : #NEWLINE# #INDENT# boot_iso_url = ilo_common . copy_image_to_web_server ( boot_iso_tmp_file , boot_iso_object_name ) #NEWLINE# driver_internal_info = task . node . driver_internal_info #NEWLINE# driver_internal_info [ 'boot_iso_created_in_web_server' ] = True #NEWLINE# task . node . driver_internal_info = driver_internal_info #NEWLINE# task . node . save ( ) #NEWLINE# LOG . debug ( 'Created boot_iso %(boot_iso)s for node %(node)s' , { #NEWLINE# #INDENT# 'boot_iso' : boot_iso_url , #NEWLINE# 'node' : task . node . uuid , #NEWLINE# #UNINDENT# } ) #NEWLINE# return boot_iso_url #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# container = CONF . ilo . swift_ilo_container #NEWLINE# swift_api = swift . SwiftAPI ( ) #NEWLINE# swift_api . create_object ( container , boot_iso_object_name , boot_iso_tmp_file ) #NEWLINE# LOG . debug ( 'Created boot_iso %s in Swift' , boot_iso_object_name ) #NEWLINE# return ( 'swift:%s' % boot_iso_object_name )