Example #1
0
    def __setup_virtual_machine_done(self, sctx):
        self.log.debug("azure virtual environment %d vm setup done" % sctx.current_job_index)
        ctx = sctx.job_ctxs[sctx.current_job_index]

        # update the status of virtual environment
        ve = self.db.find_first_object_by(VirtualEnvironment, id=ctx.virtual_environment_id)

        adapter = VirtualMachineAdapter(ctx.subscription_id, ctx.pem_url, host=ctx.management_host)
        if ve:
            ve.status = VEStatus.RUNNING

            public_ip, port = adapter.get_virtual_machine_public_endpoint(
                ctx.cloud_service_name,
                ctx.deployment_name,
                ctx.virtual_machine_name,
                ctx.endpoint_name)

            if not public_ip:
                self.log.warn("unable to find public ip for vm %s, set guacamole failed" % ctx.virtual_machine_name)
            else:
                remote_para = get_remote_parameters(
                    ctx.raw_system_config,
                    ctx.remote,
                    ctx.virtual_machine_name,
                    public_ip, port)

                ve.remote_paras = json.dumps(remote_para)

            self.db.commit()
            self.expr_manager.check_expr_status(ve.experiment)

        self.log.debug("azure virtual environment %d vm success callback done, step to next" % sctx.current_job_index)
        # step to config next unit
        sctx.current_job_index += 1
        self.__schedule_setup(sctx)
Example #2
0
    def __setup_virtual_machine_done(self, sctx):
        self.log.debug("azure virtual environment %d vm setup done" %
                       sctx.current_job_index)
        ctx = sctx.job_ctxs[sctx.current_job_index]

        # update the status of virtual environment
        ve = self.db.find_first_object_by(VirtualEnvironment,
                                          id=ctx.virtual_environment_id)

        adapter = VirtualMachineAdapter(ctx.subscription_id,
                                        ctx.pem_url,
                                        host=ctx.management_host)
        if ve:
            ve.status = VEStatus.RUNNING

            public_ip, port = adapter.get_virtual_machine_public_endpoint(
                ctx.cloud_service_name, ctx.deployment_name,
                ctx.virtual_machine_name, ctx.endpoint_name)

            if not public_ip:
                self.log.warn(
                    "unable to find public ip for vm %s, set guacamole failed"
                    % ctx.virtual_machine_name)
            else:
                remote_para = get_remote_parameters(ctx.raw_system_config,
                                                    ctx.remote,
                                                    ctx.virtual_machine_name,
                                                    public_ip, port)

                ve.remote_paras = json.dumps(remote_para)

            self.db.commit()
            self.expr_manager.check_expr_status(ve.experiment)

        self.log.debug(
            "azure virtual environment %d vm success callback done, step to next"
            % sctx.current_job_index)
        # step to config next unit
        sctx.current_job_index += 1
        self.__schedule_setup(sctx)