Example #1
0
def load_local_drivers( storage_driver_module_names ):
   '''
      Cache locally-hosted storage drivers
   '''
   
   global REQUIRED_DRIVER_FIELDS
   
   drivers = {}
   
   for sd_name in storage_driver_module_names:
      sd_module = None
      
      try:
         sd_module = __import__(sd_name)
      except Exception, e:
         log.exception( e )
         continue
      
      # validate it
      sd_module_dict = dict( [ (attr_name, getattr(sd_module, attr_name)) for attr in dir(sd_module) ] )
      
      try:
         rg_common.validate_fields( sd_module_dict, REQUIRED_DRIVER_FIELDS )
         validate_driver( sd_module_dict )
      except Excetion, e:
         log.exception( e )
         continue
Example #2
0
def load_local_drivers(storage_driver_module_names):
    '''
      Cache locally-hosted storage drivers
   '''

    global REQUIRED_DRIVER_FIELDS

    drivers = {}

    for sd_name in storage_driver_module_names:
        sd_module = None

        try:
            sd_module = __import__(sd_name)
        except Exception, e:
            log.exception(e)
            continue

        # validate it
        sd_module_dict = dict([(attr_name, getattr(sd_module, attr_name))
                               for attr in dir(sd_module)])

        try:
            rg_common.validate_fields(sd_module_dict, REQUIRED_DRIVER_FIELDS)
            validate_driver(sd_module_dict)
        except Excetion, e:
            log.exception(e)
            continue
Example #3
0
def validate_post(self, post_dict):

    global REQUIRED_POST_FIELDS

    # sanity check
    try:
        rg_common.validate_fields(post_dict, REQUIRED_POST_FIELDS)
        return 0
    except:
        return 400
Example #4
0
def validate_post( self, post_dict ):
   
   global REQUIRED_POST_FIELDS
   
   # sanity check
   try:
      rg_common.validate_fields( post_dict, REQUIRED_POST_FIELDS )
      return 0
   except:
      return 400
Example #5
0
 try:
    python_text = base64.b64decode( python_text_b64 )
 except Exception, e:
    log.exception( e )
    return None
 
 closure_module = imp.new_module("closure")
 
 try:
    exec( python_text, closure_module.__dict__ )
 except Exception, e:
    log.exception( e )
    return None
 
 # sanity check 
 rg_common.validate_fields( closure_module.__dict__, REQUIRED_CLOSURE_FIELDS )
 validate_closure( closure_module.__dict__ )
 
 config_dict = {}
 if config_text_b64 != None:
    # unmarshall the config text
    try:
       config_dict_str = base64.b64decode( config_text_b64 )
    except Exception, e:
       log.exception( e )
       return None
    
    try:
       config_dict = json.loads( config_dict_str )
    except Exception, e:
       log.exception( e )
Example #6
0
    try:
        python_text = base64.b64decode(python_text_b64)
    except Exception, e:
        log.exception(e)
        return None

    closure_module = imp.new_module("closure")

    try:
        exec(python_text, closure_module.__dict__)
    except Exception, e:
        log.exception(e)
        return None

    # sanity check
    rg_common.validate_fields(closure_module.__dict__, REQUIRED_CLOSURE_FIELDS)
    validate_closure(closure_module.__dict__)

    config_dict = {}
    if config_text_b64 != None:
        # unmarshall the config text
        try:
            config_dict_str = base64.b64decode(config_text_b64)
        except Exception, e:
            log.exception(e)
            return None

        try:
            config_dict = json.loads(config_dict_str)
        except Exception, e:
            log.exception(e)