#NEWLINE# def build_instance_info_for_deploy( task ) : #NEWLINE# #INDENT# 'Build instance_info necessary for deploying to a node.\n\n    :param task: a TaskManager object containing the node\n    :returns: a dictionary containing the properties to be updated\n        in instance_info\n    :raises: exception.ImageRefValidationFailed if image_source is not\n        Glance href and is not HTTP(S) URL.\n    ' #NEWLINE# node = task . node #NEWLINE# instance_info = node . instance_info #NEWLINE# image_source = instance_info [ 'image_source' ] #NEWLINE# if service_utils . is_glance_image ( image_source ) : #NEWLINE# #INDENT# glance = image_service . GlanceImageService ( version = 2 , context = task . context ) #NEWLINE# image_info = glance . show ( instance_info ) #NEWLINE# swift_temp_url = glance . swift_temp_url ( image_info ) #NEWLINE# LOG . debug ( 'Got image info: %(info)s for node %(node)s.' , { #NEWLINE# #INDENT# 'info' : image_info , #NEWLINE# 'node' : node . uuid , #NEWLINE# #UNINDENT# } ) #NEWLINE# instance_info [ 'image_url' ] = swift_temp_url #NEWLINE# instance_info [ 'image_checksum' ] = image_info [ 'checksum' ] #NEWLINE# instance_info [ 'image_disk_format' ] = image_info [ 'disk_format' ] #NEWLINE# instance_info [ 'image_container_format' ] = image_info [ 'container_format' ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# image_service . HttpImageService ( ) . validate_href ( image_source ) #NEWLINE# #UNINDENT# except exception . ImageRefValidationFailed : #NEWLINE# #INDENT# with excutils . save_and_reraise_exception ( ) : #NEWLINE# #INDENT# LOG . error ( _LE ( "Agent deploy supports only HTTP(S) URLs as instance_info['image_source']. Either %s is not a valid HTTP(S) URL or is not reachable." ) , image_source ) #NEWLINE# #UNINDENT# #UNINDENT# instance_info [ 'image_url' ] = image_source #NEWLINE# #UNINDENT# return instance_info