def next_page(self, load_page_callback):

        hostname = self.ui.txtHostname.get_text()

        if len(hostname) == 0:
            self.show_error(_('The host name cannot be empty.'))
            return

        elif hostname in self.hostnames:
            self.show_error(_('The host name already exists in the Chef server.'))
            return

        self.server_conf.get_chef_conf().set_hostname(hostname)

        result, messages = ServerConf.setup_server(
            server_conf=self.server_conf,
            link_ldap=self.link_ldap,
            unlink_ldap=self.unlink_ldap,
            link_chef=self.link_chef,
            unlink_chef=self.unlink_chef
        )

        load_page_callback(LinkToServerResultsPage, {
            'server_conf': self.server_conf,
            'result': result,
            'messages': messages
        })
    def next_page(self, load_page_callback):

        if not self.unlink_from_chef and self.ui.chkChef.get_active():
            # The unique host name for Chef is mandatory, so we need
            # to ask for it before the setup.

            try:
                used_hostnames = ServerConf.get_chef_hostnames(self.server_conf.get_chef_conf())

                load_page_callback(LinkToServerHostnamePage, {
                    'server_conf': self.server_conf,
                    'link_ldap': self.ui.chkLDAP.get_active(),
                    'unlink_ldap': self.unlink_from_ldap,
                    'link_chef': self.ui.chkChef.get_active(),
                    'unlink_chef': self.unlink_from_chef,
                    'used_hostnames': used_hostnames
                })

            except ServerConf.ServerConfException as e:
                messages = [{'type': 'error', 'message': str(e)}]

                load_page_callback(LinkToServerResultsPage, {
                    'result': False,
                    'server_conf': self.server_conf,
                    'messages': messages
                })

        else:
            result, messages = ServerConf.setup_server(
                server_conf=self.server_conf,
                link_ldap=self.ui.chkLDAP.get_active(),
                unlink_ldap=self.unlink_from_ldap,
                link_chef=self.ui.chkChef.get_active(),
                unlink_chef=self.unlink_from_chef
            )

            load_page_callback(LinkToServerResultsPage, {
                'result': result,
                'server_conf': self.server_conf,
                'messages': messages
            })