Patch init grain

e9
Erik Johnson 9 years ago
parent 60989dcd14
commit 75232878d1

@ -1,3 +1,57 @@
diff -ur a/salt/grains/core.py b/salt/grains/core.py
--- a/salt/grains/core.py 2015-07-07 15:42:37.000000000 -0500
+++ b/salt/grains/core.py 2015-07-10 16:24:29.097483841 -0500
@@ -1042,28 +1042,29 @@
with salt.utils.fopen('/proc/1/cmdline') as fhr:
init_cmdline = fhr.read().replace('\x00', ' ').split()
init_bin = salt.utils.which(init_cmdline[0])
- supported_inits = ('upstart', 'sysvinit', 'systemd')
- edge_len = max(len(x) for x in supported_inits) - 1
- buf_size = __opts__['file_buffer_size']
- try:
- with open(init_bin, 'rb') as fp_:
- buf = True
- edge = ''
- buf = fp_.read(buf_size).lower()
- while buf:
- buf = edge + buf
- for item in supported_inits:
- if item in buf:
- grains['init'] = item
- buf = ''
- break
- edge = buf[-edge_len:]
+ if init_bin:
+ supported_inits = ('upstart', 'sysvinit', 'systemd')
+ edge_len = max(len(x) for x in supported_inits) - 1
+ buf_size = __opts__['file_buffer_size']
+ try:
+ with open(init_bin, 'rb') as fp_:
+ buf = True
+ edge = ''
buf = fp_.read(buf_size).lower()
- except (IOError, OSError) as exc:
- log.error(
- 'Unable to read from init_bin ({0}): {1}'
- .format(init_bin, exc)
- )
+ while buf:
+ buf = edge + buf
+ for item in supported_inits:
+ if item in buf:
+ grains['init'] = item
+ buf = ''
+ break
+ edge = buf[-edge_len:]
+ buf = fp_.read(buf_size).lower()
+ except (IOError, OSError) as exc:
+ log.error(
+ 'Unable to read from init_bin ({0}): {1}'
+ .format(init_bin, exc)
+ )
# Add lsb grains on any distro with lsb-release
try:
diff -ur a/tests/unit/modules/artifactory_test.py b/tests/unit/modules/artifactory_test.py
--- a/tests/unit/modules/artifactory_test.py 2015-07-07 15:42:37.000000000 -0500
+++ b/tests/unit/modules/artifactory_test.py 2015-07-10 12:11:33.942671443 -0500

@ -455,7 +455,10 @@ rm -rf %{buildroot}
%endif
%changelog
* Mon Jun 4 2015 Erik Johnson <erik@saltstack.com> - 2015.5.3-2
* Fri Jul 10 2015 Erik Johnson <erik@saltstack.com> - 2015.5.3-3
- Patch init grain
* Fri Jul 10 2015 Erik Johnson <erik@saltstack.com> - 2015.5.3-2
- Update to bugfix release 2015.5.3, add bash completion
* Fri Jun 19 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 2015.5.2-4

Loading…
Cancel
Save