#NEWLINE# @ post ( '/:hypervisor/:host/guests/:guest_id/network_interfaces' ) #NEWLINE# def network_interface_create( hypervisor , host , guest_id ) : #NEWLINE# #INDENT# '\n    Create a network interface for a given guest\n\n    ::\n\n      POST /:hypervisor/:host/guests/:guest_id/network_interfaces\n\n\n    The body should contain a JSON object. The required keys should vary for\n    each hypervisor.\n\n    Xen example:\n    {"network": "THE NETWORK NAME"}\n    ' #NEWLINE# response . content_type = 'application/json' #NEWLINE# manager = create_manager ( hypervisor , host ) #NEWLINE# data = request . body . readline ( ) #NEWLINE# if ( not data ) : #NEWLINE# #INDENT# abort ( 400 , 'No data received' ) #NEWLINE# #UNINDENT# data = json . loads ( data ) #NEWLINE# network_interface = manager . network_interface_create ( guest_id , data ) #NEWLINE# location = ( '/%s/%s/guests/%s/network_interfaces/%s' % ( hypervisor , host , guest_id , network_interface [ 'id' ] ) ) #NEWLINE# response . set_header ( 'Location' , location ) #NEWLINE# manager . logout ( ) #NEWLINE# return json . dumps ( network_interface )