예제 #1
0
    def next_page(self, load_page_callback):
        if self.unlink_ldap == True or self.unlink_ad == True:
            messages = []
            # TODO Implements unlink from ldap or ad into serverconf class
            if self.unlink_ldap:
                messages += serverconf.unlink_from_sssd()
            else:
                messages += serverconf.unlink_from_sssd()
            result = len(messages) == 0
            if result:
                server_conf = serverconf.get_server_conf(None)
                auth_conf = server_conf.get_auth_conf()
                content = serverconf.get_json_content()
                if content != None:
                    auth_conf_cached = AuthConf.AuthConf()
                    auth_conf_cached.load_data(content['auth'])
                    server_conf.set_auth_conf(auth_conf_cached)
                else:
                    server_conf.set_auth_conf(AuthConf.AuthConf())

                if self.unlink_ldap:
                    auth_conf.set_auth_type('ldap')
                    #os.remove(__LDAP_FLAG__)
                else:
                    auth_conf.set_auth_type('ad')
                    #os.remove(__AD_FLAG__)

            auth_conf.set_auth_link(False)
            load_page_callback(LinkToServerResultsPage, {
                'result': True,
                'messages': None
            })
            return

        if self.ui.radioNone.get_active() or (self.ldap_is_configured
                                              or self.ad_is_configured):
            if self.ui.radioNone.get_active():
                server_conf = serverconf.get_server_conf(None)
                server_conf.set_auth_conf(AuthConf.AuthConf())
            self.emit('status-changed', 'linkToServer', True)
            load_page_callback(firstboot.pages.localUsers)
            return

        self.show_status()

        try:
            server_conf = serverconf.get_server_conf(None)

            load_page_callback(
                LinkToServerConfEditorPage, {
                    'ldap_is_configured': self.ldap_is_configured,
                    'auth_method': self.get_auth_method(),
                    'ad_is_configured': self.ad_is_configured,
                })

        except serverconf.ServerConfException as e:
            self.show_status(__STATUS_ERROR__, e)

        except Exception as e:
            self.show_status(__STATUS_ERROR__, e)
예제 #2
0
    def next_page(self, load_page_callback):
        if self.unlink_ldap == True or self.unlink_ad == True:
            messages = []
# TODO Implements unlink from ldap or ad into serverconf class
            if self.unlink_ldap:
                messages += serverconf.unlink_from_sssd()
            else:
                messages += serverconf.unlink_from_sssd()
            result = len(messages) == 0
            if result:
                server_conf = serverconf.get_server_conf(None)
                auth_conf = server_conf.get_auth_conf()
                content = serverconf.get_json_content()
                if content != None:
                    auth_conf_cached = AuthConf.AuthConf()
                    auth_conf_cached.load_data(content['auth'])
                    server_conf.set_auth_conf(auth_conf_cached)
                else:
                    server_conf.set_auth_conf(AuthConf.AuthConf())

                if self.unlink_ldap:
                    auth_conf.set_auth_type('ldap')
                    #os.remove(__LDAP_FLAG__)
                else:
                    auth_conf.set_auth_type('ad')
                    #os.remove(__AD_FLAG__)

            auth_conf.set_auth_link(False)
            load_page_callback(LinkToServerResultsPage, {
                'result': True,
                'messages': None
            })
            return
        
        if self.ui.radioNone.get_active() or (self.ldap_is_configured or self.ad_is_configured):
            if self.ui.radioNone.get_active():
                server_conf = serverconf.get_server_conf(None)
                server_conf.set_auth_conf(AuthConf.AuthConf())
            self.emit('status-changed', 'linkToServer', True)
            load_page_callback(firstboot.pages.localUsers)
            return

        self.show_status()

        try:
            server_conf = serverconf.get_server_conf(None)

            load_page_callback(LinkToServerConfEditorPage, {
                'ldap_is_configured': self.ldap_is_configured,
                'auth_method': self.get_auth_method(),
                'ad_is_configured': self.ad_is_configured,
            })

        except serverconf.ServerConfException as e:
            self.show_status(__STATUS_ERROR__, e)

        except Exception as e:
            self.show_status(__STATUS_ERROR__, e)
예제 #3
0
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This software 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 package; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

__author__ = "Antonio Hernández <*****@*****.**>"
__copyright__ = "Copyright (C) 2011, Junta de Andalucía <*****@*****.**>"
__license__ = "GPL-2"


import network
import dateSync
import pcLabel
import linkToServer
import localUsers
import installSoftware
from firstboot import serverconf

content = serverconf.get_json_content()
#Fist initialization of ServerConf if the json is cached
sc = serverconf.get_server_conf(content)

pages = ['network','autoConfig','dateSync','pcLabel', 'linkToChef', 'linkToServer', 'localUsers', 'installSoftware']
예제 #4
0
#
# This software 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 package; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

