The Puppet Labs Issue Tracker has Moved: https://tickets.puppetlabs.com

Feature #11663

Add FreeBSD support to blockdevice fact(s)

Added by Mike Carlson over 2 years ago. Updated over 1 year ago.

Status:Merged - Pending ReleaseStart date:01/02/2012
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:library
Target version:-
Keywords: Affected Facter version:
Branch:https://github.com/puppetlabs/facter/pull/414

We've Moved!

Ticket tracking is now hosted in JIRA: https://tickets.puppetlabs.com

This issue is currently not available for export. If you are experiencing the issue described below, please file a new ticket in JIRA. Once a new ticket has been created, please add a link to it that points back to this Redmine ticket.


Description

I’ve added to the blockdevice.rb lib in master to support FreeBSD.

You can see the code on a fork I made of facter on github

Here is an example on a FreeBSD Xen guest:

blockdevices => ad0,da0,da1
blockdevice_ad0_model => QEMU HARDDISK/0.10.2
blockdevice_ad0_size => 4194304000
blockdevice_da0_model => QEMU QEMU HARDDISK 0.10
blockdevice_da0_size => 42991616000
blockdevice_da1_model => QEMU QEMU HARDDISK 0.10
blockdevice_da1_size => 10695475200

And here is a physical system with a combination of USB drives:

blockdevices => ad10,ad12,ad4,ad6,ad8,da0,da1
blockdevice_ad10_model => WDC WD1003FBYX-01Y7B0/01.01V01
blockdevice_ad10_size => 1000204886016
blockdevice_ad12_model => WDC WD1003FBYX-01Y7B0/01.01V01
blockdevice_ad12_size => 1000204886016
blockdevice_ad4_model => ST2000DL003-9VT166/CC98
blockdevice_ad4_size => 2000398934016
blockdevice_ad6_model => WDC WD1003FBYX-01Y7B0/01.01V01
blockdevice_ad6_size => 1000204886016
blockdevice_ad8_model => WDC WD1003FBYX-01Y7B0/01.01V01
blockdevice_ad8_size => 1000204886016
blockdevice_da0_model => WD Ext HDD 1021 2021
blockdevice_da0_size => 3000590401536
blockdevice_da1_model => Initio INIC-1610P 1.01
blockdevice_da1_size => 2000398934016

size is reported in bytes.

History

#1 Updated by James Turnbull over 2 years ago

  • Status changed from Unreviewed to Requires CLA to be signed
  • Assignee set to Mike Carlson

Hi Mike – thanks for your contribution! Can I please get you to sign a Contributor License Agreement (top right menu) so we can review and merge your code. Also if you send through a pull request for the code that’d help too.

Thanks!

#2 Updated by Mike Carlson over 2 years ago

Hey James, thanks. I went a head and signed the CLA and sent a pull request.

#3 Updated by James Turnbull over 2 years ago

  • Status changed from Requires CLA to be signed to In Topic Branch Pending Review
  • Branch set to https://github.com/puppetlabs/facter/pull/137

Awesome! Thanks.

#4 Updated by Anonymous over 2 years ago

  • Status changed from In Topic Branch Pending Review to Tests Insufficient

Mike, this is awesome. The one thing that we need to do before we can merge it is get some tests added.

Would you be willing to tackle that – we really don’t want to accidentally break this in future without knowing.

If you can’t, let us know and we can write them ourselves, but that will delay getting the code merged. :)

#5 Updated by Mike Carlson over 2 years ago

I have not written any tests before, but I would be happy to take a look at the documentation.

#6 Updated by Adrien Thebo over 2 years ago

Hi Mike, Daniel has asked me to offer you a hand for getting tests for this. A good resource for this would be the existing tests for the linux block device facts, viewable at https://github.com/puppetlabs/facter/blob/master/spec/unit/blockdevices_spec.rb . In addition, if you have further questions you can email me at adrien@puppetlabs.com and I’m available on freenode as adrient.

