#NEWLINE# def pub_ListResources( self , credentials , options ) : #NEWLINE# #INDENT# 'Return information about available resources or resources allocated to a slice\n\n    List the resources at this aggregate in an RSpec: may be all resources,\n    only those available for reservation, or only those already reserved for the given slice.\n\n    ' #NEWLINE# try : #NEWLINE# #INDENT# CredVerifier . checkValid ( credentials , [ ] ) #NEWLINE# compressed = options . get ( 'geni_compressed' , False ) #NEWLINE# urn = options . get ( 'geni_slice_urn' , None ) #NEWLINE# spec_version = options . get ( 'geni_rspec_version' ) #NEWLINE# supported_spec = { #NEWLINE# #INDENT# 'version' : '3' , #NEWLINE# 'type' : 'GENI' , #NEWLINE# #UNINDENT# } #NEWLINE# if spec_version : #NEWLINE# #INDENT# if ( spec_version != supported_spec ) : #NEWLINE# #INDENT# msg = 'RSpec type/version not supported' #NEWLINE# propertyList = self . buildPropertyList ( GENI_ERROR_CODE . BADVERSION , output = msg ) #NEWLINE# return propertyList #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# msg = 'Required option geni_rspec_version missing' #NEWLINE# propertyList = self . buildPropertyList ( GENI_ERROR_CODE . BADARGS , output = msg ) #NEWLINE# return propertyList #NEWLINE# #UNINDENT# if urn : #NEWLINE# #INDENT# CredVerifier . checkValid ( msg , 'getsliceresources' , urn ) #NEWLINE# self . recordAction ( 'listresources' , credentials , urn ) #NEWLINE# sliver_urn = GeniDB . getSliverURN ( urn ) #NEWLINE# if ( sliver_urn is None ) : #NEWLINE# #INDENT# raise Exception ( ( 'Sliver for slice URN (%s) does not exist' % urn ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# rspec = GeniDB . getManifest ( sliver_urn ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# self . recordAction ( 'listresources' , credentials ) #NEWLINE# rspec = foam . geni . lib . getAdvertisement ( ) #NEWLINE# #UNINDENT# if compressed : #NEWLINE# #INDENT# zrspec = zlib . compress ( rspec ) #NEWLINE# rspec = base64 . b64encode ( zrspec ) #NEWLINE# #UNINDENT# propertyList = self . buildPropertyList ( GENI_ERROR_CODE . SUCCESS , value = rspec ) #NEWLINE# #UNINDENT# except ExpatError : #NEWLINE# #INDENT# msg = 'Error parsing credential strings' #NEWLINE# propertyList = self . buildPropertyList ( GENI_ERROR_CODE . BADARGS , output = msg ) #NEWLINE# self . _log . error ( msg ) #NEWLINE# #UNINDENT# except UnknownSlice as x : #NEWLINE# #INDENT# msg = ( 'Attempt to list resources on sliver for unknown slice %s' % urn ) #NEWLINE# propertyList = self . buildPropertyList ( GENI_ERROR_CODE . ERROR , output = msg ) #NEWLINE# x . log ( self . _log , msg , logging . INFO ) #NEWLINE# #UNINDENT# except xmlrpclib . Fault as x : #NEWLINE# #INDENT# msg = ( 'GCF credential check failure: <%s>' % x ) #NEWLINE# propertyList = self . buildPropertyList ( GENI_ERROR_CODE . ERROR , output = msg ) #NEWLINE# self . _log . info ( msg ) #NEWLINE# self . _log . debug ( x , exc_info = True ) #NEWLINE# #UNINDENT# except AttributeError as x : #NEWLINE# #INDENT# msg = ( 'GCF credential check failure: <%s>' % x ) #NEWLINE# propertyList = self . buildPropertyList ( GENI_ERROR_CODE . ERROR , output = msg ) #NEWLINE# self . _log . info ( msg ) #NEWLINE# self . _log . debug ( x , exc_info = True ) #NEWLINE# #UNINDENT# except Exception as e : #NEWLINE# #INDENT# msg = ( 'Exception: %s' % str ( e ) ) #NEWLINE# propertyList = self . buildPropertyList ( GENI_ERROR_CODE . ERROR , output = msg ) #NEWLINE# self . _log . exception ( msg ) #NEWLINE# #UNINDENT# finally : #NEWLINE# #INDENT# return propertyList