-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Find max OCF UID #178
base: master
Are you sure you want to change the base?
Find max OCF UID #178
Conversation
Historically you would just look in #atool for the most recently created account, but this is cool too. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternatively, since this is same as https://github.com/ocf/ocflib/blame/889145860a908e23610e5b4edd7774691a1beab2/ocflib/account/creation.py#L75, maybe abstract it into a separate function in ocflib
.
|
||
|
||
def is_valid_uid(uid): | ||
for start, end in IGNORED_UID_RANGES: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean INVALID_UID_RANGES
?
) | ||
uids = [int(entry['attributes']['uidNumber']) for entry in c.response] | ||
uids = filter(is_valid_uid, uids) | ||
print('Max currently used OCF UID is: %s' % max(uids)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer .format
but this works as well
def main(): | ||
print('Searching for maximum currently used OCF UID') | ||
with ldap_ocf() as c: | ||
c.search( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to what @cg505 said this is fine but indeed a little slow tbh; if we are not running this constantly I guess it's fine?
I had to bump
_KNOWN_UID
(here) recently, and to do so find the maximum currently in use OCF UID from LDAP. Realistically this should be simple enough, but the true maximum value is excluded so more processing is required. This script should automate that process.