Example #1
0
    def _customization(self):
        if self.environment[odockerccons.ConfigEnv.DOCKERC_CINDER] is None:
            self.environment[
                odockerccons.ConfigEnv.DOCKERC_CINDER] = dialog.queryBoolean(
                    dialog=self.dialog,
                    name='OVESETUP_CONFIG_DOCKERC_CINDER',
                    note=_('Deploy Cinder container on this host '
                           '(@VALUES@) [@DEFAULT@]: '),
                    prompt=True,
                    default=True,
                )
        if self.environment[odockerccons.ConfigEnv.DOCKERC_GLANCE] is None:
            self.environment[
                odockerccons.ConfigEnv.DOCKERC_GLANCE] = dialog.queryBoolean(
                    dialog=self.dialog,
                    name='OVESETUP_CONFIG_DOCKERC_GLANCE',
                    note=_('Deploy Glance container on this host '
                           '(@VALUES@) [@DEFAULT@]: '),
                    prompt=True,
                    default=True,
                )
        self._enabled = self.environment[
            odockerccons.ConfigEnv.DOCKERC_CINDER] or self.environment[
                odockerccons.ConfigEnv.DOCKERC_GLANCE]

        tag = ':' + self.environment[odockerccons.ConfigEnv.DOCKERC_CTAG]

        self._dimages = [{
            'image': odockerccons.Const.C_IMAGE_RABBITMQ + tag,
            'name': odockerccons.Const.C_NAME_RABBITMQ
        }, {
            'image': odockerccons.Const.C_IMAGE_MARIADBDATA + tag,
            'name': odockerccons.Const.C_NAME_MARIADBDATA
        }, {
            'image': odockerccons.Const.C_IMAGE_MARIADBAPP + tag,
            'name': odockerccons.Const.C_NAME_MARIADBAPP
        }, {
            'image': odockerccons.Const.C_IMAGE_KEYSTONE + tag,
            'name': odockerccons.Const.C_NAME_KEYSTONE
        }]

        if self.environment[odockerccons.ConfigEnv.DOCKERC_CINDER]:
            self._dimages.append({
                'image': odockerccons.Const.C_IMAGE_CINDER + tag,
                'name': odockerccons.Const.C_NAME_CINDER
            })

        if self.environment[odockerccons.ConfigEnv.DOCKERC_GLANCE]:
            self._dimages.extend([
                {
                    'image': odockerccons.Const.C_IMAGE_GLANCE_REG + tag,
                    'name': odockerccons.Const.C_NAME_GLANCE_REG
                },
                {
                    'image': odockerccons.Const.C_IMAGE_GLANCE_API + tag,
                    'name': odockerccons.Const.C_NAME_GLANCE_API
                },
            ])
        if self._enabled:
            self.environment[odockerccons.ConfigEnv.DOCKERC_NEEDED] = True
Example #2
0
    def _customization(self):
        if self.environment[
            oengcommcons.ProvisioningEnv.POSTGRES_PROVISIONING_ENABLED
        ] is None:
            local = dialog.queryBoolean(
                dialog=self.dialog,
                name='OVESETUP_PROVISIONING_POSTGRES_LOCATION',
                note=_(
                    'Where is the Engine database located? '
                    '(@VALUES@) [@DEFAULT@]: '
                ),
                prompt=True,
                true=_('Local'),
                false=_('Remote'),
                default=True,
            )
            if local:
                self.environment[oenginecons.EngineDBEnv.HOST] = 'localhost'
                self.environment[
                    oenginecons.EngineDBEnv.PORT
                ] = oenginecons.Defaults.DEFAULT_DB_PORT

                # TODO:
                # consider creating database and role
                # at engine_@RANDOM@
                self.environment[
                    oengcommcons.ProvisioningEnv.POSTGRES_PROVISIONING_ENABLED
                ] = dialog.queryBoolean(
                    dialog=self.dialog,
                    name='OVESETUP_PROVISIONING_POSTGRES_ENABLED',
                    note=_(
                        'Setup can configure the local postgresql server '
                        'automatically for the engine to run. This may '
                        'conflict with existing applications.\n'
                        'Would you like Setup to automatically configure '
                        'postgresql and create Engine database, '
                        'or prefer to perform that '
                        'manually? (@VALUES@) [@DEFAULT@]: '
                    ),
                    prompt=True,
                    true=_('Automatic'),
                    false=_('Manual'),
                    default=True,
                )

            else:
                self.environment[
                    oengcommcons.ProvisioningEnv.POSTGRES_PROVISIONING_ENABLED
                ] = False

        self._enabled = self.environment[
            oengcommcons.ProvisioningEnv.POSTGRES_PROVISIONING_ENABLED
        ]
        if self._enabled:
            self._provisioning.applyEnvironment()
Example #3
0
    def _customization(self):
        enabled = self.environment[
            oreportscons.ProvisioningEnv.POSTGRES_PROVISIONING_ENABLED
        ]

        if not self.environment[oreportscons.CoreEnv.ENABLE]:
            enabled = False

        if enabled is None:
            local = dialog.queryBoolean(
                dialog=self.dialog,
                name='OVESETUP_REPORTS_PROVISIONING_POSTGRES_LOCATION',
                note=_(
                    'Where is the Reports database located? '
                    '(@VALUES@) [@DEFAULT@]: '
                ),
                prompt=True,
                true=_('Local'),
                false=_('Remote'),
                default=True,
            )
            if local:
                self.environment[oreportscons.DBEnv.HOST] = 'localhost'
                self.environment[
                    oreportscons.DBEnv.PORT
                ] = oreportscons.Defaults.DEFAULT_DB_PORT

                enabled = dialog.queryBoolean(
                    dialog=self.dialog,
                    name='OVESETUP_REPORTS_PROVISIONING_POSTGRES_ENABLED',
                    note=_(
                        'Setup can configure the local postgresql server '
                        'automatically for the Reports to run. This may '
                        'conflict with existing applications.\n'
                        'Would you like Setup to automatically configure '
                        'postgresql and create Reports database, '
                        'or prefer to perform that '
                        'manually? (@VALUES@) [@DEFAULT@]: '
                    ),
                    prompt=True,
                    true=_('Automatic'),
                    false=_('Manual'),
                    default=True,
                )

        if enabled:
            self._provisioning.applyEnvironment()

        self.environment[
            oreportscons.ProvisioningEnv.POSTGRES_PROVISIONING_ENABLED
        ] = self._enabled = enabled
Example #4
0
    def _customization(self):
        if self.environment[oengcommcons.ProvisioningEnv.
                            POSTGRES_PROVISIONING_ENABLED] is None:
            local = dialog.queryBoolean(
                dialog=self.dialog,
                name='OVESETUP_PROVISIONING_POSTGRES_LOCATION',
                note=_('Where is the Engine database located? '
                       '(@VALUES@) [@DEFAULT@]: '),
                prompt=True,
                true=_('Local'),
                false=_('Remote'),
                default=True,
            )
            if local:
                self.environment[oenginecons.EngineDBEnv.HOST] = 'localhost'
                self.environment[oenginecons.EngineDBEnv.
                                 PORT] = oenginecons.Defaults.DEFAULT_DB_PORT

                # TODO:
                # consider creating database and role
                # at engine_@RANDOM@
                self.environment[
                    oengcommcons.ProvisioningEnv.
                    POSTGRES_PROVISIONING_ENABLED] = dialog.queryBoolean(
                        dialog=self.dialog,
                        name='OVESETUP_PROVISIONING_POSTGRES_ENABLED',
                        note=_(
                            'Setup can configure the local postgresql server '
                            'automatically for the engine to run. This may '
                            'conflict with existing applications.\n'
                            'Would you like Setup to automatically configure '
                            'postgresql and create Engine database, '
                            'or prefer to perform that '
                            'manually? (@VALUES@) [@DEFAULT@]: '),
                        prompt=True,
                        true=_('Automatic'),
                        false=_('Manual'),
                        default=True,
                    )

            else:
                self.environment[oengcommcons.ProvisioningEnv.
                                 POSTGRES_PROVISIONING_ENABLED] = False

        self._enabled = self.environment[
            oengcommcons.ProvisioningEnv.POSTGRES_PROVISIONING_ENABLED]
        if self._enabled:
            self._provisioning.applyEnvironment()
