<commit_before>'''
Created on Oct 1, 2010

@author: jnaous
'''
from expedient.common.rpc4django import rpcmethod
import xmlrpclib
import logging
from geni import CredentialVerifier
from django.conf import settings
from decorator import decorator
from openflow.plugin.gapi import gapi
from expedient.clearinghouse.slice.models import Slice
from openflow.plugin.gapi.gapi import DuplicateSliceNameException

logger = logging.getLogger("openflow.plugin.gapi.rpc")

# Parameter Types
CREDENTIALS_TYPE = 'array' # of strings
OPTIONS_TYPE = 'struct'
RSPEC_TYPE = 'string'
VERSION_TYPE = 'struct'
URN_TYPE = 'string'
SUCCESS_TYPE = 'boolean'
STATUS_TYPE = 'struct'
TIME_TYPE = 'string'

# SFA permissions mapping
PRIVS_MAP = dict(
    ListResources=(),
    RenewSliver=('renewsliver',),
    CreateSliver=('createsliver',),
    DeleteSliver=('deleteslice',),
    SliverStatus=('getsliceresources',),
)

def no_such_slice(slice_urn):
    "Raise a no such slice exception."
    fault_code = 'No such slice.'
    fault_string = 'The slice named by %s does not exist' % (slice_urn)
    raise xmlrpclib.Fault(fault_code, fault_string)

def duplicate_slice_name(slice_name):
    "Raise duplicate slice name exception."
    fault_code = "Duplicate slice name."
    fault_string = "The slice name is already in use. Please choose a" \
        " different slice name."
    raise xmlrpclib.Fault(fault_code, fault_string)

def require_creds(use_slice_urn):
    """Decorator to verify credentials"""
    def require_creds(func, *args, **kw):
        
        logger.debug("Checking creds")
        
        client_cert = kw["request"].META["SSL_CLIENT_CERT"]<commit_msg>missing priv map for shutdown<commit_after>'''
Created on Oct 1, 2010

@author: jnaous
'''
from expedient.common.rpc4django import rpcmethod
import xmlrpclib
import logging
from geni import CredentialVerifier
from django.conf import settings
from decorator import decorator
from openflow.plugin.gapi import gapi
from expedient.clearinghouse.slice.models import Slice
from openflow.plugin.gapi.gapi import DuplicateSliceNameException

logger = logging.getLogger("openflow.plugin.gapi.rpc")

# Parameter Types
CREDENTIALS_TYPE = 'array' # of strings
OPTIONS_TYPE = 'struct'
RSPEC_TYPE = 'string'
VERSION_TYPE = 'struct'
URN_TYPE = 'string'
SUCCESS_TYPE = 'boolean'
STATUS_TYPE = 'struct'
TIME_TYPE = 'string'

# SFA permissions mapping
PRIVS_MAP = dict(
    ListResources=(),
    RenewSliver=('renewsliver',),
    CreateSliver=('createsliver',),
    DeleteSliver=('deleteslice',),
    SliverStatus=('getsliceresources',),
    Shutdown=('shutdown',),
)

def no_such_slice(slice_urn):
    "Raise a no such slice exception."
    fault_code = 'No such slice.'
    fault_string = 'The slice named by %s does not exist' % (slice_urn)
    raise xmlrpclib.Fault(fault_code, fault_string)

def duplicate_slice_name(slice_name):
    "Raise duplicate slice name exception."
    fault_code = "Duplicate slice name."
    fault_string = "The slice name is already in use. Please choose a" \
        " different slice name."
    raise xmlrpclib.Fault(fault_code, fault_string)

def require_creds(use_slice_urn):
    """Decorator to verify credentials"""
    def require_creds(func, *args, **kw):
        
        logger.debug("Checking creds")
        
        client_cert = kw["request"].META["SSL_CLIENT_CERT"]
{'fraction_non_alphanumeric': 0.10310818888224746, 'fraction_numerical': 0.0035863717872086074, 'mean_word_length': 4.559800664451827, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1067998', 'n_tokens_mistral': 1076, 'n_tokens_neox': 1056, 'n_words': 282}