Ejemplo n.º 1
0
    def _CreateAVD(self, avd_spec, no_prompts):
        """Create the AVD.

        Args:
            avd_spec: AVDSpec object that tells us what we're going to create.
            no_prompts: Boolean, True to skip all prompts.

        Returns:
            A Report instance.
        """
        device_factory = remote_instance_cf_device_factory.RemoteInstanceDeviceFactory(
            avd_spec,
            avd_spec.local_image_artifact,
            create_common.GetCvdHostPackage())
        report = common_operations.CreateDevices(
            "create_cf", avd_spec.cfg, device_factory, num=1,
            report_internal_ip=avd_spec.report_internal_ip,
            autoconnect=avd_spec.autoconnect,
            avd_type=constants.TYPE_CF,
            boot_timeout_secs=avd_spec.boot_timeout_secs,
            unlock_screen=avd_spec.unlock_screen,
            wait_for_boot=False,
            connect_webrtc=avd_spec.connect_webrtc)
        # Launch vnc client if we're auto-connecting.
        if avd_spec.connect_vnc:
            utils.LaunchVNCFromReport(report, avd_spec, no_prompts)
        return report
Ejemplo n.º 2
0
    def _CreateAVD(self, avd_spec, no_prompts):
        """Create the AVD.

        Args:
            avd_spec: AVDSpec object that tells us what we're going to create.
            no_prompts: Boolean, True to skip all prompts.

        Returns:
            A Report instance.
        """
        logger.info("Creating a cheeps device in project %s, build_id: %s",
                    avd_spec.cfg.project,
                    avd_spec.remote_image[constants.BUILD_ID])

        device_factory = CheepsDeviceFactory(avd_spec.cfg, avd_spec)

        report = common_operations.CreateDevices(
            command="create_cheeps",
            cfg=avd_spec.cfg,
            device_factory=device_factory,
            num=avd_spec.num,
            report_internal_ip=avd_spec.report_internal_ip,
            autoconnect=avd_spec.autoconnect,
            avd_type=constants.TYPE_CHEEPS,
            client_adb_port=avd_spec.client_adb_port,
            boot_timeout_secs=avd_spec.boot_timeout_secs)

        # Launch vnc client if we're auto-connecting.
        if avd_spec.connect_vnc:
            utils.LaunchVNCFromReport(report, avd_spec, no_prompts)

        return report
Ejemplo n.º 3
0
    def _CreateAVD(self, avd_spec, no_prompts):
        """Create the AVD.

        Args:
            avd_spec: AVDSpec object that tells us what we're going to create.
            no_prompts: Boolean, True to skip all prompts.

        Returns:
            A Report instance.
        """
        logger.info("GCE local image: %s", avd_spec.local_image_artifact)

        report = device_driver.CreateGCETypeAVD(
            avd_spec.cfg,
            num=avd_spec.num,
            local_disk_image=avd_spec.local_image_artifact,
            autoconnect=avd_spec.autoconnect,
            report_internal_ip=avd_spec.report_internal_ip,
            avd_spec=avd_spec)

        # Launch vnc client if we're auto-connecting.
        if avd_spec.connect_vnc:
            utils.LaunchVNCFromReport(report, avd_spec, no_prompts)

        return report
    def _CreateAVD(self, avd_spec, no_prompts):
        """Create the AVD.

        Args:
            avd_spec: AVDSpec object that tells us what we're going to create.
            no_prompts: Boolean, True to skip all prompts.

        Returns:
            A Report instance.
        """
        report = create_goldfish_action.CreateDevices(avd_spec=avd_spec)

        # Launch vnc client if we're auto-connecting.
        if avd_spec.connect_vnc:
            utils.LaunchVNCFromReport(report, avd_spec, no_prompts)
        return report
    def _CreateAVD(self, avd_spec, no_prompts):
        """Create the AVD.

        Args:
            avd_spec: AVDSpec object that tells us what we're going to create.
            no_prompts: Boolean, True to skip all prompts.

        Returns:
            A Report instance.
        """
        report = device_driver.CreateGCETypeAVD(
            avd_spec.cfg,
            avd_spec.remote_image[constants.BUILD_TARGET],
            avd_spec.remote_image[constants.BUILD_ID],
            num=avd_spec.num,
            autoconnect=avd_spec.autoconnect,
            report_internal_ip=avd_spec.report_internal_ip,
            avd_spec=avd_spec)

        # Launch vnc client if we're auto-connecting.
        if avd_spec.connect_vnc:
            utils.LaunchVNCFromReport(report, avd_spec, no_prompts)

        return report
    def _CreateInstance(self, local_instance_id, local_image_path,
                        host_bins_path, avd_spec, no_prompts):
        """Create a CVD instance.

        Args:
            local_instance_id: Integer of instance id.
            local_image_path: String of local image directory.
            host_bins_path: String of host package directory.
            avd_spec: AVDSpec for the instance.
            no_prompts: Boolean, True to skip all prompts.

        Returns:
            A Report instance.
        """
        if avd_spec.connect_webrtc:
            utils.ReleasePort(constants.WEBRTC_LOCAL_PORT)

        launch_cvd_path = os.path.join(host_bins_path, "bin",
                                       constants.CMD_LAUNCH_CVD)
        cmd = self.PrepareLaunchCVDCmd(launch_cvd_path, avd_spec.hw_property,
                                       avd_spec.connect_adb, local_image_path,
                                       local_instance_id,
                                       avd_spec.connect_webrtc, avd_spec.gpu)

        result_report = report.Report(command="create")
        instance_name = instance.GetLocalInstanceName(local_instance_id)
        try:
            self._LaunchCvd(cmd, local_instance_id, host_bins_path,
                            (avd_spec.boot_timeout_secs
                             or constants.DEFAULT_CF_BOOT_TIMEOUT))
        except errors.LaunchCVDFail as launch_error:
            result_report.SetStatus(report.Status.BOOT_FAIL)
            result_report.AddDeviceBootFailure(instance_name,
                                               constants.LOCALHOST,
                                               None,
                                               None,
                                               error=str(launch_error))
            return result_report

        active_ins = list_instance.GetActiveCVD(local_instance_id)
        if active_ins:
            result_report.SetStatus(report.Status.SUCCESS)
            result_report.AddDevice(instance_name, constants.LOCALHOST,
                                    active_ins.adb_port, active_ins.vnc_port)
            # Launch vnc client if we're auto-connecting.
            if avd_spec.connect_vnc:
                utils.LaunchVNCFromReport(result_report, avd_spec, no_prompts)
            if avd_spec.connect_webrtc:
                utils.LaunchBrowserFromReport(result_report)
            if avd_spec.unlock_screen:
                AdbTools(active_ins.adb_port).AutoUnlockScreen()
        else:
            err_msg = "cvd_status return non-zero after launch_cvd"
            logger.error(err_msg)
            result_report.SetStatus(report.Status.BOOT_FAIL)
            result_report.AddDeviceBootFailure(instance_name,
                                               constants.LOCALHOST,
                                               None,
                                               None,
                                               error=err_msg)
        return result_report