<s> '''<STR_LIT>''' <EOL> from expedient . common . rpc4django import rpcmethod <EOL> import xmlrpclib <EOL> import logging <EOL> from geni import CredentialVerifier <EOL> from django . conf import settings <EOL> from decorator import decorator <EOL> from openflow . plugin . gapi import gapi <EOL> from expedient . clearinghouse . slice . models import Slice <EOL> from openflow . plugin . gapi . gapi import DuplicateSliceNameException <EOL> logger = logging . getLogger ( "<STR_LIT>" ) <EOL> CREDENTIALS_TYPE = '<STR_LIT>' <EOL> OPTIONS_TYPE = '<STR_LIT>' <EOL> RSPEC_TYPE = '<STR_LIT:string>' <EOL> VERSION_TYPE = '<STR_LIT>' <EOL> URN_TYPE = '<STR_LIT:string>' <EOL> SUCCESS_TYPE = '<STR_LIT>' <EOL> STATUS_TYPE = '<STR_LIT>' <EOL> TIME_TYPE = '<STR_LIT:string>' <EOL> PRIVS_MAP = dict ( <EOL> ListResources = ( ) , <EOL> RenewSliver = ( '<STR_LIT>' , ) , <EOL> CreateSliver = ( '<STR_LIT>' , ) , <EOL> DeleteSliver = ( '<STR_LIT>' , ) , <EOL> SliverStatus = ( '<STR_LIT>' , ) , <EOL> Shutdown = ( '<STR_LIT>' , ) , <EOL> ) <EOL> def no_such_slice ( slice_urn ) : <EOL> "<STR_LIT>" <EOL> fault_code = '<STR_LIT>' <EOL> fault_string = '<STR_LIT>' % ( slice_urn ) <EOL> raise xmlrpclib . Fault ( fault_code , fault_string ) <EOL> def duplicate_slice_name ( slice_name ) : <EOL> "<STR_LIT>" <EOL> fault_code = "<STR_LIT>" <EOL> fault_string = "<STR_LIT>" "<STR_LIT>" <EOL> raise xmlrpclib . Fault ( fault_code , fault_string ) <EOL> def require_creds ( use_slice_urn ) : <EOL> """<STR_LIT>""" <EOL> def require_creds ( func , * args , ** kw ) : <EOL> logger . debug ( "<STR_LIT>" ) <EOL> client_cert = kw [ "<STR_LIT>" ] . META [ "<STR_LIT>" ] <EOL> if use_slice_urn : <EOL> slice_urn = args [ <NUM_LIT:0> ] <EOL> credentials = args [ <NUM_LIT:1> ] <EOL> else : <EOL> slice_urn = None <EOL> credentials = args [ <NUM_LIT:0> ] <EOL> cred_verifier = CredentialVerifier ( settings . GCF_X509_TRUSTED_CERT_DIR ) <EOL> cred_verifier . verify_from_strings ( <EOL> client_cert , credentials , <EOL> slice_urn , PRIVS_MAP [ func . func_name ] ) <EOL> logger . debug ( "<STR_LIT>" ) <EOL> return func ( * args , ** kw ) <EOL> return decorator ( require_creds ) <EOL> @ rpcmethod ( signature = [ '<STR_LIT:string>' , '<STR_LIT:string>' ] , url_name = "<STR_LIT>" ) <EOL> def ping ( str , ** kwargs ) : <EOL> return "<STR_LIT>" % str <EOL> @ rpcmethod ( signature = [ VERSION_TYPE ] , url_name = "<STR_LIT>" ) <EOL> def GetVersion ( ** kwargs ) : <EOL> logger . debug ( "<STR_LIT>" ) <EOL> return gapi . GetVersion ( ) <EOL> @ rpcmethod ( signature = [ RSPEC_TYPE , CREDENTIALS_TYPE , OPTIONS_TYPE ] , <EOL> url_name = "<STR_LIT>" ) <EOL> @ require_creds ( False ) <EOL> def ListResources ( credentials , options , ** kwargs ) : <EOL> logger . debug ( "<STR_LIT>" ) <EOL> return gapi . ListResources ( options , kwargs [ "<STR_LIT>" ] . user ) <EOL> @ require_creds ( True ) <EOL> @ rpcmethod ( signature = [ RSPEC_TYPE , URN_TYPE , CREDENTIALS_TYPE , OPTIONS_TYPE ] , <EOL> url_name = "<STR_LIT>" ) <EOL> def CreateSliver ( slice_urn , credentials , rspec , users , ** kwargs ) : <EOL> logger . debug ( "<STR_LIT>" % kwargs [ "<STR_LIT>" ] . user ) <EOL> try : <EOL> return gapi . CreateSliver ( slice_urn , rspec , kwargs [ "<STR_LIT>" ] . user ) <EOL> except Slice . DoesNotExist : <EOL> no_such_slice ( slice_urn ) <EOL> except DuplicateSliceNameException as e : <EOL> duplicate_slice_name ( e . slice_name ) <EOL> @ require_creds ( True ) <EOL> @ rpcmethod ( signature = [ SUCCESS_TYPE , URN_TYPE , CREDENTIALS_TYPE ] , <EOL> url_name = "<STR_LIT>" ) <EOL> def DeleteSliver ( slice_urn , credentials , ** kwargs ) : <EOL> logger . debug ( "<STR_LIT>" ) <EOL> try : <EOL> return gapi . DeleteSliver ( slice_urn , kwargs [ "<STR_LIT>" ] . user ) <EOL> except Slice . DoesNotExist : <EOL> no_such_slice ( slice_urn ) <EOL> @ require_creds ( True ) <EOL> @ rpcmethod ( signature = [ STATUS_TYPE , URN_TYPE , CREDENTIALS_TYPE ] , <EOL> url_name = "<STR_LIT>" ) <EOL> def SliverStatus ( slice_urn , credentials , ** kwargs ) : <EOL> logger . debug ( "<STR_LIT>" ) <EOL> try : <EOL> return gapi . SliverStatus ( slice_urn ) <EOL> except Slice . DoesNotExist : <EOL> no_such_slice ( slice_urn ) <EOL> @ require_creds ( True ) <EOL> @ rpcmethod ( signature = [ SUCCESS_TYPE , URN_TYPE , CREDENTIALS_TYPE , TIME_TYPE ] , <EOL> url_name = "<STR_LIT>" ) <EOL> def RenewSliver ( slice_urn , credentials , expiration_time , ** kwargs ) : <EOL> logger . debug ( "<STR_LIT>" ) <EOL> try : <EOL> return gapi . RenewSliver ( slice_urn , expiration_time ) <EOL> except Slice . DoesNotExist : <EOL> no_such_slice ( slice_urn ) <EOL> @ require_creds ( True ) <EOL> @ rpcmethod ( signature = [ SUCCESS_TYPE , URN_TYPE , CREDENTIALS_TYPE ] , <EOL> url_name = "<STR_LIT>" ) <EOL> def Shutdown ( slice_urn , credentials , ** kwargs ) : <EOL> logger . debug ( "<STR_LIT>" ) <EOL> try : <EOL> return gapi . Shutdown ( slice_urn , kwargs [ "<STR_LIT>" ] . user ) <EOL> except Slice . DoesNotExist : <EOL> no_such_slice ( slice_urn ) </s>