Example #5
0
    def _customization(self):
        self.dialog.note(
            text=_('\n--== CONFIGURATION PREVIEW ==--\n\n'),
        )
        shown = set()
        for c in sum(
            [
                constobj.__dict__['__osetup_attrs__']
                for constobj in self.environment[
                    osetupcons.CoreEnv.SETUP_ATTRS_MODULES
                ]
            ],
            [],
        ):
            for k in c.__dict__.values():
                if hasattr(k, '__osetup_attrs__'):
                    attrs = k.__osetup_attrs__
                    if (
                        attrs['summary'] and
                        attrs['summary_condition'](self.environment)
                    ):
                        env = k.fget(None)
                        value = self.environment.get(env)
                        if value is not None and env not in shown:
                            shown.add(env)
                            self.dialog.note(
                                text=_('{key:40}: {value}').format(
                                    key=(
                                        attrs['description']
                                        if attrs['description'] is not None
                                        else env
                                    ),
                                    value=value,
                                ),
                            )

        confirmed = self.environment[
            osetupcons.DialogEnv.CONFIRM_SETTINGS
        ]
        if confirmed is None:
            confirmed = dialog.queryBoolean(
                dialog=self.dialog,
                name='OVESETUP_DIALOG_CONFIRM_SETTINGS',
                note=_(
                    '\n'
                    'Please confirm installation settings '
                    '(@VALUES@) [@DEFAULT@]: '
                ),
                prompt=True,
                true=_('OK'),
                false=_('Cancel'),
                default=True,
            )

        if not confirmed:
            raise RuntimeError(_('Configuration was rejected by user'))

        self.environment[
            osetupcons.DialogEnv.CONFIRM_SETTINGS
        ] = True
Example #6
0
 def _customization(self):
     if self.environment[
         osetupcons.RemoveEnv.REMOVE_ALL
     ]:
         self.environment[
             odockerccons.RemoveEnv.REMOVE_DOCKERC
         ] = True
     else:
         if self.environment[
             odockerccons.RemoveEnv.REMOVE_DOCKERC
         ] is None:
             self.environment[
                 odockerccons.RemoveEnv.REMOVE_DOCKERC
             ] = dialog.queryBoolean(
                 dialog=self.dialog,
                 name='OVESETUP_REMOVE_DOCKERC',
                 note=_(
                     'Do you want to remove the Setup-deployed\n'
                     'Docker containers ({clist})?\n'
                     'Data will be lost\n'
                     '(@VALUES@) [@DEFAULT@]: '
                 ).format(
                     clist=self.environment[
                         odockerccons.RemoveEnv.REMOVE_DCLIST
                     ]
                 ),
                 prompt=True,
                 true=_('Yes'),
                 false=_('No'),
                 default=False,
             )
Example #7
0
    def _validation(self):
        self.logger.info(_('Checking the Engine database consistency'))
        violations, issues_found = self._checkDb()
        if issues_found:
            if self.environment[
                    oenginecons.EngineDBEnv.FIX_DB_VIOLATIONS] is None:
                self.logger.warn(
                    _('The following inconsistencies were found '
                      'in Engine database: {violations}. ').format(
                          violations=violations, ), )
                self.environment[
                    oenginecons.EngineDBEnv.
                    FIX_DB_VIOLATIONS] = dialog.queryBoolean(
                        dialog=self.dialog,
                        name='OVESETUP_FIX_DB_VALIDATIONS',
                        note=_('Would you like to automatically clear '
                               'inconsistencies before upgraing?\n'
                               '(Answering no will stop the upgrade): '),
                        prompt=True,
                    )

            if not self.environment[oenginecons.EngineDBEnv.FIX_DB_VIOLATIONS]:
                raise RuntimeError(
                    _('Upgrade aborted, database integrity '
                      'cannot be established.'))
Example #8
0
    def _validation(self):
        if (
            self.services.exists(
                name=oenginecons.Const.ENGINE_SERVICE_NAME
            ) and self.services.status(
                name=oenginecons.Const.ENGINE_SERVICE_NAME
            )
        ):
            if self.environment[
                oenginecons.CoreEnv.ENGINE_SERVICE_STOP
            ] is None:
                self.environment[
                    oenginecons.CoreEnv.ENGINE_SERVICE_STOP
                ] = dialog.queryBoolean(
                    dialog=self.dialog,
                    name='OVESETUP_CORE_ENGINE_STOP',
                    note=_(
                        'During execution engine service will be stopped '
                        '(@VALUES@) [@DEFAULT@]: '
                    ),
                    prompt=True,
                    true=_('OK'),
                    false=_('Cancel'),
                    default=True,
                )

            if not self.environment[oenginecons.CoreEnv.ENGINE_SERVICE_STOP]:
                raise RuntimeError(
                    _('Engine service is running, no approval to stop')
                )
Example #9
0
    def _customization(self):
        # TODO:
        # Currently engine-setup does the configuration when
        # ovirt-vmconsole-proxy is installed, and it is installed in the
        # same host as Engine. This is ensured checking for ovirt-vmconsole
        # user/group above.
        #
        # We should not depend (and we don't yet) on ovirt-vmconsole-proxy in
        # rpm spec because the serial console support is optional:
        # if it is there and it isenabled, then will be configured,
        # and skipped in any other case.
        #
        # Manual setup instructions will be provided on the feature page:
        # http://www.ovirt.org/Features/Serial_Console
        if not _existsUserGroup(self.logger, ovmpcons.Const.OVIRT_VMCONSOLE_USER, ovmpcons.Const.OVIRT_VMCONSOLE_GROUP):
            self.logger.warning(_("VM Console Proxy seems not installed on this host. " "Disabled configuration."))
            enabled = False

        elif self.environment[ovmpcons.ConfigEnv.VMCONSOLE_PROXY_CONFIG] is None:
            enabled = dialog.queryBoolean(
                dialog=self.dialog,
                name="OVESETUP_CONFIG_VMCONSOLE_PROXY",
                note=_("Configure VM Console Proxy on this host " "(@VALUES@) [@DEFAULT@]: "),
                prompt=True,
                default=True,
            )

            self.environment[ovmpcons.ConfigEnv.VMCONSOLE_PROXY_CONFIG] = enabled
Example #10
0
    def _continueSetupWithoutAIO(self):
        if self.environment[
            oenginecons.AIOEnv.CONTINUE_WITHOUT_AIO
        ] is None:
            self.environment[
                oenginecons.AIOEnv.CONTINUE_WITHOUT_AIO
            ] = dialog.queryBoolean(
                dialog=self.dialog,
                name='OVESETUP_CONTINUE_WITHOUT_AIO',
                note=_(
                    'Disabling all-in-one plugin because hardware '
                    'supporting virtualization could not be detected. '
                    'Do you want to continue setup without AIO plugin? '
                    '(@VALUES@) [@DEFAULT@]: '
                ),
                prompt=True,
                default=False,
            )

        if self.environment[
            oenginecons.AIOEnv.CONTINUE_WITHOUT_AIO
        ]:
            self._enabled = False
            self.environment[oenginecons.AIOEnv.CONFIGURE] = False
        else:
            raise RuntimeError(
                _('Aborted by user.')
            )
Example #11
0
    def _validation(self):
        if self.environment[osetupcons.CoreEnv.REMOVE] is None:
            if self.environment[osetupcons.RemoveEnv.REMOVE_ALL]:
                cnote = _(
                    "All the installed ovirt components are about to be "
                    "removed, data will be lost (@VALUES@) [@DEFAULT@]: "
                )
            elif self.environment[osetupcons.RemoveEnv.REMOVE_OPTIONS]:
                cnote = _("{clist} is/are about to be removed, data will be lost " "(@VALUES@) [@DEFAULT@]: ").format(
                    clist=", ".join(self.environment[osetupcons.RemoveEnv.REMOVE_OPTIONS])
                )
            else:
                raise RuntimeError(_("Nothing to remove"))

            self.environment[osetupcons.CoreEnv.REMOVE] = dialog.queryBoolean(
                dialog=self.dialog,
                name="OVESETUP_CORE_REMOVE",
                note=cnote,
                prompt=True,
                true=_("OK"),
                false=_("Cancel"),
                default=False,
            )

        if not self.environment[osetupcons.CoreEnv.REMOVE]:
            raise RuntimeError(_("Aborted by user"))
