Example #1
0
def uninstall(opts):
    for src, dst in getlinks():
        environment.debug(opts, 'removing link: %s' % dst)
        if not os.path.islink(dst):
            environment.debug(opts, '%s does not exist, skipping' % dst)
            continue
        os.unlink(dst)

    environment.uninstall_files(get_paths_to_copy(), opts)

    # Link between pulp and apache
    if os.path.exists('/var/www/pub'):
        os.unlink('/var/www/pub')

    # Old link between pulp and apache, make sure it's cleaned up
    if os.path.exists('/var/www/html/pub'):
        os.unlink('/var/www/html/pub')

    # Remove generated certificates
    print 'removing certificates'
    os.system('rm -rf /etc/pki/pulp/*')

    # Remove the Python packages
    environment.manage_setup_pys('uninstall')

    if LSB_VERSION >= 6.0:
        # Reload systemd unit files
        os.system('systemctl daemon-reload')

    return os.EX_OK
Example #2
0
def create_link(opts, src, dst):
    if not os.path.lexists(dst):
        return _create_link(opts, src, dst)

    if not os.path.islink(dst):
        return "[%s] is not a symbolic link as we expected, " \
               "please adjust if this is not what you intended." % dst

    if not os.path.exists(os.readlink(dst)):
        environment.warning('BROKEN LINK: [%s] attempting to delete and fix it to point to %s.' % (dst, src))
        try:
            os.unlink(dst)
            return _create_link(opts, src, dst)
        except:
            msg = "[%s] was a broken symlink, failed to delete " \
                  "and relink to [%s], please fix this manually" % (dst, src)
            return msg

    environment.debug(opts, 'verifying link: %s points to %s' % (dst, src))
    dst_stat = os.stat(dst)
    src_stat = os.stat(src)
    if dst_stat.st_ino != src_stat.st_ino:
        msg = "[%s] is pointing to [%s] which is different than " \
              "the intended target [%s]" % (dst, os.readlink(dst), src)
        return msg
Example #3
0
def uninstall(opts):
    for src, dst in getlinks():
        environment.debug(opts, 'removing link: %s' % dst)
        if not os.path.islink(dst):
            environment.debug(opts, '%s does not exist, skipping' % dst)
            continue
        os.unlink(dst)

    environment.uninstall_files(get_paths_to_copy(), opts)

    # Link between pulp and apache
    if os.path.exists('/var/www/pub'):
        os.unlink('/var/www/pub')

    # Old link between pulp and apache, make sure it's cleaned up
    if os.path.exists('/var/www/html/pub'):
        os.unlink('/var/www/html/pub')

    # Remove generated certificates
    print 'removing certificates'
    os.system('rm -rf /etc/pki/pulp/*')

    # Remove the Python packages
    environment.manage_setup_pys('uninstall')

    return os.EX_OK
Example #4
0
def create_dirs(opts):
    for d in DIRS:
        if os.path.exists(d) and os.path.isdir(d):
            environment.debug(opts, 'skipping %s exists' % d)
            continue
        environment.debug(opts, 'creating directory: %s' % d)
        os.makedirs(d, 0777)
Example #5
0
def create_link(opts, src, dst):
    if not os.path.lexists(dst):
        return _create_link(opts, src, dst)

    if not os.path.islink(dst):
        return "[%s] is not a symbolic link as we expected, " \
               "please adjust if this is not what you intended." % dst

    if not os.path.exists(os.readlink(dst)):
        environment.warning(
            'BROKEN LINK: [%s] attempting to delete and fix it to point to %s.'
            % (dst, src))
        try:
            os.unlink(dst)
            return _create_link(opts, src, dst)
        except:
            msg = "[%s] was a broken symlink, failed to delete " \
                  "and relink to [%s], please fix this manually" % (dst, src)
            return msg

    environment.debug(opts, 'verifying link: %s points to %s' % (dst, src))
    dst_stat = os.stat(dst)
    src_stat = os.stat(src)
    if dst_stat.st_ino != src_stat.st_ino:
        msg = "[%s] is pointing to [%s] which is different than " \
              "the intended target [%s]" % (dst, os.readlink(dst), src)
        return msg
Example #6
0
def create_dirs(opts):
    for d in DIRS:
        if os.path.exists(d) and os.path.isdir(d):
            environment.debug(opts, 'skipping %s exists' % d)
            continue
        environment.debug(opts, 'creating directory: %s' % d)
        os.makedirs(d, 0777)
Example #7
0
def _create_link(opts, src, dst):
    environment.debug(opts, 'creating link: %s pointing to %s' % (dst, src))
    try:
        os.symlink(src, dst)
    except OSError, e:
        msg = "Unable to create symlink for [%s] pointing to [%s], " \
              "received error: <%s>" % (dst, src, e)
        return msg
Example #8
0
def _create_link(opts, src, dst):
    environment.debug(opts, 'creating link: %s pointing to %s' % (dst, src))
    try:
        os.symlink(src, dst)
    except OSError, e:
        msg = "Unable to create symlink for [%s] pointing to [%s], " \
              "received error: <%s>" % (dst, src, e)
        return msg
Example #9
0
def apf_startup():
	environment.debug('Starting ASF')
	if parse_cli_args():
		apf_shutdown()
	for i in os.listdir(environment.cwd):
		if os.path.isdir(i):
			if 'sourcing.py' in os.listdir(i):
				environment.modules.append(os.path.join(environment.cwd, i))
	
	environment.debug('List of all modules that will be analyzed by the auto learner/model maker:')
	for module in environment.modules:
		environment.debug(module)
	environment.debug()
	for module in environment.modules:
		environment.current_module = module
		module_start()
		module_stop()
Example #10
0
def module_start():
	environment.debug('Starting module ' + environment.current_module)
	sys.path.append(environment.current_module)
	import sourcing
	loader.load(environment, sourcing)
	del sourcing
Example #11
0
def apf_shutdown(code=0):
	#Will be properly rewritten later for a graceful shutdown
	environment.debug('ASF shutdown')
	exit(code)
Example #12
0
def module_stop():
	environment.debug('Stopping module '+environment.current_module)
	sys.path.remove(environment.current_module)