def __init__(self, args=None, role='master', language='en'):
        init_logger('info')
        self.args = self.parse_args(args)
        self.ocr_config = self.__get_ocr_config()
        self.vm_config = VmConfig(ip=self.args.ip,
                                  role=role,
                                  language=language)

        host = self.__get_host()
        self.vnc_connection = VNCConnection(host)
示例#2
0
class UCSSetup(UCSInstallation):
    def __init__(self, args):
        init_logger('info')
        self.args = args
        self.config = OCRConfig()
        self.config.update(lang='eng')
        self.timeout = 40
        self.connect()

    def click(self, text):
        self.client.waitForText(text, timeout=self.timeout)
        self.client.mouseClickOnText(text)

    def screenshot(self, filename):
        if not os.path.isdir(self.args.screenshot_dir):
            os.mkdir(self.args.screenshot_dir)
        screenshot_file = os.path.join(self.args.screenshot_dir, filename)
        self.client.captureScreen(screenshot_file)

    def __next__(self):
        self.client.waitForText('NEXT', timeout=self.timeout)
        self.client.mouseClickOnText('NEXT')

    next = __next__  # Python 2

    def language(self, language):
        if self.text_is_visible('Notification', timeout=self.timeout):
            self.screenshot('notification.png')
            self.mouseClickOnText('OK')
        self.client.waitForText('English',
                                timeout=self.timeout,
                                prevent_screen_saver=True)
        self.screenshot('language-setup.png')
        self.next()
        self.client.waitForText('Default system locale', timeout=self.timeout)
        self.next()

    def network(self):
        try:
            self.client.waitForText('IP address', timeout=self.timeout)
        except VNCDoException:
            self.connect()
            self.client.waitForText('Domain and network', timeout=self.timeout)
        self.screenshot('network-setup.png')
        if self.args.role in ['admember', 'slave']:
            self.click('Preferred DNS')
            self.client.enterText(self.args.dns)
        self.next()
        time.sleep(60)
        # check APIPA warning (automatic private address for eth0 if no dhcp answer)
        try:
            self.client.waitForText('APIPA', timeout=self.timeout)
            self.client.keyPress('enter')
            time.sleep(60)
        except VNCDoException:
            self.connect()
        try:
            self.client.waitForText('No gateway has been',
                                    timeout=self.timeout)
            self.client.keyPress('enter')
            time.sleep(60)
        except VNCDoException:
            self.connect()
        try:
            self.client.waitForText('continue without access',
                                    timeout=self.timeout)
            self.client.keyPress('enter')
            time.sleep(60)
        except VNCDoException:
            self.connect()
        time.sleep(120)

    def domain(self, role):
        text = 'Manage users and permissions'
        if self.args.ucs is True:
            text = 'Create a new UCS domain'
        if role == 'admember':
            text = 'Join into an existing Microsoft Active'
        elif role in ['join', 'slave']:
            text = 'Join into an existing UCS domain'
        elif role == 'fast':
            text = 'Fast demo'
        self.client.waitForText(text, timeout=self.timeout)
        self.client.mouseClickOnText(text, timeout=self.timeout)
        self.screenshot('domain-setup.png')
        self.next()
        time.sleep(10)
        if role == 'slave':
            self.client.keyPress('down')
            self.next()
            self.click('Username')
            self.client.enterText(self.args.join_user)
            self.click('Password')
            self.client.enterText(self.args.join_password)
            self.next()
        if role == 'admember':
            self.client.waitForText('Active Directory join',
                                    timeout=self.timeout)
            self.click('Username')
            self.client.enterText(self.args.join_user)
            self.click('Password')
            self.client.enterText(self.args.join_password)
            self.next()

    def orga(self, orga, password):
        self.client.waitForText('Account information', timeout=self.timeout)
        self.screenshot('organisation-setup.png')
        self.client.enterText('home')
        self.client.keyPress('tab')
        self.client.keyPress('tab')
        self.client.keyPress('tab')
        self.client.enterText(password)
        self.client.keyPress('tab')
        self.client.enterText(password)
        self.next()

    def hostname(self, hostname):
        self.client.waitForText('Host settings', timeout=self.timeout)
        self.screenshot('hostname-setup.png')
        # delete the pre-filled hostname
        self.client.keyPress('end')
        for i in range(1, 200):
            self.client.keyPress('bsp')
        time.sleep(3)
        self.client.enterText(hostname)
        self.client.keyPress('tab')
        if self.args.role in ['admember', 'slave']:
            self.client.keyPress('tab')
            self.client.enterText(self.args.password)
            self.client.keyPress('tab')
            self.client.enterText(self.args.password)
        self.next()

    def start(self):
        self.client.waitForText('confirm configuration', timeout=self.timeout)
        self.screenshot('start-setup.png')
        found = False
        try:
            self.client.mouseClickOnText('configuresystem')
            found = True
        except VNCDoException:
            self.connect()
        if not found:
            self.client.mouseClickOnText('configure system')

    def finish(self):
        self.client.waitForText('Setup successful',
                                timeout=3600,
                                prevent_screen_saver=True)
        self.screenshot('finished-setup.png')
        self.client.keyPress('tab')
        self.client.keyPress('enter')
        # except welcome screen
        found = False
        try:
            self.client.waitForText('www', timeout=self.timeout)
            found = True
        except VNCDoException:
            self.connect()
        if not found:
            self.client.waitForText('press any key', timeout=self.timeout)
        self.screenshot('welcome-screen.png')

    def connect(self):
        self.conn = VNCConnection(self.args.vnc)
        self.client = self.conn.__enter__()
        self.client.updateOCRConfig(self.config)

    def setup(self):
        try:
            self.language('English')
            self.network()
            self.domain(self.args.role)
            if self.args.role == 'master':
                self.orga(self.args.organisation, self.args.password)
            if not self.args.role == 'fast':
                self.hostname(self.args.fqdn)
            try:
                self.client.waitForText('Software configuration',
                                        timeout=self.timeout)
                self.next()
            except VNCDoException:
                self.connect()
            self.start()
            self.finish()
        except Exception:
            self.connect()
            self.screenshot('error.png')
            raise
