Example #1
0
def SaltGrainsAll():
    salt = SaltApi()
    print "----------Grainsall------------"
    clientkey = salt.List_all_keys()['minions']
    for i in clientkey:
        data = salt.grainsall(i)
    return clientkey
Example #2
0
def GetALLkeys():
    saltmaster = SaltServer.objects.all()

    for server in saltmaster:
        salt = SaltApi(server.url, server.username, server.password)
        minions, minions_pre, minions_rej, minions_deny = salt.List_all_keys()
        for i in minions:
            try:
                Minions.objects.create(minion=i,
                                       saltserver=server,
                                       status="Accepted")
            except:
                minion = Minions.objects.get(minion=i)
                minion.status = 'Accepted'
                minion.save()
        for pre in minions_pre:
            try:
                Minions.objects.create(minion=pre,
                                       saltserver=server,
                                       status="Unaccepted")
            except:
                minion = Minions.objects.get(minion=pre)
                minion.status = 'Unaccepted'
                minion.save()

        for rej in minions_rej:
            try:
                Minions.objects.create(minion=rej,
                                       saltserver=server,
                                       status="Rejected")
            except:
                minion = Minions.objects.get(minion=rej)
                minion.status = 'Rejected'
                minion.save()

        for deny in minions_deny:
            try:
                Minions.objects.create(minion=deny,
                                       saltserver=server,
                                       status="Denied")
            except:
                minion = Minions.objects.get(minion=deny)
                minion.status = 'Denied'
                minion.save()