#7 Updated by Mike Carlson over 2 years ago

Thanks Adrian!

I’m going to work with the blockdevices_spec.rb and I’ll see how far I can get.

I may have a few questions, so I’ll ask those through email.

Mike C

#8 Updated by Mike Carlson over 2 years ago

Hey Daniel, here is the requested output for each command and fact (for the tests)

blockdevices

 "blockdevices = Facter::Util::Resolution.exec('/sbin/sysctl -n kern.disks').split(' ')":
# /sbin/sysctl -n kern.disks
ad10,ad12,ad4,ad6,ad8,da0,da1

# facter blockdevices
ad10,ad12,ad4,ad6,ad8,da0,da1

blockdevice_device_size

    Facter.add("blockdevice_#{device}_size".to_sym) do
      setcode { Facter::Util::Resolution.exec("/usr/sbin/diskinfo #{device} | /usr/bin/awk '{print $3}'") }
    end

ATA Device

# /usr/sbin/diskinfo ad10
ad10    512     1000204886016   1953525168      0       0       1938021 16      63

# /usr/sbin/diskinfo ad10 | /usr/bin/awk '{print $3}'
1000204886016

# facter blockdevice_ad10_size
1000204886016

SCSI Device

# /usr/sbin/diskinfo da0
da0     512     2000398934016   3907029168      0       0       243201  255     63

# /usr/sbin/diskinfo da0 | /usr/bin/awk '{print $3}'
2000398934016

facter blockdevice_da0_size
2000398934016

blockdevice_device_model

    Facter.add("blockdevice_#{device}_model".to_sym) do
      if device =~ /ad/
        setcode { Facter::Util::Resolution.exec("/sbin/atacontrol list | /usr/bin/awk -F '<|>' '/#{device}/ { print $2 }'") }
      elsif device =~ /mfi/
        setcode { "MFI Local Disk" }
      else
        setcode { Facter::Util::Resolution.exec("/sbin/camcontrol inquiry #{device} -D | /usr/bin/awk -F '<|>' '{ print $2}'" ) }
      end

ATA Device

# /sbin/atacontrol list
ATA channel 2:
    Master:  ad4  SATA revision 2.x
    Slave:       no device present
ATA channel 3:
    Master:  ad6  SATA revision 2.x
    Slave:       no device present
ATA channel 4:
    Master:  ad8  SATA revision 2.x
    Slave:       no device present
ATA channel 5:
    Master: ad10  SATA revision 2.x
    Slave:       no device present
ATA channel 6:
    Master: ad12  SATA revision 2.x
    Slave:       no device present
ATA channel 7:
    Master:      no device present
    Slave:       no device present

# /sbin/atacontrol list | /usr/bin/awk -F '<|>' '/ad10/ { print $2}'
WDC WD1003FBYX-01Y7B0/01.01V01

# facter blockdevice_ad10_model
WDC WD1003FBYX-01Y7B0/01.01V01

SCSI Device

# /sbin/camcontrol inquiry da0
pass0:  Fixed Direct Access SCSI-4 device
pass0: Serial Number 0010101E40000000
pass0: 40.000MB/s transfers

# /sbin/camcontrol inquiry da0 -D | /usr/bin/awk -F '<|>' '{ print $2}'
Initio INIC-1610P 1.01

# facter blockdevice_da0_model
Initio INIC-1610P 1.01

#9 Updated by Anonymous over 2 years ago

Mike Carlson wrote:

Hey Daniel, here is the requested output for each command and fact (for the tests)

Thanks very much for that. :)

#10 Updated by Ken Barber over 2 years ago

  • Target version set to 186

#11 Updated by Anonymous over 2 years ago

  • Target version deleted (186)

#12 Updated by Michael Moll about 2 years ago

I just opened pull request 248 at github with an updated version.

Here the facts on a system using SCSI:

