Esempio n. 1
0
File: parser.py Progetto: czfgd/lava
def parse_action(job_data, name, device, pipeline, test_info, test_count):
    """
    If protocols are defined, each Action may need to be aware of the protocol parameters.
    """
    parameters = job_data[name]
    if "protocols" in pipeline.job.parameters:
        parameters.update(pipeline.job.parameters["protocols"])

    if name == "boot":
        Boot.select(device, parameters)(pipeline, parameters)
    elif name == "test":
        # stage starts at 0
        parameters["stage"] = test_count - 1
        action = LavaTest.select(device, parameters)
        action(pipeline, parameters)
        return action
    elif name == "deploy":
        candidate = Deployment.select(device, parameters)
        if parameters["namespace"] in test_info and candidate.uses_deployment_data():
            if any(
                [
                    testclass
                    for testclass in test_info[parameters["namespace"]]
                    if testclass["class"].needs_deployment_data()
                ]
            ):
                parameters.update(
                    {"deployment_data": get_deployment_data(parameters.get("os", ""))}
                )
        if "preseed" in parameters:
            parameters.update(
                {"deployment_data": get_deployment_data(parameters.get("os", ""))}
            )
        Deployment.select(device, parameters)(pipeline, parameters)
Esempio n. 2
0
def parse_action(job_data, name, device, pipeline, test_info, test_count):
    """
    If protocols are defined, each Action may need to be aware of the protocol parameters.
    """
    parameters = job_data[name]
    parameters['test_info'] = test_info
    if 'protocols' in pipeline.job.parameters:
        parameters.update(pipeline.job.parameters['protocols'])

    if name == 'boot':
        Boot.select(device, parameters)(pipeline, parameters)
    elif name == 'test':
        # stage starts at 0
        parameters['stage'] = test_count - 1
        LavaTest.select(device, parameters)(pipeline, parameters)
    elif name == 'deploy':
        candidate = Deployment.select(device, parameters)
        if parameters[
                'namespace'] in test_info and candidate.uses_deployment_data():
            if any([
                    testclass
                    for testclass in test_info[parameters['namespace']]
                    if testclass['class'].needs_deployment_data()
            ]):
                parameters.update({
                    'deployment_data':
                    get_deployment_data(parameters.get('os', ''))
                })
        if 'preseed' in parameters:
            parameters.update({
                'deployment_data':
                get_deployment_data(parameters.get('os', ''))
            })
        Deployment.select(device, parameters)(pipeline, parameters)
Esempio n. 3
0
File: parser.py Progetto: slawr/lava
def parse_action(job_data, name, device, pipeline, test_info, test_count):
    """
    If protocols are defined, each Action may need to be aware of the protocol parameters.
    """
    parameters = job_data[name]
    if "protocols" in pipeline.job.parameters:
        parameters.update(pipeline.job.parameters["protocols"])

    if name == "boot":
        cls = Boot.select(device, parameters)
        action = cls.action()
    elif name == "test":
        parameters["stage"] = test_count
        cls = LavaTest.select(device, parameters)
        action = cls.action(parameters)
    elif name == "deploy":
        cls = Deployment.select(device, parameters)
        ns = parameters["namespace"]
        # Does the action needs deployment_data field?
        needs_deployment_data = False
        if ns in test_info and cls.uses_deployment_data():
            needs_deployment_data = any([
                t["class"].needs_deployment_data(t["parameters"])
                for t in test_info[ns]
            ])
        if needs_deployment_data or "preseed" in parameters:
            parameters.update({
                "deployment_data":
                get_deployment_data(parameters.get("os", ""))
            })
        cls = Deployment.select(device, parameters)
        action = cls.action()

    action.section = cls.section
    pipeline.add_action(action, parameters)
    pipeline.job.compatibility = max(cls.compatibility,
                                     pipeline.job.compatibility)
    return cls