diff --git a/jasset/models.py b/jasset/models.py index 8398cc679..8c668db17 100644 --- a/jasset/models.py +++ b/jasset/models.py @@ -59,13 +59,13 @@ class AssetGroup(models.Model): class Asset(models.Model): - ip = models.IPAddressField(unique=True) - port = models.IntegerField(max_length=6, blank=True, null=True) + ip = models.GenericIPAddressField(unique=True) + port = models.IntegerField(blank=True, null=True) group = models.ManyToManyField(AssetGroup) username = models.CharField(max_length=20, blank=True, null=True) password = models.CharField(max_length=80, blank=True, null=True) use_default = models.BooleanField(default=True) - date_added = models.DateTimeField(auto_now=True, default=datetime.datetime.now(), null=True) + date_added = models.DateTimeField(auto_now=True) is_active = models.BooleanField(default=True) comment = models.CharField(max_length=100, blank=True, null=True) diff --git a/jasset/views.py b/jasset/views.py index 8e639c3b3..57f88fdbe 100644 --- a/jasset/views.py +++ b/jasset/views.py @@ -96,7 +96,7 @@ def asset_add(request): username = request.POST.get('username') password = request.POST.get('password') port = request.POST.get('port') - password_encode = CRYPTOR.encrypt(password) + password_encode = password else: username = None port = None diff --git a/jlog/models.py b/jlog/models.py index baaffb5a7..cf13a5354 100644 --- a/jlog/models.py +++ b/jlog/models.py @@ -8,7 +8,7 @@ class Log(models.Model): dept_name = models.CharField(max_length=20) log_path = models.CharField(max_length=100) start_time = models.DateTimeField(null=True) - pid = models.IntegerField(max_length=10) + pid = models.IntegerField() is_finished = models.BooleanField(default=False) handle_finished = models.BooleanField(default=False) end_time = models.DateTimeField(null=True) diff --git a/jperm/ansible_api.py b/jperm/ansible_api.py index 1c6402dfa..4017cce16 100644 --- a/jperm/ansible_api.py +++ b/jperm/ansible_api.py @@ -132,10 +132,7 @@ class Command(MyInventory): forks=forks ) self.results = hoc.run() -<<<<<<< HEAD -======= ->>>>>>> 1c3d642be250026193bbdd9e2fe798e0197f5696 if self.stdout: return {"ok": self.stdout} else: @@ -446,10 +443,7 @@ class App(MyPlaybook): if __name__ == "__main__": pass -<<<<<<< HEAD -======= ->>>>>>> 1c3d642be250026193bbdd9e2fe798e0197f5696 # resource = { # "group1": { # "hosts": [{"hostname": "127.0.0.1", "port": "22", "username": "root", "password": "xxx"},], @@ -459,15 +453,9 @@ if __name__ == "__main__": # command = Command(resource) # print command.run("who", group="group1") -<<<<<<< HEAD # resource = [{"hostname": "192.168.10.148", "port": "22", "username": "root", "password": "xxx"}] # task = Tasks(resource) # print task.get_host_info() -======= -# resource = [{"hostname": "127.0.1.1", "port": "22", "username": "root", "password": "xxx"}] -# command = Command(resource) -# print command.run("who") ->>>>>>> 1c3d642be250026193bbdd9e2fe798e0197f5696 # playbook = MyPlaybook(resource) # playbook.run('test.yml') diff --git a/jperm/views.py b/jperm/views.py index 5ea6ea1f3..700ed444f 100644 --- a/jperm/views.py +++ b/jperm/views.py @@ -9,15 +9,9 @@ from jperm.models import SysUser from juser.user_api import gen_ssh_key -<<<<<<< HEAD from juser.models import User, UserGroup from jasset.models import Asset, AssetGroup from jperm.models import PermRole, PermRule -======= -from juser.models import User, UserGroup -from jasset.models import Asset, AssetGroup -from jperm.models import PermRole, PermRule ->>>>>>> 1c3d642be250026193bbdd9e2fe798e0197f5696 from jperm.utils import updates_dict from jperm.ansible_api import Tasks @@ -156,7 +150,6 @@ def perm_rule_add(request): else: return HttpResponse("add rule failed") -<<<<<<< HEAD @require_role('admin') def perm_rule_list(request): """ @@ -176,59 +169,6 @@ def perm_rule_list(request): -======= - user_id = request.GET.get('id', '') - user = get_object(User, id=user_id) - - if request.method == 'GET' and user: - # 获取所有 用户,用户组,资产,资产组,用户角色, 用于添加授权规则 - users = User.objects.all() - user_groups = UserGroup.objects.all() - assets = Asset.objects.all() - asset_groups = AssetGroup.objects.all() - roles = PermRole.objects.all() - - data_content = {"users": users, "user_groups": user_groups, - "assets": assets, "asset_groups": asset_groups, - "roles": roles} - render_data = updates_dict(data_nav, data_content) - return my_render('jperm/rule_add.html', render_data, request) - - elif request.method == 'POST' and user: - # 获取用户选择的 用户,用户组,资产,资产组,用户角色 - users_select = request.POST.getlist('user', []) - user_groups_select = request.POST.getlist('usergroup', []) - assets_select = request.POST.getlist('asset', []) - asset_groups_select = request.POST.getlist('assetgroup', []) - roles_select = request.POST.getlist('role', []) - - # 获取需要授权的主机列表 - assets_obj = [Asset.objects.get(ip=asset) for asset in assets_select] - asset_groups_obj = [AssetGroup.objects.get(name=group) for group in asset_groups_select] - - group_assets_obj = [ asset for assets in [group.user_set.all() for group in asset_groups_obj]] - - - - # 获取需要授权的用户列表 - users_obj = [User.objects.get(name=user) for user in users_select] - user_groups_obj = [UserGroup.objects.get(name=group) for group in user_groups_select] - - group_users_obj = [user for user in [group.user_set.all() for group in user_groups_obj]] - - - # 获取授予的角色列表 - roles_obj = [User.objects.get(name=role) for role in roles_select] - - - # 调用Ansible API 执行授权 - - - # 授权成功,写回数据库 - - print request.POST - return HttpResponse(request.POST) ->>>>>>> 1c3d642be250026193bbdd9e2fe798e0197f5696 @require_role('admin') diff --git a/jumpserver.conf b/jumpserver.conf index dd6d3fca7..ea9802f83 100644 --- a/jumpserver.conf +++ b/jumpserver.conf @@ -1,12 +1,12 @@ #coding: utf8 [base] -url = http://192.168.10.148 +url = http://127.0.0.1 key = 88aaaf7ffe3c6c04 log = debug [db] -host = 192.168.10.148 +host = 127.0.0.1 port = 3306 user = jumpserver password =mysql1234 @@ -20,7 +20,7 @@ root_dn = cn=admin,dc=jumpserver,dc=org root_pw = secret234 [websocket] -web_socket_host = 192.168.10.148:3000 +web_socket_host = 1127.0.0.1:3000 [mail] mail_enable = 1 diff --git a/jumpserver/models.py b/jumpserver/models.py index 5958c5e1a..7cc924a1e 100644 --- a/jumpserver/models.py +++ b/jumpserver/models.py @@ -6,7 +6,7 @@ from django.db import models class Setting(models.Model): name = models.CharField(max_length=100) default_user = models.CharField(max_length=100, null=True, blank=True) - default_port = models.IntegerField(max_length=10, null=True, blank=True) + default_port = models.IntegerField(null=True, blank=True) default_pri_key_path = models.CharField(max_length=100, null=True, blank=True) class Meta: