Esempio n. 1
0
    def SubmitJob(self, op, cl=None):
        """Generic wrapper for submit job, for better http compatibility.

    @type op: list
    @param op: the list of opcodes for the job
    @type cl: None or luxi.Client
    @param cl: optional luxi client to use
    @rtype: string
    @return: the job ID

    """
        if cl is None:
            cl = self.GetClient()
        try:
            for opcode in op:
                # Add an authorized user name to the reason trail
                trail = getattr(opcode, constants.OPCODE_REASON, [])
                trail.append(self.GetAuthReason())
                setattr(opcode, constants.OPCODE_REASON, trail)
            return cl.SubmitJob(op)
        except errors.JobQueueFull:
            raise http.HttpServiceUnavailable(
                "Job queue is full, needs archiving")
        except errors.JobQueueDrainError:
            raise http.HttpServiceUnavailable(
                "Job queue is drained, cannot submit")
        except rpcerr.NoMasterError, err:
            raise http.HttpBadGateway("Master seems to be unreachable: %s" %
                                      err)
Esempio n. 2
0
    def SubmitJob(self, op, cl=None):
        """Generic wrapper for submit job, for better http compatibility.

    @type op: list
    @param op: the list of opcodes for the job
    @type cl: None or luxi.Client
    @param cl: optional luxi client to use
    @rtype: string
    @return: the job ID

    """
        if cl is None:
            cl = self.GetClient()
        try:
            return cl.SubmitJob(op)
        except errors.JobQueueFull:
            raise http.HttpServiceUnavailable(
                "Job queue is full, needs archiving")
        except errors.JobQueueDrainError:
            raise http.HttpServiceUnavailable(
                "Job queue is drained, cannot submit")
        except rpcerr.NoMasterError as err:
            raise http.HttpBadGateway("Master seems to be unreachable: %s" %
                                      err)
        except rpcerr.PermissionError:
            raise http.HttpInternalServerError(
                "Internal error: no permission to"
                " connect to the master daemon")
        except rpcerr.TimeoutError as err:
            raise http.HttpGatewayTimeout("Timeout while talking to the master"
                                          " daemon: %s" % err)
Esempio n. 3
0
  def SubmitJob(self, op, cl=None):
    """Generic wrapper for submit job, for better http compatibility.

    @type op: list
    @param op: the list of opcodes for the job
    @type cl: None or luxi.Client
    @param cl: optional luxi client to use
    @rtype: string
    @return: the job ID

    """
    if cl is None:
      cl = self.GetClient()
    try:
      return cl.SubmitJob(op)
    except errors.JobQueueFull:
      raise http.HttpServiceUnavailable("Job queue is full, needs archiving")
    except errors.JobQueueDrainError:
      raise http.HttpServiceUnavailable("Job queue is drained, cannot submit")
    except rpcerr.NoMasterError, err:
      raise http.HttpBadGateway("Master seems to be unreachable: %s" % err)
Esempio n. 4
0
    def GET(self):
        """Request information for connecting to instance's console.

    @return: Serialized instance console description, see
             L{objects.InstanceConsole}

    """
        instance_name = self.items[0]
        client = self.GetClient()

        ((console, oper_state), ) = \
            client.QueryInstances([instance_name], ["console", "oper_state"], False)

        if not oper_state:
            raise http.HttpServiceUnavailable("Instance console unavailable")

        assert isinstance(console, dict)
        return console