示例#3
0
 def connect(self):
     self.conn = VNCConnection(self.args.vnc)
     self.client = self.conn.__enter__()
     self.client.updateOCRConfig(self.config)
示例#4
0
class UCSInstallation(object):
    def __init__(self, args):
        init_logger('info')
        self.args = args
        self.config = OCRConfig()
        self.config.update(lang=self.args.language)
        self.timeout = 60
        self.connect()

    def screenshot(self, filename):
        if not os.path.isdir(self.args.screenshot_dir):
            os.mkdir(self.args.screenshot_dir)
        screenshot_file = os.path.join(self.args.screenshot_dir, filename)
        self.client.captureScreen(screenshot_file)

    def click(self, text):
        self.client.waitForText(text, timeout=self.timeout)
        self.client.mouseClickOnText(text)

    def connect(self):
        self.conn = VNCConnection(self.args.vnc)
        self.client = self.conn.__enter__()
        self.client.updateOCRConfig(self.config)

    def text_is_visible(self, text, timeout=30):
        try:
            self.client.waitForText(text, timeout=timeout)
            return True
        except VNCDoException:
            self.connect()
            return False

    def installer(self):
        # language
        self.client.waitForText('Select a language',
                                timeout=self.timeout + 120,
                                prevent_screen_saver=True)
        self.client.enterText(self._['english_language_name'])
        self.click('Continue')
        self.client.waitForText(self._['select_location'],
                                timeout=self.timeout)
        self.client.enterText(self._['location'])
        self.client.keyPress('enter')
        self.client.waitForText(self._['select_keyboard'],
                                timeout=self.timeout)
        self.client.enterText(self._['us_keyboard_layout'])
        self.client.keyPress('enter')

        if not self.network_setup():
            self.client.mouseMove(100, 320)
            self.client.mousePress(1)
            time.sleep(1)

        # root
        self.client.waitForText(self._['user_and_password'],
                                timeout=self.timeout)
        self.client.enterText(self.args.password)
        self.client.keyPress('tab')
        self.client.keyPress('tab')
        self.client.enterText(self.args.password)
        self.client.keyPress('enter')
        if self.args.language == 'eng':
            self.client.waitForText(self._['configure_clock'],
                                    timeout=self.timeout)
            #self.client.enterText(self._['clock'])
            self.client.keyPress('enter')
        # hd
        time.sleep(60)
        self.client.waitForText(self._['partition_disks'],
                                timeout=self.timeout)
        if self.args.role == 'applianceLVM':
            self.click(self._['entire_disk_with_lvm'])
            self.client.keyPress('enter')
            time.sleep(3)
            self.client.keyPress('enter')
            self.click(self._['all_files_on_partition'])
            self.client.keyPress('enter')
            time.sleep(3)
            self.client.keyPress('down')
            self.client.keyPress('enter')
            self.click(self._['finish_partition'])
            self.client.keyPress('enter')
            self.client.waitForText(self._['continue_partition'],
                                    timeout=self.timeout)
            self.client.keyPress('down')
            self.client.keyPress('enter')
        elif self.args.role == 'applianceEC2':
            # Manuel
            self.click(self._['manual'])
            self.client.keyPress('enter')
            time.sleep(3)
            # Virtuelle Festplatte 1
            self.click(self._['virtual_disk_1'])
            time.sleep(3)
            self.client.keyPress('enter')
            time.sleep(3)
            self.client.keyPress('down')
            time.sleep(3)
            self.client.keyPress('enter')
            time.sleep(3)
            self.click(self._['free_space'])
            self.client.keyPress('enter')
            time.sleep(3)
            # neue partition erstellen
            self.client.keyPress('enter')
            time.sleep(3)
            # enter: ganze festplattengröße ist eingetragen
            self.client.keyPress('enter')
            time.sleep(3)
            # enter: primär
            self.client.keyPress('enter')
            time.sleep(3)
            self.click(self._['boot_flag'])
            # enter: boot-flag aktivieren
            self.client.keyPress('enter')
            time.sleep(3)
            self.click(self._['finish_create_partition'])
            self.client.keyPress('enter')
            time.sleep(3)
            self.click(self._['finish_partition'])
            self.client.keyPress('enter')
            time.sleep(3)
            # Nein (kein swap speicher)
            self.click(self._['no'])
            self.client.keyPress('enter')
            self.client.waitForText(self._['continue_partition'],
                                    timeout=self.timeout)
            self.client.keyPress('down')
            self.client.keyPress('enter')
            self.client.keyPress('enter')
        else:
            self.click(self._['entire_disk'])
            self.client.keyPress('enter')
            time.sleep(3)
            self.client.keyPress('enter')
            self.click(self._['all_files_on_partition'])
            self.client.keyPress('enter')
            self.click(self._['finish_partition'])
            self.client.keyPress('enter')
            self.client.waitForText(self._['continue_partition'],
                                    timeout=self.timeout)
            self.client.keyPress('down')
            self.client.keyPress('enter')

    def network_setup(self):
        time.sleep(60)
        # we may not see this because the only interface is configured via dhcp
        if not self.text_is_visible(self._['configure_network'], timeout=120):
            return False
        self.client.waitForText(self._['configure_network'],
                                timeout=self.timeout)
        if not self.text_is_visible(self._['ip_address'],
                                    timeout=self.timeout):
            # always use first interface
            self.click(self._['continue'])
            time.sleep(60)
        if self.args.ip:
            if self.text_is_visible(self._['not_using_dhcp'],
                                    timeout=self.timeout):
                self.client.waitForText(self._['not_using_dhcp'],
                                        timeout=self.timeout)
                self.client.keyPress('enter')
                self.client.waitForText(self._['manual_network_config'],
                                        timeout=self.timeout)
                self.client.mouseClickOnText(self._['manual_network_config'])
                self.client.keyPress('enter')
            self.client.waitForText(self._['ip_address'], timeout=self.timeout)
            self.client.enterText(self.args.ip)
            self.client.keyPress('enter')
            self.client.waitForText(self._['netmask'], timeout=self.timeout)
            if self.args.netmask:
                self.client.enterText(self.args.netmask)
            self.client.keyPress('enter')
            self.client.waitForText(self._['gateway'], timeout=self.timeout)
            if self.args.gateway:
                self.client.enterText(self.args.gateway)
            self.client.keyPress('enter')
            self.client.waitForText(self._['name_server'],
                                    timeout=self.timeout)
            if self.args.dns:
                self.client.enterText(self.args.dns)
            self.client.keyPress('enter')
        return True

    def configure_kvm_network(self):
        if 'all' in self.args.components or 'kde' in self.args.components:
            time.sleep(10)
            self.client.keyDown('alt')
            self.client.keyDown('ctrl')
            self.client.keyPress('f1')
            self.client.keyUp('alt')
            self.client.keyUp('ctrl')
        elif self.args.role == 'basesystem':
            time.sleep(3)
        else:
            self.client.waitForText('corporate server')
            self.client.keyPress('enter')
        time.sleep(3)
        self.client.enterText('root')
        self.client.keyPress('enter')
        time.sleep(5)
        self.client.enterText(self.args.password)
        self.client.keyPress('enter')
        self.client.enterText('ucr set interfaces-ens6-tzpe`manual')
        self.client.keyPress('enter')
        time.sleep(30)
        self.client.enterText('ifconfig ens6 up')
        self.client.keyPress('enter')
        self.client.enterText('echo ')
        self.client.keyDown('shift')
        self.client.enterText('2')  # @
        self.client.keyUp('shift')
        self.client.enterText('reboot -sbin-ifconfig ens6 up ')
        self.client.keyDown('shift')
        self.client.enterText("'")  # |
        self.client.keyUp('shift')
        self.client.enterText(' crontab')
        self.client.keyPress('enter')

    def setup(self):
        self.client.waitForText(self._['domain_setup'],
                                timeout=self.timeout + 900)
        if self.args.role == 'master':
            self.click(self._['new_domain'])
            self.click(self._['next'])
            self.client.waitForText(self._['account_information'],
                                    timeout=self.timeout)
            self.client.enterText('home')
            self.click(self._['next'])
        elif self.args.role in ['slave', 'backup', 'member']:
            self.click(self._['join_domain'])
            self.click(self._['next'])
            self.client.waitForText(self._['no_dc_dns'])
            #self.click(self._['no_dc_dns_adapt'])
            self.client.keyPress('tab')
            self.client.keyPress('enter')
            self.click(self._['preferred_dns'])
            self.client.enterText(self.args.dns)
            self.client.keyPress('enter')
            time.sleep(120)
            if self.text_is_visible(self._['repositories_not_reachable']):
                self.client.keyPress('enter')
                time.sleep(30)
            self.click(self._['join_domain'])
            self.click(self._['next'])
            time.sleep(10)
            if self.args.role == 'backup':
                self.click(self._['next'])
            if self.args.role == 'slave':
                self.client.keyPress('down')
                self.click(self._['next'])
            if self.args.role == 'member':
                self.client.keyPress('down')
                self.client.keyPress('down')
                self.click(self._['next'])
            self.client.waitForText(self._['start_join'], timeout=self.timeout)
            self.client.keyPress('tab')
            self.client.keyPress('tab')
            self.client.enterText(self.args.join_user)
            self.client.keyPress('tab')
            self.client.enterText(self.args.join_password)
            self.client.keyPress('enter')
        elif self.args.role == 'admember':
            self.click(self._['ad_domain'])
            self.click(self._['next'])
            self.client.waitForText(self._['no_dc_dns'], timeout=self.timeout)
            self.client.keyPress('enter')
            self.click(self._['preferred_dns'])
            self.client.enterText(self.args.dns)
            self.client.keyPress('enter')
            time.sleep(120)
            if self.text_is_visible(self._['repositories_not_reachable']):
                self.client.keyPress('enter')
                time.sleep(30)
            if self.text_is_visible('APIPA', timeout=self.timeout):
                self.client.keyPress('enter')
                time.sleep(60)
            self.click(self._['next'])
            self.client.waitForText(self._['ad_account_information'],
                                    timeout=self.timeout)
            self.client.keyPress('tab')
            self.client.enterText(self.args.join_user)
            self.client.keyPress('tab')
            self.client.enterText(self.args.join_password)
            self.click(self._['next'])
        elif self.args.role == 'basesystem':
            self.click(self._['no_domain'])
            self.click(self._['next'])
            self.client.waitForText(self._['warning_no_domain'],
                                    timeout=self.timeout)
            self.click(self._['next'])
        elif self.args.role == 'applianceEC2' or self.args.role == 'applianceLVM':
            self.client.keyDown('ctrl')
            self.client.keyPress('q')
            self.client.keyUp('ctrl')
            time.sleep(300)
            self.client.waitForText(self._['appliance_modus'],
                                    timeout=self.timeout)
            self.click(self._['continue'])
            time.sleep(60)
            sys.exit(0)
        else:
            raise NotImplemented

    def hostname(self):
        # name hostname
        if self.args.role == 'master':
            self.client.waitForText(self._['host_settings'],
                                    timeout=self.timeout)
        else:
            self.client.waitForText(self._['system_name'])
        self.client.keyPress('end')
        for i in range(1, 200):
            self.client.keyPress('bsp')
        self.client.enterText(self.args.fqdn)
        self.client.keyPress('tab')
        self.click(self._['next'])

    def finish(self):
        self.client.waitForText(self._['setup_successful'], timeout=3200)
        #self.click(self._['finish'])
        self.client.keyPress('tab')
        self.client.keyPress('enter')
        time.sleep(200)

    def software_configuration(self):
        # software configuration
        if self.args.role != 'basesystem':
            if self.args.role == 'master':
                self.client.waitForText(self._['software_configuration'],
                                        timeout=self.timeout)
            else:
                self.client.waitForText(
                    self._['software_configuration_non_master'],
                    timeout=self.timeout)
            self.select_components()
            self.click(self._['next'])
        time.sleep(5)
        self.client.keyPress('enter')

    def select_components(self):
        # this is needed to make the down button work
        if 'all' in self.args.components:
            self.client.mouseMove(325, 200)
            self.client.mousePress(1)
        else:
            print('move mouse')
            self.client.mouseMove(325, 300)
            self.client.mousePress(1)
            time.sleep(1)
            self.client.mousePress(1)
            for name, steps in components.iteritems():
                if name in self.args.components:
                    # go to the top
                    print('go up')
                    for step in range(1, 20):
                        self.client.keyPress('up')
                        time.sleep(0.2)
                    for step in range(1, steps):
                        print('go down')
                        self.client.keyPress('down')
                        time.sleep(0.2)
                    self.click(self._[name])

    def ucsschool(self):
        # ucs@school role
        if self.args.school_dep:
            self.client.waitForText(self._['school_role'],
                                    timeout=self.timeout)
            if self.args.school_dep == 'adm':
                self.click(self._['school_adm'])
            elif self.args.school_dep == 'edu':
                self.click(self._['school_edu'])
            elif self.args.school_dep == 'central':
                self.click(self._['school_central'])
            else:
                raise NotImplemented()
            self.click(self._['next'])

    def bootmenu(self):
        if self.text_is_visible('Univention Corporate Server Installer',
                                timeout=120):
            if self.args.ip:
                self.client.keyPress('down')
            self.client.keyPress('enter')

    def installation(self):
        if self.args.language == 'eng':
            self._ = english.strings
        elif self.args.language == 'fra':
            self._ = french.strings
        else:
            self._ = german.strings

        try:
            self.bootmenu()
            self.installer()
            self.setup()
            self.hostname()
            self.ucsschool()
            self.software_configuration()
            self.finish()
            if not self.args.no_second_interface:
                # TODO activate ens6 so that ucs-kvm-create can connect to instance
                # this is done via login and setting interfaces/eth0/type, is there a better way?
                self.configure_kvm_network()
        except Exception:
            self.connect()
            self.screenshot('error.png')
            raise
