#NEWLINE# @ auth #NEWLINE# def _POST( self , * param , **params ) : #NEWLINE# #INDENT# ( host_id , guest_id ) = self . chk_guestby1 ( param ) #NEWLINE# if ( guest_id is None ) : #NEWLINE# #INDENT# return web . notfound ( ) #NEWLINE# #UNINDENT# model = findbyguest1 ( self . orm , guest_id ) #NEWLINE# kvc = KaresansuiVirtConnection ( ) #NEWLINE# try : #NEWLINE# #INDENT# domname = kvc . uuid_to_domname ( model . uniq_key ) #NEWLINE# if ( not domname ) : #NEWLINE# #INDENT# return web . conflict ( web . ctx . path ) #NEWLINE# #UNINDENT# virt = kvc . search_kvg_guests ( domname ) [ 0 ] #NEWLINE# nic_info = virt . get_interface_info ( ) #NEWLINE# if ( self . input . device_type == 'nic' ) : #NEWLINE# #INDENT# if ( not validates_nic ( self ) ) : #NEWLINE# #INDENT# return web . badrequest ( self . view . alert ) #NEWLINE# #UNINDENT# f_chk = True #NEWLINE# for x in nic_info : #NEWLINE# #INDENT# if ( x [ 'mac' ] [ 'address' ] == self . input . mac_address ) : #NEWLINE# #INDENT# f_chk = False #NEWLINE# break #NEWLINE# #UNINDENT# #UNINDENT# if ( f_chk is False ) : #NEWLINE# #INDENT# return web . badrequest ( _ ( 'Specified MAC address is already defined.' ) ) #NEWLINE# #UNINDENT# mac = self . input . mac_address #NEWLINE# bridge = None #NEWLINE# network = None #NEWLINE# if ( self . input . nic_type == 'phydev' ) : #NEWLINE# #INDENT# bridge = self . input . phydev #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( self . input . nic_type == 'virnet' ) : #NEWLINE# #INDENT# network = self . input . virnet #NEWLINE# #UNINDENT# #UNINDENT# self . logger . debug ( ( 'spinning off create_nic_job dom=%s, mac=%s, bridge=%s, network=%s' % ( domname , mac , bridge , network ) ) ) #NEWLINE# create_nic_job ( self , model , domname , mac , bridge , network ) #NEWLINE# return web . accepted ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( self . input . device_type == 'disk' ) : #NEWLINE# #INDENT# if ( not validates_disk ( self ) ) : #NEWLINE# #INDENT# return web . badrequest ( self . view . alert ) #NEWLINE# #UNINDENT# volume_job = None #NEWLINE# order = 0 #NEWLINE# if ( ( self . input . pool_type == 'dir' ) or ( self . input . pool_type == 'fs' ) ) : #NEWLINE# #INDENT# disk_type = 'file' #NEWLINE# pool_name = self . input . pool_dir #NEWLINE# volume_name = string_from_uuid ( generate_uuid ( ) ) #NEWLINE# volume_job = create_storage_volume_dir ( self , model , domname , volume_name , self . input . pool_dir , self . input . disk_format , self . input . disk_size , self . input . disk_size , 'M' , order ) #NEWLINE# order += 1 #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( self . input . pool_type == 'block' ) : #NEWLINE# #INDENT# disk_type = 'iscsi' #NEWLINE# ( iscsi_pool , iscsi_volume ) = self . input . pool_dir . split ( '/' , 2 ) #NEWLINE# pool_name = iscsi_pool #NEWLINE# volume_name = iscsi_volume #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return badrequest ( _ ( 'No storage type specified.' ) ) #NEWLINE# #UNINDENT# #UNINDENT# disk_job = create_disk_job ( self , guest = model , domain_name = domname , pool = pool_name , volume = volume_name , bus = self . input . bus_type , format = self . input . disk_format , type = disk_type , order = order ) #NEWLINE# order += 1 #NEWLINE# if ( exec_disk_job ( obj = self , guest = model , disk_job = disk_job , volume_job = volume_job , order = order ) is True ) : #NEWLINE# #INDENT# return web . accepted ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return False #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# return False #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# finally : #NEWLINE# #INDENT# kvc . close ( )