[Pkg-puppet-devel] [facter] 286/352: Revert "Merge branch 'feature/facter-2/patition_uuid_fact' into facter-2"
Stig Sandbeck Mathisen
ssm at debian.org
Sun Apr 6 22:21:54 UTC 2014
This is an automated email from the git hooks/post-receive script.
ssm pushed a commit to branch master
in repository facter.
commit 3c3ef4cfec2dd7b57aa17ad29f9cb602ab617e96
Author: Adrien Thebo <git at somethingsinistral.net>
Date: Mon Feb 24 14:24:37 2014 -0800
Revert "Merge branch 'feature/facter-2/patition_uuid_fact' into facter-2"
This reverts commit 33a4f18aa473b450f887e4eb4c8639c01403ea76, reversing
changes made to 8102a72a90c43cd16e62c946e1b6646a42c08cd2.
---
lib/facter/blockdevices.rb | 55 +++------------------------------------
spec/unit/blockdevices_spec.rb | 58 +-----------------------------------------
2 files changed, 4 insertions(+), 109 deletions(-)
diff --git a/lib/facter/blockdevices.rb b/lib/facter/blockdevices.rb
index 28da29f..e0ddc48 100644
--- a/lib/facter/blockdevices.rb
+++ b/lib/facter/blockdevices.rb
@@ -34,6 +34,7 @@
# Only supports Linux 2.6+ at this time, due to the reliance on sysfs
#
+
# Fact: blockdevices
#
# Purpose:
@@ -46,30 +47,6 @@
# Block devices must have been identified using sysfs information
#
-# Fact: blockdevice_<devicename>_partitions
-#
-# Purpose:
-# Returns a comma separated list of partitions on the block device.
-#
-# Resolution:
-# Parses the contents of /sys/block/<device/<device>*
-#
-# Caveats:
-# Only supports Linux 2.6+ at this time, due to the reliance on sysfs
-#
-
-# Fact: blockdevice_<devicename><partition>_uuid
-#
-# Purpose:
-# Returns the UUID of the partitions on blockdevices.
-#
-# Resolution:
-# Parses /dev/disk/by-uuid and resolves the links back to the partitions in /dev
-#
-# Caveats:
-# Only supports Linux 2.6+ at this time, due to the reliance on sysfs
-#
-
# Author: Jason Gill <jasongill at gmail.com>
require 'facter'
@@ -95,8 +72,6 @@ if Facter.value(:kernel) == 'Linux'
sizefile = sysfs_block_directory + device + "/size"
vendorfile = sysfs_device_directory + "/vendor"
modelfile = sysfs_device_directory + "/model"
- partitions = Dir.glob(sysfs_block_directory + device + "/#{device}*").map { |d| File.basename(d) }
- devdisk_by_uuid_directory = '/dev/disk/by-uuid/'
if File.exist?(sizefile)
Facter.add("blockdevice_#{device}_size".to_sym) do
@@ -116,33 +91,8 @@ if Facter.value(:kernel) == 'Linux'
end
end
- unless partitions.empty?
- Facter.add("blockdevice_#{device}_partitions") do
- setcode { partitions.join(',') }
- end
- end
-
- partitions.each do |part|
- Facter.add("blockdevice_#{part}_uuid") do
- setcode do
- uuid = nil
- if File.directory?(devdisk_by_uuid_directory)
- Dir.entries(devdisk_by_uuid_directory).each do |file|
- qualified_file = "#{devdisk_by_uuid_directory}#{file}"
-
- #A uuid is 16 octets long (RFC4122) which is 32hex chars + 4 '-'s
- next unless file.length == 36
- next unless File.symlink?(qualified_file)
- next unless File.readlink(qualified_file).match(%r[(?:\.\./\.\./|/dev/)#{part}$])
-
- uuid = file
- end
- end
- uuid
- end
- end
- end
end
+
end
# Return a comma-seperated list of block devices found
@@ -151,4 +101,5 @@ if Facter.value(:kernel) == 'Linux'
setcode { blockdevices.sort.join(',') }
end
end
+
end
diff --git a/spec/unit/blockdevices_spec.rb b/spec/unit/blockdevices_spec.rb
index 9d12cd9..54620b8 100644
--- a/spec/unit/blockdevices_spec.rb
+++ b/spec/unit/blockdevices_spec.rb
@@ -47,44 +47,6 @@ describe "Block device facts" do
IO.stubs(:read).with(stubdir + "/device/vendor").returns(vendor) if vendor
IO.stubs(:read).with(stubdir + "/device/model").returns(model) if model
end
-
- #Stubs relating to the Partition UUID facts
- File.stubs(:exist?).with('/dev/disk/by-uuid/').returns(true)
-
- Dir.stubs(:glob).with("/sys/block/hda/hda*").returns([])
-
- Dir.stubs(:glob).with("/sys/block/sda/sda*").returns([
- '/sys/block/sda/sda1',
- '/sys/block/sda/sda2',
- ])
-
- Dir.stubs(:glob).with("/sys/block/sdb/sdb*").returns([
- '/sys/block/sda/sdb1',
- '/sys/block/sda/sdb2',
- ])
-
- File.stubs(:directory?).returns(true)
-
- Dir.stubs(:entries).with('/dev/disk/by-uuid/').returns([
- ".", #wont match the length requirements
- "..", #wont match the length requirements
- "11111111-1111-1111-1111-111111111111", #Should be valid
- "22222222-2222-2222-2222-222222222222", #Should be valid
- "33333333-3333-3333-3333-333333333333", #Should be valid
- "44444444-4444-4444-4444-444444444444", #Wont match the link regex
- "55555555-5555-5555-5555-555555555555" #Wont be a symlink
- ])
-
- File.stubs(:readlink).with('/dev/disk/by-uuid/11111111-1111-1111-1111-111111111111').returns('../../sda1')
- File.stubs(:readlink).with('/dev/disk/by-uuid/22222222-2222-2222-2222-222222222222').returns('../../sda2')
- File.stubs(:readlink).with('/dev/disk/by-uuid/33333333-3333-3333-3333-333333333333').returns('../../sdb1')
- File.stubs(:readlink).with('/dev/disk/by-uuid/44444444-4444-4444-4444-444444444444').returns('/dont/match/regex/sdb2')
-
- File.stubs(:symlink?).with('/dev/disk/by-uuid/11111111-1111-1111-1111-111111111111').returns(true)
- File.stubs(:symlink?).with('/dev/disk/by-uuid/22222222-2222-2222-2222-222222222222').returns(true)
- File.stubs(:symlink?).with('/dev/disk/by-uuid/33333333-3333-3333-3333-333333333333').returns(true)
- File.stubs(:symlink?).with('/dev/disk/by-uuid/44444444-4444-4444-4444-444444444444').returns(true)
- File.stubs(:symlink?).with('/dev/disk/by-uuid/55555555-5555-5555-5555-555555555555').returns(false)
end
it "should report three block devices, hda, sda, and sdb, with accurate information from sda and sdb, and without invalid . or .. entries" do
@@ -102,32 +64,16 @@ describe "Block device facts" do
Facter.fact("blockdevice_#{device}_size".to_sym).should_not == nil
Facter.fact("blockdevice_#{device}_vendor".to_sym).should_not == nil
Facter.fact("blockdevice_#{device}_model".to_sym).should_not == nil
- Facter.fact("blockdevice_#{device}_partitions".to_sym).should_not == nil
end
Facter.fact(:blockdevice_sda_model).value.should == "WDC WD5000AAKS-0"
Facter.fact(:blockdevice_sda_vendor).value.should == "ATA"
Facter.fact(:blockdevice_sda_size).value.should == 500107862016
- Facter.fact(:blockdevice_sda_partitions).value.should == 'sda1,sda2'
Facter.fact(:blockdevice_sdb_model).value.should == "PERC H700"
Facter.fact(:blockdevice_sdb_vendor).value.should == "DELL"
Facter.fact(:blockdevice_sdb_size).value.should == 4499246678016
- Facter.fact(:blockdevice_sdb_partitions).value.should == 'sdb1,sdb2'
-
- #These partitions should have a UUID
- %w{ sda1 sda2 sdb1 }.each do |d|
- Facter.value("blockdevice_#{d}_uuid".to_sym).should_not == nil
- end
- #These should not create a UUID fact
- [ ".", "..", "sdb2" ].each do |d|
- Facter.value("partition_#{d}_uuid".to_sym).should == nil
- end
-
- Facter.fact(:blockdevice_sda1_uuid).value.should == "11111111-1111-1111-1111-111111111111"
- Facter.fact(:blockdevice_sda2_uuid).value.should == "22222222-2222-2222-2222-222222222222"
- Facter.fact(:blockdevice_sdb1_uuid).value.should == "33333333-3333-3333-3333-333333333333"
end
end
@@ -142,9 +88,6 @@ describe "Block device facts" do
File.stubs(:exist?).with("/sys/block/../device").returns(false)
File.stubs(:exist?).with("/sys/block/xda/device").returns(false)
File.stubs(:exist?).with("/sys/block/ydb/device").returns(false)
-
- #This is here to surpress errors when Dir.entries is run in relation to uuids
- Dir.stubs(:entries).with('/dev/disk/by-uuid/').returns([])
end
it "should not exist with invalid entries in /sys/block" do
@@ -161,5 +104,6 @@ describe "Block device facts" do
end
end
+
end
end
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-puppet/facter.git
More information about the Pkg-puppet-devel
mailing list