__author__ = "Antonio Hernández <*****@*****.**>"
__copyright__ = "Copyright (C) 2011, Junta de Andalucía <*****@*****.**>"
__license__ = "GPL-2"

import network
import dateSync
import pcLabel
import linkToServer
import localUsers
import installSoftware
from firstboot import serverconf

content = serverconf.get_json_content()
#Fist initialization of ServerConf if the json is cached
sc = serverconf.get_server_conf(content)

pages = [
    'network', 'autoConfig', 'dateSync', 'pcLabel', 'linkToChef',
    'linkToServer', 'localUsers', 'installSoftware'
]
    def next_page(self, load_page_callback):
        if (self.ui.chkLinkChef.get_visible() and not self.ui.chkLinkChef.get_active()) or \
            (self.gcc_is_configured and not self.ui.chkUnlinkChef.get_active()):
            self.emit('status-changed', 'linkToChef', True)
            load_page_callback(firstboot.pages.linkToServer)
            return
        self.show_status()
        try:
            server_conf = None

            if not self.gcc_is_configured:
                load_page_callback(LinkToChefConfEditorPage)

            elif self.ui.chkUnlinkChef.get_active():
                server_conf = serverconf.get_server_conf(None)
                ## TODO Implement unlink GCC an Chef into serverconf Class
                gcc_flag = open(__GCC_FLAG__, 'r')
                content = gcc_flag.read()
                gcc_flag.close()
                gcc_flag_json = json.loads(content)
                server_conf.get_gcc_conf().set_uri_gcc(
                    gcc_flag_json['uri_gcc'])
                server_conf.get_gcc_conf().set_gcc_nodename(
                    gcc_flag_json['gcc_nodename'])
                server_conf.get_gcc_conf().set_gcc_link(False)
                server_conf.get_gcc_conf().set_run(True)
                json_server = serverconf.validate_credentials(
                    gcc_flag_json['uri_gcc'] + '/auth/config/')
                json_server = json.loads(json_server)
                pem = json_server['chef']['chef_validation']
                server_conf.get_gcc_conf().set_gcc_username(
                    json_server['gcc']['gcc_username'])
                serverconf.create_pem(pem)

                chef_flag = open(__CHEF_FLAG__, 'r')
                content = chef_flag.read()
                chef_flag.close()
                chef_flag_json = json.loads(content)
                server_conf.get_chef_conf().set_url(
                    chef_flag_json['chef_server_url'])
                server_conf.get_chef_conf().set_node_name(
                    chef_flag_json['chef_node_name'])
                server_conf.get_chef_conf().set_admin_name(
                    json_server['gcc']['gcc_username'])
                server_conf.get_chef_conf().set_chef_link(False)
                password = serverconf.ACTUAL_USER[1]
                if password == None:
                    raise Exception(_('Error in user and password'))
                messages = []
                messages += serverconf.unlink_from_gcc(password)
                messages += serverconf.unlink_from_chef()
                result = len(messages) == 0
                if result:
                    content = serverconf.get_json_content()
                    if content != None:
                        gcc_conf_cached = GCCConf.GCCConf()
                        gcc_conf_cached.load_data(content['gcc'])
                        chef_conf_cached = ChefConf.ChefConf()
                        chef_conf_cached.load_data(content['chef'])
                        server_conf.set_chef_conf(chef_conf_cached)
                        server_conf.set_gcc_conf(gcc_conf_cached)
                    else:
                        server_conf.set_chef_conf(ChefConf.ChefConf())
                        server_conf.set_gcc_conf(GCCConf.GCCConf())
                load_page_callback(LinkToChefResultsPage, {
                    'result': True,
                    'messages': messages
                })

        except serverconf.ServerConfException as e:
            self.show_status(__STATUS_ERROR__, e)

        except Exception as e:
            self.show_status(__STATUS_ERROR__, e)
