@@ -368,43 +368,43 @@ def macos?
368368 alias macosx? macos?
369369
370370 def macos10?
371- macos? && node [ 'platform_version' ] . start_with? ( '10.' )
371+ macos? && self [ 'platform_version' ] . start_with? ( '10.' )
372372 end
373373
374374 def macos11?
375- macos? && node [ 'platform_version' ] . start_with? ( '11.' )
375+ macos? && self [ 'platform_version' ] . start_with? ( '11.' )
376376 end
377377
378378 def macos12?
379- macos? && node [ 'platform_version' ] . start_with? ( '12.' )
379+ macos? && self [ 'platform_version' ] . start_with? ( '12.' )
380380 end
381381
382382 def macos13?
383- macos? && node [ 'platform_version' ] . start_with? ( '13.' )
383+ macos? && self [ 'platform_version' ] . start_with? ( '13.' )
384384 end
385385
386386 def macos14?
387- macos? && node [ 'platform_version' ] . start_with? ( '14.' )
387+ macos? && self [ 'platform_version' ] . start_with? ( '14.' )
388388 end
389389
390390 def macos15?
391- macos? && node [ 'platform_version' ] . start_with? ( '15.' )
391+ macos? && self [ 'platform_version' ] . start_with? ( '15.' )
392392 end
393393
394394 def mac_mini_2018?
395- macos? && node [ 'hardware' ] [ 'machine_model' ] == 'Macmini8,1'
395+ macos? && self [ 'hardware' ] [ 'machine_model' ] == 'Macmini8,1'
396396 end
397397
398398 def mac_mini_2020?
399- macos? && node [ 'hardware' ] [ 'machine_model' ] == 'Macmini9,1'
399+ macos? && self [ 'hardware' ] [ 'machine_model' ] == 'Macmini9,1'
400400 end
401401
402402 def windows?
403403 self [ 'platform_family' ] == 'windows'
404404 end
405405
406406 def windows_desktop?
407- windows? && node [ 'kernel' ] [ 'product_type' ] == 'Workstation'
407+ windows? && self [ 'kernel' ] [ 'product_type' ] == 'Workstation'
408408 end
409409
410410 def windows8?
@@ -428,7 +428,7 @@ def windows10_or_newer?
428428 end
429429
430430 def windows_server?
431- windows? && node [ 'kernel' ] [ 'product_type' ] == 'Server'
431+ windows? && self [ 'kernel' ] [ 'product_type' ] == 'Server'
432432 end
433433
434434 def windows2008?
@@ -647,7 +647,7 @@ def in_aws_account?(*accts)
647647
648648 def ohai_fs_ver
649649 @ohai_fs_ver ||=
650- node [ 'filesystem2' ] ? 'filesystem2' : 'filesystem'
650+ self [ 'filesystem2' ] ? 'filesystem2' : 'filesystem'
651651 end
652652
653653 # Take a string representing a mount point, and return the
@@ -773,15 +773,15 @@ def efi?
773773
774774 def coreboot?
775775 File . directory? ( '/sys/firmware/vpd' ) ||
776- node [ 'dmi' ] [ 'bios' ] [ 'vendor' ] == 'coreboot'
776+ self [ 'dmi' ] [ 'bios' ] [ 'vendor' ] == 'coreboot'
777777 end
778778
779779 def aarch64?
780- node [ 'kernel' ] [ 'machine' ] == 'aarch64'
780+ self [ 'kernel' ] [ 'machine' ] == 'aarch64'
781781 end
782782
783783 def x64?
784- node [ 'kernel' ] [ 'machine' ] == 'x86_64'
784+ self [ 'kernel' ] [ 'machine' ] == 'x86_64'
785785 end
786786
787787 def cgroup_mounted?
@@ -803,12 +803,12 @@ def cgroup2?
803803 def get_flexible_shard ( shard_size )
804804 @flexible_shard_value ||= { }
805805 @flexible_shard_value [ shard_size ] ||=
806- if node [ 'shard_seed' ]
807- node [ 'shard_seed' ] % shard_size
806+ if self [ 'shard_seed' ]
807+ self [ 'shard_seed' ] % shard_size
808808 else
809809 # backwards compat for Facebook until
810810 # https://github.com/chef/ohai/pull/877 is out
811- node [ 'fb' ] [ 'shard_seed' ] % shard_size
811+ self [ 'fb' ] [ 'shard_seed' ] % shard_size
812812 end
813813 @flexible_shard_value [ shard_size ]
814814 end
@@ -951,7 +951,7 @@ def rollout_shard(start_date)
951951 def firstboot_os?
952952 # this has to work even when we fail early on so we can call this from
953953 # broken runs in handlers
954- node [ 'fb_init' ] [ 'firstboot_os' ]
954+ self [ 'fb_init' ] [ 'firstboot_os' ]
955955 rescue StandardError
956956 prefix = macos? ? '/var/root' : '/root'
957957 File . exist? ( File . join ( prefix , 'firstboot_os' ) )
@@ -960,7 +960,7 @@ def firstboot_os?
960960 def firstboot_tier?
961961 # this has to work even when we fail early on so we can call this from
962962 # broken runs in handlers
963- node [ 'fb_init' ] [ 'firstboot_tier' ]
963+ self [ 'fb_init' ] [ 'firstboot_tier' ]
964964 rescue StandardError
965965 prefix = macos? ? '/var/root' : '/root'
966966 File . exist? ( File . join ( prefix , 'firstboot_tier' ) )
@@ -973,11 +973,11 @@ def firstboot_any_phase?
973973 # is this device a SSD? If it's not rotational, then it's SSD
974974 # expects a short device name, e.g. 'sda', not '/dev/sda', not '/dev/sda3'
975975 def device_ssd? ( device )
976- unless node [ 'block_device' ] [ device ]
976+ unless self [ 'block_device' ] [ device ]
977977 fail "fb_helpers: Device '#{ device } ' passed to node.device_ssd? " +
978978 "doesn't appear to be a block device!"
979979 end
980- node [ 'block_device' ] [ device ] [ 'rotational' ] == '0'
980+ self [ 'block_device' ] [ device ] [ 'rotational' ] == '0'
981981 end
982982
983983 def root_compressed?
@@ -1061,35 +1061,35 @@ def rpm_version(name)
10611061 end
10621062
10631063 def selinux_mode
1064- node [ 'selinux' ] [ 'status' ] [ 'current_mode' ] || 'unknown'
1064+ self [ 'selinux' ] [ 'status' ] [ 'current_mode' ] || 'unknown'
10651065 end
10661066
10671067 def selinux_policy
1068- node [ 'selinux' ] [ 'status' ] [ 'loaded_policy_name' ]
1068+ self [ 'selinux' ] [ 'status' ] [ 'loaded_policy_name' ]
10691069 end
10701070
10711071 def selinux_enabled?
1072- node [ 'selinux' ] [ 'status' ] [ 'selinux_status' ] == 'enabled'
1072+ self [ 'selinux' ] [ 'status' ] [ 'selinux_status' ] == 'enabled'
10731073 end
10741074
10751075 def host_chef_base_path
1076- if node . windows?
1076+ if self . windows?
10771077 File . join ( 'C:' , 'chef' )
10781078 else
10791079 File . join ( '/var' , 'chef' )
10801080 end
10811081 end
10821082
10831083 def solo_chef_base_path
1084- if node . windows?
1084+ if self . windows?
10851085 File . join ( 'C:' , 'chef' , 'solo' )
10861086 else
10871087 File . join ( '/opt' , 'chef-solo' )
10881088 end
10891089 end
10901090
10911091 def chef_base_path
1092- if node . solo?
1092+ if self . solo?
10931093 self . solo_chef_base_path
10941094 else
10951095 self . host_chef_base_path
@@ -1145,7 +1145,7 @@ def attr_lookup(path, delim: '/', default: nil)
11451145 end
11461146
11471147 def default_package_manager
1148- cls = Chef ::ResourceResolver . resolve ( :package , :node => node )
1148+ cls = Chef ::ResourceResolver . resolve ( :package , :node => self )
11491149 if cls
11501150 m = cls . to_s . match ( /Chef::Resource::(\w +)Package/ )
11511151 if m [ 1 ]
@@ -1163,7 +1163,7 @@ def eth_is_affinitized?
11631163 # mlx is special cased because of their device naming convention
11641164 r = /^(eth(.*[Rr]x|\d +-\d +)|mlx4-\d +@.*|mlx5_comp\d +@.*)/
11651165
1166- irqs = node [ 'interrupts' ] [ 'irq' ] . select do |_irq , v |
1166+ irqs = self [ 'interrupts' ] [ 'irq' ] . select do |_irq , v |
11671167 v [ 'device' ] && r . match? ( v [ 'device' ] ) &&
11681168 v [ 'type' ] && v [ 'type' ] . end_with? ( 'MSI' )
11691169 end
@@ -1174,7 +1174,7 @@ def eth_is_affinitized?
11741174 )
11751175 return true
11761176 end
1177- default_affinity = node [ 'interrupts' ] [ 'smp_affinity_by_cpu' ]
1177+ default_affinity = self [ 'interrupts' ] [ 'smp_affinity_by_cpu' ]
11781178 # When all interrupts are affinitized, smp_affinity will be different
11791179 # from the default one, and won't be global. Global technically says
11801180 # that interrupts can be processed on all CPUs, but in reality what's
@@ -1203,7 +1203,7 @@ def eth_is_affinitized?
12031203 end
12041204
12051205 def validate_and_fail_on_dynamic_addresses
1206- node [ 'network' ] [ 'interfaces' ] . each do |if_str , if_data |
1206+ self [ 'network' ] [ 'interfaces' ] . each do |if_str , if_data |
12071207 next unless if_data [ 'addresses' ]
12081208
12091209 if_data [ 'addresses' ] . each do |addr_str , addr_data |
@@ -1218,23 +1218,23 @@ def validate_and_fail_on_dynamic_addresses
12181218 end
12191219
12201220 def nw_changes_allowed?
1221- method = node [ 'fb_helpers' ] [ 'network_changes_allowed_method' ]
1221+ method = self [ 'fb_helpers' ] [ 'network_changes_allowed_method' ]
12221222 if method
1223- return method . call ( node )
1223+ return method . call ( self )
12241224 else
12251225 return @nw_changes_allowed unless @nw_changes_allowed . nil?
12261226
1227- @nw_changes_allowed = node . firstboot_any_phase? ||
1227+ @nw_changes_allowed = self . firstboot_any_phase? ||
12281228 ::File . exist? ( ::FB ::Helpers ::NW_CHANGES_ALLOWED )
12291229 end
12301230 end
12311231
12321232 # We can change interface configs if nw_changes_allowed? or we are operating
12331233 # on a DSR VIP
12341234 def interface_change_allowed? ( interface )
1235- method = node [ 'fb_helpers' ] [ 'interface_change_allowed_method' ]
1235+ method = self [ 'fb_helpers' ] [ 'interface_change_allowed_method' ]
12361236 if method
1237- return method . call ( node , interface )
1237+ return method . call ( self , interface )
12381238 else
12391239 return self . nw_changes_allowed? ||
12401240 [ 'ip6tnl0' , 'tunlany0' , 'tunl0' ] . include? ( interface ) ||
@@ -1243,9 +1243,9 @@ def interface_change_allowed?(interface)
12431243 end
12441244
12451245 def interface_start_allowed? ( interface )
1246- method = node [ 'fb_helpers' ] [ 'interface_start_allowed_method' ]
1246+ method = self [ 'fb_helpers' ] [ 'interface_start_allowed_method' ]
12471247 if method
1248- return method . call ( node , interface )
1248+ return method . call ( self , interface )
12491249 else
12501250 return self . interface_change_allowed? ( interface )
12511251 end
@@ -1255,7 +1255,7 @@ def interface_start_allowed?(interface)
12551255 # provisioning or upon boot
12561256 def disruptable?
12571257 @disruptable ||=
1258- node . firstboot_any_phase? || ENV [ 'CHEF_BOOT_SERVICE' ] == 'true'
1258+ self . firstboot_any_phase? || ENV [ 'CHEF_BOOT_SERVICE' ] == 'true'
12591259 end
12601260 end
12611261end
0 commit comments