Beispiel #1
0
def salt_delete_key(request):
    """
    delete salt minions key
    """

    node_name = request.GET.get('node_name')
    sapi = SaltAPI(url=settings.SALT_API['url'],username=settings.SALT_API['user'],password=settings.SALT_API['password'])  
    ret = sapi.delete_key(node_name)
    return HttpResponseRedirect(reverse('key_list'))
Beispiel #2
0
def salt_delete_key(request):
    """
    delete salt minions key
    """

    node_name = request.GET.get('node_name')
    sapi = SaltAPI(url=settings.SALT_API['url'],
                   username=settings.SALT_API['user'],
                   password=settings.SALT_API['password'])
    ret = sapi.delete_key(node_name)
    return HttpResponseRedirect(reverse('key_list'))
Beispiel #3
0
 def delete(self, request, *args, **kwargs):
     _saltapi = SaltAPI(url=SALT_API_URL,
                        username=SALT_API_USERNAME,
                        password=SALT_API_PASSWORD)
     pk = kwargs.get('pk')
     try:
         _minion = SaltMinion.objects.get(id=pk)
     except:
         return Response(status=status.HTTP_400_BAD_REQUEST)
     _ret = _saltapi.delete_key(_minion.hostname)
     if _ret:
         SaltMinion.objects.filter(hostname=_minion.hostname).update(
             is_alive=False, status=5)
         return Response(status=status.HTTP_204_NO_CONTENT)
     return Response(status=status.HTTP_400_BAD_REQUEST)
Beispiel #4
0
def rejDeleteKey(request):
    '''
    Delete reject keys;
    :param request:
    :return:
    '''

    node_name = request.GET.getlist('rejectkeys')
    str_node_name = ','.join(node_name)

    sapi = SaltAPI(
        url=settings.SALT_API['url'],
        username=settings.SALT_API['user'],
        password=settings.SALT_API['password'])
    ret = sapi.delete_key(str_node_name)

    return HttpResponseRedirect(reverse('key_reject'))