From 70a4f137b8208e6863dac7ccb5a286ea69678352 Mon Sep 17 00:00:00 2001 From: ibuler Date: Tue, 15 Oct 2019 16:27:22 +0800 Subject: [PATCH] =?UTF-8?q?[Update]=20=E6=B7=BB=E5=8A=A0=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/get_no_parent_nodes.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 utils/get_no_parent_nodes.py diff --git a/utils/get_no_parent_nodes.py b/utils/get_no_parent_nodes.py new file mode 100644 index 000000000..e472fa4b4 --- /dev/null +++ b/utils/get_no_parent_nodes.py @@ -0,0 +1,31 @@ +#!/usr/bin/python +# + +import os +import sys +import django + + +if os.path.exists('../apps'): + sys.path.insert(0, '../apps') +elif os.path.exists('./apps'): + sys.path.insert(0, './apps') + +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "jumpserver.settings") +django.setup() + +from assets.models import * +from orgs.utils import Organization + +Organization.root().change_to() + +ns = Node.objects.all() + +for i in ns: + try: + pkey = i.parent.key + except: + pkey = '' + if i.parent_key != pkey and not i.key.isdigit(): + print("Node parent not found: {} -> {}".format(i.key, i.parent_key)) +