예제 #6
0
    def next_page(self, load_page_callback):
        if (self.ui.chkLinkChef.get_visible() and not self.ui.chkLinkChef.get_active()) or \
            (self.gcc_is_configured and not self.ui.chkUnlinkChef.get_active()):
            self.emit('status-changed', 'linkToChef', True)
            load_page_callback(firstboot.pages.linkToServer)
            return
        self.show_status()
        try:
            server_conf = None

            if not self.gcc_is_configured:
                load_page_callback(LinkToChefConfEditorPage)

            elif self.ui.chkUnlinkChef.get_active():
                server_conf = serverconf.get_server_conf(None)
                ## TODO Implement unlink GCC an Chef into serverconf Class
                gcc_flag = open(__GCC_FLAG__, 'r')
                content = gcc_flag.read()
                gcc_flag.close()
                gcc_flag_json = json.loads(content)
                server_conf.get_gcc_conf().set_uri_gcc(gcc_flag_json['uri_gcc'])
                server_conf.get_gcc_conf().set_gcc_nodename(gcc_flag_json['gcc_nodename'])
                server_conf.get_gcc_conf().set_gcc_link(False)
                server_conf.get_gcc_conf().set_run(True)
                json_server = serverconf.validate_credentials(gcc_flag_json['uri_gcc']+'/auth/config/')
                json_server = json.loads(json_server)
                pem = json_server['chef']['chef_validation']
                server_conf.get_gcc_conf().set_gcc_username(json_server['gcc']['gcc_username'])
                serverconf.create_pem(pem)
 
                chef_flag = open(__CHEF_FLAG__, 'r')
                content = chef_flag.read()
                chef_flag.close()
                chef_flag_json = json.loads(content)
                server_conf.get_chef_conf().set_url(chef_flag_json['chef_server_url'])
                server_conf.get_chef_conf().set_node_name(chef_flag_json['chef_node_name'])
                server_conf.get_chef_conf().set_admin_name(json_server['gcc']['gcc_username'])
                server_conf.get_chef_conf().set_chef_link(False)
                password = serverconf.ACTUAL_USER[1]
                if password == None:
                   raise Exception(_('Error in user and password'))
                messages = []
                messages += serverconf.unlink_from_gcc(password)
                messages += serverconf.unlink_from_chef()
                result = len(messages) == 0
                if result:
                    content = serverconf.get_json_content()
                    if content != None:
                        gcc_conf_cached = GCCConf.GCCConf()
                        gcc_conf_cached.load_data(content['gcc'])
                        chef_conf_cached = ChefConf.ChefConf()
                        chef_conf_cached.load_data(content['chef'])
                        server_conf.set_chef_conf(chef_conf_cached)
                        server_conf.set_gcc_conf(gcc_conf_cached)
                    else:
                        server_conf.set_chef_conf(ChefConf.ChefConf())
                        server_conf.set_gcc_conf(GCCConf.GCCConf())
                load_page_callback(LinkToChefResultsPage, {
                    'result': True,
                    'messages': messages
                })

        except serverconf.ServerConfException as e:
            self.show_status(__STATUS_ERROR__, e)

        except Exception as e:
            self.show_status(__STATUS_ERROR__, e)
예제 #7
0
    def next_page(self, load_page_callback):

        if self.unlink_ldap == True or self.unlink_ad == True:
            messages = []

            auth_flag = open(__AUTH_FLAG__, 'r')
            content = auth_flag.read()
            auth_flag.close()
            auth_flag_json = json.loads(content)
            server_conf = serverconf.get_server_conf(None)
            server_conf.get_auth_conf().set_auth_type(
                auth_flag_json['auth_type'])
            if auth_flag_json['auth_type'] == 'ad':
                retval = serverconf.auth_dialog(
                    _('Authentication Required'),
                    _('Please, provide administration credentials for the Active Directory.'
                      ))
                ad_conf = server_conf.get_auth_conf().get_auth_properties()
                ad_conf.get_ad_properties().set_user_ad(retval[0])
                ad_conf.get_ad_properties().set_passwd_ad(retval[1])
                messages += serverconf.unlink_from_sssd()

            result = len(messages) == 0
            if result:
                server_conf = serverconf.get_server_conf(None)
                auth_conf = server_conf.get_auth_conf()
                content = serverconf.get_json_content()
                if content != None:
                    auth_conf_cached = AuthConf.AuthConf()
                    auth_conf_cached.load_data(content['auth'])
                    server_conf.set_auth_conf(auth_conf_cached)
                else:
                    server_conf.set_auth_conf(AuthConf.AuthConf())

                if self.unlink_ldap:
                    auth_conf.set_auth_type('ldap')
                    #os.remove(__LDAP_FLAG__)
                else:
                    auth_conf.set_auth_type('ad')
                    #os.remove(__AD_FLAG__)

            auth_conf.set_auth_link(False)
            load_page_callback(LinkToServerResultsPage, {
                'result': True,
                'messages': None
            })
            return

        if self.ui.radioNone.get_active() or (self.ldap_is_configured
                                              or self.ad_is_configured):
            if self.ui.radioNone.get_active():
                server_conf = serverconf.get_server_conf(None)
                server_conf.set_auth_conf(AuthConf.AuthConf())
            self.emit('status-changed', 'linkToServer', True)
            load_page_callback(firstboot.pages.localUsers)
            return

        self.show_status()

        try:
            if len(socket.gethostname()) > 15:
                raise Exception(
                    _("The hostname can't not be longer than 15 characters"))
            server_conf = serverconf.get_server_conf(None)

            load_page_callback(
                LinkToServerConfEditorPage, {
                    'ldap_is_configured': self.ldap_is_configured,
                    'auth_method': self.get_auth_method(),
                    'ad_is_configured': self.ad_is_configured,
                })

        except serverconf.ServerConfException as e:
            self.show_status(__STATUS_ERROR__, e)

        except Exception as e:
            self.show_status(__STATUS_ERROR__, e)