Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F12427598
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/requirements.txt b/requirements.txt
index cd6963f..57e99ff 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,9 +1,11 @@
# Linters
flake8>=3.5.0,<4.0
autopep8>=1.3,<2.0
pycodestyle>=2.3.1,<3.0
-# Tests
+# Tests and utilities
PyYAML>=3.12,<4.0
+
+# Tests
mock>=2.0.0,<3.0
salt==2017.7.2
diff --git a/utils/next-uid.py b/utils/next-uid.py
new file mode 100755
index 0000000..84b71e9
--- /dev/null
+++ b/utils/next-uid.py
@@ -0,0 +1,32 @@
+#!/usr/bin/env python3
+#
+# Guesses a free sequential user ID for a new account.
+#
+# To do so, reads from pillar/core/users.sls (USERS_DATASOURCE) the last users
+# uid # and offers the next one available.
+#
+# ID > 5000 (USERS_CUT) are ignored.
+
+import yaml
+
+
+USERS_DATASOURCE = 'pillar/core/users.sls'
+USERS_DATASOURCE_KEY = 'shellusers'
+USERS_CUT = 5000
+
+
+def get_shellusers(filename, key):
+ with open(filename) as stream:
+ data = yaml.load(stream)
+ return data['shellusers']
+
+
+def get_uids(users, threshold):
+ return [users[username]['uid']
+ for username in users
+ if users[username]['uid'] < threshold]
+
+
+users = get_shellusers(USERS_DATASOURCE, USERS_DATASOURCE_KEY)
+uids = get_uids(users, USERS_CUT)
+print(max(uids) + 1)
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Fri, Nov 7, 08:43 (21 h, 21 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3138764
Default Alt Text
(1 KB)
Attached To
Mode
rOPS Nasqueron Operations
Attached
Detach File
Event Timeline
Log In to Comment