rework the df/mount caching so it can be flushed if needed
This commit is contained in:
parent
5ab46cc6b5
commit
10832e756e
@ -1,4 +1,4 @@
|
||||
# $OpenBSD: Makefile,v 1.81 2015/08/24 10:32:00 jasper Exp $
|
||||
# $OpenBSD: Makefile,v 1.82 2015/09/01 07:23:35 jasper Exp $
|
||||
|
||||
PORTROACH= limit:^2
|
||||
|
||||
@ -6,7 +6,7 @@ COMMENT= Ruby library for retrieving facts from operating systems
|
||||
|
||||
VERSION= 2.4.4
|
||||
DISTNAME= facter-${VERSION}
|
||||
REVISION= 3
|
||||
REVISION= 4
|
||||
PKGSPEC= facter->=2.0,<3.0
|
||||
CATEGORIES= sysutils
|
||||
|
||||
|
15
sysutils/ruby-facter/patches/patch-lib_facter_partitions_rb
Normal file
15
sysutils/ruby-facter/patches/patch-lib_facter_partitions_rb
Normal file
@ -0,0 +1,15 @@
|
||||
$OpenBSD: patch-lib_facter_partitions_rb,v 1.4 2015/09/01 07:23:35 jasper Exp $
|
||||
|
||||
Cache df/mount output to prevent running these programs 3 times for every partition found.
|
||||
https://github.com/puppetlabs/facter/pull/1119
|
||||
|
||||
--- lib/facter/partitions.rb.orig Mon Aug 31 19:03:25 2015
|
||||
+++ lib/facter/partitions.rb Mon Aug 31 19:03:35 2015
|
||||
@@ -36,4 +36,7 @@ Facter.add(:partitions) do
|
||||
end
|
||||
partitions
|
||||
end
|
||||
+ on_flush do
|
||||
+ Facter::Util::Partitions.flush! if Facter::Util::Partitions.flushable?
|
||||
+ end
|
||||
end
|
@ -1,10 +1,11 @@
|
||||
$OpenBSD: patch-lib_facter_util_partitions_openbsd_rb,v 1.4 2015/08/24 10:32:00 jasper Exp $
|
||||
$OpenBSD: patch-lib_facter_util_partitions_openbsd_rb,v 1.5 2015/09/01 07:23:35 jasper Exp $
|
||||
|
||||
Cache df/mount output to prevent running these programs 3 times for every partition found.
|
||||
https://github.com/puppetlabs/facter/pull/1119
|
||||
|
||||
--- lib/facter/util/partitions/openbsd.rb.orig Mon Aug 24 09:42:02 2015
|
||||
+++ lib/facter/util/partitions/openbsd.rb Mon Aug 24 09:42:05 2015
|
||||
@@ -1,7 +1,11 @@
|
||||
--- lib/facter/util/partitions/openbsd.rb.orig Tue May 19 18:41:15 2015
|
||||
+++ lib/facter/util/partitions/openbsd.rb Mon Aug 31 19:03:46 2015
|
||||
@@ -1,9 +1,26 @@
|
||||
module Facter::Util::Partitions
|
||||
module OpenBSD
|
||||
+ @df_output = nil
|
||||
@ -16,8 +17,23 @@ Cache df/mount output to prevent running these programs 3 times for every partit
|
||||
+ @df_output.scan(/\/dev\/(\S+)/).flatten
|
||||
end
|
||||
|
||||
+ def self.flushable?
|
||||
+ true
|
||||
+ end
|
||||
+
|
||||
+ def self.flush!
|
||||
+ @df_output = nil
|
||||
+ @mount_output = nil
|
||||
+ end
|
||||
+
|
||||
+ def self.flushed?
|
||||
+ !@df_output
|
||||
+ end
|
||||
+
|
||||
# On OpenBSD partitions don't have a UUID; disks have DUID but that's not
|
||||
@@ -22,19 +26,29 @@ module Facter::Util::Partitions
|
||||
# compatible.
|
||||
def self.uuid(partition)
|
||||
@@ -22,19 +39,29 @@ module Facter::Util::Partitions
|
||||
def self.filesystem(partition)
|
||||
scan_mount(/\/dev\/#{partition}\son\s\S+\stype\s(\S+)/)
|
||||
end
|
||||
@ -36,7 +52,7 @@ Cache df/mount output to prevent running these programs 3 times for every partit
|
||||
+ def self.run_df
|
||||
+ Facter::Core::Execution.exec('df -k')
|
||||
+ end
|
||||
+
|
||||
+
|
||||
def self.scan_mount(scan_regex)
|
||||
- Facter::Core::Execution.exec('mount').scan(scan_regex).flatten.first
|
||||
+ @mount_output ||= run_mount
|
||||
|
@ -0,0 +1,24 @@
|
||||
$OpenBSD: patch-lib_facter_util_partitions_rb,v 1.4 2015/09/01 07:23:35 jasper Exp $
|
||||
|
||||
Cache df/mount output to prevent running these programs 3 times for every partition found.
|
||||
https://github.com/puppetlabs/facter/pull/1119
|
||||
|
||||
--- lib/facter/util/partitions.rb.orig Mon Aug 31 19:03:29 2015
|
||||
+++ lib/facter/util/partitions.rb Mon Aug 31 19:03:38 2015
|
||||
@@ -44,4 +44,16 @@ module Facter::Util::Partitions
|
||||
def self.available?
|
||||
!self.list.empty?
|
||||
end
|
||||
+
|
||||
+ def self.flushable?
|
||||
+ implementation.flushable?
|
||||
+ end
|
||||
+
|
||||
+ def self.flushed?
|
||||
+ implementation.flushed?
|
||||
+ end
|
||||
+
|
||||
+ def self.flush!
|
||||
+ implementation.flush!
|
||||
+ end
|
||||
end
|
Loading…
Reference in New Issue
Block a user