示例#1
0
def _create_host(hostname, afe, afe_host):
    """Create a CrosHost object for a DUT to be installed.

    @param hostname  Hostname of the target DUT.
    @param afe       A frontend.AFE object.
    @param afe_host  AFE Host object for the DUT.
    """
    machine_dict = {
        'hostname': hostname,
        'afe_host': afe_host,
        'host_info_store': afe_store.AfeStore(hostname, afe),
    }
    servo_args = hosts.CrosHost.get_servo_arguments({})
    return hosts.create_host(machine_dict, servo_args=servo_args)
def check_dut_image(build, suite_job_id):
    """Confirm all DUTs used for the suite are imaged to expected build.

    @param build: Expected build to be imaged.
    @param suite_job_id: job ID of the suite job.
    @raise TestPushException: If a DUT does not have expected build imaged.
    """
    print 'Checking image installed in DUTs...'
    job_ids = [
        job.id for job in models.Job.objects.filter(parent_job_id=suite_job_id)
    ]
    hqes = [
        models.HostQueueEntry.objects.filter(job_id=job_id)[0]
        for job_id in job_ids
    ]
    hostnames = set([hqe.host.hostname for hqe in hqes])
    for hostname in hostnames:
        host_info_store = afe_store.AfeStore(hostname, AFE)
        info = host_info_store.get()
        if info.build != build:
            raise TestPushException('DUT is not imaged properly. Host %s has '
                                    'build %s, while build %s is expected.' %
                                    (hostname, info.build, build))
 def setUp(self):
     self.hostname = 'some-host'
     self.mock_afe = mock.create_autospec(frontend.AFE, instance=True)
     self.store = afe_store.AfeStore(self.hostname, afe=self.mock_afe)