Exemplo n.º 1
0
def validate_request_create_args(request_args, config, *args, **kwargs):
    """
    *arg and **kwargs are only for the interface
    validate post request
    1. read data from body
    2. validate using spec validation
    3. convert data from body to arguments (spec instance, argument with default setting) 
    TODO: rasie right kind of error with clear message 
    """
    
    initialize_request_args(request_args, config)
    #check the permission for creating the request
    permission = getWritePermission(request_args)
    authz_match(permission['role'], permission['group'])
    
    # set default values for teh request_args
    specClass = loadSpecClassByType(request_args["RequestType"])
    setArgumentsWithDefault(request_args, specClass.getWorkloadArguments())
    
    # get the spec type and validate arguments
    spec = loadSpecByType(request_args["RequestType"])
    if request_args["RequestType"] == "Resubmission":
        request_args["OriginalRequestCouchURL"] = '%s/%s' % (config.couch_host, 
                                                             config.couch_reqmgr_db)
    workload = spec.factoryWorkloadConstruction(request_args["RequestName"], 
                                                request_args)
    return workload, request_args
Exemplo n.º 2
0
def validate_request_create_args(request_args, config, reqmgr_db_service, *args, **kwargs):
    """
    *arg and **kwargs are only for the interface
    validate post request
    1. read data from body
    2. validate using spec validation
    3. convert data from body to arguments (spec instance, argument with default setting) 
    TODO: rasie right kind of error with clear message 
    """

    initialize_request_args(request_args, config)
    # check the permission for creating the request
    permission = getWritePermission(request_args)
    authz_match(permission['role'], permission['group'])

    # set default values for teh request_args
    specClass = loadSpecClassByType(request_args["RequestType"])
    setArgumentsWithDefault(request_args, specClass.getWorkloadArguments())

    # get the spec type and validate arguments
    spec = loadSpecByType(request_args["RequestType"])
    if request_args["RequestType"] == "Resubmission":
        initialize_resubmission(request_args, config, reqmgr_db_service)
        
    workload = spec.factoryWorkloadConstruction(request_args["RequestName"],
                                                request_args)
    return workload, request_args
Exemplo n.º 3
0
    def initialize_clone(self, request_name):
        requests = self.reqmgr_db_service.getRequestByNames(request_name)
        clone_args = requests.values()[0]
        # overwrite the name and time stamp.
        initialize_request_args(clone_args, self.config, clone=True)
        # timestamp status update

        spec = loadSpecByType(clone_args["RequestType"])
        workload = spec.factoryWorkloadConstruction(clone_args["RequestName"], clone_args)
        return (workload, clone_args)
Exemplo n.º 4
0
    def initialize_clone(self, request_name):
        requests = self.reqmgr_db_service.getRequestByNames(request_name)
        clone_args = requests.values()[0]
        # overwrite the name and time stamp.
        initialize_request_args(clone_args, self.config, clone=True)
        # timestamp status update

        spec = loadSpecByType(clone_args["RequestType"])
        workload = spec.factoryWorkloadConstruction(clone_args["RequestName"],
                                                    clone_args)
        return (workload, clone_args)
Exemplo n.º 5
0
def validate_request_create_args(request_args, config, *args, **kwargs):
    """
    *arg and **kwargs are only for the interface
    validate post request
    1. read data from body
    2. validate using spec validation
    3. convert data from body to arguments (spec instance, argument with default setting) 
    TODO: rasie right kind of error with clear message 
    """

    initialize_request_args(request_args, config)
    #check the permission for creating the request
    permission = getWritePermission(request_args)
    authz_match(permission['role'], permission['group'])

    # get the spec type and validate arguments
    spec = loadSpecByType(request_args["RequestType"])
    if request_args["RequestType"] == "Resubmission":
        request_args["OriginalRequestCouchURL"] = '%s/%s' % (
            config.couch_host, config.couch_reqmgr_db)
    workload = spec.factoryWorkloadConstruction(request_args["RequestName"],
                                                request_args)
    return workload, request_args