class Installer(object):
    def __init__(self, args=None, role='master', language='en'):
        init_logger('info')
        self.args = self.parse_args(args)
        self.ocr_config = self.__get_ocr_config()
        self.vm_config = VmConfig(ip=self.args.ip,
                                  role=role,
                                  language=language)

        host = self.__get_host()
        self.vnc_connection = VNCConnection(host)
        # Note: The second part of this initialisation is in __enter__().

    def __enter__(self):
        self.client = self.vnc_connection.__enter__()
        self.__set_language(self.vm_config.language)
        return self

    def __exit__(self, etype, exc, etraceback):
        self.vnc_connection.__exit__(etype, exc, etraceback)

    def parse_args(self, args=None):
        parser = argparse.ArgumentParser(description='VNC example test')
        parser.add_argument('host',
                            metavar='vnc_host',
                            help='Host with VNC port to connect to')
        parser.add_argument('--ip',
                            dest='ip',
                            required=True,
                            help='The IP to assign to this virtual machine')
        add_config_options_to_parser(parser)
        args = parser.parse_args(args)
        return args

    def __get_ocr_config(self):
        config = get_config_from_args(self.args)
        return config

    def __set_language(self, language):
        self.locale_strings = self.__get_strings(language)
        self.__set_ocr_language(language)

    def __get_strings(self, language):
        if language == 'en':
            return english.strings
        elif language == 'de':
            return german.strings
        elif language == 'fr':
            return french.strings

    def __set_ocr_language(self, language):
        language_iso_639_2 = utils.iso_639_1_to_iso_639_2(language)
        self.ocr_config.update(lang=language_iso_639_2)
        self.client.updateOCRConfig(self.ocr_config)

    def __get_host(self):
        return self.args.host

    def skip_boot_device_selection(self):
        self.__set_language('en')
        self.client.waitForText('start with default settings')
        self.client.keyPress('enter')

    def select_language(self):
        self.__set_language('en')
        language_english_name = utils.iso_639_1_to_english_name(
            self.vm_config.language)

        self.client.waitForText('select a language', timeout=30)
        self.client.mouseClickOnText('English')
        self.client.enterText(language_english_name)
        self.client.keyPress('enter')

        self.__set_language(self.vm_config.language)

    def set_country_and_keyboard_layout(self):
        self.client.waitForText(self.locale_strings['location_selection'],
                                timeout=30)
        self.client.keyPress('enter')

        # Always using US keyboard layout here, because it's the only one
        # vncdotool fully supports.
        self.client.waitForText(self.locale_strings['configure_keyboard'],
                                timeout=30)
        self.client.mouseClickOnText(
            self.locale_strings['default_keyboard_layout_of_current_language'])
        self.client.enterText(self.locale_strings['us_keyboard_layout'])
        self.client.keyPress('enter')

    def network_setup(self, has_multiple_network_devices=False):
        if has_multiple_network_devices:
            self.client.waitForText(
                self.locale_strings['multiple_network_devices'], timeout=120)
            self.client.keyPress('enter')

        self.client.waitForText(self.locale_strings['dhcp_configuration'],
                                timeout=120)
        self.client.mouseClickOnText(self.locale_strings['cancel'])

        self.client.waitForText(self.locale_strings['not_using_dhcp'],
                                timeout=30)
        self.client.keyPress('enter')

        self.client.waitForText(self.locale_strings['manual_network_config'],
                                timeout=30)
        self.client.mouseClickOnText(
            self.locale_strings['manual_network_config'])
        self.client.keyPress('enter')
        self.client.waitForText(self.locale_strings['ip_address'], timeout=30)
        self.client.enterText(self.vm_config.ip)
        self.client.keyPress('enter')

        self.client.waitForText(self.locale_strings['netmask'], timeout=30)
        self.client.keyPress('enter')

        self.client.waitForText(self.locale_strings['gateway'], timeout=30)
        self.client.keyPress('enter')

        self.client.waitForText(self.locale_strings['name_server'], timeout=30)
        self.client.enterText(self.vm_config.dns_server_ip)
        self.client.keyPress('enter')

    def account_setup(self):
        self.client.waitForText(self.locale_strings['user_and_password'],
                                timeout=30)
        self.client.enterText(self.vm_config.password)
        self.client.keyPress('tab')
        self.client.enterText(self.vm_config.password)
        self.client.keyPress('enter')

    # Only some countries (e.g. USA) have a time zone selection dialog here.
    def set_time_zone(self):
        self.client.waitForText(self.locale_strings['time_zone'], timeout=60)
        self.client.keyPress('enter')

    def hdd_setup(self, hdd_empty=True):
        self.client.waitForText(self.locale_strings['partitioning_method'],
                                timeout=60)
        self.client.keyPress('enter')
        self.client.waitForText(self.locale_strings['partitioning_device'],
                                timeout=30)
        self.client.keyPress('enter')
        self.client.waitForText(self.locale_strings['partitioning_structure'],
                                timeout=30)
        if self.vm_config.use_multiple_partitions:
            self.client.mouseClickOnText(
                self.locale_strings['multiple_partitions'])
        self.client.keyPress('enter')

        # This dialog only appears when the HDD is not empty.
        if not hdd_empty:
            self.client.waitForText(
                self.locale_strings['partitioning_warning1'], timeout=30)
            self.client.keyPress('down')
            self.client.keyPress('enter')

        self.client.waitForText(self.locale_strings['partitioning_warning2'],
                                timeout=30)
        self.client.keyPress('down')
        self.client.keyPress('enter')

        self.client.waitForText(self.locale_strings['partitioning_commit'],
                                timeout=30)
        self.client.keyPress('enter')

        self.client.waitForText(self.locale_strings['partitioning_warning3'],
                                timeout=30)
        self.client.keyPress('down')
        self.client.keyPress('enter')
        self.client.waitForText(self.locale_strings['domain_setup'],
                                timeout=1200,
                                prevent_screen_saver=True)

    def setup_ucs(self, expect_login_screen=False):
        self.choose_system_role()
        self.set_domain_settings()
        self.select_software_components()
        self.confirm_config(expect_login_screen)

    def choose_system_role(self):
        if self.vm_config.role == "master":
            self.client.mouseClickOnText(self.locale_strings['setup_master'])
            self.client.mouseClickOnText(self.locale_strings['next'])
            self.client.waitForText(self.locale_strings['account_info'],
                                    timeout=30)
        elif self.vm_config.role == "backup" or self.vm_config.role == "slave" or self.vm_config.role == "member":
            self.client.mouseClickOnText(self.locale_strings['join_ucs'])
            self.client.mouseClickOnText(self.locale_strings['next'])
            self.client.waitForText(self.locale_strings['system_role'],
                                    timeout=30)
        elif self.vm_config.role == "basesystem":
            self.client.mouseClickOnText(self.locale_strings['no_domain'])
            self.client.mouseClickOnText(self.locale_strings['next'])
            self.client.waitForText(self.locale_strings['no_domain_warn'],
                                    timeout=30)

        if self.vm_config.role == "backup":
            self.client.mouseClickOnText(self.locale_strings['next'])
        if self.vm_config.role == "slave":
            self.client.keyPress('down')
            self.client.mouseClickOnText(self.locale_strings['next'])
        if self.vm_config.role == "member":
            self.client.keyPress('down')
            self.client.keyPress('down')
            self.client.mouseClickOnText(self.locale_strings['next'])

    def set_domain_settings(self):
        if self.vm_config.role == "master":
            self.client.enterText(self.locale_strings['company'])
            self.client.mouseClickOnText(self.locale_strings['next'])
            self.client.waitForText(self.locale_strings['host_settings'],
                                    timeout=30)

            self.client.mouseClickOnText(self.locale_strings['ldap_base'])
            self.client.enterText(self.vm_config.ldap_base)
            self.client.mouseClickOnText(self.locale_strings['next'])
            self.client.waitForText(self.locale_strings['software_config'],
                                    timeout=30)

        elif self.vm_config.role == "backup" or self.vm_config.role == "slave" or self.vm_config.role == "member":
            self.client.waitForText(self.locale_strings['domain_join'],
                                    timeout=30)
            self.client.mouseClickOnText(self.locale_strings['password_field'])
            self.client.enterText(self.vm_config.password)
            self.client.mouseClickOnText(self.locale_strings['next'])
            self.client.waitForText(self.locale_strings['host_settings'],
                                    timeout=30)
            self.client.mouseClickOnText(self.locale_strings['next'])
            self.client.waitForText(self.locale_strings['software_config'],
                                    timeout=30)

        elif self.vm_config.role == "basesystem":
            self.client.mouseClickOnText(self.locale_strings['next'])

            self.client.waitForText(self.locale_strings['host_settings'],
                                    timeout=30)
            self.client.mouseClickOnText(self.locale_strings['next'])

            self.client.waitForText(self.locale_strings['confirm_config'],
                                    timeout=30)

    def select_software_components(self):
        if self.vm_config.role != "basesystem":
            if self.vm_config.install_all_additional_components:
                self.client.mouseMove(320, 215)
                self.client.mousePress(1)
            self.client.mouseClickOnText(self.locale_strings['next'])
            self.client.waitForText(self.locale_strings['confirm_config'],
                                    timeout=30)

    def confirm_config(self, expect_login_screen):
        if not self.vm_config.update_ucs_after_install:
            # The tab is needed to take away the focus from the text, because
            # when focused the text is surrounded by a frame, which irritates
            # tesseract-ocr, sometimes.
            self.client.keyPress('tab')
            # Pressing page down is needed, because the checkbox is off screen
            # when the software components list is long.
            time.sleep(3)
            self.client.keyPress('pgdn')
            self.client.mouseClickOnText(self.locale_strings['do_update'])
        self.client.keyPress('enter')

        # The setup will probably take at least 20min, so this sleep reduces the
        # load while waiting. This sleep is also needed to add to the timeout
        # of the following waitForText(), where the maximum timeout is 3600s,
        # due to limitations of vncdotool.
        time.sleep(20 * 60)
        self.client.waitForText(self.locale_strings['setup_successful'],
                                timeout=3550,
                                prevent_screen_saver=True)
        self.client.mouseClickOnText(self.locale_strings['finish'])

        if self.vm_config.role == "basesystem":
            self.client.waitForText('login:'******'expected_welcome_screen_with_kde.png'),
                                     timeout=360)
        else:
            self.client.waitForText(self.locale_strings['welcome'],
                                    timeout=360)