2012-06-08 01:31:37 -05:00
|
|
|
# Authors: Martin Kosek <mkosek@redhat.com>
|
|
|
|
#
|
|
|
|
# Copyright (C) 2012 Red Hat
|
|
|
|
# see file 'COPYING' for use and warranty information
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
#
|
|
|
|
|
|
|
|
import os
|
|
|
|
import os.path
|
|
|
|
|
|
|
|
from ipapython import sysrestore
|
2014-05-29 07:47:17 -05:00
|
|
|
from ipaplatform.paths import paths
|
2015-12-16 12:04:20 -06:00
|
|
|
from ipapython.ipa_log_manager import root_logger
|
2012-06-08 01:31:37 -05:00
|
|
|
|
|
|
|
STATEFILE_FILE = 'sysupgrade.state'
|
|
|
|
|
2014-03-19 06:56:03 -05:00
|
|
|
_sstore = None
|
|
|
|
|
|
|
|
def _load_sstore():
|
|
|
|
global _sstore
|
|
|
|
if _sstore is None:
|
2014-10-03 18:27:57 -05:00
|
|
|
_sstore = sysrestore.StateFile(paths.STATEFILE_DIR, STATEFILE_FILE)
|
2012-06-08 01:31:37 -05:00
|
|
|
|
|
|
|
def get_upgrade_state(module, state):
|
2014-03-19 06:56:03 -05:00
|
|
|
_load_sstore()
|
2012-06-08 01:31:37 -05:00
|
|
|
return _sstore.get_state(module, state)
|
|
|
|
|
|
|
|
def set_upgrade_state(module, state, value):
|
2014-03-19 06:56:03 -05:00
|
|
|
_load_sstore()
|
2012-06-08 01:31:37 -05:00
|
|
|
_sstore.backup_state(module, state, value)
|
|
|
|
|
|
|
|
def remove_upgrade_state(module, state):
|
2014-03-19 06:56:03 -05:00
|
|
|
_load_sstore()
|
2012-06-08 01:31:37 -05:00
|
|
|
_sstore.delete_state(module, state)
|
|
|
|
|
|
|
|
def remove_upgrade_file():
|
|
|
|
try:
|
2014-10-03 18:27:57 -05:00
|
|
|
os.remove(os.path.join(paths.STATEFILE_DIR, STATEFILE_FILE))
|
2015-07-30 09:49:29 -05:00
|
|
|
except Exception as e:
|
2012-06-08 01:31:37 -05:00
|
|
|
root_logger.debug('Cannot remove sysupgrade state file: %s', e)
|