예제 #1
0
  def brew(self, request, id):
    """Redeploy a cluster."""
    cluster = models.Cluster.objects.get(pk=id)
    hosts = models.Host.objects.filter(cluster=cluster)

    # TODO(termie): A bit of a hack because I don't want to replicate the
    #               entire __call__ method in piston's Resource.
    try:
      utils.translate_mime(request)
    except utils.MimerDataException:
      return rc.BAD_REQUEST

    request.data = getattr(request, 'data', None)
    if cluster.claim and (not request.data or
                          cluster.claim != request.data.get('claim')):
      resp = rc.FORBIDDEN
      resp.content = ('FORBIDDEN: This cluster has been claimed: %s'
                      % cluster.claim)
      return resp

    for host in hosts:
      host.local_boot =  False
      host.save()
      remote.pxe_reboot(host)

    return hosts
예제 #2
0
    def brew(self, request, id):
        """Redeploy a cluster."""
        cluster = models.Cluster.objects.get(pk=id)
        hosts = models.Host.objects.filter(cluster=cluster)

        # TODO(termie): A bit of a hack because I don't want to replicate the
        #               entire __call__ method in piston's Resource.
        try:
            utils.translate_mime(request)
        except utils.MimerDataException:
            return rc.BAD_REQUEST

        request.data = getattr(request, 'data', None)
        if cluster.claim and (not request.data
                              or cluster.claim != request.data.get('claim')):
            resp = rc.FORBIDDEN
            resp.content = ('FORBIDDEN: This cluster has been claimed: %s' %
                            cluster.claim)
            return resp

        for host in hosts:
            host.local_boot = False
            host.save()
            remote.pxe_reboot(host)

        return hosts
예제 #3
0
 def create(self, request, **kwargs):
     """ Rekick a single host """
     host = self.host_from_kwargs(kwargs)
     host.local_boot = False
     host.save()
     remote.pxe_reboot(host)