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

(MODULES-4188) Add UUID generation function #700

Merged
merged 1 commit into from
Dec 13, 2016

Conversation

petems
Copy link
Contributor

@petems petems commented Dec 7, 2016

  • Generates UUID based on a given string and
    optional seed


$uuid = uuid_generate($::fqdn)

The seed is optional. If given it must be a string.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should mention if the seed should be numeric, hex, or an arbitrary string.

seed = nil
fqdn = args[0]
elsif args.length == 2
fqdn = args[0]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically it doesn't have to be an FQDN so it should be called input_string or something.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this was a holdover from the older FQDN specific code

end

# The UUID for our namespace (6ba7b810-9dad-11d1-80b4-00c04fd430c8)
ns_uuid = "\x0b\x7a\x81\xff\xdb\x8d\x42\xfe\x8d\x9f\x76\x8e\xa5\xb8\xed\x1a"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This UUID name space ID is only for prefixing FQDNs and as this is an "uuid_generate puppet function arbitrary string" UUID, we should create a new namespace specifically for this function (I imagine anything will do).

As per RFC-4122:

Allocate a UUID to use as a "name space ID" for all UUIDs generated from names in that name space; see Appendix C for some pre-defined values.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I'm thinking of adding two functions: one for an arbitrary uuid from a string and seed, which would use our own custom namespace, one for the FQDN following RFC-4122. Sound good?


hash_input = ns_uuid + fqdn
unless seed.nil?
hash_input += "\x00" + seed
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the seed can be any string, why prefix with '\x00'?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TBH I'm not sure about this bit, I was leveraging an existing bit of code

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would need to change here?

* Generates UUID based on a given FQDN string and the DNS namespace (6ba7b810-9dad-11d1-80b4-00c04fd430c8)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants