Esempio n. 1
0
    def _validation(self):
        self._statement = database.Statement(
            dbenvkeys=oenginecons.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')
                )
Esempio n. 2
0
 def _misc(self):
     try:
         statement = self.environment[odwhcons.EngineDBEnv.STATEMENT]
         db_dwh_uuid = engine_db_timekeeping.getValueFromTimekeeping(
             statement=statement,
             name=engine_db_timekeeping.DB_KEY_UUID
         )
         if self.environment[odwhcons.CoreEnv.UUID] != db_dwh_uuid:
             self.logger.debug('_ is %s' % _)
             self.logger.warning(
                 _(
                     'Not updating engine database to disconnect from dwh '
                     '- seems like a different dwh was already setup for it'
                 )
             )
         else:
             engine_db_timekeeping.updateValueInTimekeeping(
                 statement=statement,
                 name=engine_db_timekeeping.DB_KEY_HOSTNAME,
                 value=''
             )
             engine_db_timekeeping.updateValueInTimekeeping(
                 statement=statement,
                 name=engine_db_timekeeping.DB_KEY_UUID,
                 value=''
             )
     except Exception as e:
         self.logger.debug('exception', exc_info=True)
         self.logger.warning(
             _(
                 'Cannot update Engine database: {error}'
             ).format(
                 error=e,
             )
         )
Esempio n. 3
0
 def _misc_stop_remote_dwh(self):
     self._statement = database.Statement(
         dbenvkeys=oenginecons.Const.ENGINE_DB_ENV_KEYS,
         environment=self.environment,
     )
     self._dwh_host = dwh_history_timekeeping.getValueFromTimekeeping(
         statement=self._statement,
         name=dwh_history_timekeeping.DB_KEY_HOSTNAME)
     if self._remote_dwh_is_up():
         self.logger.info(
             _('Stopping DWH service on host {hostname}...').format(
                 hostname=self._dwh_host, ))
         try:
             self._update_DisconnectDwh('1')
             retries = self.RETRIES
             while self._remote_dwh_is_up() and retries > 0:
                 retries -= 1
                 self.logger.debug(
                     'Waiting for remote dwh to die, %s retries left' %
                     retries)
                 time.sleep(self.DELAY)
         finally:
             self._update_DisconnectDwh('0')
         if self._remote_dwh_is_up():
             self.logger.error(
                 _('dwhd is currently running.\n'
                   'Its hostname is {hostname}.\n'
                   'Please stop it before running Setup.').format(
                       hostname=self._dwh_host, ))
             raise RuntimeError(_('dwhd is currently running'))
         self.logger.info(_('Stopped DWH'))
         self._remote_dwh_stopped = True
Esempio n. 4
0
    def _get_dwh_host(self):
        self._statement = database.Statement(
            dbenvkeys=oenginecons.Const.ENGINE_DB_ENV_KEYS,
            environment=self.environment,
        )

        self._dwhHost = dwh_history_timekeeping.getValueFromTimekeeping(
            statement=self._statement,
            name=dwh_history_timekeeping.DB_KEY_HOSTNAME)

        self.logger.debug(
            _('DWH host is {dwhHost}.').format(dwhHost=self._dwhHost, ))
Esempio n. 5
0
 def _closeupDWHConfig(self):
     self._statement = database.Statement(
         dbenvkeys=oenginecons.Const.ENGINE_DB_ENV_KEYS,
         environment=self.environment,
     )
     self._dwh_host = dwh_history_timekeeping.getValueFromTimekeeping(
         statement=self._statement,
         name=dwh_history_timekeeping.DB_KEY_HOSTNAME)
     if not self._dwh_host:
         self.dialog.note(
             _('The engine requires access to the Data Warehouse '
               'database.\nData Warehouse was not set up. Please set it '
               'up on some other machine and configure access to it on '
               'the engine.'))
Esempio n. 6
0
 def _transactionBegin(self):
     if engine_db_timekeeping.getValueFromTimekeeping(
         statement=self._statement,
         name=engine_db_timekeeping.DB_KEY_RUNNING
     ) == '1':
         self.logger.error(
             _(
                 'dwhd is currently running.\n'
                 'Its hostname is {hostname}.\n'
                 'Please stop it before running Setup.'
             ).format(
                 hostname=self._db_dwh_hostname,
             )
         )
         raise RuntimeError(_('dwhd is currently running'))
Esempio n. 7
0
 def _misc_stop_remote_dwh(self):
     self._statement = database.Statement(
         dbenvkeys=oenginecons.Const.ENGINE_DB_ENV_KEYS,
         environment=self.environment,
     )
     self._dwh_host = dwh_history_timekeeping.getValueFromTimekeeping(
         statement=self._statement,
         name=dwh_history_timekeeping.DB_KEY_HOSTNAME
     )
     if dwh_history_timekeeping.dwhIsUp(self._statement):
         self.logger.info(
             _(
                 'Stopping DWH service on host {hostname}...'
             ).format(
                 hostname=self._dwh_host,
             )
         )
         try:
             self._update_DisconnectDwh('1')
             retries = self.RETRIES
             while dwh_history_timekeeping.dwhIsUp(
                 self._statement
             ) and retries > 0:
                 retries -= 1
                 self.logger.debug(
                     'Waiting for remote dwh to die, %s retries left' %
                     retries
                 )
                 time.sleep(self.DELAY)
         finally:
             self._update_DisconnectDwh('0')
         if dwh_history_timekeeping.dwhIsUp(self._statement):
             self.logger.error(
                 _(
                     '{service} is currently running.\n'
                     'Its hostname is {hostname}.\n'
                     'Please stop it before running Setup.'
                 ).format(
                     service=oengcommcons.DWHConst.ENGINE_DWHD_SERVICE_NAME,
                     hostname=self._dwh_host,
                 )
             )
             raise RuntimeError(_('{service} is currently running').format(
                 service=oengcommcons.DWHConst.ENGINE_DWHD_SERVICE_NAME,
             ))
         self.logger.info(_('Stopped DWH'))
         self._remote_dwh_stopped = True
Esempio n. 8
0
 def _closeupDWHConfig(self):
     self._statement = database.Statement(
         dbenvkeys=oenginecons.Const.ENGINE_DB_ENV_KEYS,
         environment=self.environment,
     )
     self._dwh_host = dwh_history_timekeeping.getValueFromTimekeeping(
         statement=self._statement,
         name=dwh_history_timekeeping.DB_KEY_HOSTNAME
     )
     if not self._dwh_host:
         self.dialog.note(
             _(
                 'The engine requires access to the Data Warehouse '
                 'database.\nData Warehouse was not set up. Please set it '
                 'up on some other machine and configure access to it on '
                 'the engine.'
             )
         )
Esempio n. 9
0
    def _get_dwh_host(self):
        self._statement = database.Statement(
            dbenvkeys=oenginecons.Const.ENGINE_DB_ENV_KEYS,
            environment=self.environment,
        )

        self._dwhHost = dwh_history_timekeeping.getValueFromTimekeeping(
            statement=self._statement,
            name=dwh_history_timekeeping.DB_KEY_HOSTNAME
        )

        self.logger.debug(
            _(
                'DWH host is {dwhHost}.'
            ).format(
                dwhHost=self._dwhHost,
            )
        )
Esempio n. 10
0
 def _misc(self):
     try:
         statement = self.environment[odwhcons.EngineDBEnv.STATEMENT]
         db_dwh_uuid = engine_db_timekeeping.getValueFromTimekeeping(
             statement=statement, name=engine_db_timekeeping.DB_KEY_UUID)
         if self.environment[odwhcons.CoreEnv.UUID] != db_dwh_uuid:
             self.logger.debug('_ is %s' % _)
             self.logger.warning(
                 _('Not updating engine database to disconnect from dwh '
                   '- seems like a different dwh was already setup for it'))
         else:
             engine_db_timekeeping.updateValueInTimekeeping(
                 statement=statement,
                 name=engine_db_timekeeping.DB_KEY_HOSTNAME,
                 value='')
             engine_db_timekeeping.updateValueInTimekeeping(
                 statement=statement,
                 name=engine_db_timekeeping.DB_KEY_UUID,
                 value='')
     except Exception as e:
         self.logger.debug('exception', exc_info=True)
         self.logger.warning(
             _('Cannot update Engine database: {error}').format(error=e, ))
Esempio n. 11
0
 def _remote_dwh_is_up(self):
     return dwh_history_timekeeping.getValueFromTimekeeping(
         statement=self._statement,
         name=dwh_history_timekeeping.DB_KEY_RUNNING
     ) == '1'
Esempio n. 12
0
 def _remote_dwh_is_up(self):
     return dwh_history_timekeeping.getValueFromTimekeeping(
         statement=self._statement,
         name=dwh_history_timekeeping.DB_KEY_RUNNING) == '1'