#NEWLINE# def pub_CreateSliver( self , slice_urn , credentials , rspec , users , options ) : #NEWLINE# #INDENT# 'Allocate resources to a slice\n\n    Reserve the resources described in the given RSpec for the given slice, returning a manifest RSpec of what has been reserved.\n\n    ' #NEWLINE# user_info = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# try : #NEWLINE# #INDENT# if CredVerifier . checkValid ( credentials , 'createsliver' ) : #NEWLINE# #INDENT# self . recordAction ( 'createsliver' , credentials , slice_urn ) #NEWLINE# try : #NEWLINE# #INDENT# cert = Certificate ( request . environ [ 'CLIENT_RAW_CERT' ] ) #NEWLINE# user_info [ 'urn' ] = cert . getURN ( ) #NEWLINE# user_info [ 'email' ] = cert . getEmailAddress ( ) #NEWLINE# self . _log . debug ( ( 'Parsed user cert with URN (%(urn)s) and email (%(email)s)' % user_info ) ) #NEWLINE# #UNINDENT# except Exception as e : #NEWLINE# #INDENT# self . _log . exception ( 'UNFILTERED EXCEPTION' ) #NEWLINE# user_info [ 'urn' ] = None #NEWLINE# user_info [ 'email' ] = None #NEWLINE# #UNINDENT# sliver = foam . geni . lib . createSliver ( slice_urn , credentials , rspec , user_info ) #NEWLINE# approve = foam . geni . approval . analyzeForApproval ( sliver ) #NEWLINE# style = ConfigDB . getConfigItemByKey ( 'geni.approval.approve-on-creation' ) . getValue ( ) #NEWLINE# if ( style == foam . geni . approval . NEVER ) : #NEWLINE# #INDENT# approve = False #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( style == foam . geni . approval . ALWAYS ) : #NEWLINE# #INDENT# approve = True #NEWLINE# #UNINDENT# #UNINDENT# if approve : #NEWLINE# #INDENT# pid = foam . task . approveSliver ( sliver . getURN ( ) , self . _auto_priority ) #NEWLINE# self . _log . debug ( ( 'task.py launched for approve-sliver (PID: %d)' % pid ) ) #NEWLINE# #UNINDENT# data = GeniDB . getSliverData ( sliver . getURN ( ) , True ) #NEWLINE# foam . task . emailCreateSliver ( data ) #NEWLINE# propertyList = self . buildPropertyList ( GENI_ERROR_CODE . SUCCESS , value = GeniDB . getManifest ( sliver . getURN ( ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# except foam . geni . lib . RspecParseError as e : #NEWLINE# #INDENT# msg = str ( e ) #NEWLINE# propertyList = self . buildPropertyList ( GENI_ERROR_CODE . BADARGS , output = msg ) #NEWLINE# e . log ( self . _log , msg , logging . INFO ) #NEWLINE# #UNINDENT# except foam . geni . lib . RspecValidationError as e : #NEWLINE# #INDENT# msg = str ( e ) #NEWLINE# propertyList = self . buildPropertyList ( GENI_ERROR_CODE . BADARGS , output = msg ) #NEWLINE# e . log ( self . _log , msg , logging . INFO ) #NEWLINE# #UNINDENT# except foam . geni . lib . DuplicateSliver as ds : #NEWLINE# #INDENT# msg = ( 'Attempt to create multiple slivers for slice [%s]' % ds . slice_urn ) #NEWLINE# propertyList = self . buildPropertyList ( GENI_ERROR_CODE . ERROR , output = msg ) #NEWLINE# ds . log ( self . _log , msg , logging . INFO ) #NEWLINE# #UNINDENT# except foam . geni . lib . UnknownComponentManagerID as ucm : #NEWLINE# #INDENT# msg = ( 'Component Manager ID specified in %s does not match this aggregate.' % ucm . cid ) #NEWLINE# propertyList = self . buildPropertyList ( GENI_ERROR_CODE . ERROR , output = msg ) #NEWLINE# ucm . log ( self . _log , msg , logging . INFO ) #NEWLINE# #UNINDENT# except ( foam . geni . lib . UnmanagedComponent , UnknownNode ) as uc : #NEWLINE# #INDENT# msg = ( 'DPID in component %s is unknown to this aggregate.' % uc . cid ) #NEWLINE# propertyList = self . buildPropertyList ( GENI_ERROR_CODE . ERROR , output = msg ) #NEWLINE# uc . log ( self . _log , msg , logging . INFO ) #NEWLINE# #UNINDENT# except Exception : #NEWLINE# #INDENT# msg = 'Exception' #NEWLINE# propertyList = self . buildPropertyList ( GENI_ERROR_CODE . ERROR , output = msg ) #NEWLINE# self . _log . exception ( msg ) #NEWLINE# #UNINDENT# finally : #NEWLINE# #INDENT# return propertyList