Ejemplo n.º 1
0
    def set(self, request):
        """Sets the lab info based on `request`."""
        for host in request.host:
            lab = model.LabModel()
            lab.name = request.name
            lab.owner = request.owner
            lab.hostname = host.hostname
            lab.ip = host.ip
            lab.script = host.script
            devices = []
            null_device_count = 0
            if host.device:
                for device in host.device:
                    devices.append("%s=%s" % (device.serial, device.product))
                    if device.product == "null":
                        null_device_count += 1
            if devices:
                lab.devices = ",".join(devices)
            lab.timestamp = datetime.datetime.now()
            lab.put()

            if null_device_count > 0:
                host_info.AddNullDevices(host.hostname, null_device_count)

        return model.DefaultResponse(
            return_code=model.ReturnCodeMessage.SUCCESS)
Ejemplo n.º 2
0
    def set(self, request):
        """Sets the schedule info based on `request`."""
        schedule = model.ScheduleModel()
        schedule.manifest_branch = request.manifest_branch
        schedule.build_storage_type = request.build_storage_type
        if request.get_assigned_value("device_pab_account_id"):
            schedule.device_pab_account_id = request.device_pab_account_id
        schedule.build_target = request.build_target
        schedule.test_name = request.test_name
        schedule.require_signed_device_build = (
            request.require_signed_device_build)
        schedule.period = request.period
        schedule.priority = request.priority
        schedule.device = request.device
        schedule.shards = request.shards
        schedule.param = request.param
        schedule.retry_count = request.retry_count
        schedule.gsi_storage_type = request.gsi_storage_type
        schedule.gsi_branch = request.gsi_branch
        schedule.gsi_build_target = request.gsi_build_target
        schedule.gsi_pab_account_id = request.gsi_pab_account_id
        schedule.test_storage_type = request.test_storage_type
        schedule.test_branch = request.test_branch
        schedule.test_build_target = request.test_build_target
        schedule.test_pab_account_id = request.test_pab_account_id
        schedule.timestamp = datetime.datetime.now()
        schedule.schedule_type = "test"
        schedule.put()

        return model.DefaultResponse(
            return_code=model.ReturnCodeMessage.SUCCESS)
Ejemplo n.º 3
0
    def set(self, request):
        """Sets the host info based on the `request`."""
        if users.get_current_user():
            username = users.get_current_user().email()
        else:
            username = "******"

        for request_device in request.devices:
            device_query = model.DeviceModel.query(
                model.DeviceModel.serial == request_device.serial)
            existing_device = device_query.fetch()
            if existing_device:
                device = existing_device[0]
            else:
                device = model.DeviceModel()
                device.serial = request_device.serial
                device.scheduling_status = Status.DEVICE_SCHEDULING_STATUS_DICT[
                    "free"]
            device.username = username
            device.hostname = request.hostname
            device.product = request_device.product
            device.status = request_device.status
            device.timestamp = datetime.datetime.now()
            device.put()

        return model.DefaultResponse(
            return_code=model.ReturnCodeMessage.SUCCESS)
Ejemplo n.º 4
0
 def clear(self, request):
     """Clears lab info in DB."""
     lab_query = model.LabModel.query()
     existing_labs = lab_query.fetch(keys_only=True)
     if existing_labs and len(existing_labs) > 0:
         ndb.delete_multi(existing_labs)
     return model.DefaultResponse(
         return_code=model.ReturnCodeMessage.SUCCESS)
Ejemplo n.º 5
0
 def clear(self, request):
     """Clears green build schedule info in DB."""
     schedule_query = model.ScheduleModel.query(
         model.ScheduleModel.schedule_type == "green")
     existing_schedules = schedule_query.fetch(keys_only=True)
     if existing_schedules and len(existing_schedules) > 0:
         ndb.delete_multi(existing_schedules)
     return model.DefaultResponse(
         return_code=model.ReturnCodeMessage.SUCCESS)
Ejemplo n.º 6
0
    def set(self, request):
        """Sets the build info based on the `request`."""
        build_query = model.BuildModel.query(
            model.BuildModel.build_id == request.build_id,
            model.BuildModel.build_target == request.build_target,
            model.BuildModel.build_type == request.build_type)
        existing_builds = build_query.fetch()

        if existing_builds and len(existing_builds) > 1:
            logging.warning("Duplicated builds found for [build_id]{} "
                            "[build_target]{} [build_type]{}".format(
                                request.build_id, request.build_target,
                                request.build_type))

        if request.signed and existing_builds:
            # only signed builds need to overwrite the exist entities.
            build = existing_builds[0]
        elif not existing_builds:
            build = model.BuildModel()
        else:
            # the same build existed and request is not signed build.
            build = None

        if build:
            build.manifest_branch = request.manifest_branch
            build.build_id = request.build_id
            build.build_target = request.build_target
            build.build_type = request.build_type
            build.artifact_type = request.artifact_type
            build.artifacts = request.artifacts
            build.timestamp = datetime.datetime.now()
            build.signed = request.signed
            build.put()

        return model.DefaultResponse(
            return_code=model.ReturnCodeMessage.SUCCESS)
Ejemplo n.º 7
0
    def set(self, request):
        """Sets the green build schedule info based on `request`."""
        schedule = model.ScheduleModel()
        schedule.name = request.name
        schedule.manifest_branch = request.manifest_branch
        schedule.build_target = request.build_target
        schedule.device_pab_account_id = request.device_pab_account_id
        schedule.test_name = request.test_name
        schedule.schedule = request.schedule
        schedule.priority = request.priority
        schedule.device = request.device
        schedule.shards = request.shards
        schedule.gsi_branch = request.gsi_branch
        schedule.gsi_build_target = request.gsi_build_target
        schedule.gsi_pab_account_id = request.gsi_pab_account_id
        schedule.test_branch = request.test_branch
        schedule.test_build_target = request.test_build_target
        schedule.test_pab_account_id = request.test_pab_account_id
        schedule.timestamp = datetime.datetime.now()
        schedule.schedule_type = "green"
        schedule.put()

        return model.DefaultResponse(
            return_code=model.ReturnCodeMessage.SUCCESS)