Skip to content
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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Find max OCF UID #178

wants to merge 2 commits into from

Conversation

Boomaa23
Copy link
Member

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.

@cg505
Copy link
Member

cg505 commented Jul 15, 2022

Historically you would just look in #atool for the most recently created account, but this is cool too.

Copy link
Contributor

@axmmisaka axmmisaka left a 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:
Copy link
Contributor

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))
Copy link
Contributor

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(
Copy link
Contributor

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants