Project

General

Profile

« Previous | Next » 

Revision ac99a245

Added by Dominic Cleal over 7 years ago

fixes #17335 - parse Solaris update as minor version

Also fixes idempotency of OSes with only a major version (as Solaris
was prior to this change), where `minor` was nil instead of "", causing
the OS to be recreated with a validation error.
(cherry picked from commit 13875289357605c80b8073c2befcf84303e3695d)

View differences:

app/services/puppet_fact_parser.rb
orel = majorjunos + "." + minorjunos
elsif os_name[/FreeBSD/i]
orel.gsub!(/\-RELEASE\-p[0-9]+/, '')
elsif os_name[/Solaris/i]
orel.gsub!(/_u/, '.')
end
major, minor = orel.split('.', 2)
major.to_s.gsub!(/\D/, '')
minor.to_s.gsub!(/[^\d\.]/, '')
major = major.to_s.gsub(/\D/, '')
minor = minor.to_s.gsub(/[^\d\.]/, '')
args = {:name => os_name, :major => major, :minor => minor}
os = Operatingsystem.find_or_initialize_by(args)
os.release_name = facts[:lsbdistcodename] if facts[:lsbdistcodename] && (os_name[/debian|ubuntu/i] || os.family == 'Debian')
test/unit/facts_solaris10.json
{
"puppetversion": "3.7.1",
"kernel": "SunOS",
"hardwareisa": "i386",
"uptime": "27 days",
"rubyversion": "2.0.0",
"netmask": "255.255.255.0",
"kernelrelease": "5.10",
"operatingsystemmajrelease": "10",
"macaddress": "00:55:55:88:bd:88",
"zonename": "global",
"sshdsakey": "ZZZ",
"sshfp_dsa": "SSHFP ZZzz",
"sshrsakey": "ZZZZ",
"sshfp_rsa": "SSHFP 1 1 ZZZZ\nSSHFP 1 2 ZZzzz",
"virtual": "vmware",
"is_virtual": "true",
"facterversion": "2.2.0",
"uptime_days": 27,
"architecture": "i86pc",
"hardwaremodel": "i86pc",
"operatingsystem": "Solaris",
"os": {
"name": "Solaris",
"family": "Solaris",
"release": {
"major": "10",
"full": "10_u9"
}
},
"ps": "ps -ef",
"kernelversion": "Generic_150502-22",
"rubysitedir": "/usr/local/lib/ruby/site_ruby/2.0.0",
"zpool_version": "32",
"fqdn": "labhost1.localdomain",
"interfaces": "lo0,e1000g0",
"ipaddress_lo0": "127.0.0.1",
"netmask_lo0": "255.0.0.0",
"mtu_lo0": "8232",
"ipaddress_e1000g0": "192.168.1.2",
"macaddress_e1000g0": "00:50:66:88:bd:88",
"netmask_e1000g0": "255.255.255.0",
"mtu_e1000g0": "1500",
"timezone": "CET",
"id": "root",
"processors": {
"models": [
"Badass intel"
],
"count": 1,
"physicalcount": 1
},
"processor0": "Badass intel",
"processorcount": "1",
"path": "/bin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/opt/csw/bin:/opt/csw/sbin:/opt/sfw/bin:/usr/sfw/bin:/usr/sfw/sbin:/usr/ccs/bin:/usr/apache2/bin:/usr/apache2/sbin:/sbin",
"hostname": "labhost1",
"operatingsystemrelease": "10_u9",
"ipaddress": "192.168.1.2",
"uptime_seconds": 2336220,
"osfamily": "Solaris",
"gid": "root",
"zone_global_id": "0",
"zone_global_name": "global",
"zone_global_status": "running",
"zone_global_path": "/",
"zone_global_uuid": "",
"zone_global_brand": "native",
"zone_global_iptype": "shared",
"zones": 1,
"kernelmajversion": "Generic_150502-22",
"zfs_version": "5",
"domain": "localdomain",
"uniqueid": "35555475",
"uptime_hours": 648,
"system_uptime": {
"seconds": 2336220,
"hours": 648,
"days": 27,
"uptime": "27 days"
},
"network_lo0": "127.0.0.0",
"network_e1000g0": "192.168.1.2",
"physicalprocessorcount": "1",
"memorysize": "2.00 GB",
"memoryfree": "262.59 MB",
"swapsize": "1024.00 MB",
"swapfree": "911.00 MB",
"swapsize_mb": "1024.00",
"swapfree_mb": "911.00",
"memorysize_mb": "2048.00",
"memoryfree_mb": "262.59",
"bios_vendor": "Phoenix Technologies LTD",
"bios_version": "None",
"bios_release_date": "09/17/2016",
"manufacturer": "VMware, Inc.",
"productname": "VMware Virtual Platform",
"serialnumber": "zz",
"uuid": "zz",
"type": "0x1 (other)"
}
test/unit/puppet_fact_parser_test.rb
assert_equal "AnyOS 6", data.to_s
assert_equal '6', data.major
assert_empty data.minor
assert_equal data, importer.operatingsystem
end
test "release_name should be nil when lsbdistcodename isn't set on Debian" do
......
assert_equal '1', @importer.operatingsystem.minor
end
test "should set os.major and minor correctly from Solaris 10 facts" do
@importer = PuppetFactParser.new(solaris10_facts)
os = @importer.operatingsystem
assert_equal 'Solaris', os.family
assert_equal '10', os.major
assert_equal '9', os.minor
end
test "#get_interfaces" do
host = FactoryGirl.create(:host, :hostgroup => FactoryGirl.create(:hostgroup))
parser = get_parser(host.facts_hash)
......
def freebsd_patch_facts
JSON.parse(File.read(File.expand_path(File.dirname(__FILE__) + '/facts_freebsd_patch.json')))['facts']
end
def solaris10_facts
JSON.parse(File.read(File.expand_path(File.dirname(__FILE__) + '/facts_solaris10.json')))
end
end

Also available in: Unified diff