blockdevice_cd0_model => DV-28E-N 1.6A
blockdevice_cd0_size => 0
blockdevice_cd0_vendor => TEAC
blockdevice_da0_model => 73.4G MAU3073NC HPC2
blockdevice_da0_size => 73407865856
blockdevice_da0_vendor => HP
blockdevice_da1_model => 73.4G MAU3073NC HPC2
blockdevice_da1_size => 73407865856
blockdevice_da1_vendor => HP
blockdevices => cd0,da0,da1

and a system using ATA_CAM:

blockdevice_ada0_model => Force GT
blockdevice_ada0_size => 120034123776
blockdevice_ada0_vendor => Corsair
blockdevice_ada1_model => HDS721010CLA332
blockdevice_ada1_size => 1000204886016
blockdevice_ada1_vendor => Hitachi
blockdevice_ada2_model => HDS721010CLA332
blockdevice_ada2_size => 1000204886016
blockdevice_ada2_vendor => Hitachi
blockdevices => ada0,ada1,ada2

And the output of the newly added command for ATA_CAM devices:

# /sbin/camcontrol identify ada0
pass0: <Corsair Force GT 1.3.3> ATA-8 SATA 3.x device
pass0: 300.000MB/s transfers (SATA 2.x, UDMA6, PIO 8192bytes)
protocol              ATA/ATAPI-8 SATA 3.x
device model          Corsair Force GT
firmware revision     1.3.3
serial number         XXX
WWN                   0000000000000000
cylinders             16383
heads                 16
sectors/track         63
sector size           logical 512, physical 512, offset 0
LBA supported         234441648 sectors
LBA48 supported       234441648 sectors
PIO supported         PIO4
DMA supported         WDMA2 UDMA6 
media RPM             non-rotating
Feature                      Support  Enabled   Value           Vendor
read ahead                     yes  yes
write cache                    yes  yes
flush cache                    yes  yes
overlap                        no
Tagged Command Queuing (TCQ)   no   no
Native Command Queuing (NCQ)   yes      32 tags
SMART                          yes  yes
microcode download             yes  yes
security                       yes  no
power management               yes  yes
advanced power management      yes  yes 254/0xFE
automatic acoustic management  no   no
media status notification      no   no
power-up in Standby            yes  no
write-read-verify              yes  no  0/0x0
unload                         yes  yes
free-fall                      no   no
data set management (TRIM)     yes

#13 Updated by Michael Moll over 1 year ago

  • Assignee changed from Mike Carlson to Michael Moll
  • Branch changed from https://github.com/puppetlabs/facter/pull/137 to https://github.com/puppetlabs/facter/pull/248

Assign to /me

Update branch

#14 Updated by Michael Moll over 1 year ago

  • Status changed from Tests Insufficient to In Topic Branch Pending Review
  • Assignee changed from Michael Moll to Adrien Thebo

Hi Adrien,

as You wrote the missing unit tests, I pass this on to You. The pull-request on github was updated accordingly.

#15 Updated by Jeff McCune over 1 year ago

  • Assignee deleted (Adrien Thebo)

I’m reviewing this now. I hope to merge it or provide next actions ASAP.

-Jeff

#16 Updated by Jeff McCune over 1 year ago

  • Status changed from In Topic Branch Pending Review to Code Insufficient

Please see my comments for next actions in the pull request at https://github.com/puppetlabs/facter/pull/248.

-Jeff

#17 Updated by Michael Moll over 1 year ago

  • Status changed from Code Insufficient to In Topic Branch Pending Review
  • Branch changed from https://github.com/puppetlabs/facter/pull/248 to https://github.com/puppetlabs/facter/pull/414

New pull request on github: https://github.com/puppetlabs/facter/pull/414

#18 Updated by Adrien Thebo over 1 year ago

  • Status changed from In Topic Branch Pending Review to Merged - Pending Release

Merged into master as 48478b3.

This should be released in 2.0.0.

Thanks again for the contribution!

-Adrien

Also available in: Atom PDF