Re: [Puppet-dev] ANNOUNCE: Facter 1.5.9rc6
On 10 May 2011 01:39, Nigel Kersten ni...@puppetlabs.com wrote: Facter 1.5.9rc6 is a maintenance release containing fixes and updates. The keen-eyed observers amongst you will notice it's been a month since our last RC5 of Facter 1.5.9, which is most certainly not our normal process. We simply missed the release after 7 days of no new bugs step, and have since set up a reminder system to make sure that poor Facter, the Cinderella of the Puppet family, doesn't get left cleaning the sooty hearth over and over again while her ugly sisters head off to Amsterdam for the Puppet Ball (EU) in search of a handsome prince. Best release note ever :) On the other hand - anyone interested in taking on more of a role in facter maintenance? Some handome prince (or princess) with the right slipper? Paul -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-dev@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
Re: [Puppet-dev] [PATCH/facter 1/1] Fixed #6695 - Updated id fact for Darwin et al
On 14 March 2011 02:57, James Turnbull ja...@lovedthanlost.net wrote: Signed-off-by: James Turnbull ja...@lovedthanlost.net This list is kinda excessive, is there anything it doesn't work for explicitly (ie do we need the confine). --- Local-branch: tickets/master/6695 lib/facter/id.rb | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/lib/facter/id.rb b/lib/facter/id.rb index c2c3594..f3de1a9 100644 --- a/lib/facter/id.rb +++ b/lib/facter/id.rb @@ -1,5 +1,5 @@ Facter.add(:id) do - confine :operatingsystem = %w{Linux Fedora RedHat CentOS SuSE SLES Debian Ubuntu Gentoo AIX OEL OVS GNU/kFreeBSD windows} + confine :operatingsystem = %w{Linux Fedora RedHat CentOS SuSE SLES Debian Ubuntu Gentoo AIX OEL OVS GNU/kFreeBSD windows Darwin NetBSD FreeBSD OpenBSD} setcode whoami end -- 1.7.1 -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-dev@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en. -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-dev@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
Re: [Puppet-dev] [PATCH/facter 1/1] Fixed #6695 - Updated id fact for Darwin et al
On 14 March 2011 15:46, James Turnbull ja...@puppetlabs.com wrote: Paul Nasrat wrote: On 14 March 2011 02:57, James Turnbull ja...@lovedthanlost.net wrote: Signed-off-by: James Turnbull ja...@lovedthanlost.net This list is kinda excessive, is there anything it doesn't work for explicitly (ie do we need the confine). Solaris. Hence the other command in the file. I don't like the list either but that's our constraint model currently. Could at least use kernel rather than operatingsystem and enumerate every distro name that we add. Also why can't we use default fact plus solaris specific confine? I'm pretty sure confined trumps non-confined - cf lib/facter/ps.rb Paul -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-dev@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
Re: [Puppet-dev] [PATCH/facter 1/1] Fixed #6695 - Updated id fact for Darwin et al
On 14 March 2011 16:52, Daniel Pittman dan...@puppetlabs.com wrote: On Sun, Mar 13, 2011 at 19:57, James Turnbull ja...@lovedthanlost.net wrote: Signed-off-by: James Turnbull ja...@lovedthanlost.net --- Local-branch: tickets/master/6695 lib/facter/id.rb | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/lib/facter/id.rb b/lib/facter/id.rb index c2c3594..f3de1a9 100644 --- a/lib/facter/id.rb +++ b/lib/facter/id.rb @@ -1,5 +1,5 @@ Facter.add(:id) do - confine :operatingsystem = %w{Linux Fedora RedHat CentOS SuSE SLES Debian Ubuntu Gentoo AIX OEL OVS GNU/kFreeBSD windows} + confine :operatingsystem = %w{Linux Fedora RedHat CentOS SuSE SLES Debian Ubuntu Gentoo AIX OEL OVS GNU/kFreeBSD windows Darwin NetBSD FreeBSD OpenBSD} setcode whoami end It would be really good to see some tests to verify that we keep delivering this fact on the appropriate platforms added; we have a real habit of making changes to Facter without testing, and that model leads to regressions later... Having CI jobs for previous and past release calling ext/facter-diff to check for regressions should help. What is the status of hudson/jenkins and puppet/facter these days? Paul -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-dev@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
Re: [Puppet-dev] [PATCH/facter 1/1] Fixed #6695 - Updated id fact for Darwin et al
On 14 March 2011 17:30, Daniel Pittman dan...@puppetlabs.com wrote: On Mon, Mar 14, 2011 at 10:29, Paul Nasrat pnas...@gmail.com wrote: On 14 March 2011 15:46, James Turnbull ja...@puppetlabs.com wrote: Paul Nasrat wrote: On 14 March 2011 02:57, James Turnbull ja...@lovedthanlost.net wrote: Signed-off-by: James Turnbull ja...@lovedthanlost.net This list is kinda excessive, is there anything it doesn't work for explicitly (ie do we need the confine). Solaris. Hence the other command in the file. I don't like the list either but that's our constraint model currently. Could at least use kernel rather than operatingsystem and enumerate every distro name that we add. Also why can't we use default fact plus solaris specific confine? I'm pretty sure confined trumps non-confined - cf lib/facter/ps.rb They do, right now, indeed. I believe this is how it is supposed to work, but the tests seem ambiguous see spec/unit/util/fact_spec.rb and spec/unit/util/resolution_spec.rb Paul -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-dev@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
Re: [Puppet-dev] [PATCH/facter 1/1] Fixed #6695 - Updated id fact for Darwin et al
On 14 March 2011 17:44, Daniel Pittman dan...@puppetlabs.com wrote: On Mon, Mar 14, 2011 at 10:32, Paul Nasrat pnas...@gmail.com wrote: On 14 March 2011 16:52, Daniel Pittman dan...@puppetlabs.com wrote: On Sun, Mar 13, 2011 at 19:57, James Turnbull ja...@lovedthanlost.net wrote: […] It would be really good to see some tests to verify that we keep delivering this fact on the appropriate platforms added; we have a real habit of making changes to Facter without testing, and that model leads to regressions later... Having CI jobs for previous and past release calling ext/facter-diff to check for regressions should help. What is the status of hudson/jenkins and puppet/facter these days? That only helps on the platforms we have running at this point in time, and delays detection compared to a test with appropriate fixtures on developer machines. We do have a bunch of platform coverage in Hudson, of course, but I don't believe any of the tests in the codebase are using the facter-diff tools to try and verify correctness at this point in time. Sure unit tests are hugely important, plus give fast feedback and our coverage is not necessarily always great, but we should also have a regression test suite I think to smoke test an RC for fact regressions. Paul -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-dev@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
Re: [Puppet-dev] [PATCH/facter 1/1] Fix #6679 - Added Scientific Linux to operatingsystem fact
On 11 March 2011 00:52, James Turnbull ja...@lovedthanlost.net wrote: Thanks to James Goddard for the patch +1 Signed-off-by: James Turnbull ja...@lovedthanlost.net --- Local-branch: ticket/master/6679 lib/facter/operatingsystem.rb | 2 ++ spec/unit/operatingsystem_spec.rb | 12 ++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/facter/operatingsystem.rb b/lib/facter/operatingsystem.rb index c5a3dc1..bda8ba3 100644 --- a/lib/facter/operatingsystem.rb +++ b/lib/facter/operatingsystem.rb @@ -36,6 +36,8 @@ Facter.add(:operatingsystem) do txt = File.read(/etc/redhat-release) if txt =~ /centos/i CentOS + elsif txt =~ /scientific/i + Scientific else RedHat end diff --git a/spec/unit/operatingsystem_spec.rb b/spec/unit/operatingsystem_spec.rb index be83916..73b3649 100755 --- a/spec/unit/operatingsystem_spec.rb +++ b/spec/unit/operatingsystem_spec.rb @@ -9,23 +9,23 @@ describe Operating System fact do before do Facter.clear end - + after do Facter.clear end - + it should default to the kernel name do Facter.fact(:kernel).stubs(:value).returns(Nutmeg) Facter.fact(:operatingsystem).value.should == Nutmeg end - + it should be Solaris for SunOS do Facter.fact(:kernel).stubs(:value).returns(SunOS) - + Facter.fact(:operatingsystem).value.should == Solaris end - + it should identify Oracle VM as OVS do Facter.fact(:kernel).stubs(:value).returns(Linux) @@ -33,7 +33,7 @@ describe Operating System fact do FileTest.expects(:exists?).with(/etc/ovs-release).returns true FileTest.expects(:exists?).with(/etc/enterprise-release).returns true - + Facter.fact(:operatingsystem).value.should == OVS end end -- 1.7.1 -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-dev@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en. -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-dev@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
Re: [Puppet-dev] [PATCH/facter 1/3] Discussion on ec2 facts - #2346
On 9 March 2011 16:55, James Turnbull ja...@puppetlabs.com wrote: Paul Nasrat wrote: On 8 March 2011 17:23, James Turnbull ja...@puppetlabs.com wrote: Paul Nasrat wrote: +1 been pending for too long Was that a +1 on patches 2 and 3 in that series also? I largely rewrote the whole fact. Just on this, I need to review the arp fact in more depth. I think the basic idea for the rewrite is sane, but again need to review. Paul We're aiming for a Facter 1.5.9rc1 next week just to give you the context. Yes and I said to you I couldn't guarantee time before the weekend. Paul James -- James Turnbull Puppet Labs 1-503-734-8571 -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-dev@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en. -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-dev@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
Re: [Puppet-dev] [PATCH/facter 1/1] (#2721) Merged patch from Brane GraAnar
On 9 March 2011 01:32, Adrien Thebo adr...@puppetlabs.com wrote: - Adds support for Slamd64 and Bluewhite64 for the operatingsystem fact - Adds support for Slamd64 and Bluewhite64 for the operatingsystemrelease fact +1 The duplication is a bit of a code smell, we probably should improve this fact some longer term as there are classes of thing (redhat release derived) that basically act very similarly. Paul Signed-off-by: Adrien Thebo adr...@puppetlabs.com --- Local-branch: tickets/next/2721 lib/facter/operatingsystem.rb | 8 ++-- lib/facter/operatingsystemrelease.rb | 26 +- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/lib/facter/operatingsystem.rb b/lib/facter/operatingsystem.rb index c5a3dc1..061e18e 100644 --- a/lib/facter/operatingsystem.rb +++ b/lib/facter/operatingsystem.rb @@ -50,8 +50,12 @@ Facter.add(:operatingsystem) do else SuSE end - elsif FileTest.exists?(/etc/slackware-version) - Slackware + elsif FileTest.exists?(/etc/bluewhite64-version) + Bluewhite64 + elsif FileTest.exists?(/etc/slamd64-version) + Slamd64 + elsif FileTest.exists?(/etc/slackware-version) + Slackware end end end diff --git a/lib/facter/operatingsystemrelease.rb b/lib/facter/operatingsystemrelease.rb index 280208b..ac9be65 100644 --- a/lib/facter/operatingsystemrelease.rb +++ b/lib/facter/operatingsystemrelease.rb @@ -72,5 +72,29 @@ Facter.add(:operatingsystemrelease) do end Facter.add(:operatingsystemrelease) do - setcode do Facter[:kernelrelease].value end + confine :operatingsystem = %w{Bluewhite64} + setcode do + releasefile = Facter::Util::Resolution.exec('cat /etc/bluewhite64-version') + if releasefile =~ /^\s*\w+\s+(\d+)\.(\d+)/ + $1 + . + $2 + else + unknown + end + end +end + +Facter.add(:operatingsystemrelease) do + confine :operatingsystem = %w{Slamd64} + setcode do + releasefile = Facter::Util::Resolution.exec('cat /etc/slamd64-version') + if releasefile =~ /^\s*\w+\s+(\d+)\.(\d+)/ + $1 + . + $2 + else + unknown + end + end +end + +Facter.add(:operatingsystemrelease) do + setcode do Facter[:kernelrelease].value end end -- 1.7.4.1 -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-dev@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en. -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-dev@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
Re: [Puppet-dev] [PATCH/facter 1/3] Discussion on ec2 facts - #2346
On 8 March 2011 17:23, James Turnbull ja...@puppetlabs.com wrote: Paul Nasrat wrote: +1 been pending for too long Was that a +1 on patches 2 and 3 in that series also? I largely rewrote the whole fact. Just on this, I need to review the arp fact in more depth. I think the basic idea for the rewrite is sane, but again need to review. Paul -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-dev@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
Re: [Puppet-dev] [PATCH/facter 1/1] Fixed #5485 - Updated selinux_mode fact
On 8 March 2011 21:33, James Turnbull ja...@lovedthanlost.net wrote: 1. Added tested 2. Refactored to use F:U:R.exec 3. Chomp trailing newline What happens if it gets output if no Current Mode line (think older, think you're missing test/handling for that. You've also changed the rule to use Current mode not Mode from config file, was this intentiional have you tested on rhel4, rhel5, rhel6 and non-rhel selinux systems? Paul Signed-off-by: James Turnbull ja...@lovedthanlost.net --- Local-branch: tickets/master/5485 lib/facter/selinux.rb | 11 +++ spec/unit/data/selinux_sestatus | 4 spec/unit/selinux_spec.rb | 15 +-- 3 files changed, 24 insertions(+), 6 deletions(-) create mode 100644 spec/unit/data/selinux_sestatus diff --git a/lib/facter/selinux.rb b/lib/facter/selinux.rb index 0e9637d..ee663a0 100644 --- a/lib/facter/selinux.rb +++ b/lib/facter/selinux.rb @@ -4,7 +4,7 @@ Facter.add(selinux) do confine :kernel = :linux - setcode do + setcode do result = false if FileTest.exists?(/selinux/enforce) if FileTest.exists?(/proc/self/attr/current) @@ -31,7 +31,7 @@ end Facter.add(selinux_policyversion) do confine :selinux = :true - setcode do + setcode do File.read(/selinux/policyvers) end end @@ -39,7 +39,10 @@ end Facter.add(selinux_mode) do confine :selinux = :true setcode do - %x{/usr/sbin/sestatus | /bin/grep Policy from config file: | awk '{print $5}'} + mode = Facter::Util::Resolution.exec('/usr/sbin/sestatus') + mode.each_line do |l| + mode = $1 if l =~ /^Current Mode:\s+(\w+)$/ + end + mode.chomp end end - diff --git a/spec/unit/data/selinux_sestatus b/spec/unit/data/selinux_sestatus new file mode 100644 index 000..b16777f --- /dev/null +++ b/spec/unit/data/selinux_sestatus @@ -0,0 +1,4 @@ +SELinux status: enabled +SELinuxfs mount: /selinux +Current Mode: permissive +Policy version: 16 diff --git a/spec/unit/selinux_spec.rb b/spec/unit/selinux_spec.rb index 43fd5bf..2af9583 100755 --- a/spec/unit/selinux_spec.rb +++ b/spec/unit/selinux_spec.rb @@ -31,11 +31,11 @@ describe SELinux facts do File.stubs(:read).with(/selinux/enforce).returns(0) FileTest.expects(:exists?).with(/selinux/enforce).returns true - File.expects(:read).with(/selinux/enforce).returns(1) + File.expects(:read).with(/selinux/enforce).returns(1) Facter.fact(:selinux_enforced).value.should == true end - + it should return an SELinux policy version do Facter.fact(:selinux).stubs(:value).returns(true) @@ -45,4 +45,15 @@ describe SELinux facts do Facter.fact(:selinux_policyversion).value.should == 1 end + + it should return the SELinux policy mode do + Facter.fact(:selinux).stubs(:value).returns(true) + + sample_output_file = File.dirname(__FILE__) + '/data/selinux_sestatus' + selinux_sestatus = File.read(sample_output_file) + + Facter::Util::Resolution.stubs(:exec).with('/usr/sbin/sestatus').returns(selinux_sestatus) + + Facter.fact(:selinux_mode).value.should == permissive + end end -- 1.7.1 -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-dev@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en. -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-dev@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
Re: [Puppet-dev] [PATCH/facter 1/1] Fixed #5485 - Updated selinux_mode fact
On 9 March 2011 14:00, Todd Zullinger t...@pobox.com wrote: Paul Nasrat wrote: You've also changed the rule to use Current mode not Mode from config file, was this intentiional have you tested on rhel4, rhel5, rhel6 and non-rhel selinux systems? It seems like a different bug that the current fact was grepping Policy from config file: from the sestatus output for selinux_mode. That's not the mode, it's the policy type. Using Mode from config file: would have been more accurate for selinux_mode. But IMO using Current mode: seems even better (assuming it falls back properly if older systems lack that in the sestatus output). Whether folks were using the selinux_mode fact to get what was really the selinux policy type and will be burned by this change is another matter, of course. Yeah - poorly defined fact purposes bite us again. I'd say for 1.5.x we might want to maintain old behaviour to not break policy type clients and breaking changes when we break the world in 2.0. Paul -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-dev@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
Re: [Puppet-dev] [PATCH/facter 1/3] Discussion on ec2 facts - #2346
+1 been pending for too long On 8 March 2011 10:28, James Turnbull ja...@lovedthanlost.net wrote: From: Paul Nasrat pnas...@googlemail.com The EC2 fact is completely broken at the moment: * Timeout::Error isn't caught by rescue (due to how it inherits) * The issue of wrong open semantics outlined here, this is causing hidden immediate failure * The fact is going to cause a 2 second wait to every facter run Whilst the following patch fixes the first two, I'm not sure we want to take the timeout hit, we also want to add tests as even simple ruby code can get logic errors such as the open(). Signed-off-by: Paul Nasrat pnas...@googlemail.com Signed-off-by: James Turnbull ja...@lovedthanlost.net --- Local-branch: tickets/master/2346 lib/facter/ec2.rb | 7 +-- 1 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/facter/ec2.rb b/lib/facter/ec2.rb index ef84757..ea29d14 100644 --- a/lib/facter/ec2.rb +++ b/lib/facter/ec2.rb @@ -6,9 +6,12 @@ require 'open-uri' require 'timeout' def can_connect?(ip,port,wait_sec=2) - Timeout::timeout(wait_sec) {open(ip, port)} + url = http://#{ip}:#{port}/; + Timeout::timeout(wait_sec) {open(url)} return true -rescue +rescue Timeout::Error + return false +rescue return false end -- 1.7.1 -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-dev@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en. -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-dev@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
Re: [Puppet-dev] [PATCH/facter 1/1] Fixed #5485 - Removed trailing line for selinux_mode fact
On 7 March 2011 09:25, James Turnbull ja...@lovedthanlost.net wrote: Signed-off-by: James Turnbull ja...@lovedthanlost.net This fact probably could do with a unittest - there is selinux_spec.rb already and you should be able to add the missing test as you are touching it. Perhaps use Resolution::Exec rather than %x{} We also should enforce the no-trailing whitespace rules in the facter lib not in each individual fact. I personally dislike the use of pipes in the fact as we can't unittest the logic, and would rather it be handled in ruby rather than grep/awk. Paul Paul --- Local-branch: tickets/master/5485 lib/facter/selinux.rb | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/facter/selinux.rb b/lib/facter/selinux.rb index 0e9637d..d312b3b 100644 --- a/lib/facter/selinux.rb +++ b/lib/facter/selinux.rb @@ -4,7 +4,7 @@ Facter.add(selinux) do confine :kernel = :linux - setcode do + setcode do result = false if FileTest.exists?(/selinux/enforce) if FileTest.exists?(/proc/self/attr/current) @@ -31,7 +31,7 @@ end Facter.add(selinux_policyversion) do confine :selinux = :true - setcode do + setcode do File.read(/selinux/policyvers) end end @@ -39,7 +39,7 @@ end Facter.add(selinux_mode) do confine :selinux = :true setcode do - %x{/usr/sbin/sestatus | /bin/grep Policy from config file: | awk '{print $5}'} + %x{/usr/sbin/sestatus | /bin/grep Policy from config file: | awk '{print $5}'}.chomp end end -- 1.7.1 -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-dev@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en. -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-dev@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
Re: [Puppet-dev] [PATCH/facter 1/1] Fixed #6611 - Fixed broken HPVM test and rationalised test structure
I don't have hpux access to test, but look sane +1 On 6 March 2011 19:52, James Turnbull ja...@lovedthanlost.net wrote: Signed-off-by: James Turnbull ja...@lovedthanlost.net --- Local-branch: tickets/master/6611 spec/unit/virtual_spec.rb | 23 --- 1 files changed, 12 insertions(+), 11 deletions(-) diff --git a/spec/unit/virtual_spec.rb b/spec/unit/virtual_spec.rb index a152b40..454a57b 100644 --- a/spec/unit/virtual_spec.rb +++ b/spec/unit/virtual_spec.rb @@ -6,9 +6,18 @@ require 'facter/util/macosx' describe Virtual fact do - after do - Facter.clear - end + before do + Facter::Util::Virtual.stubs(:zone?).returns(false) + Facter::Util::Virtual.stubs(:openvz?).returns(false) + Facter::Util::Virtual.stubs(:vserver?).returns(false) + Facter::Util::Virtual.stubs(:xen?).returns(false) + Facter::Util::Virtual.stubs(:kvm?).returns(false) + Facter::Util::Virtual.stubs(:hpvm?).returns(false) + end + + after do + Facter.clear + end it should be zone on Solaris when a zone do Facter.fact(:kernel).stubs(:value).returns(SunOS) @@ -58,13 +67,6 @@ describe Virtual fact do end describe on Linux do - before do - Facter::Util::Virtual.stubs(:zone?).returns(false) - Facter::Util::Virtual.stubs(:openvz?).returns(false) - Facter::Util::Virtual.stubs(:vserver?).returns(false) - Facter::Util::Virtual.stubs(:xen?).returns(false) - Facter::Util::Virtual.stubs(:kvm?).returns(false) - end it should be parallels with Parallels vendor id from lspci do Facter.fact(:kernel).stubs(:value).returns(Linux) @@ -114,7 +116,6 @@ describe Virtual fact do Facter.fact(:virtual).value.should == parallels end end - end describe is_virtual fact do -- 1.7.1 -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-dev@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en. -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-dev@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
Re: [Puppet-dev] Re: How much Do What I Mean magic should we embed in network facts?
On 15 February 2011 21:43, Richard Crowley r...@rcrowley.org wrote: While Matt and I were pairing on getting IPv6 support into facter we ran across some code that, on Darwin, would try and DWIM out the main address of the system. Specifically, it assumed that the main IP address of a machine was the one associated with a default route. I have recreated this behavior in a custom fact on Linux before and would support it being declared the correct behavior everywhere. IMO this is site specific and we can't do the right thing, it's one of the areas where there may be the common case but it's not by any means conclusive. Being able to say programatically that ipaddress_eth1 is the answer when someone asks for ipaddress would be cool and then the default route looks like a reasonable default - nothing more. Based on previous discussions with facter users I don't think we can make this assumption. Now enabling easy labelling/aliasing of facts to help make the code in puppet more readable is probably a reasonable compromise. As is having rich data so you could say: ${route.default.interfaces}, but even then with bonding, etc it may be more complex than a 1:1 mapping. Paul -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-dev@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
Re: [Puppet-dev] [PATCH] Adds IPv6 related facts to facter's core.
On 5 February 2011 15:16, Cody Herriges c.a.herri...@gmail.com wrote: The following patch provides an ipaddress6 fact to report IP addresses that follow the IPv6 standard, RFC 2460. Basic code structure was modeled after the already current ipaddress facts available in facter core and are not intended to make large behaviour changes to the way facter functions when discovering IP addresses. Intial support is only for FreeBSD, Linux, SunOS, and Darwin. The only platforms I had available for testing at the time, more support coming soon. Another minor change in the patch is a replacement of %x with the Facter::Util::Resolution.exec method for ease of rspec mocking. You mention mocking but I don't see any tests in this commit. It'd be nice to have them :) Paul -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-dev@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
Re: [Puppet-dev] [PATCH 1/3] Refactor #6044 -- port testing to rspec2
On 1 February 2011 01:57, Daniel Pittman dan...@puppetlabs.com wrote: On Sun, Jan 30, 2011 at 09:28, Paul Nasrat pnas...@gmail.com wrote: On 28 January 2011 18:44, Daniel Pittman dan...@puppetlabs.com wrote: From: Daniel Pittman dan...@rimspace.net We have moved to rspec2 for puppet, and facter should follow suit. +1 with minor query [...] index b7e3089..c104856 --- a/spec/unit/util/uptime.rb +++ b/spec/unit/util/uptime.rb @@ -7,7 +7,7 @@ require 'facter/util/uptime' describe Facter::Util::Uptime do describe .get_uptime_seconds_unix do - context when /proc/uptime is available do + describe when /proc/uptime is available do I thought context within describe is still supported http://relishapp.com/rspec/rspec-core/v/2-4/file/upgrade It is: when we went looking during the review and testing we didn't actually find the right bit of documentation, so thought it was uniformly disabled, not just at the top level. This hunk could have been dropped, although I don't think that is strictly required. Fine as I said it's fine to be describe everywhere for the moment +1 Paul -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-dev@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
Re: [Puppet-dev] [PATCH 3/3] Refactor #6044 -- use _spec.rb as the pattern for spec tests.
On 28 January 2011 18:44, Daniel Pittman dan...@puppetlabs.com wrote: From: Daniel Pittman dan...@rimspace.net Rename all the spec tests to follow the rspec convention of *_spec.rb rather than unadorned *.rb; this also makes it easier to work with them consistently without using the Rakefile support that customizes that. +1 --- Rakefile | 4 ++-- spec/integration/{facter.rb = facter_spec.rb} | 0 spec/unit/{facter.rb = facter_spec.rb} | 0 spec/unit/{interfaces.rb = interfaces_spec.rb} | 0 ...{operatingsystem.rb = operatingsystem_spec.rb} | 0 ...emrelease.rb = operatingsystemrelease_spec.rb} | 0 spec/unit/{selinux.rb = selinux_spec.rb} | 0 spec/unit/{uptime.rb = uptime_spec.rb} | 0 .../util/{collection.rb = collection_spec.rb} | 0 spec/unit/util/{confine.rb = confine_spec.rb} | 0 spec/unit/util/{fact.rb = fact_spec.rb} | 0 spec/unit/util/{ip.rb = ip_spec.rb} | 0 spec/unit/util/{loader.rb = loader_spec.rb} | 0 .../util/{macaddress.rb = macaddress_spec.rb} | 0 spec/unit/util/{macosx.rb = macosx_spec.rb} | 0 .../util/{manufacturer.rb = manufacturer_spec.rb} | 0 .../util/{resolution.rb = resolution_spec.rb} | 0 spec/unit/util/{uptime.rb = uptime_spec.rb} | 0 spec/unit/util/{virtual.rb = virtual_spec.rb} | 0 spec/unit/util/{vlans.rb = vlans_spec.rb} | 0 .../util/{xendomains.rb = xendomains_spec.rb} | 0 spec/unit/{virtual.rb = virtual_spec.rb} | 0 22 files changed, 2 insertions(+), 2 deletions(-) rename spec/integration/{facter.rb = facter_spec.rb} (100%) rename spec/unit/{facter.rb = facter_spec.rb} (100%) rename spec/unit/{interfaces.rb = interfaces_spec.rb} (100%) rename spec/unit/{operatingsystem.rb = operatingsystem_spec.rb} (100%) rename spec/unit/{operatingsystemrelease.rb = operatingsystemrelease_spec.rb} (100%) rename spec/unit/{selinux.rb = selinux_spec.rb} (100%) rename spec/unit/{uptime.rb = uptime_spec.rb} (100%) rename spec/unit/util/{collection.rb = collection_spec.rb} (100%) rename spec/unit/util/{confine.rb = confine_spec.rb} (100%) rename spec/unit/util/{fact.rb = fact_spec.rb} (100%) rename spec/unit/util/{ip.rb = ip_spec.rb} (100%) rename spec/unit/util/{loader.rb = loader_spec.rb} (100%) rename spec/unit/util/{macaddress.rb = macaddress_spec.rb} (100%) rename spec/unit/util/{macosx.rb = macosx_spec.rb} (100%) rename spec/unit/util/{manufacturer.rb = manufacturer_spec.rb} (100%) rename spec/unit/util/{resolution.rb = resolution_spec.rb} (100%) rename spec/unit/util/{uptime.rb = uptime_spec.rb} (100%) rename spec/unit/util/{virtual.rb = virtual_spec.rb} (100%) rename spec/unit/util/{vlans.rb = vlans_spec.rb} (100%) rename spec/unit/util/{xendomains.rb = xendomains_spec.rb} (100%) rename spec/unit/{virtual.rb = virtual_spec.rb} (100%) diff --git a/Rakefile b/Rakefile index 9b79613..9d7d906 100644 --- a/Rakefile +++ b/Rakefile @@ -63,12 +63,12 @@ task :default do end RSpec::Core::RakeTask.new do |t| - t.pattern ='spec/{unit,integration}/**/*.rb' + t.pattern ='spec/{unit,integration}/**/*_spec.rb' t.fail_on_error = false end RSpec::Core::RakeTask.new('spec:rcov') do |t| - t.pattern ='spec/{unit,integration}/**/*.rb' + t.pattern ='spec/{unit,integration}/**/*_spec.rb' t.fail_on_error = false if defined?(Rcov) t.rcov = true diff --git a/spec/integration/facter.rb b/spec/integration/facter_spec.rb similarity index 100% rename from spec/integration/facter.rb rename to spec/integration/facter_spec.rb diff --git a/spec/unit/facter.rb b/spec/unit/facter_spec.rb similarity index 100% rename from spec/unit/facter.rb rename to spec/unit/facter_spec.rb diff --git a/spec/unit/interfaces.rb b/spec/unit/interfaces_spec.rb similarity index 100% rename from spec/unit/interfaces.rb rename to spec/unit/interfaces_spec.rb diff --git a/spec/unit/operatingsystem.rb b/spec/unit/operatingsystem_spec.rb similarity index 100% rename from spec/unit/operatingsystem.rb rename to spec/unit/operatingsystem_spec.rb diff --git a/spec/unit/operatingsystemrelease.rb b/spec/unit/operatingsystemrelease_spec.rb similarity index 100% rename from spec/unit/operatingsystemrelease.rb rename to spec/unit/operatingsystemrelease_spec.rb diff --git a/spec/unit/selinux.rb b/spec/unit/selinux_spec.rb similarity index 100% rename from spec/unit/selinux.rb rename to spec/unit/selinux_spec.rb diff --git a/spec/unit/uptime.rb b/spec/unit/uptime_spec.rb similarity index 100% rename from spec/unit/uptime.rb rename to spec/unit/uptime_spec.rb diff --git a/spec/unit/util/collection.rb b/spec/unit/util/collection_spec.rb similarity index 100% rename from spec/unit/util/collection.rb rename to spec/unit/util/collection_spec.rb diff --git
Re: [Puppet-dev] [PATCH 2/3] Refactor #6044 -- require spec_helper with a consistent path.
On 28 January 2011 18:44, Daniel Pittman dan...@puppetlabs.com wrote: From: Daniel Pittman dan...@rimspace.net Because we pull in spec_helper in individual tests, we need to use a consistent path or Ruby will evaluate it multiple times. Make the path consistent by expanding it before require. +1 --- spec/integration/facter.rb | 2 +- spec/unit/facter.rb | 2 +- spec/unit/interfaces.rb | 2 +- spec/unit/operatingsystem.rb | 2 +- spec/unit/operatingsystemrelease.rb | 2 +- spec/unit/selinux.rb | 2 +- spec/unit/uptime.rb | 2 +- spec/unit/util/collection.rb | 2 +- spec/unit/util/confine.rb | 2 +- spec/unit/util/fact.rb | 2 +- spec/unit/util/ip.rb | 2 +- spec/unit/util/loader.rb | 2 +- spec/unit/util/macaddress.rb | 2 +- spec/unit/util/macosx.rb | 2 +- spec/unit/util/manufacturer.rb | 2 +- spec/unit/util/resolution.rb | 2 +- spec/unit/util/uptime.rb | 2 +- spec/unit/util/virtual.rb | 2 +- spec/unit/util/vlans.rb | 2 +- spec/unit/util/xendomains.rb | 2 +- spec/unit/virtual.rb | 2 +- 21 files changed, 21 insertions(+), 21 deletions(-) mode change 100644 = 100755 spec/unit/interfaces.rb mode change 100644 = 100755 spec/unit/operatingsystem.rb mode change 100644 = 100755 spec/unit/selinux.rb mode change 100644 = 100755 spec/unit/util/vlans.rb diff --git a/spec/integration/facter.rb b/spec/integration/facter.rb index 79a1f0f..8351de1 100755 --- a/spec/integration/facter.rb +++ b/spec/integration/facter.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../spec_helper' +require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe Facter do before do diff --git a/spec/unit/facter.rb b/spec/unit/facter.rb index 20f9ed1..e63bc76 100755 --- a/spec/unit/facter.rb +++ b/spec/unit/facter.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../spec_helper' +require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe Facter do diff --git a/spec/unit/interfaces.rb b/spec/unit/interfaces.rb old mode 100644 new mode 100755 index 49d5d1f..8b295d6 --- a/spec/unit/interfaces.rb +++ b/spec/unit/interfaces.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../spec_helper' +require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') require 'facter' diff --git a/spec/unit/operatingsystem.rb b/spec/unit/operatingsystem.rb old mode 100644 new mode 100755 index de86230..be83916 --- a/spec/unit/operatingsystem.rb +++ b/spec/unit/operatingsystem.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../spec_helper' +require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') require 'facter' diff --git a/spec/unit/operatingsystemrelease.rb b/spec/unit/operatingsystemrelease.rb index 5c821c3..1cfb4ac 100755 --- a/spec/unit/operatingsystemrelease.rb +++ b/spec/unit/operatingsystemrelease.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../spec_helper' +require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') require 'facter' diff --git a/spec/unit/selinux.rb b/spec/unit/selinux.rb old mode 100644 new mode 100755 index 8afa463..43fd5bf --- a/spec/unit/selinux.rb +++ b/spec/unit/selinux.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../spec_helper' +require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') require 'facter' diff --git a/spec/unit/uptime.rb b/spec/unit/uptime.rb index fc592e3..bd695fa 100755 --- a/spec/unit/uptime.rb +++ b/spec/unit/uptime.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../spec_helper' +require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') require 'facter' require 'facter/util/uptime' diff --git a/spec/unit/util/collection.rb b/spec/unit/util/collection.rb index 7baef96..86b602f 100755 --- a/spec/unit/util/collection.rb +++ b/spec/unit/util/collection.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../../spec_helper' +require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') require 'facter/util/collection' diff --git a/spec/unit/util/confine.rb b/spec/unit/util/confine.rb index 757ca26..147c70d 100755 --- a/spec/unit/util/confine.rb +++ b/spec/unit/util/confine.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../../spec_helper' +require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') require 'facter/util/confine' require 'facter/util/values' diff --git a/spec/unit/util/fact.rb b/spec/unit/util/fact.rb
Re: [Puppet-dev] [PATCH 1/3] Refactor #6044 -- port testing to rspec2
On 28 January 2011 18:44, Daniel Pittman dan...@puppetlabs.com wrote: From: Daniel Pittman dan...@rimspace.net We have moved to rspec2 for puppet, and facter should follow suit. +1 with minor query --- Rakefile | 14 -- spec/Rakefile | 18 -- spec/spec_helper.rb | 4 ++-- spec/unit/operatingsystemrelease.rb | 2 +- spec/unit/uptime.rb | 6 +++--- spec/unit/util/macaddress.rb | 10 +- spec/unit/util/uptime.rb | 10 +- spec/unit/util/virtual.rb | 2 +- spec/unit/util/xendomains.rb | 2 +- 9 files changed, 26 insertions(+), 42 deletions(-) delete mode 100644 spec/Rakefile mode change 100644 = 100755 spec/unit/operatingsystemrelease.rb mode change 100644 = 100755 spec/unit/uptime.rb mode change 100644 = 100755 spec/unit/util/macaddress.rb mode change 100644 = 100755 spec/unit/util/uptime.rb mode change 100644 = 100755 spec/unit/util/xendomains.rb diff --git a/Rakefile b/Rakefile index ba939be..9b79613 100644 --- a/Rakefile +++ b/Rakefile @@ -4,8 +4,8 @@ $: File.expand_path('lib') $LOAD_PATH File.join(File.dirname(__FILE__), 'tasks') require 'rubygems' -require 'spec' -require 'spec/rake/spectask' +require 'rspec' +require 'rspec/core/rake_task' begin require 'rcov' rescue LoadError @@ -62,12 +62,14 @@ task :default do sh %{rake -T} end -Spec::Rake::SpecTask.new(:spec) do |t| - t.spec_files = FileList['spec/**/*.rb'] +RSpec::Core::RakeTask.new do |t| + t.pattern ='spec/{unit,integration}/**/*.rb' + t.fail_on_error = false end -Spec::Rake::SpecTask.new('spec:rcov') do |t| - t.spec_files = FileList['spec/**/*.rb'] +RSpec::Core::RakeTask.new('spec:rcov') do |t| + t.pattern ='spec/{unit,integration}/**/*.rb' + t.fail_on_error = false if defined?(Rcov) t.rcov = true t.rcov_opts = ['--exclude', 'spec/*,test/*,results/*,/usr/lib/*,/usr/local/lib/*,gems/*'] diff --git a/spec/Rakefile b/spec/Rakefile deleted file mode 100644 index e2996f6..000 --- a/spec/Rakefile +++ /dev/null @@ -1,18 +0,0 @@ -require File.join(File.dirname(__FILE__), spec_helper.rb) -require 'rake' -require 'spec/rake/spectask' - -basedir = File.dirname(__FILE__) -puppetlibdir = File.join(basedir, ../lib) -puppettestlibdir = File.join(basedir, ../test/lib) -speclibdir = File.join(basedir, lib) - -libs = [puppetlibdir, puppettestlibdir, speclibdir] -desc Run all specs -Spec::Rake::SpecTask.new('all') do |t| - t.spec_files = FileList['integration/**/*.rb', 'unit/**/*.rb'] - t.libs = libs - t.spec_opts = ['--options', 'spec.opts'] -end - -task :default = [:all] diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index c8bd547..d9db445 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -7,12 +7,12 @@ $LOAD_PATH.unshift(#{dir}/../lib) require 'rubygems' require 'mocha' -require 'spec' +require 'rspec' require 'facter' # load any monkey-patches Dir[#{dir}/monkey_patches/*.rb].map { |file| require file } -Spec::Runner.configure do |config| +RSpec.configure do |config| config.mock_with :mocha end diff --git a/spec/unit/operatingsystemrelease.rb b/spec/unit/operatingsystemrelease.rb old mode 100644 new mode 100755 index 31d4ae8..5c821c3 --- a/spec/unit/operatingsystemrelease.rb +++ b/spec/unit/operatingsystemrelease.rb @@ -26,7 +26,7 @@ describe Operating System Release fact do } test_cases.each do |system, file| - context with operatingsystem reported as #{system.inspect} do + describe with operatingsystem reported as #{system.inspect} do it should read the #{file.inspect} file do Facter.fact(:operatingsystem).stubs(:value).returns(system) diff --git a/spec/unit/uptime.rb b/spec/unit/uptime.rb old mode 100644 new mode 100755 index 19a55fe..fc592e3 --- a/spec/unit/uptime.rb +++ b/spec/unit/uptime.rb @@ -9,7 +9,7 @@ describe uptime facts: do before { Facter.clear } after { Facter.clear } - context when uptime information is available do + describe when uptime information is available do describe uptime do test_cases = [ [60 * 60 * 24 * 3, '3 days'], @@ -34,7 +34,7 @@ describe uptime facts: do end - context when uptime information is available do + describe when uptime information is available do before do Facter::Util::Uptime.stubs(:get_uptime_seconds_unix).returns(60 * 60 * 24 + 23) Facter::Util::Uptime.stubs(:get_uptime_seconds_win).returns(60 * 60 * 24 + 23) @@ -59,7 +59,7 @@ describe uptime facts: do end end - context when uptime information is not available do + describe when uptime information is not available do before do Facter::Util::Uptime.stubs(:get_uptime_seconds_unix).returns(nil)
Re: [Puppet-dev] [PATCH] (#5699) Facter does not work properly with zLinux (s390x)
On 28 December 2010 12:04, Hector Rivas Gandara key...@gmail.com wrote: Modified the facts processorN, processorcount, is_virtual and virtual: * is_virtual=true and virtual=.zlinux. if architecture=s390x * /proc/cpuinfo has diferent syntax, matching /processor\s+(\d+):\s+(.*)/ IIRC both LPAR and z/vm are supported modes on zSeries. How does thie identify both install types? Is zlinux the best value to be using here? Are you testing on hercules? Paul -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
Re: [Puppet-dev] [PATCH/puppet 2/2] maint: Add vim swap files to .gitignore
On 6 January 2011 23:22, Matt Robinson m...@puppetlabs.com wrote: Paired-with: Jesse Wolfe Signed-off-by: Matt Robinson m...@puppetlabs.com --- .gitignore | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/.gitignore b/.gitignore index 1e6b959..a208237 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .rspec results +.*.sw[op] Any reason this needs to be in the project gitignore and not set per-user via a ~/.gitignore configured by git config --global core.excludesfile ~/.gitignore I can see the point of artefacts generated by tests/packaging but editors are a personal choice right :) Paul -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
Re: [Puppet-dev] [PATCH/puppet 2/2] maint: Add vim swap files to .gitignore
On 7 January 2011 17:12, Daniel Pittman dan...@rimspace.net wrote: On Jan 7, 2011 8:53 AM, Matt Robinson m...@puppetlabs.com wrote: On Fri, Jan 7, 2011 at 8:45 AM, Paul Nasrat pnas...@gmail.com wrote: On 6 January 2011 23:22, Matt Robinson m...@puppetlabs.com wrote: Paired-with: Jesse Wolfe Signed-off-by: Matt Robinson m...@puppetlabs.com --- .gitignore | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/.gitignore b/.gitignore index 1e6b959..a208237 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .rspec results +.*.sw[op] Any reason this needs to be in the project gitignore and not set per-user via a ~/.gitignore configured by git config --global core.excludesfile ~/.gitignore I can see the point of artefacts generated by tests/packaging but editors are a personal choice right :) It's not a personal choice if people accidentally try to commit .swp files to the project (not that this has happened so far as I know), and we can't edit users ~/.gitignore files. Any reason anyone should ever want to commit a .swp file to the project? I fully agree with this: adding routine editor backup files to the project ignore list costs pretty much nothing and leads to a nicer experience for everyone who develops on it. If that's the case then add the full set not just vim - eg *~, \#* .\#*, intellij/rubymine and eclipse settings dirs/project metadata files, os files such as .DS_Store, etc Feel free to commit whatever but IMO it's better for non-project things to be in per user gitignore. Paul -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
Re: [Puppet-dev] [PATCH/facter 1/1] (#5666) windows support for facter/id.rb
On 24 December 2010 02:52, William Van Hevelingen wva...@gmail.com wrote: From: William Van Hevelingen w...@cs.pdx.edu Looks good - according to this: http://www.windowsitpro.com/article/tips/jsi-tip-7308-the-windows-xp-and-windows-server-2003-whoami-utility-.aspx It's new in XP/2003 server. Can someone from puppetlabs let us know what the version support for Windows is meant to cover. Paul Signed-off-by: William Van Hevelingen wva...@gmail.com --- Local-branch: feature/master/5666 lib/facter/id.rb | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/lib/facter/id.rb b/lib/facter/id.rb index 0a4067d..deddc4a 100644 --- a/lib/facter/id.rb +++ b/lib/facter/id.rb @@ -1,5 +1,5 @@ Facter.add(:id) do - confine :operatingsystem = %w{Linux Fedora RedHat CentOS SuSE SLES Debian Ubuntu Gentoo AIX OEL OVS} + confine :operatingsystem = %w{Linux Fedora RedHat CentOS SuSE SLES Debian Ubuntu Gentoo AIX OEL OVS windows} setcode whoami end -- 1.7.0.4 -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en. -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
Re: [Puppet-dev] [PATCH/facter 1/1] (#5666) windows support for facter/id.rb
Sure well +1 for this and we can always add more specific facts. I'll merge for next post Xmas Paul On Dec 24, 2010 6:09 PM, Nigel Kersten ni...@puppetlabs.com wrote: On Fri, Dec 24, 2010 at 12:41 AM, Paul Nasrat pnas...@gmail.com wrote: On 24 December 2010 02:52, William Van Hevelingen wva...@gmail.com wrote: From: William Van Hevelingen w...@cs.pdx.edu Looks good - according to this: http://www.windowsitpro.com/article/tips/jsi-tip-7308-the-windows-xp-and-windows-server-2003-whoami-utility-.aspx It's new in XP/2003 server. Can someone from puppetlabs let us know what the version support for Windows is meant to cover. There's no need to defer that to Puppet Labs Paul. You're setting a lot of the agenda for Facter, you can make decisions like this. Frankly, anything that improves coverage is welcome in my book. Paul Signed-off-by: William Van Hevelingen wva...@gmail.com --- Local-branch: feature/master/5666 lib/facter/id.rb | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/lib/facter/id.rb b/lib/facter/id.rb index 0a4067d..deddc4a 100644 --- a/lib/facter/id.rb +++ b/lib/facter/id.rb @@ -1,5 +1,5 @@ Facter.add(:id) do - confine :operatingsystem = %w{Linux Fedora RedHat CentOS SuSE SLES Debian Ubuntu Gentoo AIX OEL OVS} + confine :operatingsystem = %w{Linux Fedora RedHat CentOS SuSE SLES Debian Ubuntu Gentoo AIX OEL OVS windows} setcode whoami end -- 1.7.0.4 -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.compuppet-dev%2bunsubscr...@googlegroups.com puppet-dev%2bunsubscr...@googlegroups.compuppet-dev%252bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en. -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.compuppet-dev%2bunsubscr...@googlegroups.com puppet-dev%2bunsubscr...@googlegroups.compuppet-dev%252bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en. -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.compuppet-dev%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en. -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
Re: [Puppet-dev] [PATCH/facter 1/1] (#1423) Memory facts for Solaris
On 2 December 2010 23:27, Paul Berry p...@puppetlabs.com wrote: On Tue, Nov 30, 2010 at 4:27 AM, Dominic Cleal dcl...@redhat.com wrote: Add total memory from prtconf output, free from vmstat plus swap free and total from swap -l listing. Signed-off-by: Dominic Cleal dcl...@redhat.com --- Local-branch: tickets/master/1423 lib/facter/memory.rb | 51 ++-- lib/facter/util/memory.rb | 12 ++ 2 files changed, 56 insertions(+), 7 deletions(-) diff --git a/lib/facter/memory.rb b/lib/facter/memory.rb index 06640e6..f744c3f 100644 --- a/lib/facter/memory.rb +++ b/lib/facter/memory.rb @@ -69,13 +69,7 @@ if Facter.value(:kernel) == OpenBSD end end - Facter.add(MemoryFree) do - confine :kernel = :openbsd - memfree = Facter::Util::Resolution.exec(vmstat | tail -n 1 | awk '{ print $5 }') - setcode do - Facter::Memory.scale_number(memfree.to_f,kB) - end - end + Facter::Memory.vmstat_find_free_memory() Facter.add(MemoryTotal) do confine :kernel = :openbsd @@ -85,3 +79,46 @@ if Facter.value(:kernel) == OpenBSD end end end + +if Facter.value(:kernel) == SunOS + swap = Facter::Util::Resolution.exec('/usr/sbin/swap -l') + swapfree, swaptotal = 0, 0 + swap.each do |dev| + if dev =~ /^\/\S+\s.*\s+(\d+)\s+(\d+)$/ + swaptotal += $1.to_i / 2 + swapfree += $2.to_i / 2 + end + end + + Facter.add(SwapSize) do + confine :kernel = :sunos + setcode do + Facter::Memory.scale_number(swaptotal.to_f,kB) + end + end + + Facter.add(SwapFree) do + confine :kernel = :sunos + setcode do + Facter::Memory.scale_number(swapfree.to_f,kB) + end + end + + # Total memory size available from prtconf + pconf = Facter::Util::Resolution.exec('/usr/sbin/prtconf') + phymem = + pconf.each do |line| + if line =~ /^Memory size:\s+(\d+) Megabytes/ + phymem = $1 + end + end + + Facter.add(MemorySize) do + confine :kernel = :sunos + setcode do + Facter::Memory.scale_number(phymem.to_f,MB) + end + end + + Facter::Memory.vmstat_find_free_memory() +end diff --git a/lib/facter/util/memory.rb b/lib/facter/util/memory.rb index 2004491..43abec6 100644 --- a/lib/facter/util/memory.rb +++ b/lib/facter/util/memory.rb @@ -50,5 +50,17 @@ module Facter::Memory return %.2f %s % [size, s] end + + def self.vmstat_find_free_memory() + row = Facter::Util::Resolution.exec('vmstat').split(\n)[-1] + if row =~ /^\s*\d+\s*\d+\s*\d+\s*\d+\s*(\d+)/ + Facter.add(MemoryFree) do + memfree = $1 + setcode do + Facter::Memory.scale_number(memfree.to_f, kB) + end + end + end + end end -- 1.7.3.2 It looks like there are two independent changes here. In addition to adding facts for SunOS, this change refactors the OpenBSD MemoryFree fact, moving it to util/memory.rb and rewriting it to use a regular expression. Looks like it was basically extract method for common usage between OpenBSD and SunOS Was the OpenBSD change intentional? Because if so it should probably be in a separate commit, and also it probably could be better written using split() Ideally yeah but tbh, I'd rather fix the platform support. Getting community patches is valuable rather than a regular expression to pick out the fifth column. Regarding the SunOS changes, we are in the process of moving offices so our solaris box is unavailable, but we should be able to test the Solaris-related facts in the next week. Umm EC2 OpenSolaris images? Obviously that doesn't help for sparc specific things but you really should be able to test things whilst your testlab is down. Have you considered getting a cage in a DC for your test equipment as that seems like it'd make sense. Paul -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
Re: [Puppet-dev] [PATCH/facter 1/1] (#2066) Make units optional
On 3 December 2010 10:54, Dominic Cleal dcl...@redhat.com wrote: On 01/12/10 13:10, Paul Nasrat wrote: On 1 December 2010 10:49, Dominic Cleal dcl...@redhat.com wrote: On 01/12/10 10:32, Dominic Cleal wrote: Memory and swap values are now given in standard units via additional facts (e.g. memorysize_mb) as well as the most appropriate unit as before. Please note that this conflicts with the patch I submitted yesterday for #1423 (Solaris memory facts), but I thought it'd be good to get it out there for review anyway. I'm happy to update and resubmit this if/when the other is merged or vice versa. I'd rather not make this change right now as I think we want a consistent approach with in Facter to handle this. Lets use this patch as a way to spark discussion but apply the 1423 patch right now. Sure, hopefully it serves to show the result I'm looking for as a user. Are you thinking to include this in the 2.0 redesign? Yeah the idea is to have the internal representation be something sane and be able to render to human readable units in the display/export layer. Paul -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
Re: [Puppet-dev] [PATCH/facter 1/1] (#1423) Memory facts for Solaris
On 3 December 2010 10:41, Dominic Cleal dcl...@redhat.com wrote: On 02/12/10 23:27, Paul Berry wrote: On Tue, Nov 30, 2010 at 4:27 AM, Dominic Cleal dcl...@redhat.com mailto:dcl...@redhat.com wrote: Add total memory from prtconf output, free from vmstat plus swap free and total from swap -l listing. Signed-off-by: Dominic Cleal dcl...@redhat.com mailto:dcl...@redhat.com It looks like there are two independent changes here. In addition to adding facts for SunOS, this change refactors the OpenBSD MemoryFree fact, moving it to util/memory.rb and rewriting it to use a regular expression. Was the OpenBSD change intentional? Because if so it should probably be in a separate commit, and also it probably could be better written using split() rather than a regular expression to pick out the fifth column. Thanks for the feedback Paul. The change was intentional as the Solaris MemoryFree code would have been identical. I'll resubmit this as two separate commits and use split(). Cool - yeah use a single branch and two commits and mail_patches will do the right thing in making it a patch series. Paul -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
Re: [Puppet-dev] [PATCH/facter 1/1] (#2066) Make units optional
On 1 December 2010 10:49, Dominic Cleal dcl...@redhat.com wrote: On 01/12/10 10:32, Dominic Cleal wrote: Memory and swap values are now given in standard units via additional facts (e.g. memorysize_mb) as well as the most appropriate unit as before. Please note that this conflicts with the patch I submitted yesterday for #1423 (Solaris memory facts), but I thought it'd be good to get it out there for review anyway. I'm happy to update and resubmit this if/when the other is merged or vice versa. I'd rather not make this change right now as I think we want a consistent approach with in Facter to handle this. Lets use this patch as a way to spark discussion but apply the 1423 patch right now. Paul -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
Re: [Puppet-dev] [PATCH/facter 2/2] (#4754) Change is_virtual logic to not enumerate virtual types
On 30 November 2010 19:10, Matt Robinson m...@puppetlabs.com wrote: While looking at the patch for adding parallels to the virtual types David Schmitt noticed that it might be easier just to list the types that are NOT virtual since there's fewer of them. +1 Paul Paired-with: Nick Lewis Signed-off-by: Matt Robinson m...@puppetlabs.com --- Local-branch: ticket/next/4754 lib/facter/virtual.rb | 3 +-- spec/unit/virtual.rb | 6 ++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/facter/virtual.rb b/lib/facter/virtual.rb index a3b7163..8412a0a 100644 --- a/lib/facter/virtual.rb +++ b/lib/facter/virtual.rb @@ -106,8 +106,7 @@ Facter.add(is_virtual) do confine :kernel = %w{Linux FreeBSD OpenBSD SunOS HP-UX Darwin} setcode do - case Facter.value(:virtual) - when xenu, openvzve, vmware, kvm, vserver, jail, zone, hpvm, parallels + if Facter.value(:virtual) != physical Facter.value(:virtual) != xen0 true else false diff --git a/spec/unit/virtual.rb b/spec/unit/virtual.rb index d607960..9e8e358 100644 --- a/spec/unit/virtual.rb +++ b/spec/unit/virtual.rb @@ -135,6 +135,12 @@ describe is_virtual fact do Facter.fact(:is_virtual).value.should == false end + it should be false when running on physical do + Facter.fact(:kernel).stubs(:value).returns(Linux) + Facter.fact(:virtual).stubs(:value).returns(physical) + Facter.fact(:is_virtual).value.should == false + end + it should be true when running on vmware do Facter.fact(:kernel).stubs(:value).returns(Linux) Facter.fact(:virtual).stubs(:value).returns(vmware) -- 1.7.3.1 -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en. -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
Re: [Puppet-dev] [PATCH/puppet 1/1] Maint: made upstart tests more robust.
Does a true command ship by default on Win32? If not this will break the tests there. Unittests should be runnable - please confirm you have a windows box in your CI pipeline by default and the tests all pass on that platform with this change. Paul On Tuesday, November 23, 2010, Paul Berry p...@puppetlabs.com wrote: The tests for the upstart provider were attempting to stub Process::Status.exitstatus. However, this doesn't work (presumably because Process::Status is implemented in C). As a result, the upstart spec tests were failing if the most recent exit code was nonzero. Changed the tests so that instead of stubbing Process::Status.exitstatus to return zero, they execute a command that is known to succeed (`true`). Paired-with: Jesse Wolfe je...@puppetlabs.com Signed-off-by: Paul Berry p...@puppetlabs.com --- Local-branch: maint/next/make_upstart_tests_more_robust spec/unit/provider/service/upstart.rb | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-) diff --git a/spec/unit/provider/service/upstart.rb b/spec/unit/provider/service/upstart.rb index 439fd2c..9fde9e6 100644 --- a/spec/unit/provider/service/upstart.rb +++ b/spec/unit/provider/service/upstart.rb @@ -24,8 +24,7 @@ describe provider_class do resource = Puppet::Type.type(:service).new(:name = foo, :provider = :upstart, :status = /bin/foo) provider = provider_class.new(resource) - Process::Status.any_instance.stubs(:exitstatus).returns(0) - provider.expects(:ucommand) + provider.expects(:ucommand).with { `true`; true } provider.status.should == :running end -- 1.7.2 -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en. -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
Re: [Puppet-dev] [PATCH/facter 1/1] maint: Fix spec failures caused by having a space in the path to facter's source
On 22 November 2010 19:27, Nick Lewis n...@puppetlabs.com wrote: Signed-off-by: Nick Lewis n...@puppetlabs.com Execing cat in the tests is yucky, we should be able to run the tests on Win32 with the fixture data/stub data from commands. Rather than hack around with shell quoting can you instead rework the tests to be a bit more robust, maybe a helper fixture function that returns the right thing using file/path joining and File.read. Paul --- Local-branch: maint/next/fix_space_related_spec_failures spec/unit/util/macaddress.rb | 6 +++--- spec/unit/util/uptime.rb | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/spec/unit/util/macaddress.rb b/spec/unit/util/macaddress.rb index 8349b36..1ccca18 100644 --- a/spec/unit/util/macaddress.rb +++ b/spec/unit/util/macaddress.rb @@ -25,7 +25,7 @@ context Darwin do context when netstat has a default interface do before do - Facter::Util::Macaddress::Darwin.stubs(:netstat_command).returns(cat #{netstat_file}) + Facter::Util::Macaddress::Darwin.stubs(:netstat_command).returns(cat \#{netstat_file}\) end it should return the default interface name do @@ -40,7 +40,7 @@ context Darwin do before do Facter.stubs(:warn) Facter::Util::Macaddress::Darwin.stubs(:default_interface).returns('') - Facter::Util::Macaddress::Darwin.stubs(:ifconfig_command).returns(cat #{ifconfig_file}) + Facter::Util::Macaddress::Darwin.stubs(:ifconfig_command).returns(cat \#{ifconfig_file}\) end it should return the macaddress of the default interface do @@ -52,7 +52,7 @@ context Darwin do context when netstat does not have a default interface do before do Facter::Util::Macaddress::Darwin.stubs(:default_interface).returns() - Facter::Util::Macaddress::Darwin.stubs(:ifconfig_command).returns(cat #{ifconfig_file_no_iface}) + Facter::Util::Macaddress::Darwin.stubs(:ifconfig_command).returns(cat \#{ifconfig_file_no_iface}\) end it should warn about the lack of default do diff --git a/spec/unit/util/uptime.rb b/spec/unit/util/uptime.rb index 9ba6665..72c97ed 100644 --- a/spec/unit/util/uptime.rb +++ b/spec/unit/util/uptime.rb @@ -10,7 +10,7 @@ describe Facter::Util::Uptime do context when /proc/uptime is available do before do uptime_file = File.join(SPECDIR, fixtures, uptime, ubuntu_proc_uptime) - Facter::Util::Uptime.stubs(:uptime_file).returns(uptime_file) + Facter::Util::Uptime.stubs(:uptime_file).returns(\#{uptime_file}\) end it should return the uptime in seconds as an integer do @@ -24,7 +24,7 @@ describe Facter::Util::Uptime do File.exists?(nonexistent_file).should == false Facter::Util::Uptime.stubs(:uptime_file).returns(nonexistent_file) sysctl_output_file = File.join(SPECDIR, 'fixtures', 'uptime', 'sysctl_kern_boottime') # Aug 01 14:13:47 -0700 2010 - Facter::Util::Uptime.stubs(:uptime_sysctl_cmd).returns(cat #{sysctl_output_file}) + Facter::Util::Uptime.stubs(:uptime_sysctl_cmd).returns(cat \#{sysctl_output_file}\) Time.stubs(:now).returns Time.parse(Aug 01 15:13:47 -0700 2010) # one hour later Facter::Util::Uptime.get_uptime_seconds_unix.should == 60 * 60 end @@ -35,7 +35,7 @@ describe Facter::Util::Uptime do Facter::Util::Uptime.stubs(:uptime_file).returns(nonexistent_file) Facter::Util::Uptime.stubs(:uptime_sysctl_cmd).returns(cat #{nonexistent_file}) who_b_output_file = File.join(SPECDIR, 'fixtures', 'uptime', 'who_b_boottime') # Aug 1 14:13 - Facter::Util::Uptime.stubs(:uptime_who_cmd).returns(cat #{who_b_output_file}) + Facter::Util::Uptime.stubs(:uptime_who_cmd).returns(cat \#{who_b_output_file}\) Time.stubs(:now).returns Time.parse(Aug 01 15:13) # one hour later Facter::Util::Uptime.get_uptime_seconds_unix.should == 60 * 60 end -- 1.7.3.2 -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en. -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to
Re: [Puppet-dev] Best way to parse /etc/services
On 21 November 2010 11:01, Stefan Schulte stefan.schu...@taunusstein.net wrote: Hi, I wanted to write a resourcetype to manage ports in /etc/services. I did write a type where you can do something like: port { 'telnet', protocol = 'tcp', number = '22', port_aliases = ['alias1','alias2'], } I think there is an augeas lens for /etc/services - see eg http://projects.puppetlabs.com/projects/1/wiki/Puppet_Augeas#Adding+a+service+that+uses+both+TCP+and+UDP+to+/etc/services So you possibly could write a define or something to do what you want there. Paul -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
Re: [Puppet-dev] [PATCH/facter 1/1] (#5325) Manufacturer and product name on SPARC
On 19 November 2010 09:37, Dominic Cleal dcl...@redhat.com wrote: Use prtdiag output on Solaris/SPARC to determine manufacturer and productname as smbios is unavailable. I don't have a sparc box to test this against but +1 Paul Signed-off-by: Dominic Cleal dcl...@redhat.com --- Local-branch: ticket/master/5325 lib/facter/manufacturer.rb | 2 ++ lib/facter/util/manufacturer.rb | 20 2 files changed, 22 insertions(+), 0 deletions(-) diff --git a/lib/facter/manufacturer.rb b/lib/facter/manufacturer.rb index 9d66465..cbbb88b 100644 --- a/lib/facter/manufacturer.rb +++ b/lib/facter/manufacturer.rb @@ -13,6 +13,8 @@ if Facter.value(:kernel) == OpenBSD } Facter::Manufacturer.sysctl_find_system_info(mfg_keys) +elsif Facter.value(:kernel) == SunOS and Facter.value(:hardwareisa) == sparc + Facter::Manufacturer.prtdiag_sparc_find_system_info() else query = { '[Ss]ystem [Ii]nformation' = [ diff --git a/lib/facter/util/manufacturer.rb b/lib/facter/util/manufacturer.rb index 112380b..5ac0585 100644 --- a/lib/facter/util/manufacturer.rb +++ b/lib/facter/util/manufacturer.rb @@ -60,4 +60,24 @@ module Facter::Manufacturer end end end + + def self.prtdiag_sparc_find_system_info() + # Parses prtdiag for a SPARC architecture string, won't work with Solaris x86 + output = Facter::Util::Resolution.exec('/usr/sbin/prtdiag') + + # System Configuration: Sun Microsystems sun4u Sun SPARC Enterprise M3000 Server + sysconfig = output.split(\n)[0] + if sysconfig =~ /^System Configuration:\s+(.+?)\s+(sun\d+\S+)\s+(.+)/ then + Facter.add('manufacturer') do + setcode do + $1 + end + end + Facter.add('productname') do + setcode do + $3 + end + end + end + end end -- 1.7.3.2 -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en. -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
Re: [Puppet-dev] [PATCH/facter 1/1] (#4754) Add support for Darwin and Parallels VM to virtual fact
On 18 November 2010 10:13, donavanm dona...@desinc.net wrote: From: Donavan Miller dona...@strewth.org Adds support for Parallels VM guest detection with existing operating systems. Detects Parallels based on hardware vendor name and pci id. The Parallels vendor id does not seem to be listed in most pci.ids. Adds resolution for virtual fact in the Darwin kernel. This uses the existing Facter::Util::Macosx module to resolve system profiler data. Both vendor name and vendor id values are checked. Resolution appears to vary based on VM Host product. Thanks for the patch and testing. It's going to take me a little bit before I can test this out. This is probably fine for 1.5.x, as you note the current virtual setup is somewhat horky and could do with some work, which we hope to clean up for 2.x Paul -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
Re: [Puppet-dev] [PATCH/facter 1/1] (#4754) Add support for Darwin and Parallels VM to virtual fact
On 18 November 2010 14:07, David Schmitt da...@dasz.at wrote: On 11/18/2010 11:13 AM, donavanm wrote: @@ -80,11 +103,11 @@ Facter.add(virtual) do end Facter.add(is_virtual) do - confine :kernel = %w{Linux FreeBSD OpenBSD SunOS HP-UX} + confine :kernel = %w{Linux FreeBSD OpenBSD SunOS HP-UX Darwin} setcode do case Facter.value(:virtual) - when xenu, openvzve, vmware, kvm, vserver, jail, zone, hpvm + when xenu, openvzve, vmware, kvm, vserver, jail, zone, hpvm, parallels true else false I'm not familiar with the code, but wouldn't this require less changes if it would just check for virtual != physical ? Yeah at this stage that makes a lot of sense, it's just grown organically. Paul -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
Re: [Puppet-dev] [PATCH/facter 1/1] Maint: add Local-branch: info to mails sent by rake mail_patches
+1 On 12 November 2010 18:27, Paul Berry p...@puppetlabs.com wrote: Signed-off-by: Paul Berry p...@puppetlabs.com --- Local-branch: maint/next/add_local_branch_to_mail_patches tasks/rake/mail_patches.rake | 13 - 1 files changed, 12 insertions(+), 1 deletions(-) diff --git a/tasks/rake/mail_patches.rake b/tasks/rake/mail_patches.rake index 6375a22..be8dda1 100644 --- a/tasks/rake/mail_patches.rake +++ b/tasks/rake/mail_patches.rake @@ -18,10 +18,21 @@ task :mail_patches do # Create all of the patches sh git format-patch -C -M -s -n --subject-prefix='PATCH/facter' #{parent}..HEAD + # Add info to the patches + additional_info = Local-branch: #{branch}\n + files = Dir.glob(00*.patch) + files.each do |file| + contents = File.read(file) + contents.sub!(/^---\n/, ---\n#{additional_info}) + File.open(file, 'w') do |file_handle| + file_handle.print contents + end + end + # And then mail them out. # If we've got more than one patch, add --compose - if Dir.glob(00*.patch).length 1 + if files.length 1 compose = --compose else compose = -- 1.7.2 -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en. -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
Re: [Puppet-dev] [PATCH/facter 1/1] Feature #5193 - Added conditional support for JSON
On 10 November 2010 00:16, Paul Berry p...@puppetlabs.com wrote: On Wed, Nov 3, 2010 at 8:04 PM, James Turnbull ja...@lovedthanlost.net wrote: From: John E. Vincent lusis.org+github@gmail.com Signed-off-by: James Turnbull ja...@lovedthanlost.net --- bin/facter | 22 -- 1 files changed, 20 insertions(+), 2 deletions(-) diff --git a/bin/facter b/bin/facter index a6cb717..d878d7f 100755 --- a/bin/facter +++ b/bin/facter @@ -6,7 +6,7 @@ # # = Usage # -# facter [-d|--debug] [-h|--help] [-p|--puppet] [-v|--version] [-y|--yaml] [fact] [fact] [...] +# facter [-d|--debug] [-h|--help] [-p|--puppet] [-v|--version] [-y|--yaml] [-j|--json] [fact] [fact] [...] # # = Description # @@ -33,6 +33,9 @@ # yaml:: # Emit facts in YAML format. # +# json:: +# Emit facts in JSON format. +# # = Example # # facter kernel @@ -80,12 +83,14 @@ result = GetoptLong.new( [ --help, -h, GetoptLong::NO_ARGUMENT ], [ --debug, -d, GetoptLong::NO_ARGUMENT ], [ --yaml, -y, GetoptLong::NO_ARGUMENT ], + [ --json, -j, GetoptLong::NO_ARGUMENT ], [ --config, -c, GetoptLong::REQUIRED_ARGUMENT ], [ --puppet, -p, GetoptLong::NO_ARGUMENT ] ) options = { - :yaml = false + :yaml = false, + :json = false } begin @@ -102,6 +107,8 @@ begin end when --yaml options[:yaml] = true + when --json + options[:json] = true when --debug Facter.debugging(1) when --help @@ -154,6 +161,17 @@ if options[:yaml] exit(0) end +if options[:json] + begin + require 'json' + puts JSON.dump(facts) + exit(0) + rescue LoadError + puts You do not have JSON support in your version of Ruby. JSON output disabled + exit(1) + end +end + facts.sort { |a, b| a[0].to_s = b[0].to_s }.each { |name,value| if facts.length == 1 unless value.nil? -- 1.7.2.3 Available in next as commit:d4df9634b94e498bdd63089f2cd95d49d4baa7f1 Did you ignore the discussion in the other thread? Paul -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
Re: [Puppet-dev] [PATCH/facter 1/1] (#4989) Add xendomains fact
On 10 November 2010 01:13, Paul Berry p...@puppetlabs.com wrote: On Mon, Oct 18, 2010 at 3:45 PM, Rein Henrichs r...@puppetlabs.com wrote: Parses `/usr/sbin/xm list` and returns a comma-separated list of domains. Based on a patch submitted by Jonas Genannt. --- Jonas, Thanks for sending us your patch. I've made a few minor changes but kept the behavior mostly the same. I've modified the implementation to use Resolution.exec instead of %x{} and I've modified the spec to stub its call. I've also added a spec for the case when /usr/sbin/xm isn't available that states that it should return nil. This is a change in design but will have end-user behavior equivalent to the previous behavior of returning . I've split the string returned by Resolution.exec on \n to give an array of lines because String#each has been removed in Ruby 1.9. I've also refactored the implementation of get_domains to make use of the map/reduce-like functionality of Ruby's #reject and #map. lib/facter/util/xendomains.rb | 10 ++ lib/facter/xendomains.rb | 10 ++ spec/unit/data/xendomains | 4 spec/unit/util/xendomains.rb | 23 +++ 4 files changed, 47 insertions(+), 0 deletions(-) create mode 100644 lib/facter/util/xendomains.rb create mode 100644 lib/facter/xendomains.rb create mode 100644 spec/unit/data/xendomains create mode 100644 spec/unit/util/xendomains.rb diff --git a/lib/facter/util/xendomains.rb b/lib/facter/util/xendomains.rb new file mode 100644 index 000..4f590a8 --- /dev/null +++ b/lib/facter/util/xendomains.rb @@ -0,0 +1,10 @@ +# A module to gather running Xen Domains +# +module Facter::Util::Xendomains + def self.get_domains + if xm_list = Facter::Util::Resolution.exec('/usr/sbin/xm list') + domains = xm_list.split(\n).reject { |line| line =~ /^(Name|Domain-0)/ } + domains.map { |line| line.split(/\s/)[0] }.join(',') + end + end +end diff --git a/lib/facter/xendomains.rb b/lib/facter/xendomains.rb new file mode 100644 index 000..972ac90 --- /dev/null +++ b/lib/facter/xendomains.rb @@ -0,0 +1,10 @@ +require 'facter/util/xendomains' + +Facter.add(xendomains) do + confine :kernel = %w{Linux FreeBSD OpenBSD SunOS} + confine :virtual = 'xen0' + + setcode do + Facter::Util::Xendomains.get_domains + end +end diff --git a/spec/unit/data/xendomains b/spec/unit/data/xendomains new file mode 100644 index 000..9b112bc --- /dev/null +++ b/spec/unit/data/xendomains @@ -0,0 +1,4 @@ +Name ID Mem VCPUs State Time(s) +Domain-0 0 656 4 r- 48140.9 +web01 48 512 2 -b 97651.5 +mailserver 53 512 4 -b 7536.1 diff --git a/spec/unit/util/xendomains.rb b/spec/unit/util/xendomains.rb new file mode 100644 index 000..a0fa345 --- /dev/null +++ b/spec/unit/util/xendomains.rb @@ -0,0 +1,23 @@ +#!/usr/bin/env ruby + +require File.dirname(__FILE__) + '/../../spec_helper' + +require 'facter/util/xendomains' + +describe Facter::Util::Xendomains do + describe .get_domains do + it should return a list of running Xen Domains on Xen0 do + sample_output_file = File.dirname(__FILE__) + '/../data/xendomains' + xen0_domains = File.read(sample_output_file) + Facter::Util::Resolution.stubs(:exec).with('/usr/sbin/xm list').returns(xen0_domains) + Facter::Util::Xendomains.get_domains.should == %{web01,mailserver} + end + + context when xm list isn't executable do + it should be nil do + Facter::Util::Resolution.stubs(:exec).with('/usr/sbin/xm list').returns(nil) + Facter::Util::Xendomains.get_domains.should == nil + end + end + end +end -- 1.7.0.4 Available in next as commit:06fb622e293100b214ac0de4f9d09d06dcbdb36e What versions of xen have you tested this against Paul? Paul -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
Re: [Puppet-dev] [PATCH/facter 1/1] Feature #5193 - Added conditional support for JSON
On 10 November 2010 06:34, Nigel Kersten ni...@puppetlabs.com wrote: On Tue, Nov 9, 2010 at 10:22 PM, Paul Nasrat pnas...@gmail.com wrote: On 10 November 2010 00:16, Paul Berry p...@puppetlabs.com wrote: On Wed, Nov 3, 2010 at 8:04 PM, James Turnbull ja...@lovedthanlost.net wrote: From: John E. Vincent lusis.org+github@gmail.com Signed-off-by: James Turnbull ja...@lovedthanlost.net --- bin/facter | 22 -- 1 files changed, 20 insertions(+), 2 deletions(-) diff --git a/bin/facter b/bin/facter index a6cb717..d878d7f 100755 --- a/bin/facter +++ b/bin/facter @@ -6,7 +6,7 @@ # # = Usage # -# facter [-d|--debug] [-h|--help] [-p|--puppet] [-v|--version] [-y|--yaml] [fact] [fact] [...] +# facter [-d|--debug] [-h|--help] [-p|--puppet] [-v|--version] [-y|--yaml] [-j|--json] [fact] [fact] [...] # # = Description # @@ -33,6 +33,9 @@ # yaml:: # Emit facts in YAML format. # +# json:: +# Emit facts in JSON format. +# # = Example # # facter kernel @@ -80,12 +83,14 @@ result = GetoptLong.new( [ --help, -h, GetoptLong::NO_ARGUMENT ], [ --debug, -d, GetoptLong::NO_ARGUMENT ], [ --yaml, -y, GetoptLong::NO_ARGUMENT ], + [ --json, -j, GetoptLong::NO_ARGUMENT ], [ --config, -c, GetoptLong::REQUIRED_ARGUMENT ], [ --puppet, -p, GetoptLong::NO_ARGUMENT ] ) options = { - :yaml = false + :yaml = false, + :json = false } begin @@ -102,6 +107,8 @@ begin end when --yaml options[:yaml] = true + when --json + options[:json] = true when --debug Facter.debugging(1) when --help @@ -154,6 +161,17 @@ if options[:yaml] exit(0) end +if options[:json] + begin + require 'json' + puts JSON.dump(facts) + exit(0) + rescue LoadError + puts You do not have JSON support in your version of Ruby. JSON output disabled + exit(1) + end +end + facts.sort { |a, b| a[0].to_s = b[0].to_s }.each { |name,value| if facts.length == 1 unless value.nil? -- 1.7.2.3 Available in next as commit:d4df9634b94e498bdd63089f2cd95d49d4baa7f1 Did you ignore the discussion in the other thread? What's the other thread you're referring to Paul? Is it on -users ? No on dev Puppet-dev] [PATCH/facter 1/1] JSON support. Works in 1.9.1. Warnings in 1.9.2. LoadError on 1.8.7 for some reason Re ensuring works on 1.8.1 and greater. Hopefully someone at puppetlabs can test it out on your test lab of OSes/versions to check the behaviour. Paul -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
Re: [Puppet-dev] [PATCH/facter 1/1] (#5016) is_virtual should be true on solaris zones
On 3 November 2010 22:41, Stefan Schulte stefan.schu...@taunusstein.net wrote: While the fact virtual recognised solaris zones before, the is_virtual fact did not. Before everyone thinks I'm just grumpy - before coffee and exceedingly busy atm so a little terse. Thanks a lot for the patches, grateful to see contributors to facter :) +1 Paul -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
Re: [Puppet-dev] [PATCH/facter 1/1] JSON support. Works in 1.9.1. Warnings in 1.9.2. LoadError on 1.8.7 for some reason
On 4 November 2010 04:20, James Turnbull ja...@lovedthanlost.net wrote: From: John E. Vincent lusis.org+github@gmail.com We need testing on 1.8.1 upwards. Do we not want json/pure rather than json? Signed-off-by: James Turnbull ja...@lovedthanlost.net --- bin/facter | 5 - lib/facter/application.rb | 13 + 2 files changed, 17 insertions(+), 1 deletions(-) diff --git a/bin/facter b/bin/facter index 9d3b49c..622d72e 100755 --- a/bin/facter +++ b/bin/facter @@ -6,7 +6,7 @@ # # = Usage # -# facter [-d|--debug] [-h|--help] [-p|--puppet] [-v|--version] [-y|--yaml] [fact] [fact] [...] +# facter [-d|--debug] [-h|--help] [-p|--puppet] [-v|--version] [-y|--yaml] [-j|--json] [fact] [fact] [...] # # = Description # @@ -21,6 +21,9 @@ # yaml:: # Emit facts in YAML format. # +# json:: +# Emit facts in JSON format. +# # puppet:: # Load the Puppet libraries, thus allowing Facter to load Puppet-specific facts. # diff --git a/lib/facter/application.rb b/lib/facter/application.rb index 9de9249..9d6bc34 100644 --- a/lib/facter/application.rb +++ b/lib/facter/application.rb @@ -31,6 +31,18 @@ module Facter exit(0) end + # Print the facts as JSON and exit + if options[:json] + begin + require 'json' + puts JSON.dump(facts) + exit(0) + rescue LoadError + $stderr.puts You do not have JSON support in your version of Ruby. JSON output disabled + exit(1) + end + end + # Print the value of a single fact, otherwise print a list sorted by fact # name and separated by = if facts.length == 1 @@ -58,6 +70,7 @@ module Facter options = {} OptionParser.new do |opts| opts.on(-y, --yaml) { |v| options[:yaml] = v } + opts.on(-j, --json) { |v| options[:json] = v } opts.on( --trace) { |v| options[:trace] = v } opts.on(-d, --debug) { |v| Facter.debugging(1) } opts.on(-t, --timing) { |v| Facter.timing(1) } -- 1.7.2.3 -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en. -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
Re: [Puppet-dev] [PATCH/facter 1/1] JSON support. Works in 1.9.1. Warnings in 1.9.2. LoadError on 1.8.7 for some reason
On 4 November 2010 16:52, Markus Roberts mar...@puppetlabs.com wrote: We need testing on 1.8.1 upwards. Do we not want json/pure rather than json? i.e. PSON? I really don't want to have to do embed that in facter. Paul -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
Re: [Puppet-dev] Re: No puppet developer patches to the puppet-dev list
On 29 October 2010 15:19, Nigel Kersten ni...@puppetlabs.com wrote: On Fri, Oct 29, 2010 at 3:42 AM, R.I.Pienaar r...@devco.net wrote: - Teyo Tyree t...@puppetlabs.com wrote: Would you all be interested knowing what we are working on each week? Our iterations will tend to have a theme. This week we are working on building out an inventory service. A high level design document is available in Redmine: http://projects.puppetlabs.com/projects/1/wiki/InventoryServiceArchitecture We have also thought about the following measures to keep you all involved: Broadcast our daily stand-ups... IRC/Mailing-list Provide weekly snapshots of our work plan for each iteration. Build a Markus effigy with a built in web-cam, point him at our planning board, and broadcast the stream. (Markus is working remotely at the moment.) Your thoughts are, as always, welcomed. We have a lot to learn. Mostly I am fine with this, except for the lack of discussion around the inventory service that is the focus of the current sprint. I know there was at least some discussions and with this kind of thing a lot of it is prototype various ways what works as a means of firming up the specs and so forth and so on. But I get the impression there might have been a RFC covering it? I recall lots of talk for example around the catalog service but it seems this is something else and havnt had quite the community opinion involvement that would be ideal. I'm pretty sure Luke sent this out a while ago and asked for input. http://projects.puppetlabs.com/projects/1/wiki/InventoryServiceArchitecture Don't see anything obvious in local gmail search or on: http://groups.google.com/group/puppet-dev/search?group=puppet-devq=Inventory+Service+Architectureqt_g=Search+this+group Paul -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
Re: [Puppet-dev] Re: No puppet developer patches to the puppet-dev list
On 28 October 2010 23:39, Teyo Tyree t...@puppetlabs.com wrote: Like to note a few things about our development shift that we unfortunately did not communicate effectively in our initial email. We are iterating on our internal development process in order to more rapidly deliver complete features across our projects. In order to be as transparent as possible and to provide the community with enough context to understand our desire to shift the way we send patches to the list, I'll summarize our new process. None of these processes are set in stone. We plan to improve and refine our internal processes each week. We have moved to short iteration cycles that deliver real value. (We are testing one week iterations at the moment.) I think it's probably good news that you are adopting xp practices as part of your development. It'll certainly mean the puppetlabs team has a better shared understanding of the code base. I realise that it's hard to figure the detail of involving the community. One thing I'm curious about is were these changes started before puppetcamp? As that would have been a great opportunity to discuss workflow in person and figure out some details and set expectations. If not it's just unfortunate timing, maybe should try something with the community and have regularish opportunities to improve the process - ie retrospectives but aimed at ensuring the puppetlabs/open source community workflow is continually improving. Paul -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
Re: [Puppet-dev] No puppet developer patches to the puppet-dev list
On 27 October 2010 21:10, Matt Robinson m...@puppetlabs.com wrote: We've gotten feedback that a lot of the patches that are sent to the puppet-dev list aren't terribly useful to our community to read and tend to overwhelm the conversation. -1. How was this survey carried out? It's pretty easy to filter mail and an open source project should be open. Paul -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
Re: [Puppet-dev] [PATCH/facter 1/1] Feature #4575: win32 support for manufacturer, productname, serialnumber
+1 Using WMI queries where we can makes sense On 19 October 2010 00:28, Rein Henrichs r...@puppetlabs.com wrote: From: William Van Hevelingen wva...@gmail.com Signed-off-by: William Van Hevelingen wva...@gmail.com Signed-off-by: Rein Henrichs r...@puppetlabs.com --- lib/facter/manufacturer.rb | 8 lib/facter/util/manufacturer.rb | 17 + 2 files changed, 25 insertions(+), 0 deletions(-) diff --git a/lib/facter/manufacturer.rb b/lib/facter/manufacturer.rb index 9d66465..68f5b96 100644 --- a/lib/facter/manufacturer.rb +++ b/lib/facter/manufacturer.rb @@ -13,6 +13,14 @@ if Facter.value(:kernel) == OpenBSD } Facter::Manufacturer.sysctl_find_system_info(mfg_keys) + +elsif Facter.value(:kernel) == windows + win32_keys = { + 'manufacturer' = ['Manufacturer', 'Bios'], + 'serialNumber' = ['Serialnumber', 'Bios'], + 'productname' = ['Name', 'ComputerSystemProduct'] + } + Facter::Manufacturer.win32_find_system_info(win32_keys) else query = { '[Ss]ystem [Ii]nformation' = [ diff --git a/lib/facter/util/manufacturer.rb b/lib/facter/util/manufacturer.rb index 112380b..368e8c1 100644 --- a/lib/facter/util/manufacturer.rb +++ b/lib/facter/util/manufacturer.rb @@ -60,4 +60,21 @@ module Facter::Manufacturer end end end + + def self.win32_find_system_info(name) + require 'win32ole' + value = + wmi = WIN32OLE.connect(winmgmts://) + name.each do |facterkey, win32key| + query = wmi.ExecQuery(select * from Win32_#{win32key.last}) + Facter.add(facterkey) do + confine :kernel = :windows + setcode do + query.each { |x| value = x.__send__( (win32key.first).to_sym) } + value + end + end + end + end + end -- 1.7.0.4 -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en. -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
Re: [Puppet-dev] [PATCH/facter 1/1] (#4989) Add xendomains fact
On 18 October 2010 23:45, Rein Henrichs r...@puppetlabs.com wrote: Parses `/usr/sbin/xm list` and returns a comma-separated list of domains. Based on a patch submitted by Jonas Genannt. Looks good - is the output of xm list consistent across all known releases of xen? Paul --- Jonas, Thanks for sending us your patch. I've made a few minor changes but kept the behavior mostly the same. I've modified the implementation to use Resolution.exec instead of %x{} and I've modified the spec to stub its call. I've also added a spec for the case when /usr/sbin/xm isn't available that states that it should return nil. This is a change in design but will have end-user behavior equivalent to the previous behavior of returning . I've split the string returned by Resolution.exec on \n to give an array of lines because String#each has been removed in Ruby 1.9. I've also refactored the implementation of get_domains to make use of the map/reduce-like functionality of Ruby's #reject and #map. lib/facter/util/xendomains.rb | 10 ++ lib/facter/xendomains.rb | 10 ++ spec/unit/data/xendomains | 4 spec/unit/util/xendomains.rb | 23 +++ 4 files changed, 47 insertions(+), 0 deletions(-) create mode 100644 lib/facter/util/xendomains.rb create mode 100644 lib/facter/xendomains.rb create mode 100644 spec/unit/data/xendomains create mode 100644 spec/unit/util/xendomains.rb diff --git a/lib/facter/util/xendomains.rb b/lib/facter/util/xendomains.rb new file mode 100644 index 000..4f590a8 --- /dev/null +++ b/lib/facter/util/xendomains.rb @@ -0,0 +1,10 @@ +# A module to gather running Xen Domains +# +module Facter::Util::Xendomains + def self.get_domains + if xm_list = Facter::Util::Resolution.exec('/usr/sbin/xm list') + domains = xm_list.split(\n).reject { |line| line =~ /^(Name|Domain-0)/ } + domains.map { |line| line.split(/\s/)[0] }.join(',') + end + end +end diff --git a/lib/facter/xendomains.rb b/lib/facter/xendomains.rb new file mode 100644 index 000..972ac90 --- /dev/null +++ b/lib/facter/xendomains.rb @@ -0,0 +1,10 @@ +require 'facter/util/xendomains' + +Facter.add(xendomains) do + confine :kernel = %w{Linux FreeBSD OpenBSD SunOS} + confine :virtual = 'xen0' + + setcode do + Facter::Util::Xendomains.get_domains + end +end diff --git a/spec/unit/data/xendomains b/spec/unit/data/xendomains new file mode 100644 index 000..9b112bc --- /dev/null +++ b/spec/unit/data/xendomains @@ -0,0 +1,4 @@ +Name ID Mem VCPUs State Time(s) +Domain-0 0 656 4 r- 48140.9 +web01 48 512 2 -b 97651.5 +mailserver 53 512 4 -b 7536.1 diff --git a/spec/unit/util/xendomains.rb b/spec/unit/util/xendomains.rb new file mode 100644 index 000..a0fa345 --- /dev/null +++ b/spec/unit/util/xendomains.rb @@ -0,0 +1,23 @@ +#!/usr/bin/env ruby + +require File.dirname(__FILE__) + '/../../spec_helper' + +require 'facter/util/xendomains' + +describe Facter::Util::Xendomains do + describe .get_domains do + it should return a list of running Xen Domains on Xen0 do + sample_output_file = File.dirname(__FILE__) + '/../data/xendomains' + xen0_domains = File.read(sample_output_file) + Facter::Util::Resolution.stubs(:exec).with('/usr/sbin/xm list').returns(xen0_domains) + Facter::Util::Xendomains.get_domains.should == %{web01,mailserver} + end + + context when xm list isn't executable do + it should be nil do + Facter::Util::Resolution.stubs(:exec).with('/usr/sbin/xm list').returns(nil) + Facter::Util::Xendomains.get_domains.should == nil + end + end + end +end -- 1.7.0.4 -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en. -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
[Puppet-dev] [PATCH/facter 1/1] Issue #4889 Fact values should all be strings
Fix is_virtual fact to return strings rather than bools. Signed-off-by: Paul Nasrat pnas...@googlemail.com --- lib/facter/virtual.rb |4 ++-- spec/unit/virtual.rb | 12 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/facter/virtual.rb b/lib/facter/virtual.rb index c14a715..af530e5 100644 --- a/lib/facter/virtual.rb +++ b/lib/facter/virtual.rb @@ -81,9 +81,9 @@ Facter.add(is_virtual) do setcode do case Facter.value(:virtual) when xenu, openvzve, vmware, kvm, vserver, jail -true +true else -false +false end end end diff --git a/spec/unit/virtual.rb b/spec/unit/virtual.rb index 8ee843b..80cd0d9 100644 --- a/spec/unit/virtual.rb +++ b/spec/unit/virtual.rb @@ -35,37 +35,37 @@ describe is_virtual fact do it should be virtual when running on xen do Facter.fact(:kernel).stubs(:value).returns(Linux) Facter.fact(:virtual).stubs(:value).returns(xenu) - Facter.fact(:is_virtual).value.should == true + Facter.fact(:is_virtual).value.should == true end it should be false when running on xen0 do Facter.fact(:kernel).stubs(:value).returns(Linux) Facter.fact(:virtual).stubs(:value).returns(xen0) - Facter.fact(:is_virtual).value.should == false + Facter.fact(:is_virtual).value.should == false end it should be true when running on vmware do Facter.fact(:kernel).stubs(:value).returns(Linux) Facter.fact(:virtual).stubs(:value).returns(vmware) -Facter.fact(:is_virtual).value.should == true +Facter.fact(:is_virtual).value.should == true end it should be true when running on openvz do Facter.fact(:kernel).stubs(:value).returns(Linux) Facter.fact(:virtual).stubs(:value).returns(openvzve) -Facter.fact(:is_virtual).value.should == true +Facter.fact(:is_virtual).value.should == true end it should be true when running on kvm do Facter.fact(:kernel).stubs(:value).returns(Linux) Facter.fact(:virtual).stubs(:value).returns(kvm) -Facter.fact(:is_virtual).value.should == true +Facter.fact(:is_virtual).value.should == true end it should be true when running in jail do Facter.fact(:kernel).stubs(:value).returns(FreeBSD) Facter.fact(:virtual).stubs(:value).returns(jail) -Facter.fact(:is_virtual).value.should == true +Facter.fact(:is_virtual).value.should == true end end -- 1.7.0.3 -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
[Puppet-dev] [PATCH/facter 1/1] Make sure FreeBSD spec also works on systems that have /proc/cpuinfo.
From: Hans de Graaff h...@degraaff.org Signed-off-by: Paul Nasrat pnas...@googlemail.com --- spec/unit/util/virtual.rb |1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/spec/unit/util/virtual.rb b/spec/unit/util/virtual.rb index 1e31a2f..cc528d1 100644 --- a/spec/unit/util/virtual.rb +++ b/spec/unit/util/virtual.rb @@ -101,6 +101,7 @@ describe Facter::Util::Virtual do end it should detect kvm on FreeBSD do +FileTest.stubs(:exists?).with(/proc/cpuinfo).returns(false) Facter.fact(:kernel).stubs(:value).returns(FreeBSD) Facter::Util::Resolution.stubs(:exec).with(/sbin/sysctl -n hw.model).returns(QEMU Virtual CPU version 0.12.4) Facter::Util::Virtual.should be_kvm -- 1.7.0.3 -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
[Puppet-dev] Re: [PATCH/facter 1/1] Make sure FreeBSD spec also works on systems that have /proc/cpuinfo.
On 7 October 2010 10:23, Paul Nasrat pnas...@gmail.com wrote: From: Hans de Graaff h...@degraaff.org Signed-off-by: Paul Nasrat pnas...@googlemail.com +1 tested on Linux machine. Paul -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
Re: [Puppet-dev] [PATCH/facter 1/1] [#4583] Refactor uptime to use Resolution.exec
On 24 August 2010 22:28, Rein Henrichs r...@puppetlabs.com wrote: Resolution.exec used to ensure that any shell errors are suppressed. +1 As said in the bug this resolves the issue Paul -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
Re: [Puppet-dev] [PATCH/facter 1/1] Resend - Discussion on ec2 facts - #2346
On 17 August 2010 19:50, Rein Henrichs r...@puppetlabs.com wrote: Excerpts from Paul Nasrat's message of Tue Aug 17 06:40:42 -0700 2010: The EC2 fact is completely broken at the moment: * Timeout::Error isn't caught by rescue (due to how it inherits) * The issue of wrong open semantics outlined here, this is causing hidden immediate failure * The fact is going to cause a 2 second wait to every facter run Whilst the following patch fixes the first two, I'm not sure we want to take the timeout hit, we also want to add tests as even simple ruby code can get logic errors such as the open(). Paul, The third issue ( the timeout hit ) is currently somewhat systematic in Facter. That is, a number of fact files do computationally expensive things at load time to then generate facts. The EC2 fact is just the most flagrant of these. While it's obviously important that we fix the EC2 fact's behavior, I think we should also consider ways to mitigate this load-time cost. Sure. I think it's an important enough platform that we should fix the bug for 1.5.8 - it's been hanging around for a while, I even talked about it at last puppet camp about why you should test your facts. Of course, structured data is a ways down the time line, and a 2 second delay in all Facter runs -- even if the EC2 fact is never called -- adversely affects Facter's apparent performance. Would it make sense to package the EC2 facts separately somehow? How else can we get rid of this performance hit? There is some discussion in the bug if you look at that. Paul -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
Re: [Puppet-dev] Re: [PATCH/puppet] Fix Debian package / gem interactions in spec_helper
On 19 August 2010 13:30, Daniel Pittman dan...@rimspace.net wrote: Daniel Pittman dan...@rimspace.net writes: This works around the interaction of Debian packaged librspec-ruby and gems. Under Debian the library is available, but the gem support fails; this ignores the gem failure and carries on anyway. In case this isn't clear, this allows me to run the tests on my Debian system without needing to install a second copy of the rspec code or anything. Arguably this is a distribution issue, but it doesn't look likely to change any time soon, hence this patch as an RFC, basically. Any chance you can make this explicitly only occur on debian, maybe using facter to determine if it is debian. If you get LoadError for another reason on another platform we probably want to propagate the exception. Paul -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
Re: [Puppet-dev] [PATCH/facter 1/1] [#4289] operatingsystemrelease fact for oel, ovs
On 18 August 2010 23:58, Rein Henrichs r...@puppetlabs.com wrote: When Facter returns operatingsystem as oel or ovs, the operatingsystemrelease fact does not catch these properly, causing an error. Specs added to catch failure and case statement updated to catch oel and ovs as well as OEL and OVS +1 Signed-off-by: Rein Henrichs r...@puppetlabs.com --- lib/facter/operatingsystemrelease.rb | 4 +- spec/unit/operatingsystemrelease.rb | 39 ++ 2 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 spec/unit/operatingsystemrelease.rb diff --git a/lib/facter/operatingsystemrelease.rb b/lib/facter/operatingsystemrelease.rb index 30f2989..280208b 100644 --- a/lib/facter/operatingsystemrelease.rb +++ b/lib/facter/operatingsystemrelease.rb @@ -8,9 +8,9 @@ Facter.add(:operatingsystemrelease) do releasefile = /etc/fedora-release when MeeGo releasefile = /etc/meego-release - when OEL + when OEL, oel releasefile = /etc/enterprise-release - when OVS + when OVS, ovs releasefile = /etc/ovs-release end File::open(releasefile, r) do |f| diff --git a/spec/unit/operatingsystemrelease.rb b/spec/unit/operatingsystemrelease.rb new file mode 100644 index 000..31d4ae8 --- /dev/null +++ b/spec/unit/operatingsystemrelease.rb @@ -0,0 +1,39 @@ +#!/usr/bin/env ruby + +require File.dirname(__FILE__) + '/../spec_helper' + +require 'facter' + +describe Operating System Release fact do + + before do + Facter.clear + end + + after do + Facter.clear + end + + test_cases = { + CentOS = /etc/redhat-release, + RedHat = /etc/redhat-release, + Fedora = /etc/fedora-release, + MeeGo = /etc/meego-release, + OEL = /etc/enterprise-release, + oel = /etc/enterprise-release, + OVS = /etc/ovs-release, + ovs = /etc/ovs-release + } + + test_cases.each do |system, file| + context with operatingsystem reported as #{system.inspect} do + it should read the #{file.inspect} file do + Facter.fact(:operatingsystem).stubs(:value).returns(system) + + File.expects(:open).with(file, r).at_least(1) + + Facter.fact(:operatingsystemrelease).value + end + end + end +end -- 1.7.0.4 -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en. -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
[Puppet-dev] [PATCH/facter 1/1] Resend - Discussion on ec2 facts - #2346
The EC2 fact is completely broken at the moment: * Timeout::Error isn't caught by rescue (due to how it inherits) * The issue of wrong open semantics outlined here, this is causing hidden immediate failure * The fact is going to cause a 2 second wait to every facter run Whilst the following patch fixes the first two, I'm not sure we want to take the timeout hit, we also want to add tests as even simple ruby code can get logic errors such as the open(). Signed-off-by: Paul Nasrat pnas...@googlemail.com --- lib/facter/ec2.rb |5 - 1 files changed, 4 insertions(+), 1 deletions(-) diff --git a/lib/facter/ec2.rb b/lib/facter/ec2.rb index ef84757..447a4d8 100644 --- a/lib/facter/ec2.rb +++ b/lib/facter/ec2.rb @@ -6,8 +6,11 @@ require 'open-uri' require 'timeout' def can_connect?(ip,port,wait_sec=2) - Timeout::timeout(wait_sec) {open(ip, port)} + url = http://#{ip}:#{port}/; + Timeout::timeout(wait_sec) {open(url)} return true +rescue Timeout::Error + return false rescue return false end -- 1.6.4.2 -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
[Puppet-dev] Facter next - merge for 1.5.8RC1
Reviewing next branch for RC as discussed, I'm happy with all the changes up to 6edf3199a212e6b33f9e09edbb3cb34710710326, we should create a branch with the RC version bump and think about generating the tarballs, documentation and release notes. Paul -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
[Puppet-dev] Re: [Puppet Users] ANNOUNCE: Facter 1.5.8rc1
On 17 August 2010 20:20, James Turnbull ja...@puppetlabs.com wrote: For 40 days and 40 nights Facter wandered in the wilderness sustained only by the occasional patch and bottle of Kool-Aid. Tanned and happy Facter 1.5.8rc1 has now emerged from its desert retreat. Testing on various virtual environments and hosts greatfully accepted. For fact regressions, 1.5.7 output to compare would be useful, please include that in bug reports. Paul -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
Re: [Puppet-dev] [PATCH/facter 1/1] Resend - Discussion on ec2 facts - #2346
On 17 August 2010 21:27, Nigel Kersten nig...@google.com wrote: On Tue, Aug 17, 2010 at 1:03 PM, Jeff McCune j...@puppetlabs.com wrote: On Tue, Aug 17, 2010 at 12:31 PM, Nigel Kersten nig...@google.com wrote: I've implemented local caching for my computational expensive and infrequently varying facts, and I've been thinking about whether it would make sense for Facter to implement something similar. Very cool. I'm thinking about an easy mechanism a la :confine for declaring that a given fact should be cached and has an expiry value (perhaps with some simple options like cache-once-per-reboot). +1, maybe file as a feature request? I anticipate a large number of facts interacting with web service API's in the future, and this would be really useful for that class of use case. There are a bunch of surrounding questions about Puppet interaction with Facter, as I can imagine you may wish to have the --test option for Puppet automatically ignore the cache for Facter, but we may as well kick it off now. http://projects.puppetlabs.com/issues/4554 This was already something I wanted on the road map and there is an issue filed as we've discussed it before but didn't have a bug. I've closed your bug as a duplicate of 4519 Paul -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
Re: [Puppet-dev] [PATCH/facter 2/2] [#2330] Update uptime calculation to use /bin/cat
On 6 August 2010 00:35, Rein Henrichs r...@puppetlabs.com wrote: * Per #4466, Ruby has trouble reading files in /proc [1]. The alternative is to use `bin/cat`. * Also refactored methods to explicitly redirect standard error to /dev/null for *nix and BSD system calls. +1 Random thought for 1.6 or later we could have a ProcFile and Sysctl specific class (and dmidecode) to encapsulate the complexities of different platforms/versions so it's easy to do stuff and provides a handy way to prevent repeated calls to the same provider. Eg later versions of dmidecode support querying by key eg dmidecode -s system-product-name This might also help get rid of the huge regex trying to do multiple platforms in that code. Paul -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
Re: [Puppet-dev] [PATCH/facter 1/2] [#2330] Uptime should not make redundant system calls
On 6 August 2010 00:35, Rein Henrichs r...@puppetlabs.com wrote: From: Rein Henrichs re...@reinh.com Rewrite of uptime facts and supporting utility methods. Works on unix, BSD, windows. No longer makes redundant system calls. +1, tested locally Uses Facter::Util::Uptime utility methods: * Implemented uptime_seconds_unix using /proc/uptime or who -b on unix, sysctl on BSD. Added unit tests for the behaviors of get_uptime_seconds_unix: read from proc/uptime, read uptime from sysctl -b kern.boottime, read uptime from who -b, and return nil if nothing else works. * Implemented uptime_seconds_win using the Win32 API. Facts implemented: * uptime_{seconds,hours,days} Returns the respective integer value. * uptime Returns human readable uptime statistic that preserves original behavior. Examples: 3 days 1 day 5:08 hours 0:35 hours Signed-off-by: Rein Henrichs r...@puppetlabs.com --- lib/facter/uptime.rb | 31 + lib/facter/uptime_days.rb | 7 ++ lib/facter/uptime_hours.rb | 7 ++ lib/facter/uptime_seconds.rb | 10 +++ lib/facter/util/uptime.rb | 66 +++-- spec/fixtures/uptime/sysctl_kern_boottime | Bin 0 - 16 bytes spec/fixtures/uptime/ubuntu_proc_uptime | 1 + spec/fixtures/uptime/who_b_boottime | 1 + spec/spec_helper.rb | 2 + spec/unit/uptime.rb | 112 + spec/unit/util/uptime.rb | 53 ++ 11 files changed, 253 insertions(+), 37 deletions(-) create mode 100644 lib/facter/uptime_days.rb create mode 100644 lib/facter/uptime_hours.rb create mode 100644 lib/facter/uptime_seconds.rb create mode 100644 spec/fixtures/uptime/sysctl_kern_boottime create mode 100644 spec/fixtures/uptime/ubuntu_proc_uptime create mode 100644 spec/fixtures/uptime/who_b_boottime create mode 100644 spec/unit/uptime.rb create mode 100644 spec/unit/util/uptime.rb diff --git a/lib/facter/uptime.rb b/lib/facter/uptime.rb index 3a3bc86..56a959b 100644 --- a/lib/facter/uptime.rb +++ b/lib/facter/uptime.rb @@ -1,20 +1,23 @@ require 'facter/util/uptime' Facter.add(:uptime) do - confine :operatingsystem = %w{Solaris Linux Fedora RedHat CentOS SuSE SLES Debian Ubuntu Gentoo AIX} - setcode do - Facter::Util::Uptime.get_uptime_simple - end -end + setcode do + seconds = Facter.fact(:uptime_seconds).value -if FileTest.exists?(/proc/uptime) - uptime = Facter::Util::Uptime.get_uptime + unless seconds + unknown + else + days = seconds / (60 * 60 * 24) + hours = seconds / (60 * 60) % 24 + minutes = seconds / 60 % 60 - %w{days hours seconds}.each do |label| - Facter.add(uptime_ + label) do - setcode do - Facter::Util::Uptime.get_uptime_period(uptime, label) - end - end - end + case days + when 0 then #{hours}:#{%02d % minutes} hours + when 1 then '1 day' + else #{days} days + end + end + + end end + diff --git a/lib/facter/uptime_days.rb b/lib/facter/uptime_days.rb new file mode 100644 index 000..add305c --- /dev/null +++ b/lib/facter/uptime_days.rb @@ -0,0 +1,7 @@ +Facter.add(:uptime_days) do + setcode do + hours = Facter.value(:uptime_hours) + hours hours / 24 # hours in day + end +end + diff --git a/lib/facter/uptime_hours.rb b/lib/facter/uptime_hours.rb new file mode 100644 index 000..ce691d2 --- /dev/null +++ b/lib/facter/uptime_hours.rb @@ -0,0 +1,7 @@ +Facter.add(:uptime_hours) do + setcode do + seconds = Facter.value(:uptime_seconds) + seconds seconds / (60 * 60) # seconds in hour + end +end + diff --git a/lib/facter/uptime_seconds.rb b/lib/facter/uptime_seconds.rb new file mode 100644 index 000..14bb573 --- /dev/null +++ b/lib/facter/uptime_seconds.rb @@ -0,0 +1,10 @@ +require 'facter/util/uptime' + +Facter.add(:uptime_seconds) do + setcode { Facter::Util::Uptime.get_uptime_seconds_unix } +end + +Facter.add(:uptime_seconds) do + confine :kernel = :windows + setcode { Facter::Util::Uptime.get_uptime_seconds_win } +end diff --git a/lib/facter/util/uptime.rb b/lib/facter/util/uptime.rb index c1e339b..f8a17db 100644 --- a/lib/facter/util/uptime.rb +++ b/lib/facter/util/uptime.rb @@ -1,32 +1,52 @@ +require 'time' + # A module to gather uptime facts # module Facter::Util::Uptime - def self.get_uptime_simple - time = Facter::Util::Resolution.exec('uptime') - if time =~ /up\s*(\d+\s\w+)/ - $1 - elsif time =~ /up\s*(\d+:\d+)/ - $1 + hours - else - unknown + def self.get_uptime_seconds_unix + uptime_proc_uptime or uptime_sysctl or uptime_who_dash_b + end + + def
Re: [Puppet-dev] [PATCH/facter 2/2] [#2330] Update uptime calculation to use /bin/cat
On 6 August 2010 17:55, Paul Berry p...@puppetlabs.com wrote: On Fri, Aug 6, 2010 at 2:23 AM, Paul Nasrat pnas...@gmail.com wrote: Random thought for 1.6 or later we could have a ProcFile and Sysctl specific class (and dmidecode) to encapsulate the complexities of different platforms/versions so it's easy to do stuff and provides a handy way to prevent repeated calls to the same provider. +1 to this idea, especially as it serves an educational purpose to developers unfamiliar with the subtleties of e.g. reading from the /proc filesystem. If a ProcFile class had existed Rein and I probably wouldn't have made the mistake if trying to read proc files directly in the first place. Yeah it makes the knowledge explicit, etc. It's been on my should get round to for a while, as there are various places we get info from repeatedly that have hidden complexities. Paul -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
Re: [Puppet-dev] [PATCH/facter 1/1] [#2330] Uptime should not make redundant system calls
On 3 August 2010 23:03, Rein Henrichs r...@puppetlabs.com wrote: From: Rein Henrichs re...@reinh.com Rewrite of uptime facts and supporting utility methods. Works on unix, BSD, windows. No longer makes redundant system calls. Uses Facter::Util::Uptime utility methods: Thanks for this, not had time to look in anger but a quick scan shows: + def self.uptime_proc_uptime + if File.exists? uptime_file + r = File.read uptime_file + r.split( ).first.to_i + end + end snip end - def self.get_uptime - r = IO.popen(/bin/cat /proc/uptime) You've moved to read from cat, that'll likely break on RHEL 4 see http://projects.reductivelabs.com/issues/2355 for example Paul -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
Re: [Puppet-dev] Patch: Implement kiB versions to all existing memory facts
On 8 July 2010 09:07, Kai hashe...@gmail.com wrote: In an earlier thread on puppet-users there was a request for a patch. This is what I could come up with without discussing much. Points that I can think of: - Perhaps a suffix of 'KiB' is better in this world where kB could be interpreted as 1000 bytes. - I'm no ruby linguist. - no tests. I wouldn't know where to start. Sorry for the delay, I've been swamped. I'd probably rather have this deferred to when we have richer fact support so things that are sizes can render themselves in different ways and we can support that via the API and CLI. Paul -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
Re: [Puppet-dev] [PATCH/facter 1/2] Fix #4352 - Support for detecting virtuals (jails) on FreeBSD
On 25 July 2010 23:50, Jiri Kubicek jiri.kubi...@kraxnet.cz wrote: There was no support for detecting FreeBSD jails as a virtual in facter. This patch detects jail by getting security.jail.jailed kernel state via sysctl. Thanks, on a scan looks good, but I'll try test later today. Paul Signed-off-by: Jiri Kubicek jiri.kubi...@kraxnet.cz --- lib/facter/util/virtual.rb | 3 +++ lib/facter/virtual.rb | 6 +- spec/unit/util/virtual.rb | 10 ++ spec/unit/virtual.rb | 6 ++ 4 files changed, 24 insertions(+), 1 deletions(-) diff --git a/lib/facter/util/virtual.rb b/lib/facter/util/virtual.rb index 80f4e2c..900375f 100644 --- a/lib/facter/util/virtual.rb +++ b/lib/facter/util/virtual.rb @@ -57,5 +57,8 @@ module Facter::Util::Virtual kvm end + def self.jail? + Facter::Util::Resolution.exec(/sbin/sysctl -n security.jail.jailed) == 1 + end end diff --git a/lib/facter/virtual.rb b/lib/facter/virtual.rb index c6d0f22..c14a715 100644 --- a/lib/facter/virtual.rb +++ b/lib/facter/virtual.rb @@ -38,6 +38,10 @@ Facter.add(virtual) do result = Facter::Util::Virtual.kvm_type() end + if Facter.value(:kernel)==FreeBSD + result = jail if Facter::Util::Virtual.jail? + end + if result == physical output = Facter::Util::Resolution.exec('lspci') if not output.nil? @@ -76,7 +80,7 @@ Facter.add(is_virtual) do setcode do case Facter.value(:virtual) - when xenu, openvzve, vmware, kvm, vserver + when xenu, openvzve, vmware, kvm, vserver, jail true else false diff --git a/spec/unit/util/virtual.rb b/spec/unit/util/virtual.rb index de339b8..f1ccf1e 100644 --- a/spec/unit/util/virtual.rb +++ b/spec/unit/util/virtual.rb @@ -100,4 +100,14 @@ describe Facter::Util::Virtual do Facter::Util::Virtual.should be_kvm end + it should identify FreeBSD jail when in jail do + Facter::Util::Resolution.stubs(:exec).with(/sbin/sysctl -n security.jail.jailed).returns(1) + Facter::Util::Virtual.should be_jail + end + + it should not identify FreeBSD jail when not in jail do + Facter::Util::Resolution.stubs(:exec).with(/sbin/sysctl -n security.jail.jailed).returns(0) + Facter::Util::Virtual.should_not be_jail + end + end diff --git a/spec/unit/virtual.rb b/spec/unit/virtual.rb index 7dbd146..311001d 100644 --- a/spec/unit/virtual.rb +++ b/spec/unit/virtual.rb @@ -55,4 +55,10 @@ describe is_virtual fact do Facter.fact(:is_virtual).value.should == true end + it should be true when running in jail do + Facter.fact(:kernel).stubs(:value).returns(FreeBSD) + Facter.fact(:virtual).stubs(:value).returns(jail) + Facter.fact(:is_virtual).value.should == true + end + end -- 1.6.4.3 -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en. -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
Re: [Puppet-dev] [PATCH/facter 2/2] Fix #4352 - Support for detecting KVM virtuals on FreeBSD
On 25 July 2010 23:50, Jiri Kubicek jiri.kubi...@kraxnet.cz wrote: There was no support for detecting FreeBSD running in KVM as a virtual in facter. This patch detects KVM by getting hw.model kernel state via sysctl. Jails running in KVM are also correctly detected as jail not kvm. Looks good, as with other patch once I've had a chance to test will merge. Thanks Paul Signed-off-by: Jiri Kubicek jiri.kubi...@kraxnet.cz --- lib/facter/util/virtual.rb | 9 + spec/unit/util/virtual.rb | 6 ++ spec/unit/virtual.rb | 7 +++ 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/lib/facter/util/virtual.rb b/lib/facter/util/virtual.rb index 900375f..2d18c33 100644 --- a/lib/facter/util/virtual.rb +++ b/lib/facter/util/virtual.rb @@ -43,11 +43,12 @@ module Facter::Util::Virtual end def self.kvm? - if FileTest.exists?(/proc/cpuinfo) - txt = File.read(/proc/cpuinfo) - return true if txt =~ /QEMU Virtual CPU/ + txt = if FileTest.exists?(/proc/cpuinfo) + File.read(/proc/cpuinfo) + elsif Facter.value(:kernel)==FreeBSD + Facter::Util::Resolution.exec(/sbin/sysctl -n hw.model) end - return false + (txt =~ /QEMU Virtual CPU/) ? true : false end def self.kvm_type diff --git a/spec/unit/util/virtual.rb b/spec/unit/util/virtual.rb index f1ccf1e..5b59cf9 100644 --- a/spec/unit/util/virtual.rb +++ b/spec/unit/util/virtual.rb @@ -100,6 +100,12 @@ describe Facter::Util::Virtual do Facter::Util::Virtual.should be_kvm end + it should detect kvm on FreeBSD do + Facter.fact(:kernel).stubs(:value).returns(FreeBSD) + Facter::Util::Resolution.stubs(:exec).with(/sbin/sysctl -n hw.model).returns(QEMU Virtual CPU version 0.12.4) + Facter::Util::Virtual.should be_kvm + end + it should identify FreeBSD jail when in jail do Facter::Util::Resolution.stubs(:exec).with(/sbin/sysctl -n security.jail.jailed).returns(1) Facter::Util::Virtual.should be_jail diff --git a/spec/unit/virtual.rb b/spec/unit/virtual.rb index 311001d..8ee843b 100644 --- a/spec/unit/virtual.rb +++ b/spec/unit/virtual.rb @@ -17,6 +17,13 @@ describe Virtual fact do Facter.fact(:virtual).value.should == zone end + it should be jail on FreeBSD when a jail in kvm do + Facter.fact(:kernel).stubs(:value).returns(FreeBSD) + Facter::Util::Virtual.stubs(:jail?).returns(true) + Facter::Util::Virtual.stubs(:kvm?).returns(true) + Facter.fact(:virtual).value.should == jail + end + end describe is_virtual fact do -- 1.6.4.3 -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en. -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
Re: [Puppet-dev] [PATCH/puppet 1/1] Fixes #3395 - CR+LF line endings in manifests cause syntax error
On 15 June 2010 18:26, James Turnbull ja...@lovedthanlost.net wrote: Thanks to Alan Barrett for the patch I know it's a trivial change but shouldn't it have a test. Paul Signed-off-by: James Turnbull ja...@lovedthanlost.net --- lib/puppet/parser/lexer.rb | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/lib/puppet/parser/lexer.rb b/lib/puppet/parser/lexer.rb index 7adb0b6..cc0b0bc 100644 --- a/lib/puppet/parser/lexer.rb +++ b/lib/puppet/parser/lexer.rb @@ -361,7 +361,7 @@ class Puppet::Parser::Lexer @file = nil # AAARR! okay, regexes in ruby are bloody annoying # no one else has \n =~ /\s/ - �...@skip = %r{[ \t]+} + �...@skip = %r{[ \t\r]+} @namestack = [] @token_queue = [] -- 1.6.6.1 -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en. -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
Re: [Puppet-dev] [PATCH/facter 1/1] Fixed #3939 - Rescue action for swap -l on AIX
On 10 June 2010 07:16, James Turnbull ja...@lovedthanlost.net wrote: Signed-off-by: James Turnbull ja...@lovedthanlost.net -1 Hmm, there are a whole bunch of facts/commands that require root or behave differently. I'd rather see this implemented as a confine. --- lib/facter/memory.rb | 14 +- 1 files changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/facter/memory.rb b/lib/facter/memory.rb index f0f0d45..94769d0 100644 --- a/lib/facter/memory.rb +++ b/lib/facter/memory.rb @@ -21,15 +21,19 @@ require 'facter/util/memory' end if Facter.value(:kernel) == AIX - swap = Facter::Util::Resolution.exec('swap -l') - swapfree, swaptotal = 0, 0 - swap.each do |dev| + begin + swap = Facter::Util::Resolution.exec('swap -l') + swapfree, swaptotal = 0, 0 + swap.each do |dev| if dev =~ /^\/\S+\s.*\s+(\S+)MB\s+(\S+)MB/ swaptotal += $1.to_i swapfree += $2.to_i - end + end + end + rescue Exception = e + puts You must be root to run swap -l on AIX puts isn't helpful if using facter as a library -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
Re: [Puppet-dev] [PATCH/facter 1/1] Fixed #3939 - Rescue action for swap -l on AIX
2010/6/10 Héctor Rivas Gándara key...@gmail.com: I think it simply could detect that the command (swap -l ) failed and raise an exception with the output (or first line of the output). Potentially yes, we should change how util.exec works and enable logging to user/exception passing to lib callers. However that's quite brittle atm, and we'd need to rewrite a bunch of facts to dtrt. But using puts isn't the right thing to do here. Now it fails with a nil access error, I had to see the code to determine that the problem was that I was running facter as a normal user and 'swap -l' was failing. If we know a fact needs root, we should make that explicit, dmidecode based stuff will also fail. Paul -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
Re: [Puppet-dev] [PATCH/facter 1/1] Fixed #3403 - Added fact to query vlans; added spec test
On 24 April 2010 06:38, James Turnbull ja...@lovedthanlost.net wrote: From: Jonas Genannt jo...@brachium-system.net Signed-off-by: James Turnbull ja...@lovedthanlost.net --- lib/facter/util/vlans.rb | 25 + lib/facter/vlans.rb |8 spec/unit/data/linux_vlan_config |6 ++ spec/unit/util/vlans.rb | 14 ++ 4 files changed, 53 insertions(+), 0 deletions(-) create mode 100644 lib/facter/util/vlans.rb create mode 100644 lib/facter/vlans.rb create mode 100644 spec/unit/data/linux_vlan_config create mode 100644 spec/unit/util/vlans.rb diff --git a/lib/facter/util/vlans.rb b/lib/facter/util/vlans.rb new file mode 100644 index 000..a9925f5 --- /dev/null +++ b/lib/facter/util/vlans.rb @@ -0,0 +1,25 @@ +# A module to gather vlan facts +# +module Facter::Util::Vlans +def self.get_vlan_config +output = +if File.exists?('/proc/net/vlan/config') and File.readable?('/proc/net/vlan/config') +output = File.open('/proc/net/vlan/config').read +end +end +output +end + +def self.get_vlans +vlans = Array.new +if self.get_vlan_config +self.get_vlan_config.each do |line| +if line =~ /^([0-9A-Za-z]+)\.([0-9]+) / +vlans.insert(-1, $~[2]) if $~[2] +end +end +end + +vlans.join(',') +end +end diff --git a/lib/facter/vlans.rb b/lib/facter/vlans.rb new file mode 100644 index 000..d65bdd8 --- /dev/null +++ b/lib/facter/vlans.rb @@ -0,0 +1,8 @@ +require 'facter/util/vlans' + +Facter.add(vlans) do +confine :kernel = :linux Your github branch still seems to have: if Facter.value(:kernel) == Linux http://github.com/hggh/facter/blob/7dd8ca90c024b50ad3fb3ba40ff6a07552ea1db0/lib/facter/vlans.rb Can you ensure the version with the confine its pushed there and I'll merge. Paul -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
Re: [Puppet-dev] [PATCH/facter 1/1] Fixed #3393 - Updates to Facter for MS Windows
On 30 April 2010 14:32, David Schmitt da...@dasz.at wrote: On 4/30/2010 10:45 AM, James Turnbull wrote: The following piece has a hole that triggers a spec fail on windows. Shell-builtins are not checked although they would work when executed. I've investigated a bit and the problem is, that ruby's %x{} under linux returns instead of failing, when the command cannot be executed. Ruby on Windows does this differently and raises Errno::ENOENT. I tried to exploit this and produced an alternative version of this patch at http://github.com/DavidS/facter/commits/ticket/master/3393 which passes all specs. I'm just going through the patch queue and this causes failing specs and all exec based facts to fail on OS X. I'm going to investigate further. Paul -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
[Puppet-dev] [PATCH/facter 1/1] Enable TLD for dnsdomainname
This addresses #3356 and supports an arbitrary TLD with hosts in. Signed-off-by: Paul Nasrat pnas...@googlemail.com --- lib/facter/domain.rb |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/lib/facter/domain.rb b/lib/facter/domain.rb index 5dfead0..a04d2b8 100644 --- a/lib/facter/domain.rb +++ b/lib/facter/domain.rb @@ -10,7 +10,7 @@ Facter.add(:domain) do end domain = Facter::Util::Resolution.exec('dnsdomainname') -next domain if domain =~ /.+\..+/ +next domain unless domain.nil? if FileTest.exists?(/etc/resolv.conf) domain = nil -- 1.7.0.3 -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
[Puppet-dev] Re: [PATCH/facter 1/1] Enable TLD for dnsdomainname
On 27 May 2010 13:45, Paul Nasrat pnas...@gmail.com wrote: This addresses #3356 and supports an arbitrary TLD with hosts in. Signed-off-by: Paul Nasrat pnas...@googlemail.com Actually I want to write a whole bunch of tests before I change anything here. Paul -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
Re: [Puppet-dev] [PATCH/facter 1/2] Fixes #3740 - split dmi output on regex
On 7 May 2010 08:21, Marc Fournier marc.fourn...@camptocamp.com wrote: Splitting dmi output on the string /^Handle/ didn't work, and caused the function to match the wrong key if it was found more than once. The intended behaviour of the function is restored by splitting the dmi output on the regex /^Handle/. +1 Where is your git setup to pull from? Paul -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
Re: [Puppet-dev] fixes for #3740
On 7 May 2010 08:21, Marc Fournier marc.fourn...@camptocamp.com wrote: Hello, I'm not sure to understand the use of these trailing dots I removed with the 2nd patch. As there isn't many tests for this function, maybe this breaks something else and needs more work. If I have time over the weekend I'll try get a more comprehensive test suite for this. Paul -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
[Puppet-dev] [PATCH/facter 1/1] Fix virtual unit test on non-linux by stubbing kernel
Signed-off-by: Paul Nasrat pnas...@googlemail.com --- spec/unit/virtual.rb |1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/spec/unit/virtual.rb b/spec/unit/virtual.rb index fe9988e..7dbd146 100644 --- a/spec/unit/virtual.rb +++ b/spec/unit/virtual.rb @@ -50,6 +50,7 @@ describe is_virtual fact do end it should be true when running on kvm do +Facter.fact(:kernel).stubs(:value).returns(Linux) Facter.fact(:virtual).stubs(:value).returns(kvm) Facter.fact(:is_virtual).value.should == true end -- 1.6.4.2 -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
Re: [Puppet-dev] Re: [PATCH/facter 1/1] Fixes #3445.
On 30 March 2010 09:52, Pavol Dilung pavol.dil...@gmail.com wrote: Hi Luke, yep, those patches are same. I messed up the Subject in first post so I've repost it again. Sorry for that ;) OK cool - I can test here at work and validate. My home internet should be back tomorrow (but at puppet meet in evening) so hopefully get some merge time over the bank holiday weekend. Paul -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
[Puppet-dev] London Puppet Meet - Wednesday 31 March
Meet up following training, open to all, we'll meet at The Green Man pub again, I get off about 18h so probably there about 18:30 but feel free to get there earlier if the class finishes up. Green Man 36 Riding Hood St London W1W 7EP http://www.thegreenmanw1.co.uk/ It's 4 mins by google maps walking: http://maps.google.co.uk/maps?f=dsource=s_dsaddr=W1T+6AAdaddr=London+W1W+7EP,+UKhl=engeocode=%3BCZjVj3tY2guRFbodEgMdO9_9_yn_wAtAKht2SDHiFtk1jMkS7wmra=lsdirflg=wsll=51.518906,-0.139461sspn=0.010909,0.027874g=w1w+7epie=UTF8z=18 http://maps.google.co.uk/maps?f=qsource=s_qhl=engeocode=q=w1w+7epsll=53.800651,-4.064941sspn=21.297675,57.084961ie=UTF8hq=hnear=London+W1W+7EP,+United+Kingdomz=16 I've not booked space but Julian thought it'd be quiet on Weds. I'll be in my Puppet Camp T-Shirt. Paul -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
Re: [Puppet-dev] Idea about sourcing facts from other languages
On 11 March 2010 18:12, Michael DeHaan mich...@reductivelabs.com wrote: It's already on the roadmap and as an issue, but we need to fix facter HEAD first. Revisiting the facter bugs list, I don't see it as particularly in bad shape now that this fact is reverted. Yup I want to get 1.5.8 rc1 out this w/e (when I have time to get through the last bugs). Exec needs love, as do some other areas but All tests pass for me on Ubuntu 9.10, for instance, though I've not begun wider testing. You know we have hudson and can kick off tests on a bunch of *nix platforms on EC2, right? I'd like to get this going on commit, have the instances moved over to a RL backed account rather than James' personal one? I'd be curious as to impressions on the state of things, and it does not seem that adding a new fact via this feature would be that intrusive. Not intrusive, but I think that and some other stuff are big enough for 1.6.0, if we get 1.5.8 out this weekend, and spend some timeboxed time getting the stuff right for 1.6.0 adding external facts (key/value), fixing up exec that'd be perfect. Then for 2.0 we want richer data structure stuff, so it's all building iteratively. Sound reasonable? Paul Paul -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
Re: [Puppet-dev] [PATCH/facter 1/1] Revert use popen3 in Resolution.exec
On 9 March 2010 18:13, Markus Roberts mar...@reductivelabs.com wrote: Doh, yes, thanks. I was reading that on the train with screen glare and missed some of the -' signs. I've commited this now, and have started working through the 1.5.8 bug list. Paul -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
Re: [Puppet-dev] [PATCH/facter 1/1] Revert use popen3 in Resolution.exec
On 9 March 2010 19:33, Michael DeHaan mich...@reductivelabs.com wrote: Excellent. I also hope to help some with the code refactoring and support for new datastructure types. I agree bugs should come first, so those too :) If you're doing this, we should do a testing branch and target for 1.6 Also, I'm a big fan of red-green-refactor, so if we come up with an end goal of where we want to be, and iteratively get there that seems the most pragmatic thing. Paul -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
Re: [Puppet-dev] [PATCH] Add shell glob support to puppetrun, and also groups using /etc/puppet/hostgroups.txt (JSON format).
On 9 March 2010 22:08, Michael DeHaan mich...@reductivelabs.com wrote: Also cleaned up a few error messages (unrelated) --- lib/puppet/application/puppetrun.rb | 12 ++- lib/puppet/daemon.rb | 2 +- lib/puppet/network/server.rb | 2 +- lib/puppet/util/runner.rb | 53 +++ You don't seem to have included any tests. Paul -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
Re: [Puppet-dev] Idea about sourcing facts from other languages
On 10 March 2010 03:56, Nigel Kersten nig...@google.com wrote: On Tue, Mar 9, 2010 at 5:52 PM, Luke Kanies l...@reductivelabs.com wrote: On Mar 9, 2010, at 5:09 AM, Michael DeHaan wrote: { facts: { network: { interface: eth0, ip: 192.168.0.1, netmask: 255.255.255.0, }, disk: { name: sda1, size: 1000, } }, } Yep, that's pretty much what I was proposing. I'm a big fan of structured stdin/stdout interfaces for quick extensibiility (and JSON). We could start by doing something that supports non-datastructured facts now, and add datastructures later. For now, it could just assert in the code that the type of each hash key was a string or int. I concur on the basic plan. I'd add that having some plain data, like /etc/facter.d/foo, wouldn't be all bad, either, so you could just statically declare facts. ++ I reckon something like: /etc/facter/facter.conf (main config file) /var/lib/facter/data.d/ (plain text files containing fact values) /var/lib/facter/plugins.d/ (foreign language executables returning fact values) The natural location for all these things differs across platforms, so it should be added to the install.rb script to make them configurable... http://projects.reductivelabs.com/issues/3361 I'd also love to move the default search path logic not to be $LOAD_PATH.collect { |d| File.join(d, facter) }, so we can have a sensible (ie not everything under util/) hierachy for facter's core functionality. But that's probably a breaking change, but we can safely add say a configurable location for native facts in parallel with config, key/value fact files and executable fact files. Paul -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
Re: [Puppet-dev] Idea about sourcing facts from other languages
On 10 March 2010 06:41, Luke Kanies l...@reductivelabs.com wrote: On Mar 9, 2010, at 10:35 PM, Paul Nasrat wrote: On 10 March 2010 03:56, Nigel Kersten nig...@google.com wrote: On Tue, Mar 9, 2010 at 5:52 PM, Luke Kanies l...@reductivelabs.com wrote: On Mar 9, 2010, at 5:09 AM, Michael DeHaan wrote: { facts: { network: { interface: eth0, ip: 192.168.0.1, netmask: 255.255.255.0, }, disk: { name: sda1, size: 1000, } }, } Yep, that's pretty much what I was proposing. I'm a big fan of structured stdin/stdout interfaces for quick extensibiility (and JSON). We could start by doing something that supports non-datastructured facts now, and add datastructures later. For now, it could just assert in the code that the type of each hash key was a string or int. I concur on the basic plan. I'd add that having some plain data, like /etc/facter.d/foo, wouldn't be all bad, either, so you could just statically declare facts. ++ I reckon something like: /etc/facter/facter.conf (main config file) /var/lib/facter/data.d/ (plain text files containing fact values) /var/lib/facter/plugins.d/ (foreign language executables returning fact values) The natural location for all these things differs across platforms, so it should be added to the install.rb script to make them configurable... http://projects.reductivelabs.com/issues/3361 I'd also love to move the default search path logic not to be $LOAD_PATH.collect { |d| File.join(d, facter) }, so we can have a sensible (ie not everything under util/) hierachy for facter's core functionality. But that's probably a breaking change, but we can safely add say a configurable location for native facts in parallel with config, key/value fact files and executable fact files. Can you explain in more detail what you mean here? Currently facter consists of basically facter.rb facter/[facts].rb facter/util/actual_facter_code/helpers The classes responsible for actually doing things in facter - resolution, loading, etc are buried under util. It's not a major thing but I think it's cleaner to split it the other way (make the facts in a special place, and the code under facter), having facter/util/config.rb for handling the config seems wrong . So eg we could eventually try move to having facter/facts (for ruby facts) FACTERLIB I can also see us potentially wanting to think about how we deal with fact hierachies potentially moving things into directories so that we can split up or conditionalize/collapse the order of loading a bit. A lot of facts have implicit dependencies on just one, or two core facts for the purposes of confines. It It's not something I'm overly worried about for now, but if we're changing the code related to ordering I'd like to be provide the ability to configure the equivalent of FACTERLIB in the config, and potentially override the behaviour to say *only look here*. That could work around some of the issues in the past that have bitten us with testing under Hudson when we change facter and have an earlier facter installed on the system we pick up stuff from the system and you get unexpected failures due to the interaction. Paul -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
Re: [Puppet-dev] Idea about sourcing facts from other languages
On 8 March 2010 20:58, Michael DeHaan mich...@reductivelabs.com wrote: Some of us have been talking about this for a while and I'm thinking about knocking this out soon. The idea is you should be able to write facts in any language, and this lowers the barrier to entry for Puppet extensions from those who don't want to learn Ruby just yet. Facter should have a 'fact' dir, for instance: /var/lib/facter/plugins It's already on the roadmap and as an issue, but we need to fix facter HEAD first. Probably want to have config to find it as /var doesn't exist on win32 Paul -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
Re: [Puppet-dev] [Feedback Wanted] Puppetrun and shell globs
On 8 March 2010 18:54, Michael DeHaan mich...@reductivelabs.com wrote: These two patches are a basic attempt to enhance Puppetrun to support shell globs. Can you configure your mailer to send inline/use git mail_patches so they're not attachments for easier review. Paul -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
Re: [Puppet-dev] [Feedback Wanted] Puppetrun and shell globs
On 8 March 2010 21:03, Michael DeHaan mich...@reductivelabs.com wrote: On Mon, Mar 8, 2010 at 4:01 PM, Paul Nasrat pnas...@googlemail.com wrote: On 8 March 2010 18:54, Michael DeHaan mich...@reductivelabs.com wrote: These two patches are a basic attempt to enhance Puppetrun to support shell globs. Can you configure your mailer to send inline/use git mail_patches so they're not attachments for easier review. Yeah, I need to get things configured for git-send-email. [sendemail] smtpserver = smtp.gmail.com smtpserverport = 587 smtpencryption = tls smtpuser = pnas...@googlemail.com wfm ISTF reductivelabs.com being google apps so you should be able to do that. Then read DevelopmentLifecycle wiki page ;) Paul -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
[Puppet-dev] [PATCH/facter 1/1] Resend - Discussion on ec2 facts - #2346
The EC2 fact is completely broken at the moment: * Timeout::Error isn't caught by rescue (due to how it inherits) * The issue of wrong open semantics outlined here, this is causing hidden immediate failure * The fact is going to cause a 2 second wait to every facter run Whilst the following patch fixes the first two, I'm not sure we want to take the timeout hit, we also want to add tests as even simple ruby code can get logic errors such as the open(). Signed-off-by: Paul Nasrat pnas...@googlemail.com --- lib/facter/ec2.rb |5 - 1 files changed, 4 insertions(+), 1 deletions(-) diff --git a/lib/facter/ec2.rb b/lib/facter/ec2.rb index ef84757..447a4d8 100644 --- a/lib/facter/ec2.rb +++ b/lib/facter/ec2.rb @@ -6,8 +6,11 @@ require 'open-uri' require 'timeout' def can_connect?(ip,port,wait_sec=2) - Timeout::timeout(wait_sec) {open(ip, port)} + url = http://#{ip}:#{port}/; + Timeout::timeout(wait_sec) {open(url)} return true +rescue Timeout::Error + return false rescue return false end -- 1.6.4.2 -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
[Puppet-dev] [PATCH/facter 1/1] fixes #2573, #2085, #1291 - fixes domain and fqdn facts resolution
From: Ohad Levy ohad.l...@infineon.com This patch removes the relationship between the domain fact and LDAP/NIS domains. domain fact relates to DNS domain - this will avoid the confusion caused by the LDAP/NIS domain (which might be different to the DNS domain name). Additionally, if hostname is already in long form, it won't try to build the fqdn fact from hostname and domain. Signed-off-by: Paul Nasrat pnas...@googlemail.com --- lib/facter/domain.rb |8 lib/facter/fqdn.rb |4 lib/facter/hostname.rb |7 --- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/lib/facter/domain.rb b/lib/facter/domain.rb index b1bba4d..5dfead0 100644 --- a/lib/facter/domain.rb +++ b/lib/facter/domain.rb @@ -4,14 +4,14 @@ Facter.add(:domain) do # steps is important Facter.value(:hostname) -next $domain if defined? $domain and ! $domain.nil? +# try to fetch the domain from hostname if long hostname is used. +if defined? $fqdn and $fqdn =~ /^([\w-]+)\.(.+)$/ + next $2 +end domain = Facter::Util::Resolution.exec('dnsdomainname') next domain if domain =~ /.+\..+/ -domain = Facter::Util::Resolution.exec('domainname') -next domain if domain =~ /.+\..+/ - if FileTest.exists?(/etc/resolv.conf) domain = nil search = nil diff --git a/lib/facter/fqdn.rb b/lib/facter/fqdn.rb index 5ebc5f5..6271995 100644 --- a/lib/facter/fqdn.rb +++ b/lib/facter/fqdn.rb @@ -1,5 +1,9 @@ Facter.add(:fqdn) do setcode do +# try to fetch the fqdn from hostname if long hostname is used. +Facter.value(:hostname) +next $fqdn if defined? $fqdn and ! $fqdn.nil? + host = Facter.value(:hostname) domain = Facter.value(:domain) if host and domain diff --git a/lib/facter/hostname.rb b/lib/facter/hostname.rb index 188efa4..c3ca968 100644 --- a/lib/facter/hostname.rb +++ b/lib/facter/hostname.rb @@ -1,12 +1,13 @@ Facter.add(:hostname, :ldapname = cn) do setcode do +require 'socket' hostname = nil -name = Facter::Util::Resolution.exec('hostname') or nil +name = Socket.gethostbyname(Socket.gethostname).first if name if name =~ /^([\w-]+)\.(.+)$/ hostname = $1 -# the Domain class uses this -$domain = $2 +# the FQDN/Domain facts use this +$fqdn = name else hostname = name end -- 1.6.4.2 -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
[Puppet-dev] [PATCH/facter 1/1] Revert use popen3 in Resolution.exec
This reverts commit 33fb7709404e706801683e6c47ab7a0a5a1884b1. This has broken master for some facts (eg OS X facts), it also breaks facter platform support on win32 as popen3 does not work there. I'd like to get master working, backlog of patches applied and revisit exec. Paul Signed-off-by: Paul Nasrat pnas...@googlemail.com --- lib/facter/util/resolution.rb | 23 +--- spec/unit/util/resolution.rb | 44 - 2 files changed, 6 insertions(+), 61 deletions(-) diff --git a/lib/facter/util/resolution.rb b/lib/facter/util/resolution.rb index f6afce6..b9e28e8 100644 --- a/lib/facter/util/resolution.rb +++ b/lib/facter/util/resolution.rb @@ -7,7 +7,6 @@ require 'facter/util/confine' require 'timeout' require 'rbconfig' -require 'open3' class Facter::Util::Resolution attr_accessor :interpreter, :code, :name, :timeout @@ -43,27 +42,17 @@ class Facter::Util::Resolution end out = nil -err = nil begin -Open3.popen3(code) do |stdin,stdout,stderr| - out = self.parse_output(stdout.readlines) - err = self.parse_output(stderr.readlines) -end +out = %x{#{code}}.chomp rescue = detail $stderr.puts detail return nil end -Facter.warn(err) - -return nil if out == -out -end - -def self.parse_output(output) -return nil unless output and output.size 0 -result = output.collect{|line| line.chomp } -return result.first unless result.size 1 -result +if out == +return nil +else +return out +end end # Add a new confine to the resolution mechanism. diff --git a/spec/unit/util/resolution.rb b/spec/unit/util/resolution.rb index 27cb150..d4bb781 100755 --- a/spec/unit/util/resolution.rb +++ b/spec/unit/util/resolution.rb @@ -227,54 +227,10 @@ describe Facter::Util::Resolution do Facter::Util::Resolution.should respond_to(:exec) end -it should have a class method to parse output do -Facter::Util::Resolution.should respond_to(:parse_output) -end - # It's not possible, AFAICT, to mock %x{}, so I can't really test this bit. describe when executing code do it should fail if any interpreter other than /bin/sh is requested do lambda { Facter::Util::Resolution.exec(/something, /bin/perl) }.should raise_error(ArgumentError) end - -it should produce stderr content as a warning do -stdout = stdin = stub('fh', :readlines = [aaa\n]) -stderr = stub('stderr', :readlines = %w{my content}) -Open3.expects(:popen3).with(/bin/true).yields(stdin, stdout, stderr) - -Facter.expects(:warn).with(['my','content']) -Facter::Util::Resolution.exec(/bin/true).should == 'aaa' -end - -it should produce nil as a warning if nothing is printed to stderr do -stdout = stdin = stub('fh', :readlines = [aaa\n]) -stderr = stub('stderr', :readlines = []) -Open3.expects(:popen3).with(/bin/true).yields(stdin, stdout, stderr) - -Facter.expects(:warn).with(nil) -Facter::Util::Resolution.exec(/bin/true).should == 'aaa' -end -end - -describe when parsing output do -it should return nil on nil do -Facter::Util::Resolution.parse_output(nil).should be_nil -end - -it should return nil on empty string do -Facter::Util::Resolution.parse_output('').should be_nil -end - -it should return nil on an empty array do -Facter::Util::Resolution.parse_output([]).should be_nil -end - -it should return a string on a 1 size array do -Facter::Util::Resolution.parse_output([aaa\n]).should == aaa -end - -it should return an array with chomped new lines on an array do -result = Facter::Util::Resolution.parse_output([aaa\n,bbb\n,ccc\n]).should == [ aaa, bbb, ccc ] -end end end -- 1.6.4.2 -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
[Puppet-dev] Re: [PATCH/facter 1/1] fixes #2573, #2085, #1291 - fixes domain and fqdn facts resolution
On 28 February 2010 13:10, Paul Nasrat pnas...@googlemail.com wrote: From: Ohad Levy ohad.l...@infineon.com This patch removes the relationship between the domain fact and LDAP/NIS domains. domain fact relates to DNS domain - this will avoid the confusion caused by the LDAP/NIS domain (which might be different to the DNS domain name). Additionally, if hostname is already in long form, it won't try to build the fqdn fact from hostname and domain. +1 These have been oustanding for ages, although I'd like to get the fix for 3080 in so I can actually test master properly before I commit Paul -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
Re: [Puppet-dev] [PATCH/facter 1/1] Fix #2746 - add architecture support for GNU/kFreeBSD
On 18 January 2010 18:34, Luke Kanies l...@reductivelabs.com wrote: What the heck is gnu/kfreebsd? Code seems ok, though. Commited Paul -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
Re: [Puppet-dev] [PATCH/puppet 1/1] Fix for #3094 (libdir should take : delimited path)
2010/1/22 Markus Roberts mar...@reality.com: Since libdir is also the default for the plugin handler, it needs to be : savvy as well. This really should be File::PATH_SEPARATOR and not ':' Paul -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
Re: [Puppet-dev] [PATCH/facter 1/1] Fix #2341 - stricter handling of dmidecode split
2010/1/18 Luke Kanies l...@reductivelabs.com: On Jan 17, 2010, at 9:03 AM, Paul Nasrat wrote: This adds a test to ensure we are not prematurely splitting on Handle Signed-off-by: Paul Nasrat pnas...@googlemail.com --- lib/facter/util/manufacturer.rb | 2 +- spec/unit/util/manufacturer.rb | 22 ++ 2 files changed, 23 insertions(+), 1 deletions(-) diff --git a/lib/facter/util/manufacturer.rb b/lib/facter/util/manufacturer.rb index d015226..baf24bc 100644 --- a/lib/facter/util/manufacturer.rb +++ b/lib/facter/util/manufacturer.rb @@ -28,7 +28,7 @@ module Facter::Manufacturer end def self.dmi_find_system_info(name) - splitstr= Facter.value(:kernel) == 'SunOS' ? ID SIZE TYPE : Handle + splitstr= Facter.value(:kernel) == 'SunOS' ? ID SIZE TYPE : /^Handle/ There's probably just not enough context in this patch, but is that really a quoted regex? Yes, and that was the patch supplied in the bug, this whole area needs revisiting. I figured it's better to start adding tests for the parser along with the fix and then get to a point where it's better abstracted rather than get into a rabbit-hole of stuff. The whole pass a nested dict with regex's into the code is smelly but for 1.5.8 I'd rather just fix the corner case. Paul -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
Re: [Puppet-dev] [PATCH/facter 1/1] Remove whitespace in DMI facts (#3008, #3011)
2010/1/11 Ohad Levy ohadl...@gmail.com: +1 is there a reason why not to strip all facts? I'm a little cautious about doing that in general in case someone has a dependancy on a fact with a space in or valid but odd setups (directories with trailing space). Although all the examples I can think of are contrived there may be valid cases. Facts should be responsible for their own data formatting so know when it's safe to strip. Paul -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
Re: [Puppet-dev] [PATCH/facter 1/1] Remove whitespace in DMI facts (#3008, #3011)
2010/1/11 Thomas Bellman bell...@nsc.liu.se: Paul Nasrat wrote: 2010/1/11 Ohad Levy ohadl...@gmail.com: is there a reason why not to strip all facts? I'm a little cautious about doing that in general in case someone has a dependancy on a fact with a space in or valid but odd setups (directories with trailing space). Although all the examples I can think of are contrived there may be valid cases. Facts should be responsible for their own data formatting so know when it's safe to strip. I use a custom fact for transferring (small) binary blobs to the server, so at least until I have rewritten that to base64-encode it, I would prefer that facts aren't mangled... Thanks for a concrete example. We'll stick with the approach of only doing formatting in the individual facts themselves as in this patch. Paul -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
[Puppet-dev] [PATCH/facter 1/1] Remove whitespace in DMI facts (#3008, #3011)
In addition to the stripping of the output of these facts this patchset: Refactor - Extracted function to enable easier testing. Tests - data driven tests for the dmidecode/smbios fact. Paul Signed-off-by: Paul Nasrat pnas...@googlemail.com --- lib/facter/util/manufacturer.rb| 17 +--- spec/unit/data/linux_dmidecode_with_spaces | 60 spec/unit/util/manufacturer.rb | 26 3 files changed, 97 insertions(+), 6 deletions(-) create mode 100644 spec/unit/data/linux_dmidecode_with_spaces create mode 100644 spec/unit/util/manufacturer.rb diff --git a/lib/facter/util/manufacturer.rb b/lib/facter/util/manufacturer.rb index c609a12..dd503f9 100644 --- a/lib/facter/util/manufacturer.rb +++ b/lib/facter/util/manufacturer.rb @@ -2,8 +2,8 @@ # Support methods for manufacturer specific facts module Facter::Manufacturer -def self.dmi_find_system_info(name) -splitstr=Handle + +def self.get_dmi_table() case Facter.value(:kernel) when 'Linux' return nil unless FileTest.exists?(/usr/sbin/dmidecode) @@ -19,18 +19,23 @@ module Facter::Manufacturer output=%x{/usr/pkg/sbin/dmidecode 2/dev/null} when 'SunOS' return nil unless FileTest.exists?(/usr/sbin/smbios) -splitstr=IDSIZE TYPE -output=%x{/usr/sbin/smbios 2/dev/null} +output=%x{/usr/sbin/smbios 2/dev/null} else -return +output=nil end +return output +end + +def self.dmi_find_system_info(name) +splitstr= Facter.value(:kernel) == 'SunOS' ? IDSIZE TYPE : Handle +output = self.get_dmi_table() name.each_pair do |key,v| v.each do |v2| v2.each_pair do |value,facterkey| output.split(splitstr).each do |line| if line =~ /#{key}/ and ( line =~ /#{value} 0x\d+ \(([-\w].*)\)\n*./ or line =~ /#{value} ([-\w].*)\n*./ ) -result = $1 +result = $1.strip Facter.add(facterkey) do confine :kernel = [ :linux, :freebsd, :netbsd, :sunos ] setcode do diff --git a/spec/unit/data/linux_dmidecode_with_spaces b/spec/unit/data/linux_dmidecode_with_spaces new file mode 100644 index 000..0d77386 --- /dev/null +++ b/spec/unit/data/linux_dmidecode_with_spaces @@ -0,0 +1,60 @@ +# dmidecode 2.2 +SMBIOS 2.3 present. +32 structures occupying 994 bytes. +Table at 0x000F0800. +Handle 0x +DMI type 0, 20 bytes. +BIOS Information +Vendor: Award Software International, Inc. +Version: 6.00 PG +Release Date: 01/03/2003 +Address: 0xE +Runtime Size: 128 kB +ROM Size: 256 kB +Characteristics: +ISA is supported +PCI is supported +PNP is supported +APM is supported +BIOS is upgradeable +BIOS shadowing is allowed +ESCD support is available +Boot from CD is supported +Selectable boot is supported +BIOS ROM is socketed +EDD is supported +5.25/360 KB floppy services are supported (int 13h) +5.25/1.2 MB floppy services are supported (int 13h) +3.5/720 KB floppy services are supported (int 13h) +3.5/2.88 MB floppy services are supported (int 13h) +Print screen service is supported (int 5h) +8042 keyboard services are supported (int 9h) +Serial services are supported (int 14h) +Printer services are supported (int 17h) +CGA/mono video services are supported (int 10h) +ACPI is supported +USB legacy is supported +AGP is supported +LS-120 boot is supported +ATAPI Zip drive boot is supported +Handle 0x0001 +DMI type 1, 25 bytes. +System Information +Manufacturer: MICRO-STAR INTERNATIONAL CO., LTD +Product Name: MS-6754 +Version: +Serial Number: +UUID: Not Present +Wake-up Type: Power Switch +Handle 0x0002 +DMI type 2, 8 bytes. +Base Board Information +Manufacturer: MICRO-STAR INTERNATIONAL CO., LTD +Product Name: MS-6754 +Version: +Serial Number: + +Handle 0x001F +DMI type 127, 4 bytes. +End Of Table + diff --git a/spec/unit
Re: [Puppet-dev] [PATCH/puppet 1/1] Proposed fix for #3013 (pipes, OSes, and ruby versions, Oh My!)
2010/1/10 Markus Roberts mar...@reality.com: The recent release of 0.25.2 contains a new method of handling communication with execed processes to support SELinux and improve performance on other OSes which, unfortunately, has a number of shortcomings: Just had a quick scan through the patch and noticed: index 000..ac536fe --- /dev/null +++ b/spec/unit/exec_test_helper @@ -0,0 +1,45 @@ +#!/usr/bin/env ruby + +require 'optparse' +options = OptionParser.new +options.on(--kill-me-withi SIGNAL,/USR[12]/) { |signal| $kill_me = signal } Looks like a typo in the options --kill-me-withi vs usage: + task = [File.dirname(__FILE__)+'/exec_test_helper','--kill-me-with','USR1','--called-by',$PID,'--repeat',n] Running with both --kill-me-with and --kill-me-withi seem to work, but I'm assuming you meant the former paul-nasrats-macbook:puppet pnasrat$ ./spec/unit/exec_test_helper --kill-me-with USR1 ./spec/unit/exec_test_helper:26: I don't believe you, is PID TTY TIME CMD. (RuntimeError) paul-nasrats-macbook:puppet pnasrat$ vi spec/unit/exec_test_helper paul-nasrats-macbook:puppet pnasrat$ ./spec/unit/exec_test_helper --kill-me-withi USR1 ./spec/unit/exec_test_helper:26: I don't believe you, is PID TTY TIME CMD. (RuntimeError) Paul -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
Re: [Puppet-dev] Facter 1.5.8
2010/1/8 Peter Meier peter.me...@immerda.ch: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi I've shuffled a few low hanging fruit tickets to a new Facter release - 1.5.8 - I intend to knock all of these over in the next week or so and cut a release. The rationale is mainly that it has been a while and some of these tickets are annoying for people and quick to resolve. I wanted to reply on the issue that Michael DeHaan reported. So I try to do it soon (today?), as we should fix that for the next release. Definitely I'd suggest we have some more extensive testing on different OS, comparing both versions fact output. Paul -- You received this message because you are subscribed to the Google Groups Puppet Developers group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.