#NEWLINE# def _create_instance_with_availability_zone( self , zone_name ) : #NEWLINE# #INDENT# def create( * args , **kwargs ) : #NEWLINE# #INDENT# self . assertIn ( 'availability_zone' , kwargs ) #NEWLINE# self . assertEqual ( 'nova' , kwargs [ 'availability_zone' ] ) #NEWLINE# return old_create ( * args , ** kwargs ) #NEWLINE# #UNINDENT# old_create = compute_api . API . create #NEWLINE# self . stubs . Set ( compute_api . API , 'create' , create ) #NEWLINE# image_href = '76fa36fc-c930-4bf3-8c8a-ea2a2420deb6' #NEWLINE# flavor_ref = ( ( 'http://localhost' + self . base_url ) + 'flavors/3' ) #NEWLINE# body = { #NEWLINE# #INDENT# 'server' : { #NEWLINE# #INDENT# 'name' : 'server_test' , #NEWLINE# 'imageRef' : image_href , #NEWLINE# 'flavorRef' : flavor_ref , #NEWLINE# 'metadata' : { #NEWLINE# #INDENT# 'hello' : 'world' , #NEWLINE# 'open' : 'stack' , #NEWLINE# #UNINDENT# } , #NEWLINE# 'availability_zone' : zone_name , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } #NEWLINE# admin_context = context . get_admin_context ( ) #NEWLINE# db . service_create ( admin_context , { #NEWLINE# #INDENT# 'host' : 'host1_zones' , #NEWLINE# 'binary' : 'nova-compute' , #NEWLINE# 'topic' : 'compute' , #NEWLINE# 'report_count' : 0 , #NEWLINE# #UNINDENT# } ) #NEWLINE# agg = db . aggregate_create ( admin_context , { #NEWLINE# #INDENT# 'name' : 'agg1' , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'availability_zone' : 'nova' , #NEWLINE# #UNINDENT# } ) #NEWLINE# db . aggregate_host_add ( image_href , agg [ 'id' ] , 'host1_zones' ) #NEWLINE# return ( self . req , body )