As part of this, made all plugins use a Installer baseclass.
https://fedorahosted.org/ipsilon/ticket/38
Signed-off-by: Patrick Uiterwijk <puiterwijk@redhat.com>
Reviewed-by: Rob Crittenden <rcritten@redhat.com>
FACILITY = 'environment_helpers'
+class EnvHelpersInstaller(object):
+ def __init__(self):
+ self.facility = FACILITY
+ self.ptype = 'helper'
+ self.name = None
+
+ def unconfigure(self, opts):
+ return
+
+ def install_args(self, group):
+ raise NotImplementedError
+
+ def configure_server(self, opts):
+ raise NotImplementedError
+
+
class EnvHelpersInstall(object):
def __init__(self):
import subprocess
import sys
+from ipsilon.helpers.common import EnvHelpersInstaller
+
IPA_CONFIG_FILE = '/etc/ipa/default.conf'
HTTPD_IPA_KEYTAB = '/etc/httpd/conf/ipa.keytab'
"""
-class Installer(object):
+class Installer(EnvHelpersInstaller):
def __init__(self, *pargs):
+ super(Installer, self).__init__()
self.name = 'ipa'
self.ptype = 'helper'
self.logger = None
def install_args(self, group):
raise NotImplementedError
+ def unconfigure(self, opts):
+ return
+
def configure(self, opts):
raise NotImplementedError
except Exception: # pylint: disable=broad-except
pass
+
def uninstall(plugins, args):
logger.info('Uninstallation initiated')
- raise Exception('Not Implemented')
+ instance_conf = os.path.join(CONFDIR, args['instance'])
+
+ httpd_conf = os.path.join(HTTPDCONFD,
+ 'ipsilon-%s.conf' % args['instance'])
+ data_dir = os.path.join(DATADIR, args['instance'])
+
+ if not os.path.exists(instance_conf):
+ raise Exception('Could not find instance %s configuration'
+ % args['instance'])
+ if not os.path.exists(httpd_conf):
+ raise Exception('Could not find instance %s httpd configuration'
+ % args['instance'])
+ if not args['yes']:
+ sure = raw_input(('Are you certain you want to erase instance %s ' +
+ '[yes/NO]: ')
+ % args['instance'])
+ if sure != 'yes':
+ raise Exception('Aborting')
+
+ logger.info('Removing environment helpers')
+ for plugin_name in plugins['Environment Helpers']:
+ plugin = plugins['Environment Helpers'][plugin_name]
+ if plugin.unconfigure(args) == False:
+ print 'Removal of environment helper %s failed' % plugin_name
+
+ logger.info('Removing login managers')
+ for plugin_name in args['lm_order']:
+ plugin = plugins['Login Managers'][plugin_name]
+ if plugin.unconfigure(args) == False:
+ print 'Removal of login manager %s failed' % plugin_name
+
+ logger.info('Removing Info providers')
+ for plugin_name in plugins['Info Provider']:
+ plugin = plugins['Info Provider'][plugin_name]
+ if plugin.unconfigure(args) == False:
+ print 'Removal of info provider %s failed' % plugin_name
+
+ logger.info('Removing Authentication Providers')
+ for plugin_name in plugins['Auth Providers']:
+ plugin = plugins['Auth Providers'][plugin_name]
+ if plugin.unconfigure(args) == False:
+ print 'Removal of auth provider %s failed' % plugin_name
+
+ logger.info('Removing httpd configuration')
+ os.remove(httpd_conf)
+ logger.info('Erasing instance configuration')
+ shutil.rmtree(instance_conf)
+ logger.info('Erasing instance data')
+ shutil.rmtree(data_dir)
+ logger.info('Uninstalled instance %s' % args['instance'])
def find_plugins():
help="Enable debugging")
parser.add_argument('--uninstall', action='store_true',
help="Uninstall the server and all data")
+ parser.add_argument('--yes', action='store_true',
+ help="Always answer yes")
lms = []
logger.info('%s: %s', k, opts[k])
if 'uninstall' in opts and opts['uninstall'] is True:
+ if not os.path.exists(os.path.join(CONFDIR, opts['instance'])):
+ print 'Instance %s could not be found' % opts['instance']
+ sys.exit(0)
uninstall(fplugins, opts)
-
- install(fplugins, opts)
+ else:
+ install(fplugins, opts)
except Exception, e: # pylint: disable=broad-except
logger.exception(e)
if 'uninstall' in opts and opts['uninstall'] is True:
# Copyright (C) 2014 Ipsilon contributors, see COPYING file for license
-from ipsilon.login.common import LoginFormBase, LoginManagerBase
+from ipsilon.login.common import LoginFormBase, LoginManagerBase, \
+ LoginManagerInstaller
from ipsilon.util.plugin import PluginObject
from ipsilon.util.policy import Policy
from ipsilon.util import config as pconfig
return self.page
-class Installer(object):
+class Installer(LoginManagerInstaller):
def __init__(self, *pargs):
+ super(Installer, self).__init__()
self.name = 'fas'
- self.ptype = 'login'
self.pargs = pargs
def install_args(self, group):
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-from ipsilon.login.common import LoginFormBase, LoginManagerBase
+from ipsilon.login.common import LoginFormBase, LoginManagerBase, \
+ LoginManagerInstaller
from ipsilon.util.plugin import PluginObject
from ipsilon.util.user import UserSession
from ipsilon.util import config as pconfig
"""
-class Installer(object):
+class Installer(LoginManagerInstaller):
def __init__(self, *pargs):
+ super(Installer, self).__init__()
self.name = 'form'
- self.ptype = 'login'
self.pargs = pargs
def install_args(self, group):
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-from ipsilon.login.common import LoginPageBase, LoginManagerBase
+from ipsilon.login.common import LoginPageBase, LoginManagerBase, \
+ LoginManagerInstaller
from ipsilon.util.plugin import PluginObject
from ipsilon.util.user import UserSession
from string import Template
"""
-class Installer(object):
+class Installer(LoginManagerInstaller):
def __init__(self, *pargs):
+ super(Installer, self).__init__()
self.name = 'krb'
- self.ptype = 'login'
self.pargs = pargs
def install_args(self, group):
# Copyright (C) 2014 Ipsilon Contributors, see COPYING for license
-from ipsilon.login.common import LoginFormBase, LoginManagerBase
+from ipsilon.login.common import LoginFormBase, LoginManagerBase, \
+ LoginManagerInstaller
from ipsilon.util.plugin import PluginObject
from ipsilon.util.log import Log
from ipsilon.util import config as pconfig
return self.page
-class Installer(object):
+class Installer(LoginManagerInstaller):
def __init__(self, *pargs):
+ super(Installer, self).__init__()
self.name = 'ldap'
- self.ptype = 'login'
self.pargs = pargs
def install_args(self, group):
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-from ipsilon.login.common import LoginFormBase, LoginManagerBase
+from ipsilon.login.common import LoginFormBase, LoginManagerBase, \
+ LoginManagerInstaller
from ipsilon.util.plugin import PluginObject
from ipsilon.util import config as pconfig
import pam
return self.page
-class Installer(object):
+class Installer(LoginManagerInstaller):
def __init__(self, *pargs):
+ super(Installer, self).__init__()
self.name = 'pam'
- self.ptype = 'login'
self.pargs = pargs
def install_args(self, group):
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-from ipsilon.login.common import LoginFormBase, LoginManagerBase
+from ipsilon.login.common import LoginFormBase, LoginManagerBase, \
+ LoginManagerInstaller
from ipsilon.util.plugin import PluginObject
from ipsilon.util import config as pconfig
import cherrypy
return self.page
-class Installer(object):
+class Installer(LoginManagerInstaller):
def __init__(self, *pargs):
+ super(Installer, self).__init__()
self.name = 'testauth'
- self.ptype = 'login'
self.pargs = pargs
def install_args(self, group):
return op(*args, **kwargs)
+class LoginManagerInstaller(object):
+ def __init__(self):
+ self.facility = FACILITY
+ self.ptype = 'login'
+ self.name = None
+
+ def unconfigure(self, opts):
+ return
+
+ def install_args(self, group):
+ raise NotImplementedError
+
+ def configure(self, opts):
+ raise NotImplementedError
+
+
class LoginMgrsInstall(object):
def __init__(self):
FACILITY = 'provider_config'
+class ProviderInstaller(object):
+ def __init__(self):
+ self.facility = FACILITY
+ self.ptype = 'provider'
+ self.name = None
+
+ def unconfigure(self, opts):
+ return
+
+ def install_args(self, group):
+ raise NotImplementedError
+
+ def configure(self, opts):
+ raise NotImplementedError
+
+
class LoadProviders(Log):
def __init__(self, root, site):
from __future__ import absolute_import
-from ipsilon.providers.common import ProviderBase
+from ipsilon.providers.common import ProviderBase, ProviderInstaller
from ipsilon.providers.openid.store import OpenIDStore
from ipsilon.providers.openid.auth import OpenID
from ipsilon.providers.openid.extensions.common import LoadExtensions
self.extensions.enable(self._config['enabled extensions'].get_value())
-class Installer(object):
+class Installer(ProviderInstaller):
def __init__(self, *pargs):
+ super(Installer, self).__init__()
self.name = 'openid'
- self.ptype = 'provider'
self.pargs = pargs
def install_args(self, group):
from __future__ import absolute_import
-from ipsilon.providers.common import ProviderBase
+from ipsilon.providers.common import ProviderBase, ProviderInstaller
from ipsilon.util.plugin import PluginObject
from ipsilon.util import config as pconfig
from ipsilon.info.common import InfoMapping
self.init_idp()
-class Installer(object):
+class Installer(ProviderInstaller):
def __init__(self, *pargs):
+ super(Installer, self).__init__()
self.name = 'persona'
- self.ptype = 'provider'
self.pargs = pargs
def install_args(self, group):
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-from ipsilon.providers.common import ProviderBase, ProviderPageBase
+from ipsilon.providers.common import ProviderBase, ProviderPageBase, \
+ ProviderInstaller
from ipsilon.providers.saml2.auth import AuthenticateRequest
from ipsilon.providers.saml2.logout import LogoutRequest
from ipsilon.providers.saml2.admin import Saml2AdminPage
return self.meta.output(path)
-class Installer(object):
+class Installer(ProviderInstaller):
def __init__(self, *pargs):
+ super(Installer, self).__init__()
self.name = 'saml2'
- self.ptype = 'provider'
self.pargs = pargs
def install_args(self, group):