Example #12
0
    def _customization(self):

        if self.environment[
                osetupcons.ConfigEnv.WEBSOCKET_PROXY_CONFIG] is None:
            self.environment[
                osetupcons.ConfigEnv.
                WEBSOCKET_PROXY_CONFIG] = dialog.queryBoolean(
                    dialog=self.dialog,
                    name='OVESETUP_CONFIG_WEBSOCKET_PROXY',
                    note=_('Configure WebSocket Proxy on this machine? '
                           '(@VALUES@) [@DEFAULT@]: '),
                    prompt=True,
                    default=True,
                )
        self._enabled = self.environment[
            osetupcons.ConfigEnv.WEBSOCKET_PROXY_CONFIG]

        if self._enabled:
            self.environment[osetupcons.NetEnv.FIREWALLD_SERVICES].extend([
                {
                    'name': 'ovirt-websocket-proxy',
                    'directory': 'base'
                },
            ])
            self.environment[osetupcons.NetEnv.FIREWALLD_SUBST].update({
                '@WEBSOCKET_PROXY_PORT@':
                self.environment[osetupcons.ConfigEnv.WEBSOCKET_PROXY_PORT],
            })
Example #13
0
    def _customization(self):
        valid = False
        password = None
        while not valid:
            password = self.dialog.queryString(
                name="OVESETUP_CONFIG_ADMIN_SETUP", note=_("Engine admin password: "******"OVESETUP_CONFIG_ADMIN_SETUP", note=_("Confirm engine admin password: "******"Passwords do not match"))
            else:
                try:
                    import cracklib

                    cracklib.FascistCheck(password)
                    valid = True
                except ImportError:
                    # do not force this optional feature
                    self.logger.debug("cannot import cracklib", exc_info=True)
                    valid = True
                except ValueError as e:
                    self.logger.warning(_("Password is weak: {error}").format(error=e))
                    valid = dialog.queryBoolean(
                        dialog=self.dialog,
                        name="OVESETUP_CONFIG_WEAK_ENGINE_PASSWORD",
                        note=_("Use weak password? " "(@VALUES@) [@DEFAULT@]: "),
                        prompt=True,
                        default=False,
                    )

        self.environment[oenginecons.ConfigEnv.ADMIN_PASSWORD] = password
Example #14
0
    def _validation(self):
        self._content = (
            "# ovirt-engine configuration.\n"
            "kernel.shmmax = %s\n"
        ) % self.environment[oengcommcons.SystemEnv.SHMMAX]

        interactive = self.environment[osetupcons.CoreEnv.DEVELOPER_MODE]

        while True:
            shmmax = self._get_shmmax()

            if shmmax >= self.environment[oengcommcons.SystemEnv.SHMMAX]:
                break
            else:
                self.logger.debug(
                    'sysctl shared memory is %s lower than %s' % (
                        shmmax,
                        self.environment[oengcommcons.SystemEnv.SHMMAX],
                    )
                )

                if not interactive:
                    self._enabled = True
                    break
                else:
                    self.logger.warning(_('Manual intervention is required'))
                    self.dialog.note(
                        text=_(
                            "Current shared memory setting is too low.\n"
                            "Unable to set while running unprivileged.\n"
                            "Please write the following file: '{file}', "
                            "with the following content:\n"
                            "---\n"
                            "{content}"
                            "---\n"
                            "Then execute the following command as root:\n"
                            "{sysctl} -p {file}"
                        ).format(
                            file=(
                                oengcommcons.FileLocations.OVIRT_ENGINE_SYSCTL
                            ),
                            content=self._content,
                            sysctl=self.command.get('sysctl'),
                        )
                    )

                    if not dialog.queryBoolean(
                        dialog=self.dialog,
                        name='OVESETUP_SYSTEM_SYSCTL_SHMEM',
                        note=_(
                            'Proceed? (@VALUES@) [@DEFAULT@]: '
                        ),
                        prompt=True,
                        true=_('OK'),
                        false=_('Cancel'),
                        default=True,
                    ):
                        raise RuntimeError(
                            _('Aborted by user')
                        )
Example #15
0
    def _customization(self):
        if self.environment[oengcommcons.ApacheEnv.CONFIGURE_SSL] is None:
            self.dialog.note(
                _("Setup can configure apache to use SSL using a " "certificate issued from the internal CA.")
            )
            self.environment[oengcommcons.ApacheEnv.CONFIGURE_SSL] = dialog.queryBoolean(
                dialog=self.dialog,
                name="OVESETUP_APACHE_CONFIG_SSL",
                note=_(
                    "Do you wish Setup to configure that, or prefer to "
                    "perform that manually? (@VALUES@) [@DEFAULT@]: "
                ),
                prompt=True,
                true=_("Automatic"),
                false=_("Manual"),
                default=True,
            )

        self._enabled = self.environment[oengcommcons.ApacheEnv.CONFIGURE_SSL]

        if self._enabled:
            if not os.path.exists(self.environment[oengcommcons.ApacheEnv.HTTPD_CONF_SSL]):
                self.logger.warning(
                    _(
                        "Automatic Apache SSL configuration was requested. "
                        "However, SSL configuration file '{file}' was not "
                        "found. Disabling automatic Apache SSL configuration."
                    )
                )
                self._enabled = False
    def _customization_is_requested(self):
        self._detected_managers = [
            m
            for m in self.environment[osetupcons.ConfigEnv.FIREWALL_MANAGERS]
            if m.selectable() and m.detect()
        ]

        if self.environment[
            osetupcons.ConfigEnv.UPDATE_FIREWALL
        ] is None:
            if not self._detected_managers:
                self.environment[osetupcons.ConfigEnv.UPDATE_FIREWALL] = False
            else:
                self.dialog.note(
                    text=_(
                        'Setup can automatically configure the firewall '
                        'on this system.\n'
                        'Note: automatic configuration of the firewall may '
                        'overwrite current settings.\n'
                    ),
                )
                self.environment[
                    osetupcons.ConfigEnv.UPDATE_FIREWALL
                ] = dialog.queryBoolean(
                    dialog=self.dialog,
                    name='OVESETUP_UPDATE_FIREWALL',
                    note=_(
                        'Do you want Setup to configure the firewall? '
                        '(@VALUES@) [@DEFAULT@]: '
                    ),
                    prompt=True,
                    true=_('Yes'),
                    false=_('No'),
                    default=True,
                )
Example #17
0
    def _aia(self):
        x509 = X509.load_cert(file=oenginecons.FileLocations.OVIRT_ENGINE_PKI_ENGINE_CA_CERT, format=X509.FORMAT_PEM)

        try:
            authorityInfoAccess = x509.get_ext("authorityInfoAccess").get_value()

            self.logger.warning(_("AIA extension found in CA certificate"))
            self.dialog.note(
                text=_(
                    "Please note:\n"
                    "The certificate for the CA contains the\n"
                    '"Authority Information Access" extension pointing\n'
                    "to the old hostname:\n"
                    "{aia}"
                    "Currently this is harmless, but it might affect future\n"
                    "upgrades. In version 3.3 the default was changed to\n"
                    "create new CA certificate without this extension. If\n"
                    "possible, it might be better to not rely on this\n"
                    "program, and instead backup, cleanup and setup again\n"
                    "cleanly.\n"
                    "\n"
                    "More details can be found at the following address:\n"
                    "http://www.ovirt.org/Changing_Engine_Hostname\n"
                ).format(aia=authorityInfoAccess)
            )
            if not dialog.queryBoolean(
                dialog=self.dialog,
                name="OVESETUP_RENAME_AIA_BYPASS",
                note=_("Do you want to continue? (@VALUES@) [@DEFAULT@]: "),
                prompt=True,
            ):
                raise RuntimeError(_("Aborted by user"))
        except LookupError:
            pass
Example #18
0
    def _customization(self):
        if self.environment[
            oengcommcons.ApacheEnv.CONFIGURE_ROOT_REDIRECTION
        ] is None:
            self.dialog.note(
                _(
                    'Setup can configure the default page of the '
                    'web server to present the application home page. '
                    'This may conflict with existing applications.'
                )
            )
            self.environment[
                oengcommcons.ApacheEnv.CONFIGURE_ROOT_REDIRECTION
            ] = dialog.queryBoolean(
                dialog=self.dialog,
                name='OVESETUP_APACHE_CONFIG_ROOT_REDIRECTION',
                note=_(
                    'Do you wish to set the application as the default page '
                    'of the web server? (@VALUES@) [@DEFAULT@]: '
                ),
                prompt=True,
                default=self.environment[
                    oengcommcons.ApacheEnv.CONFIGURE_ROOT_REDIRECTIOND_DEFAULT
                ],
            )

        self._enabled = self.environment[
            oengcommcons.ApacheEnv.CONFIGURE_ROOT_REDIRECTION
        ]
Example #19
0
    def _customization(self):

        if self.services.status(name=odockerccons.Const.DOCKER_SERVICE_NANE, ):
            self.logger.info(_('Found a running docker daemon'))
        else:
            self.logger.info(_('Unable to find an active docker daemon'))
            if self.environment[odockerccons.ConfigEnv.DOCKERC_DAEMON] is None:
                self.environment[
                    odockerccons.ConfigEnv.
                    DOCKERC_DAEMON] = dialog.queryBoolean(
                        dialog=self.dialog,
                        name='OVESETUP_CONFIG_DOCKERC_DAEMON',
                        note=_(
                            'To continue with this setup the docker daemon '
                            'should be active.\n'
                            'Would you like to start it and continue with Setup? '
                            '(@VALUES@) [@DEFAULT@]: '),
                        prompt=True,
                        default=True,
                    )
            if self.environment[odockerccons.ConfigEnv.DOCKERC_DAEMON]:
                self.logger.info(_('Starting Docker'))
                self.services.state(
                    name=odockerccons.Const.DOCKER_SERVICE_NANE,
                    state=True,
                )
            else:
                raise RuntimeError(
                    _('Docker daemon is required to complete this setup'))
Example #20
0
    def _customization(self):

        if self.environment[
            osetupcons.ConfigEnv.WEBSOCKET_PROXY_CONFIG
        ] is None:
            self.environment[
                osetupcons.ConfigEnv.WEBSOCKET_PROXY_CONFIG
            ] = dialog.queryBoolean(
                dialog=self.dialog,
                name='OVESETUP_CONFIG_WEBSOCKET_PROXY',
                note=_(
                    'Configure WebSocket Proxy on this machine? '
                    '(@VALUES@) [@DEFAULT@]: '
                ),
                prompt=True,
                default=True,
            )
        self._enabled = self.environment[
            osetupcons.ConfigEnv.WEBSOCKET_PROXY_CONFIG
        ]

        if self._enabled:
            self.environment[osetupcons.NetEnv.FIREWALLD_SERVICES].extend([
                {
                    'name': 'ovirt-websocket-proxy',
                    'directory': 'base'
                },
            ])
            self.environment[
                osetupcons.NetEnv.FIREWALLD_SUBST
            ].update({
                '@WEBSOCKET_PROXY_PORT@': self.environment[
                    osetupcons.ConfigEnv.WEBSOCKET_PROXY_PORT
                ],
            })
Example #21
0
    def _customization_is_requested(self):
        self._detected_managers = [
            m for m in self.environment[osetupcons.ConfigEnv.FIREWALL_MANAGERS]
            if m.selectable() and m.detect()
        ]

        if self.environment[osetupcons.ConfigEnv.UPDATE_FIREWALL] is None:
            if not self._detected_managers:
                self.environment[osetupcons.ConfigEnv.UPDATE_FIREWALL] = False
            else:
                self.dialog.note(text=_(
                    'Setup can automatically configure the firewall '
                    'on this system.\n'
                    'Note: automatic configuration of the firewall may '
                    'overwrite current settings.\n'), )
                self.environment[
                    osetupcons.ConfigEnv.
                    UPDATE_FIREWALL] = dialog.queryBoolean(
                        dialog=self.dialog,
                        name='OVESETUP_UPDATE_FIREWALL',
                        note=_('Do you want Setup to configure the firewall? '
                               '(@VALUES@) [@DEFAULT@]: '),
                        prompt=True,
                        true=_('Yes'),
                        false=_('No'),
                        default=True,
                    )
Example #22
0
    def _validation(self):
        if self.environment[osetupcons.CoreEnv.REMOVE] is None:
            if self.environment[osetupcons.RemoveEnv.REMOVE_ALL]:
                cnote = _(
                    'All the installed ovirt components are about to be '
                    'removed, data will be lost (@VALUES@) [@DEFAULT@]: ')
            elif (self.environment[osetupcons.RemoveEnv.REMOVE_OPTIONS]
                  or self.environment[osetupcons.RemoveEnv.REMOVE_GROUPS]):
                cnote = _(
                    'The following components are about to be removed, data '
                    'will be lost:\n'
                    '{clist}'
                    '(@VALUES@) [@DEFAULT@]: ').format(clist=', '.join(
                        self.environment[osetupcons.RemoveEnv.REMOVE_OPTIONS] +
                        [
                            x.strip() for x in self.environment[
                                osetupcons.RemoveEnv.REMOVE_GROUPS].split(',')
                            if x
                        ]))
            else:
                raise RuntimeError(_('Nothing to remove'))

            self.environment[osetupcons.CoreEnv.REMOVE] = dialog.queryBoolean(
                dialog=self.dialog,
                name='OVESETUP_CORE_REMOVE',
                note=cnote,
                prompt=True,
                true=_('OK'),
                false=_('Cancel'),
                default=False,
            )

        if not self.environment[osetupcons.CoreEnv.REMOVE]:
            raise RuntimeError(_('Aborted by user'))
Example #23
0
    def _customization(self):
        self.dialog.note(
            text=_('\n--== CONFIGURATION PREVIEW ==--\n\n'),
        )
        shown = set()
        for c in sum(
            [
                constobj.__dict__['__osetup_attrs__']
                for constobj in self.environment[
                    osetupcons.CoreEnv.SETUP_ATTRS_MODULES
                ]
            ],
            [],
        ):
            for k in c.__dict__.values():
                if hasattr(k, '__osetup_attrs__'):
                    attrs = k.__osetup_attrs__
                    if (
                        attrs['summary'] and
                        attrs['summary_condition'](self.environment)
                    ):
                        env = k.fget(None)
                        value = self.environment.get(env)
                        if value is not None and env not in shown:
                            shown.add(env)
                            self.dialog.note(
                                text=_('{key:40}: {value}').format(
                                    key=(
                                        attrs['description']
                                        if attrs['description'] is not None
                                        else env
                                    ),
                                    value=value,
                                ),
                            )

        confirmed = self.environment[
            osetupcons.DialogEnv.CONFIRM_SETTINGS
        ]
        if confirmed is None:
            confirmed = dialog.queryBoolean(
                dialog=self.dialog,
                name='OVESETUP_DIALOG_CONFIRM_SETTINGS',
                note=_(
                    '\n'
                    'Please confirm installation settings '
                    '(@VALUES@) [@DEFAULT@]: '
                ),
                prompt=True,
                true=_('OK'),
                false=_('Cancel'),
                default=True,
            )

        if not confirmed:
            raise RuntimeError(_('Configuration was rejected by user'))

        self.environment[
            osetupcons.DialogEnv.CONFIRM_SETTINGS
        ] = True
Example #24
0
    def _customization(self):
        """
        If the application mode is gluster don't ask to configure NFS.
        Else if not already configured, ask if you want to use NFS shares for
        ISO domain. If acknowledged, configure NFS related services.
        """
        if self.environment[
                osetupcons.ConfigEnv.APPLICATION_MODE] == 'gluster':
            self.logger.info(
                _('NFS configuration skipped with application mode Gluster'))
            self._enabled = False
        else:
            enabled = self.environment[
                oenginecons.SystemEnv.NFS_CONFIG_ENABLED]
            if enabled is None:
                self._enabled = dialog.queryBoolean(
                    dialog=self.dialog,
                    name='NFS_CONFIG_ENABLED',
                    note=_('Configure an NFS share on this server to be used '
                           'as an ISO Domain? '
                           '(@VALUES@) [@DEFAULT@]: '),
                    prompt=True,
                    default=True,
                )
            else:
                self._enabled = enabled

        # expose to other modules
        self.environment[
            oenginecons.SystemEnv.NFS_CONFIG_ENABLED] = self._enabled
Example #25
0
    def _customization(self):
        if self.environment[osetupcons.RemoveEnv.REMOVE_ALL]:
            self.environment[owspcons.RemoveEnv.REMOVE_WSP] = True

        if self.environment[owspcons.RemoveEnv.REMOVE_WSP] is None:
            self.environment[
                owspcons.RemoveEnv.REMOVE_WSP
            ] = dialog.queryBoolean(
                dialog=self.dialog,
                name='OVESETUP_REMOVE_WEBSOCKET_PROXY',
                note=_(
                    'Do you want to remove the WebSocket proxy? '
                    '(@VALUES@) [@DEFAULT@]: '
                ),
                prompt=True,
                true=_('Yes'),
                false=_('No'),
                default=False,
            )

        if self.environment[owspcons.RemoveEnv.REMOVE_WSP]:
            self.environment[osetupcons.RemoveEnv.REMOVE_OPTIONS].append(
                owspcons.Const.WEBSOCKET_PROXY_PACKAGE_NAME
            )
            self.environment[
                owspcons.ConfigEnv.WEBSOCKET_PROXY_STOP_NEEDED
            ] = True
Example #26
0
 def _customization_upgrade(self):
     if True in [
             self._expired(
                 X509.load_cert(oenginecons.FileLocations.
                                OVIRT_ENGINE_PKI_ENGINE_CA_CERT))
     ] + [
             self._ok_to_renew_cert(
                 os.path.join(
                     oenginecons.FileLocations.OVIRT_ENGINE_PKIKEYSDIR,
                     '%s.p12' % entry['name']), entry['name'],
                 entry['extract']) for entry in self._PKI_ENTRIES
     ]:
         if self.environment[oenginecons.PKIEnv.RENEW] is None:
             self.environment[oenginecons.PKIEnv.RENEW] = dialog.queryBoolean(
                 dialog=self.dialog,
                 name='OVESETUP_RENEW_PKI',
                 note=_(
                     'One or more of the certificates should be renewed, '
                     'because they expire soon or include an invalid '
                     'expiry date, which is rejected by recent browsers.\n'
                     'If you choose "No", you will be asked again the next '
                     'time you run Setup.\n'
                     'See {url} for more details.\n'
                     'Renew certificates? '
                     '(@VALUES@) [@DEFAULT@]: ').format(url=(
                         'http://www.ovirt.org/OVirt_3.5.3_Release_Notes'
                         '#PKI'), ),
                 prompt=True,
                 default=None,
             )
Example #27
0
    def _customization(self):
        if self.environment[
            osetupcons.RemoveEnv.REMOVE_ALL
        ]:
            self.environment[
                odwhcons.RemoveEnv.REMOVE_DATABASE
            ] = True

        if self.environment[
            odwhcons.RemoveEnv.REMOVE_DATABASE
        ] is None:
            self.environment[
                odwhcons.RemoveEnv.REMOVE_DATABASE
            ] = dialog.queryBoolean(
                dialog=self.dialog,
                name='OVESETUP_DWH_REMOVE_DATABASE',
                note=_(
                    'Do you want to remove DWH DB content? All data will '
                    'be lost (@VALUES@) [@DEFAULT@]: '
                ),
                prompt=True,
                true=_('Yes'),
                false=_('No'),
                default=False,
            )
Example #28
0
    def _continueSetupWithoutAIO(self):
        if self.environment[
            osetupcons.AIOEnv.CONTINUE_WITHOUT_AIO
        ] is None:
            self.environment[
                osetupcons.AIOEnv.CONTINUE_WITHOUT_AIO
            ] = dialog.queryBoolean(
                dialog=self.dialog,
                name='OVESETUP_CONTINUE_WITHOUT_AIO',
                note=_(
                    'Disabling all-in-one plugin because hardware '
                    'supporting virtualization could not be detected. '
                    'Do you want to continue setup without AIO plugin? '
                    '(@VALUES@) [@DEFAULT@]: '
                ),
                prompt=True,
                default=False,
            )

        if self.environment[
            osetupcons.AIOEnv.CONTINUE_WITHOUT_AIO
        ]:
            self._enabled = False
            self.environment[osetupcons.AIOEnv.CONFIGURE] = False
        else:
            raise RuntimeError(
                _('Aborted by user.')
            )
Example #29
0
    def _customization(self):
        if self.environment[oengcommcons.ApacheEnv.CONFIGURE_SSL] is None:
            self.dialog.note(
                _('Setup can configure apache to use SSL using a '
                  'certificate issued from the internal CA.'))
            self.environment[
                oengcommcons.ApacheEnv.CONFIGURE_SSL] = dialog.queryBoolean(
                    dialog=self.dialog,
                    name='OVESETUP_APACHE_CONFIG_SSL',
                    note=_('Do you wish Setup to configure that, or prefer to '
                           'perform that manually? (@VALUES@) [@DEFAULT@]: '),
                    prompt=True,
                    true=_('Automatic'),
                    false=_('Manual'),
                    default=True,
                )

        self._enabled = self.environment[oengcommcons.ApacheEnv.CONFIGURE_SSL]

        if self._enabled:
            if not os.path.exists(
                    self.environment[oengcommcons.ApacheEnv.HTTPD_CONF_SSL]):
                self.logger.warning(
                    _("Automatic Apache SSL configuration was requested. "
                      "However, SSL configuration file '{file}' was not "
                      "found. Disabling automatic Apache SSL configuration."))
                self._enabled = False
Example #30
0
    def _customization(self):
        if self.environment[
            osetupcons.RemoveEnv.REMOVE_ALL
        ]:
            self.environment[
                oreportscons.RemoveEnv.REMOVE_JASPER_ARTIFACTS
            ] = True

        if self.environment[
            oreportscons.RemoveEnv.REMOVE_JASPER_ARTIFACTS
        ] is None:
            self.environment[
                oreportscons.RemoveEnv.REMOVE_JASPER_ARTIFACTS
            ] = dialog.queryBoolean(
                dialog=self.dialog,
                name='OVESETUP_REPORTS_REMOVE_JASPER_ARTIFACTS',
                note=_(
                    'Do you want to remove Reports Jasper artifacts? '
                    '(@VALUES@) [@DEFAULT@]: '
                ),
                prompt=True,
                true=_('Yes'),
                false=_('No'),
                default=False,
            )
Example #31
0
    def _customization(self):
        self._enabled = self.environment[osetupcons.DBEnv.NEW_DATABASE]

        if not self._enabled:
            self.dialog.note(text=_(
                'Skipping storing options as database already '
                'prepared'), )
        else:
            if self.environment[osetupcons.ConfigEnv.ADMIN_PASSWORD] is None:
                valid = False
                password = None
                while not valid:
                    password = self.dialog.queryString(
                        name='OVESETUP_CONFIG_ADMIN_SETUP',
                        note=_('Engine admin password: '******'OVESETUP_CONFIG_ADMIN_SETUP',
                        note=_('Confirm engine admin password: '******'Passwords do not match'))
                    else:
                        try:
                            import cracklib
                            cracklib.FascistCheck(password)
                            valid = True
                        except ImportError:
                            # do not force this optional feature
                            self.logger.debug(
                                'cannot import cracklib',
                                exc_info=True,
                            )
                            valid = True
                        except ValueError as e:
                            self.logger.warning(
                                _('Password is weak: {error}').format(
                                    error=e, ))
                            valid = dialog.queryBoolean(
                                dialog=self.dialog,
                                name='OVESETUP_CONFIG_WEAK_ENGINE_PASSWORD',
                                note=_('Use weak password? '
                                       '(@VALUES@) [@DEFAULT@]: '),
                                prompt=True,
                                default=False,
                            )

                self.environment[
                    osetupcons.ConfigEnv.ADMIN_PASSWORD] = password

            self.environment[otopicons.CoreEnv.LOG_FILTER].append(
                self.environment[osetupcons.ConfigEnv.ADMIN_PASSWORD])
Example #32
0
    def _customization(self):
        if self.environment[
            oreportscons.ConfigEnv.ADMIN_PASSWORD
        ] is None:
            valid = False
            password = None
            while not valid:
                password = self.dialog.queryString(
                    name='OVESETUP_REPORTS_CONFIG_JASPER_ADMIN_PASSWORD',
                    note=_('Reports power users password: '******'OVESETUP_REPOTS_CONFIG_JASPER_ADMIN_PASSWORD',
                    note=_('Confirm Reports power users password: '******'Passwords do not match'))
                else:
                    try:
                        import cracklib
                        cracklib.FascistCheck(password)
                        valid = True
                    except ImportError:
                        # do not force this optional feature
                        self.logger.debug(
                            'cannot import cracklib',
                            exc_info=True,
                        )
                        valid = True
                    except ValueError as e:
                        self.logger.warning(
                            _('Password is weak: {error}').format(
                                error=e,
                            )
                        )
                        valid = dialog.queryBoolean(
                            dialog=self.dialog,
                            name=(
                                'OVESETUP_REPORTS_CONFIG_WEAK_JASPER_PASSWORD'
                            ),
                            note=_(
                                'Use weak password? '
                                '(@VALUES@) [@DEFAULT@]: '
                            ),
                            prompt=True,
                            default=False,
                        )

            self.environment[oreportscons.ConfigEnv.ADMIN_PASSWORD] = password
Example #33
0
    def _validation(self):
        self._content = ("# ovirt-engine configuration.\n"
                         "kernel.shmmax = %s\n"
                         ) % self.environment[osetupcons.SystemEnv.SHMMAX]

        interactive = self.environment[osetupcons.CoreEnv.DEVELOPER_MODE]

        while True:
            rc, shmmax, stderr = self.execute((
                self.command.get('sysctl'),
                '-n',
                'kernel.shmmax',
            ), )
            shmmax = int(shmmax[0])

            if shmmax >= self.environment[osetupcons.SystemEnv.SHMMAX]:
                break
            else:
                self.logger.debug(
                    'sysctl shared memory is %s lower than %s' % (
                        shmmax,
                        self.environment[osetupcons.SystemEnv.SHMMAX],
                    ))

                if not interactive:
                    self._enabled = True
                    break
                else:
                    self.logger.warning(_('Manual intervention is required'))
                    self.dialog.note(text=_(
                        "Current shared memory setting is too low.\n"
                        "Unable to set while running unprivileged.\n"
                        "Please write the following file: '{file}', "
                        "with the following content:\n"
                        "---\n"
                        "{content}"
                        "---\n"
                        "Then execute the following command as root:\n"
                        "{sysctl} -p {file}").format(
                            file=osetupcons.FileLocations.OVIRT_ENGINE_SYSCTL,
                            content=self._content,
                            sysctl=self.command.get('sysctl'),
                        ))

                    if not dialog.queryBoolean(
                            dialog=self.dialog,
                            name='OVESETUP_SYSTEM_SYSCTL_SHMEM',
                            note=_('Proceed? (@VALUES@) [@DEFAULT@]: '),
                            prompt=True,
                            true=_('OK'),
                            false=_('Cancel'),
                            default=True,
                    ):
                        raise RuntimeError(_('Aborted by user'))
Example #34
0
 def _customization(self):
     if self.environment[osetupcons.RemoveEnv.REMOVE_ALL] is None:
         self.environment[osetupcons.RemoveEnv.REMOVE_ALL] = dialog.queryBoolean(
             dialog=self.dialog,
             name="OVESETUP_REMOVE_ALL",
             note=_("Do you want to remove all components? " "(@VALUES@) [@DEFAULT@]: "),
             prompt=True,
             true=_("Yes"),
             false=_("No"),
             default=True,
         )
Example #35
0
 def _customization(self):
     if self.environment[ovmpcons.ConfigEnv.VMCONSOLE_PROXY_CONFIG] is None:
         self.environment[ovmpcons.ConfigEnv.
                          VMCONSOLE_PROXY_CONFIG] = dialog.queryBoolean(
                              dialog=self.dialog,
                              name='OVESETUP_CONFIG_VMCONSOLE_PROXY',
                              note=_(
                                  'Configure VM Console Proxy on this host '
                                  '(@VALUES@) [@DEFAULT@]: '),
                              prompt=True,
                              default=True,
                          )
Example #36
0
 def _customization(self):
     if (
         self.environment[
             oenginecons.RemoveEnv.REMOVE_ENGINE
         ] is None and
         self.environment[
             oenginecons.CoreEnv.ENABLE
         ]
     ):
         self.environment[
             oenginecons.RemoveEnv.REMOVE_ENGINE
         ] = dialog.queryBoolean(
             dialog=self.dialog,
             name='OVESETUP_REMOVE_ENGINE',
             note=_(
                 'Do you want to remove the engine? '
                 '(@VALUES@) [@DEFAULT@]: '
             ),
             prompt=True,
             true=_('Yes'),
             false=_('No'),
             default=True,
         )
         if self.environment[oenginecons.RemoveEnv.REMOVE_ENGINE]:
             self.environment[osetupcons.RemoveEnv.REMOVE_OPTIONS].append(
                 oenginecons.Const.ENGINE_PACKAGE_NAME
             )
             # TODO: avoid to hard-coded group names here.
             # we should modify all groups with some engine prefix so we
             # know what they are, then just iterate based on prefix.
             # alternatively have a group of groups.
             # Put as much information within uninstall so that the
             # uninstall will be as stupid as we can have.
             # as uninstall will be modified after upgrade, new groups will
             # be available there anyway... so we can modify names.
             # also, if there is some kind of a problem we can have
             # temporary mapping between old and new.
             # anything that will require update of both setup and remove
             # on regular basis.
             self.environment[
                 osetupcons.RemoveEnv.REMOVE_SPEC_OPTION_GROUP_LIST
             ].extend(
                 [
                     'ca_pki',
                     'exportfs',
                     'nfs_config',
                     'ca_pki',
                     'iso_domain',
                     'ca_config',
                     'ssl',
                     'versionlock',
                 ]
             )
Example #37
0
 def _configureSANWipeAfterDelete(self):
     if self.environment[SAN_WIPE_AFTER_DELETE] is None:
         # Value for SAN_WIPE_AFTER_DELETE is not forced.
         sanWipeAfterDelete = dialog.queryBoolean(
             dialog=self.dialog,
             name='OVESETUP_CONFIG_SAN_WIPE_AFTER_DELETE',
             note=_('Default SAN wipe after delete '
                    '(@VALUES@) [@DEFAULT@]: '),
             prompt=True,
             default=False,
         )
         self.environment[SAN_WIPE_AFTER_DELETE] = sanWipeAfterDelete
Example #38
0
 def _customization(self):
     if (
         self.environment[
             oenginecons.RemoveEnv.REMOVE_ENGINE
         ] is None and
         self.environment[
             oenginecons.CoreEnv.ENABLE
         ]
     ):
         self.environment[
             oenginecons.RemoveEnv.REMOVE_ENGINE
         ] = dialog.queryBoolean(
             dialog=self.dialog,
             name='OVESETUP_REMOVE_ENGINE',
             note=_(
                 'Do you want to remove the engine? '
                 '(@VALUES@) [@DEFAULT@]: '
             ),
             prompt=True,
             true=_('Yes'),
             false=_('No'),
             default=False,
         )
         if self.environment[oenginecons.RemoveEnv.REMOVE_ENGINE]:
             self.environment[osetupcons.RemoveEnv.REMOVE_OPTIONS].append(
                 oenginecons.Const.ENGINE_PACKAGE_NAME
             )
             # TODO: avoid to hard-coded group names here.
             # we should modify all groups with some engine prefix so we
             # know what they are, then just iterate based on prefix.
             # alternatively have a group of groups.
             # Put as much information within uninstall so that the
             # uninstall will be as stupid as we can have.
             # as uninstall will be modified after upgrade, new groups will
             # be available there anyway... so we can modify names.
             # also, if there is some kind of a problem we can have
             # temporary mapping between old and new.
             # anything that will require update of both setup and remove
             # on regular basis.
             self.environment[
                 osetupcons.RemoveEnv.REMOVE_SPEC_OPTION_GROUP_LIST
             ].extend(
                 [
                     'ca_pki',
                     'exportfs',
                     'nfs_config',
                     'ca_pki',
                     'iso_domain',
                     'ca_config',
                     'ssl',
                     'versionlock',
                 ]
             )
Example #39
0
 def _constomization(self):
     if self.environment[oenginecons.AIOEnv.CONFIGURE] is None:
         self.environment[oenginecons.AIOEnv.CONFIGURE] = dialog.queryBoolean(
             dialog=self.dialog,
             name="OVESETUP_AIO_CONFIGURE",
             note=_("Configure VDSM on this host? " "(@VALUES@) [@DEFAULT@]: "),
             prompt=True,
             default=False,
         )
     if self.environment[oenginecons.AIOEnv.CONFIGURE]:
         self.environment[osetupcons.ConfigEnv.FQDN_REVERSE_VALIDATION] = True
         self.environment[osetupcons.ConfigEnv.FQDN_NON_LOOPBACK_VALIDATION] = True
Example #40
0
    def _validation(self):
        if self.environment[
            osetupcons.CoreEnv.REMOVE
        ] is None:
            if self.environment[osetupcons.RemoveEnv.REMOVE_ALL]:
                cnote = _(
                    'All the installed ovirt components are about to be '
                    'removed, data will be lost (@VALUES@) [@DEFAULT@]: '
                )
            elif (
                self.environment[osetupcons.RemoveEnv.REMOVE_OPTIONS] or
                self.environment[osetupcons.RemoveEnv.REMOVE_GROUPS]
            ):
                cnote = _(
                    'The following components are about to be removed, data '
                    'will be lost:\n'
                    '{clist}'
                    '(@VALUES@) [@DEFAULT@]: '
                ).format(
                    clist=', '.join(
                        self.environment[
                            osetupcons.RemoveEnv.REMOVE_OPTIONS
                        ] + [
                            x.strip()
                            for x in self.environment[
                                osetupcons.RemoveEnv.REMOVE_GROUPS
                            ].split(',')
                            if x
                        ]
                    )
                )
            else:
                raise RuntimeError(
                    _('Nothing to remove')
                )

            self.environment[
                osetupcons.CoreEnv.REMOVE
            ] = dialog.queryBoolean(
                dialog=self.dialog,
                name='OVESETUP_CORE_REMOVE',
                note=cnote,
                prompt=True,
                true=_('OK'),
                false=_('Cancel'),
                default=False,
            )

        if not self.environment[osetupcons.CoreEnv.REMOVE]:
            raise RuntimeError(
                _('Aborted by user')
            )
Example #41
0
 def _customization(self):
     if self.environment[osetupcons.RemoveEnv.REMOVE_ALL] is None:
         self.environment[
             osetupcons.RemoveEnv.REMOVE_ALL] = dialog.queryBoolean(
                 dialog=self.dialog,
                 name='OVESETUP_REMOVE_ALL',
                 note=_('Do you want to remove all components? '
                        '(@VALUES@) [@DEFAULT@]: '),
                 prompt=True,
                 true=_('Yes'),
                 false=_('No'),
                 default=True,
             )
Example #42
0
    def _validation(self):
        self._statement = database.Statement(
            dbenvkeys=odwhcons.Const.ENGINE_DB_ENV_KEYS,
            environment=self.environment,
        )
        self._db_dwh_hostname = engine_db_timekeeping.getValueFromTimekeeping(
            statement=self._statement,
            name=engine_db_timekeeping.DB_KEY_HOSTNAME
        )
        db_dwh_uuid = engine_db_timekeeping.getValueFromTimekeeping(
            statement=self._statement,
            name=engine_db_timekeeping.DB_KEY_UUID
        )

        if (
            db_dwh_uuid and
            db_dwh_uuid != self.environment[odwhcons.CoreEnv.UUID]
        ):
            if self.environment[
                odwhcons.DBEnv.DISCONNECT_EXISTING_DWH
            ] is None:
                self.environment[
                    odwhcons.DBEnv.DISCONNECT_EXISTING_DWH
                ] = dialog.queryBoolean(
                    dialog=self.dialog,
                    name='OVESETUP_DWH_DISCONNECT_EXISTING',
                    note=_(
                        'An existing DWH is configured to work with this '
                        'engine.\n'
                        'Its hostname is {hostname}.\n'
                        'A positive answer to the following question will '
                        'cause the existing DWH to be permanently '
                        'disconnected from the engine.\n'
                        'A negative answer will stop Setup.\n'
                        'Do you want to permanently disconnect this DWH from '
                        'the engine? '
                        '(@VALUES@) [@DEFAULT@]: '
                    ).format(
                        hostname=self._db_dwh_hostname,
                    ),
                    prompt=True,
                    true=_('Yes'),
                    false=_('No'),
                    default=False,
                )
            if not self.environment[
                odwhcons.DBEnv.DISCONNECT_EXISTING_DWH
            ]:
                raise RuntimeError(
                    _('An existing DWH found - Setup cancelled by user')
                )
Example #43
0
 def _customization(self):
     if self.environment[odwhcons.CoreEnv.ENABLE] is None:
         self.environment[
             odwhcons.CoreEnv.ENABLE
         ] = dialog.queryBoolean(
             dialog=self.dialog,
             name='OVESETUP_DWH_ENABLE',
             note=_(
                 'Configure Data Warehouse on this host '
                 '(@VALUES@) [@DEFAULT@]: '
             ),
             prompt=True,
             default=True,
         )
Example #44
0
 def _customization(self):
     if self.environment[oreportscons.CoreEnv.ENABLE] is None:
         self.environment[
             oreportscons.CoreEnv.ENABLE
         ] = dialog.queryBoolean(
             dialog=self.dialog,
             name='OVESETUP_REPORTS_ENABLE',
             note=_(
                 'Install Reports on this host '
                 '(@VALUES@) [@DEFAULT@]: '
             ),
             prompt=True,
             default=True,
         )
Example #45
0
 def _askUserToWaitForTasks(
     self,
     runningTasks,
     runningCommands,
     compensations,
 ):
     self.dialog.note(
         text=_(
             'The following system tasks have been '
             'found running in the system:\n'
             '{tasks}'
         ).format(
             tasks='\n'.join(runningTasks),
         )
     )
     self.dialog.note(
         text=_(
             'The following commands have been '
             'found running in the system:\n'
             '{commands}'
         ).format(
             commands='\n'.join(runningCommands),
         )
     )
     self.dialog.note(
         text=_(
             'The following compensations have been '
             'found running in the system:\n'
             '{compensations}'
         ).format(
             compensations='\n'.join(compensations),
         )
     )
     if not dialog.queryBoolean(
         dialog=self.dialog,
         name='OVESETUP_WAIT_RUNNING_TASKS',
         note=_(
             'Would you like to try to wait for that?\n'
             '(Answering "no" will stop the upgrade (@VALUES@) '
         ),
         prompt=True,
     ):
         raise RuntimeError(
             _(
                 'Upgrade cannot be completed; asynchronious tasks or '
                 'commands or compensations are still running. Please '
                 'make sure that there are no running tasks before you '
                 'continue.'
             )
         )
Example #46
0
 def _configureSANWipeAfterDelete(self):
     if self.environment[SAN_WIPE_AFTER_DELETE] is None:
         # Value for SAN_WIPE_AFTER_DELETE is not forced.
         sanWipeAfterDelete = dialog.queryBoolean(
             dialog=self.dialog,
             name='OVESETUP_CONFIG_SAN_WIPE_AFTER_DELETE',
             note=_(
                 'Default SAN wipe after delete '
                 '(@VALUES@) [@DEFAULT@]: '
             ),
             prompt=True,
             default=False,
         )
         self.environment[SAN_WIPE_AFTER_DELETE] = sanWipeAfterDelete
Example #47
0
    def _validation(self):
        if self.environment[osetupcons.CoreEnv.REMOVE] is None:
            self.environment[osetupcons.CoreEnv.REMOVE] = dialog.queryBoolean(
                dialog=self.dialog,
                name='OVESETUP_CORE_REMOVE',
                note=_('ovirt-engine is about to be removed, data will '
                       'be lost (@VALUES@) [@DEFAULT@]: '),
                prompt=True,
                true=_('OK'),
                false=_('Cancel'),
                default=False,
            )

        if not self.environment[osetupcons.CoreEnv.REMOVE]:
            raise RuntimeError(_('Aborted by user'))
Example #48
0
    def _customization(self):

        if self.environment[owspcons.ConfigEnv.WEBSOCKET_PROXY_CONFIG] is None:
            self.environment[owspcons.ConfigEnv.
                             WEBSOCKET_PROXY_CONFIG] = dialog.queryBoolean(
                                 dialog=self.dialog,
                                 name='OVESETUP_CONFIG_WEBSOCKET_PROXY',
                                 note=_(
                                     'Configure WebSocket Proxy on this host '
                                     '(@VALUES@) [@DEFAULT@]: '),
                                 prompt=True,
                                 default=True,
                             )
        self._enabled = self.environment[
            owspcons.ConfigEnv.WEBSOCKET_PROXY_CONFIG]
Example #49
0
 def _customization(self):
     if self.environment[owspcons.RemoveEnv.REMOVE_WSP] is None:
         self.environment[owspcons.RemoveEnv.REMOVE_WSP] = dialog.queryBoolean(
             dialog=self.dialog,
             name="OVESETUP_REMOVE_ENGINE",
             note=_("Do you want to remove the WebSocket proxy? " "(@VALUES@) [@DEFAULT@]: "),
             prompt=True,
             true=_("Yes"),
             false=_("No"),
             default=True,
         )
         if self.environment[owspcons.RemoveEnv.REMOVE_WSP]:
             self.environment[osetupcons.RemoveEnv.REMOVE_OPTIONS].append(
                 owspcons.Const.WEBSOCKET_PROXY_PACKAGE_NAME
             )
Example #50
0
 def _customization(self):
     if self.environment[
             oenginecons.RemoveEnv.REMOVE_ENGINE_DATABASE] is None:
         self.environment[
             oenginecons.RemoveEnv.
             REMOVE_ENGINE_DATABASE] = dialog.queryBoolean(
                 dialog=self.dialog,
                 name='OVESETUP_ENGINE_DB_REMOVE',
                 note=_('Do you want to remove Engine database content? '
                        'All data will be lost (@VALUES@) [@DEFAULT@]: '),
                 prompt=True,
                 true=_('Yes'),
                 false=_('No'),
                 default=False,
             )
Example #51
0
    def _init(self):

        self.environment.setdefault(osetupcons.CoreEnv.GENERATED_BY_VERSION,
                                    None)

        self.environment[osetupcons.CoreEnv.
                         ORIGINAL_GENERATED_BY_VERSION] = self.environment[
                             osetupcons.CoreEnv.GENERATED_BY_VERSION]

        self.environment[
            osetupcons.CoreEnv.
            GENERATED_BY_VERSION] = osetupcons.Const.PACKAGE_VERSION

        self.environment.setdefault(osetupcons.CoreEnv.DEVELOPER_MODE, None)
        self.environment.setdefault(
            osetupcons.CoreEnv.UPGRADE_SUPPORTED_VERSIONS,
            '3.0,3.1,3.2,3.3,3.4,3.5,3.6')

        self.logger.debug(
            'Package: %s-%s (%s)',
            osetupcons.Const.PACKAGE_NAME,
            osetupcons.Const.PACKAGE_VERSION,
            osetupcons.Const.DISPLAY_VERSION,
        )

        self.environment[osetupcons.CoreEnv.SETUP_ATTRS_MODULES] = [osetupcons]

        if self.environment[osetupcons.CoreEnv.DEVELOPER_MODE] is None:
            self.environment[osetupcons.CoreEnv.DEVELOPER_MODE] = False
            if os.geteuid() != 0:
                if not dialog.queryBoolean(
                        dialog=self.dialog,
                        name='OVESETUP_SYSTEM_UNPRIVILEGED',
                        note=_(
                            'Setup was run under unprivileged user '
                            'this will produce development installation '
                            'do you wish to proceed? (@VALUES@) [@DEFAULT@]: '
                        ),
                        prompt=True,
                        default=False,
                ):
                    raise RuntimeError(_('Aborted by user'))
                self.environment[osetupcons.CoreEnv.DEVELOPER_MODE] = True

        if (not self.environment[osetupcons.CoreEnv.DEVELOPER_MODE]
                and os.geteuid() != 0):
            raise RuntimeError(
                _('Running as non root and not in development mode'))
Example #52
0
 def _customization(self):
     if self.environment[
         ovmpcons.ConfigEnv.VMCONSOLE_PROXY_CONFIG
     ] is None:
         self.environment[
             ovmpcons.ConfigEnv.VMCONSOLE_PROXY_CONFIG
         ] = dialog.queryBoolean(
             dialog=self.dialog,
             name='OVESETUP_CONFIG_VMCONSOLE_PROXY',
             note=_(
                 'Configure VM Console Proxy on this host '
                 '(@VALUES@) [@DEFAULT@]: '
             ),
             prompt=True,
             default=True,
         )
Example #53
0
 def _customization(self):
     if self.environment[oenginecons.CoreEnv.ENABLE] is None:
         self.environment[oenginecons.CoreEnv.ENABLE] = (
             dialog.queryBoolean(
                 dialog=self.dialog,
                 name='OVESETUP_ENGINE_ENABLE',
                 note=_('Configure Engine on this host '
                        '(@VALUES@) [@DEFAULT@]: '),
                 prompt=True,
                 default=True,
             ) if self.environment[oenginecons.EngineDBEnv.NEW_DATABASE]
             else (self._engine_fqdn is not None
                   and self.environment[osetupcons.ConfigEnv.FQDN]
                   == self._engine_fqdn))
     if self.environment[oenginecons.CoreEnv.ENABLE]:
         self.environment[oengcommcons.ApacheEnv.ENABLE] = True
Example #54
0
 def _constomization(self):
     if self.environment[osetupcons.AIOEnv.CONFIGURE] is None:
         self.environment[
             osetupcons.AIOEnv.CONFIGURE] = dialog.queryBoolean(
                 dialog=self.dialog,
                 name='OVESETUP_AIO_CONFIGURE',
                 note=_('Configure VDSM on this host? '
                        '(@VALUES@) [@DEFAULT@]: '),
                 prompt=True,
                 default=False,
             )
     if self.environment[osetupcons.AIOEnv.CONFIGURE]:
         self.environment[
             osetupcons.ConfigEnv.FQDN_REVERSE_VALIDATION] = True
         self.environment[
             osetupcons.ConfigEnv.FQDN_NON_LOOPBACK_VALIDATION] = True
Example #55
0
    def _validateContinueLowMemory(self):
        if (self.environment[oenginecons.SystemEnv.MEMCHECK_ENABLED]
                and not self._satisfied):
            if not dialog.queryBoolean(
                    dialog=self.dialog,
                    name='OVESETUP_MEMCHECK_ENABLED',
                    note=_(
                        'Do you want Setup to continue, with amount of memory '
                        'less than recommended? (@VALUES@) [@DEFAULT@]: '),
                    prompt=True,
                    true=_('Yes'),
                    false=_('No'),
                    default=False,
            ):
                raise RuntimeError(_('Aborted by user'))

            self.environment[oenginecons.SystemEnv.MEMCHECK_ENABLED] = False
Example #56
0
    def _customization(self):
        valid = False
        password = None
        while not valid:
            password = self.dialog.queryString(
                name='OVESETUP_CONFIG_ADMIN_SETUP',
                note=_('Engine admin password: '******'OVESETUP_CONFIG_ADMIN_SETUP',
                note=_('Confirm engine admin password: '******'Passwords do not match'))
            else:
                try:
                    import cracklib
                    cracklib.FascistCheck(password)
                    valid = True
                except ImportError:
                    # do not force this optional feature
                    self.logger.debug(
                        'cannot import cracklib',
                        exc_info=True,
                    )
                    valid = True
                except ValueError as e:
                    self.logger.warning(
                        _('Password is weak: {error}').format(error=e, ))
                    valid = dialog.queryBoolean(
                        dialog=self.dialog,
                        name='OVESETUP_CONFIG_WEAK_ENGINE_PASSWORD',
                        note=_('Use weak password? '
                               '(@VALUES@) [@DEFAULT@]: '),
                        prompt=True,
                        default=False,
                    )

        self.environment[oenginecons.ConfigEnv.ADMIN_PASSWORD] = password
Example #57
0
 def _customization(self):
     if self.environment[oenginecons.CoreEnv.ENABLE] is None:
         if not self.environment[oenginecons.EngineDBEnv.NEW_DATABASE]:
             # we are upgrading from 3.4 that doesn't ask about it
             # but we need to upgrade the engine cause has been configured
             # in the past
             # It can be removed in future release ( > 3.5)
             self.environment[oenginecons.CoreEnv.ENABLE] = True
         else:
             self.environment[
                 oenginecons.CoreEnv.ENABLE] = dialog.queryBoolean(
                     dialog=self.dialog,
                     name='OVESETUP_ENGINE_ENABLE',
                     note=_('Configure Engine on this host '
                            '(@VALUES@) [@DEFAULT@]: '),
                     prompt=True,
                     default=True,
                 )
     if self.environment[oenginecons.CoreEnv.ENABLE]:
         self.environment[oengcommcons.ApacheEnv.ENABLE] = True
Example #58
0
    def _validation(self):
        if (self.services.exists(name=oenginecons.Const.ENGINE_SERVICE_NAME)
                and self.services.status(
                    name=oenginecons.Const.ENGINE_SERVICE_NAME)):
            if self.environment[
                    oenginecons.CoreEnv.ENGINE_SERVICE_STOP] is None:
                self.environment[
                    oenginecons.CoreEnv.
                    ENGINE_SERVICE_STOP] = dialog.queryBoolean(
                        dialog=self.dialog,
                        name='OVESETUP_CORE_ENGINE_STOP',
                        note=_(
                            'During execution engine service will be stopped '
                            '(@VALUES@) [@DEFAULT@]: '),
                        prompt=True,
                        true=_('OK'),
                        false=_('Cancel'),
                        default=True,
                    )

            if not self.environment[oenginecons.CoreEnv.ENGINE_SERVICE_STOP]:
                raise RuntimeError(
                    _('Engine service is running, no approval to stop'))