SHA256
1
0
forked from pool/salt
salt/_service:extract_file:zyppnotify
Klaus Kämpf e628fd1d19 Accepting request 540260 from systemsmanagement:saltstack:products:unstable.py3
- Update to 2017.7.2
  See https://docs.saltstack.com/en/latest/topics/releases/2017.7.2.html
- Added:
 * enable-with-salt-version-parameter-for-setup.py-scri.patch
- Removed:
 * add-a-salt-minion-service-control-file.patch
 * add-clean_id-function-to-salt.utils.verify.py.patch
 * add-options-for-dockerng.patch
 * add-ssh-option-to-salt-ssh.patch
 * add-unit-test-for-skip-false-values-from-preferred_i.patch
 * add-yum-plugin.patch
 * add-zypp-notify-plugin.patch
 * adding-salt-minion-watchdog-for-sysv-systems-rhel6-a.patch
 * adding-support-for-installing-patches-in-yum-dnf-exe.patch
 * avoid-failures-on-sles-12-sp2-because-of-new-systemd.patch
 * bugfix-jobs-scheduled-to-run-at-a-future-time-stay-p.patch
 * bugfix-unable-to-use-127-as-hostname.patch
 * catching-error-when-pidfile-cannot-be-deleted.patch
 * change-travis-configuration-file-to-use-salt-toaster.patch
 * check-if-byte-strings-are-properly-encoded-in-utf-8.patch
 * clean-up-change-attribute-from-interface-dict.patch
 * do-not-generate-a-date-in-a-comment-to-prevent-rebui.patch
 * enables-salt-minion-watchdog-on-init.d-script-for-sy.patch
 * escape-the-os.sep.patch
 * fix-for-delete_deployment-in-kubernetes-module.patch
 * fix-format-error-bsc-1043111.patch
 * fix-grain-for-os_family-on-suse-series.patch
 * fix-os_family-case-in-unittest.patch
 * fix-regression-in-file.get_managed-add-unit-tests.patch
 * fix-salt-summary-to-count-not-responding-minions-cor.patch

OBS-URL: https://build.opensuse.org/request/show/540260
OBS-URL: https://build.opensuse.org/package/show/systemsmanagement:saltstack/salt?expand=0&rev=98
2017-11-10 07:17:55 +00:00

60 lines
1.5 KiB
Python

#!/usr/bin/python
#
# Copyright (c) 2016 SUSE Linux LLC
# All Rights Reserved.
#
# Author: Bo Maryniuk <bo@suse.de>
import sys
import os
import hashlib
from zypp_plugin import Plugin
class DriftDetector(Plugin):
"""
Return diff of the installed packages outside the Salt.
"""
def __init__(self):
Plugin.__init__(self)
self.ck_path = "/var/cache/salt/minion/rpmdb.cookie"
self.rpm_path = "/var/lib/rpm/Packages"
def _get_mtime(self):
'''
Get the modified time of the RPM Database.
Returns:
Unix ticks
'''
return os.path.exists(self.rpm_path) and int(os.path.getmtime(self.rpm_path)) or 0
def _get_checksum(self):
'''
Get the checksum of the RPM Database.
Returns:
hexdigest
'''
digest = hashlib.md5()
with open(self.rpm_path, "rb") as rpm_db_fh:
while True:
buff = rpm_db_fh.read(0x1000)
if not buff:
break
digest.update(buff)
return digest.hexdigest()
def PLUGINEND(self, headers, body):
"""
Hook when plugin closes Zypper's transaction.
"""
if 'SALT_RUNNING' not in os.environ:
with open(self.ck_path, 'w') as ck_fh:
ck_fh.write('{chksum} {mtime}\n'.format(chksum=self._get_checksum(), mtime=self._get_mtime()))
self.ack()
DriftDetector().main()