remove environment_check stuff
This commit is contained in:
parent
5dca5e861e
commit
b24dbf7095
|
@ -20,20 +20,6 @@ import logging
|
|||
from subiquitycore.log import setup_logger
|
||||
from subiquitycore import __version__ as VERSION
|
||||
from console_conf.core import ConsoleConf
|
||||
from subiquitycore.utils import environment_check
|
||||
|
||||
|
||||
# Does console-conf actually need any of this?
|
||||
ENVIRONMENT = '''
|
||||
checks:
|
||||
write:
|
||||
directory:
|
||||
- /tmp
|
||||
mount:
|
||||
directory:
|
||||
- /proc
|
||||
- /sys
|
||||
'''
|
||||
|
||||
|
||||
class ClickAction(argparse.Action):
|
||||
|
@ -75,17 +61,11 @@ def main():
|
|||
global LOGDIR
|
||||
if opts.dry_run:
|
||||
LOGDIR = ".subiquity"
|
||||
LOGFILE = setup_logger(dir=LOGDIR)
|
||||
setup_logger(dir=LOGDIR)
|
||||
logger = logging.getLogger('console_conf')
|
||||
logger.info("Starting console-conf v{}".format(VERSION))
|
||||
logger.info("Arguments passed: {}".format(sys.argv))
|
||||
|
||||
env_ok = environment_check(ENVIRONMENT)
|
||||
if env_ok is False and not opts.dry_run:
|
||||
print('Failed environment check. '
|
||||
'Check {} for errors.'.format(LOGFILE))
|
||||
return 1
|
||||
|
||||
interface = ConsoleConf(opts)
|
||||
interface.run()
|
||||
|
||||
|
|
|
@ -22,26 +22,10 @@ import sys
|
|||
|
||||
from subiquitycore.log import setup_logger
|
||||
from subiquitycore import __version__ as VERSION
|
||||
from subiquitycore.utils import environment_check
|
||||
|
||||
from subiquity.core import Subiquity
|
||||
|
||||
|
||||
ENVIRONMENT = '''
|
||||
checks:
|
||||
read:
|
||||
file:
|
||||
- /var/log/syslog
|
||||
write:
|
||||
directory:
|
||||
- /tmp
|
||||
mount:
|
||||
directory:
|
||||
- /proc
|
||||
- /sys
|
||||
'''
|
||||
|
||||
|
||||
class ClickAction(argparse.Action):
|
||||
def __call__(self, parser, namespace, values, option_string=None):
|
||||
namespace.scripts.append("c(" + repr(values) + ")")
|
||||
|
@ -106,7 +90,7 @@ def main():
|
|||
LOGDIR = ".subiquity"
|
||||
if opts.snaps_from_examples is None:
|
||||
opts.snaps_from_examples = True
|
||||
LOGFILE = setup_logger(dir=LOGDIR)
|
||||
setup_logger(dir=LOGDIR)
|
||||
|
||||
logger = logging.getLogger('subiquity')
|
||||
logger.info("Starting SUbiquity v{}".format(VERSION))
|
||||
|
@ -123,12 +107,6 @@ def main():
|
|||
logging.getLogger('curtin').addHandler(handler)
|
||||
logging.getLogger('block-discover').addHandler(handler)
|
||||
|
||||
env_ok = environment_check(ENVIRONMENT)
|
||||
if env_ok is False and not opts.dry_run:
|
||||
print('Failed environment check. '
|
||||
'Check {} for errors.'.format(LOGFILE))
|
||||
return 1
|
||||
|
||||
if opts.answers is None and os.path.exists(AUTO_ANSWERS_FILE):
|
||||
logger.debug("Autoloading answers from %s", AUTO_ANSWERS_FILE)
|
||||
opts.answers = AUTO_ANSWERS_FILE
|
||||
|
|
|
@ -17,79 +17,9 @@ import crypt
|
|||
import logging
|
||||
import os
|
||||
import random
|
||||
import yaml
|
||||
import subprocess
|
||||
|
||||
log = logging.getLogger("subiquitycore.utils")
|
||||
SYS_CLASS_NET = "/sys/class/net/"
|
||||
|
||||
|
||||
def environment_check(check):
|
||||
''' Check the environment to ensure subiquity can run without issues.
|
||||
'''
|
||||
log.info('Checking environment for installer requirements...')
|
||||
|
||||
def is_file(x):
|
||||
return os.path.isfile(x)
|
||||
|
||||
def is_directory(x):
|
||||
return os.path.isdir(x)
|
||||
|
||||
def is_mount(x):
|
||||
return os.path.ismount(x)
|
||||
|
||||
def is_writable(x):
|
||||
return os.access(x, os.W_OK)
|
||||
|
||||
def is_readable(x):
|
||||
return os.access(x, os.R_OK)
|
||||
|
||||
def is_executable(x):
|
||||
return os.access(x, os.X_OK)
|
||||
|
||||
check_map = {
|
||||
'read': is_readable,
|
||||
'write': is_writable,
|
||||
'exec': is_executable,
|
||||
'file': is_file,
|
||||
'directory': is_directory,
|
||||
'mount': is_mount,
|
||||
}
|
||||
|
||||
checks = yaml.safe_load(check).get('checks', None)
|
||||
if not checks:
|
||||
log.error('Invalid environment check configuration')
|
||||
return False
|
||||
|
||||
env_ok = True
|
||||
for check_type in [c for c in checks
|
||||
if c in ['read', 'write', 'mount', 'exec']]:
|
||||
for ftype, items in checks[check_type].items():
|
||||
for i in items:
|
||||
if not os.path.exists(i):
|
||||
if 'SNAP' in os.environ:
|
||||
log.warn("Adjusting path for snaps: %s",
|
||||
os.environ.get('SNAP'))
|
||||
i = os.environ.get('SNAP') + i
|
||||
if not os.path.exists(i):
|
||||
env_ok = False
|
||||
else:
|
||||
env_ok = False
|
||||
|
||||
if not env_ok:
|
||||
log.error('FAIL: {} is not found on the'
|
||||
' filesystem'.format(i))
|
||||
continue
|
||||
if check_map[ftype](i) is False:
|
||||
log.error('FAIL: {} is NOT of type: {}'.format(i, ftype))
|
||||
env_ok = False
|
||||
continue
|
||||
if check_map[check_type](i) is False:
|
||||
log.error('FAIL: {} does NOT have required attr:'
|
||||
' {}'.format(i, check_type))
|
||||
env_ok = False
|
||||
|
||||
return env_ok
|
||||
|
||||
|
||||
def _clean_env(env):
|
||||
|
|
Loading…
Reference in New Issue