diff options
author | James Shubin <james@shubin.ca> | 2014-07-10 20:06:41 -0400 |
---|---|---|
committer | James Shubin <james@shubin.ca> | 2014-07-10 20:06:41 -0400 |
commit | 8da4002f83e6505c7c09042df1c10cb1e290c7c7 (patch) | |
tree | 87c1b6bdf582aae8d91d3b5c78c8ef741693c740 /lib | |
parent | cd182e0ef68c9ee0f5701b436050de7538ab6ff1 (diff) | |
download | puppet-gluster-8da4002f83e6505c7c09042df1c10cb1e290c7c7.tar.gz puppet-gluster-8da4002f83e6505c7c09042df1c10cb1e290c7c7.tar.xz puppet-gluster-8da4002f83e6505c7c09042df1c10cb1e290c7c7.zip |
Ensure that UUID directory is actually managed.
This isn't necessary, but is more correct. I realized how I could do
this, and have now implemented it.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/facter/gluster_uuid.rb | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/lib/facter/gluster_uuid.rb b/lib/facter/gluster_uuid.rb index ed0bf70..fa99a40 100644 --- a/lib/facter/gluster_uuid.rb +++ b/lib/facter/gluster_uuid.rb @@ -63,12 +63,25 @@ end # generate uuid and parent directory if they don't already exist... if not(module_vardir.nil?) and File.directory?(module_vardir) - if not File.directory?(uuiddir) - Dir::mkdir(uuiddir) + + create = false + if File.directory?(uuiddir) + + if File.exist?(uuidfile) + test = File.open(uuidfile, 'r').read.strip.downcase # read into str + # skip over uuid's of the wrong length or that don't match (security!!) + if test.length == 36 and regexp.match(test) + create = false + else + create = true + end + else + create = true + end end # create a uuid and store it in our vardir if it doesn't already exist! - if File.directory?(uuiddir) and (not File.exist?(uuidfile)) + if create result = system("/usr/bin/uuidgen > '" + uuidfile + "'") if not(result) # TODO: print warning |