Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
honglei5181 committed May 11, 2016
1 parent 5bdcacf commit 6ef6552
Showing 1 changed file with 30 additions and 2 deletions.
32 changes: 30 additions & 2 deletions states_config/views.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
from django.shortcuts import render
from django.http import HttpResponse
from django.contrib.auth.decorators import login_required
from django.contrib.auth.models import User
from account.models import Businesses,Privileges,UserProfiles
from groups.models import Groups,Hosts
from shaker.shaker_core import *
from shaker.nodegroups import *
from shaker.highstate import *
Expand All @@ -9,9 +12,34 @@

@login_required(login_url="/account/login/")
def highstate(request):
group = NodeGroups()
high = HighState()
all_host = group.list_groups_hosts()
#group = NodeGroups()
#all_host = group.list_groups_hosts()
_u = request.user
_user = User.objects.get(username=_u)

_businesses = []
all = {}
try:
if _user.is_superuser:
_userprofile = UserProfiles.objects.all()
_b = Businesses.objects.all()
else:
_userprofile = UserProfiles.objects.get(user=_user)
_b = _userprofile.business.all()
for _tmp in _b:
_businesses.append(_tmp.name)

_groups=Groups.objects.filter(business__in = _businesses)
for _group in _groups:
_h=[]
_hosts=_group.groups_hosts_related.all()
for _host in _hosts:
_h.append(_host.minion.minion_id)
all[_group.name]=_h
except Exception as e:
pass
all_host = all
all_sls = high.list_sls('/srv/salt/')
return render(request, 'states_config/highstate.html', {'list_groups': all_host, 'all_sls': all_sls})

Expand Down

0 comments on commit 6ef6552

Please sign in to comment.