Example #1
0
    def _update_old_records_vm_list(self, session):
        conf_dict = self.rc_config.get_value('recover_starter')
        notification_expiration_sec = int(
            conf_dict.get('notification_expiration_sec'))
        now = datetime.datetime.now()
        border_time = now - \
            datetime.timedelta(seconds=notification_expiration_sec)
        border_time_str = border_time.strftime('%Y-%m-%d %H:%M:%S')

        msg = "Do get_old_records_vm_list."
        LOG.info(msg)
        result = dbapi.get_old_records_vm_list(session, border_time_str,
                                               border_time_str)
        msg = "Succeeded in get_old_records_vm_list. " \
            + "Return_value = " + str(result)
        LOG.info(msg)

        if result:
            msg = 'Old and incomplete records will be skipped.'
            LOG.info(msg)

            # Set progress = 4 for old record
            for row in result:
                update_val = {
                    'progress': 4,
                    'update_at': datetime.datetime.now(),
                    'delete_at': datetime.datetime.now()
                }
                msg = "Do update_vm_list_by_id_dict."
                LOG.info(msg)
                dbapi.update_vm_list_by_id_dict(session, row.id, update_val)
                msg = "Succeeded in update_vm_list_by_id_dict."
                LOG.info(msg)
Example #2
0
    def _update_old_records_vm_list(self, session):
        conf_dict = self.rc_config.get_value('recover_starter')
        notification_expiration_sec = int(
            conf_dict.get('notification_expiration_sec'))
        now = datetime.datetime.now()
        border_time = now - \
            datetime.timedelta(seconds=notification_expiration_sec)
        border_time_str = border_time.strftime('%Y-%m-%d %H:%M:%S')
        self.rc_util.syslogout_ex("RecoveryControllerStarter_0026",
                                  syslog.LOG_INFO)
        result = dbapi.get_old_records_vm_list(session, border_time_str,
                                               border_time_str)
        self.rc_util.syslogout(result, syslog.LOG_INFO)

        if result:
            self.rc_util.syslogout_ex("RecoveryControllerStarter_0035",
                                      syslog.LOG_INFO)
            msg = 'Old and incomplete records will be skipped.'
            self.rc_util.syslogout(msg, syslog.LOG_INFO)

            # Set progress = 4 for old record
            for row in result:
                update_val = {
                    'progress': 4,
                    'update_at': datetime.datetime.now(),
                    'delete_at': datetime.datetime.now()
                }
                dbapi.update_vm_list_by_id_dict(session, row.id, update_val)
                self.rc_util.syslogout_ex("RecoveryControllerStarter_0036",
                                          syslog.LOG_INFO)
Example #3
0
    def _find_reprocessing_records_vm_list(self, session):
        return_value = []
        result = dbapi.get_all_vm_list_by_progress(session)

        # UUID to see one by one, and look for the re-processing target record
        for row in result:
            result2 = dbapi.get_vm_list_by_uuid_and_progress_sorted(
                session, row.uuid)

            row_cnt = 0
            for row2 in result2:
                # First row is the re-processing target
                if row_cnt == 0:
                    return_value.append(row2)
                # Update progress that is not the re-processing target
                else:
                    self.rc_util.syslogout_ex("RecoveryControllerStarter_0039",
                                              syslog.LOG_INFO)
                    update_val = {
                        'progress': 4,
                        'update_at': datetime.datetime.now(),
                        'delete_at': datetime.datetime.now()
                    }

                    dbapi.update_vm_list_by_id_dict(session, row2.id,
                                                    update_val)

                row_cnt += 1

        return return_value
Example #4
0
    def _find_reprocessing_records_vm_list(self, session):
        return_value = []
        result = dbapi.get_all_vm_list_by_progress(session)

        # UUID to see one by one, and look for the re-processing target record
        for row in result:
            result2 = dbapi.get_vm_list_by_uuid_and_progress_sorted(session, row.uuid)

            row_cnt = 0
            for row2 in result2:
                # First row is the re-processing target
                if row_cnt == 0:
                    return_value.append(row2)
                # Update progress that is not the re-processing target
                else:
                    self.rc_util.syslogout_ex("RecoveryControllerStarter_0039", syslog.LOG_INFO)
                    update_val = {
                        "progress": 4,
                        "update_at": datetime.datetime.now(),
                        "delete_at": datetime.datetime.now(),
                    }

                    dbapi.update_vm_list_by_id_dict(session, row2.id, update_val)

                row_cnt += 1

        return return_value
Example #5
0
    def _update_old_records_vm_list(self, session):
        conf_dict = self.rc_config.get_value('recover_starter')
        notification_expiration_sec = int(conf_dict.get(
            'notification_expiration_sec'))
        now = datetime.datetime.now()
        border_time = now - \
            datetime.timedelta(seconds=notification_expiration_sec)
        border_time_str = border_time.strftime('%Y-%m-%d %H:%M:%S')

        msg = "Do get_old_records_vm_list."
        LOG.info(msg)
        result = dbapi.get_old_records_vm_list(
            session,
            border_time_str,
            border_time_str
        )
        msg = "Succeeded in get_old_records_vm_list. " \
            + "Return_value = " + str(result)
        LOG.info(msg)

        if result:
            msg = 'Old and incomplete records will be skipped.'
            LOG.info(msg)

            # Set progress = 4 for old record
            for row in result:
                update_val = {'progress': 4,
                              'update_at': datetime.datetime.now(),
                              'delete_at': datetime.datetime.now()
                              }
                msg = "Do update_vm_list_by_id_dict."
                LOG.info(msg)
                dbapi.update_vm_list_by_id_dict(session, row.id, update_val)
                msg = "Succeeded in update_vm_list_by_id_dict."
                LOG.info(msg)
Example #6
0
    def _find_reprocessing_records_vm_list(self, session):
        return_value = []
        msg = "Do get_all_vm_list_by_progress."
        LOG.info(msg)
        result = dbapi.get_all_vm_list_by_progress(session)
        msg = "Succeeded in get_all_vm_list_by_progress. " \
            + "Return_value = " + str(result)
        LOG.info(msg)

        # UUID to see one by one, and look for the re-processing target record
        for row in result:
            msg = "Do get_vm_list_by_uuid_and_progress_sorted."
            LOG.info(msg)
            result2 = dbapi.get_vm_list_by_uuid_and_progress_sorted(
                session,
                row.uuid
            )
            msg = "Succeeded in get_vm_list_by_uuid_and_progress_sorted. " \
                + "Return_value = " + str(result2)
            LOG.info(msg)

            row_cnt = 0
            for row2 in result2:
                # First row is the re-processing target
                if row_cnt == 0:
                    return_value.append(row2)
                # Update progress that is not the re-processing target
                else:
                    update_val = {'progress': 4,
                                  'update_at': datetime.datetime.now(),
                                  'delete_at': datetime.datetime.now()
                                  }

                    msg = "Do update_vm_list_by_id_dict."
                    LOG.info(msg)
                    dbapi.update_vm_list_by_id_dict(
                        session,
                        row2.id,
                        update_val
                    )
                    msg = "Succeeded in update_vm_list_by_id_dict."
                    LOG.info(msg)

                row_cnt += 1

        return return_value
Example #7
0
    def _update_old_records_vm_list(self, session):
        conf_dict = self.rc_config.get_value("recover_starter")
        notification_expiration_sec = int(conf_dict.get("notification_expiration_sec"))
        now = datetime.datetime.now()
        border_time = now - datetime.timedelta(seconds=notification_expiration_sec)
        border_time_str = border_time.strftime("%Y-%m-%d %H:%M:%S")
        self.rc_util.syslogout_ex("RecoveryControllerStarter_0026", syslog.LOG_INFO)
        result = dbapi.get_old_records_vm_list(session, border_time_str, border_time_str)
        self.rc_util.syslogout(result, syslog.LOG_INFO)

        if result:
            self.rc_util.syslogout_ex("RecoveryControllerStarter_0035", syslog.LOG_INFO)
            msg = "Old and incomplete records will be skipped."
            self.rc_util.syslogout(msg, syslog.LOG_INFO)

            # Set progress = 4 for old record
            for row in result:
                update_val = {"progress": 4, "update_at": datetime.datetime.now(), "delete_at": datetime.datetime.now()}
                dbapi.update_vm_list_by_id_dict(session, row.id, update_val)
                self.rc_util.syslogout_ex("RecoveryControllerStarter_0036", syslog.LOG_INFO)
Example #8
0
    def update_vm_list_db(self,  session, key, value, primary_id):
        """
        VM list table update
        :param :key: Update column name
        :param :value: Updated value
        :param :uuid: VM of uuid (updated narrowing condition of VM list table)
        """

        try:
            # Updated progress to start
            now = datetime.datetime.now()
            update_val = {}
            if key == 'progress' and value == 1:
                update_val['update_at'] = now
                update_val['progress'] = value
            # End the progress([success:2][error:3][skipped old:4])
            elif key == 'progress':
                update_val['update_at'] = now
                update_val['progress'] = value
                update_val['delete_at'] = now
            # Update than progress
            else:
                if hasattr(VmList, key):
                    update_val[key] = value
                else:
                    raise AttributeError
            dbapi.update_vm_list_by_id_dict(session, primary_id, update_val)

        except AttributeError:
            error_type, error_value, traceback_ = sys.exc_info()
            tb_list = traceback.format_tb(traceback_)
            self.rc_util.syslogout(error_type, syslog.LOG_ERR)
            self.rc_util.syslogout(error_value, syslog.LOG_ERR)
            for tb in tb_list:
                self.rc_util.syslogout(tb, syslog.LOG_ERR)

            msg = "Exception : %s is not in attribute of \
            VmList" % (key)
            self.rc_util.syslogout(msg, syslog.LOG_ERR)
            raise AttributeError

        except exc.SQLAlchemyError:

            self.rc_util.syslogout_ex("RecoveryControllerUtilDb_0014",
                                      syslog.LOG_ERR)
            error_type, error_value, traceback_ = sys.exc_info()
            tb_list = traceback.format_tb(traceback_)
            self.rc_util.syslogout(error_type, syslog.LOG_ERR)
            self.rc_util.syslogout(error_value, syslog.LOG_ERR)
            for tb in tb_list:
                self.rc_util.syslogout(tb, syslog.LOG_ERR)

            msg = "Exception : SQLAlchemy.Error in \
            update_vm_list_by_id_dict()."
            self.rc_util.syslogout(msg, syslog.LOG_ERR)

            raise exc.SQLAlchemyError

        except KeyError:

            self.rc_util.syslogout_ex("RecoveryControllerUtilDb_0017",
                                      syslog.LOG_ERR)
            error_type, error_value, traceback_ = sys.exc_info()
            tb_list = traceback.format_tb(traceback_)
            self.rc_util.syslogout(error_type, syslog.LOG_ERR)
            self.rc_util.syslogout(error_value, syslog.LOG_ERR)
            for tb in tb_list:
                self.rc_util.syslogout(tb, syslog.LOG_ERR)

            msg = "Exception : KeyError in update_notification_list_db()."
            self.rc_util.syslogout(msg, syslog.LOG_ERR)

            raise KeyError
Example #9
0
    def update_vm_list_db(self, session, key, value, primary_id):
        """
        VM list table update
        :param :key: Update column name
        :param :value: Updated value
        :param :uuid: VM of uuid (updated narrowing condition of VM list table)
        """

        try:
            # Updated progress to start
            now = datetime.datetime.now()
            update_val = {}
            if key == 'progress' and value == 1:
                update_val['update_at'] = now
                update_val['progress'] = value
            # End the progress([success:2][error:3][skipped old:4])
            elif key == 'progress':
                update_val['update_at'] = now
                update_val['progress'] = value
                update_val['delete_at'] = now
            # Update than progress
            else:
                if hasattr(VmList, key):
                    update_val[key] = value
                else:
                    raise AttributeError
            msg = "Do update_vm_list_by_id_dict."
            LOG.info(msg)
            dbapi.update_vm_list_by_id_dict(session, primary_id, update_val)
            msg = "Succeeded in update_vm_list_by_id_dict."
            LOG.info(msg)

        except AttributeError:
            error_type, error_value, traceback_ = sys.exc_info()
            tb_list = traceback.format_tb(traceback_)
            LOG.error(error_type)
            LOG.error(error_value)
            for tb in tb_list:
                LOG.error(tb)

            msg = "Exception : %s is not in attribute of \
            VmList" % (key)
            LOG.error(msg)
            raise AttributeError

        except exc.SQLAlchemyError:

            error_type, error_value, traceback_ = sys.exc_info()
            tb_list = traceback.format_tb(traceback_)
            LOG.error(error_type)
            LOG.error(error_value)
            for tb in tb_list:
                LOG.error(tb)

            msg = "Exception : SQLAlchemy.Error in \
            update_vm_list_by_id_dict()."

            LOG.error(msg)

            raise exc.SQLAlchemyError

        except KeyError:

            error_type, error_value, traceback_ = sys.exc_info()
            tb_list = traceback.format_tb(traceback_)
            LOG.error(error_type)
            LOG.error(error_value)
            for tb in tb_list:
                LOG.error(tb)

            msg = "Exception : KeyError in update_notification_list_db()."
            LOG.error(msg)

            raise KeyError
Example #10
0
    def update_vm_list_db(self,  session, key, value, primary_id):
        """
        VM list table update
        :param :key: Update column name
        :param :value: Updated value
        :param :uuid: VM of uuid (updated narrowing condition of VM list table)
        """

        try:
            # Updated progress to start
            now = datetime.datetime.now()
            update_val = {}
            if key == 'progress' and value == 1:
                update_val['update_at'] = now
                update_val['progress'] = value
            # End the progress([success:2][error:3][skipped old:4])
            elif key == 'progress':
                update_val['update_at'] = now
                update_val['progress'] = value
                update_val['delete_at'] = now
            # Update than progress
            else:
                if hasattr(VmList, key):
                    update_val[key] = value
                else:
                    raise AttributeError
            msg = "Do update_vm_list_by_id_dict."
            LOG.info(msg)
            dbapi.update_vm_list_by_id_dict(session, primary_id, update_val)
            msg = "Succeeded in update_vm_list_by_id_dict."
            LOG.info(msg)

        except AttributeError:
            error_type, error_value, traceback_ = sys.exc_info()
            tb_list = traceback.format_tb(traceback_)
            LOG.error(error_type)
            LOG.error(error_value)
            for tb in tb_list:
                LOG.error(tb)

            msg = "Exception : %s is not in attribute of \
            VmList" % (key)
            LOG.error(msg)
            raise AttributeError

        except exc.SQLAlchemyError:

            error_type, error_value, traceback_ = sys.exc_info()
            tb_list = traceback.format_tb(traceback_)
            LOG.error(error_type)
            LOG.error(error_value)
            for tb in tb_list:
                LOG.error(tb)

            msg = "Exception : SQLAlchemy.Error in \
            update_vm_list_by_id_dict()."
            LOG.error(msg)

            raise exc.SQLAlchemyError

        except KeyError:

            error_type, error_value, traceback_ = sys.exc_info()
            tb_list = traceback.format_tb(traceback_)
            LOG.error(error_type)
            LOG.error(error_value)
            for tb in tb_list:
                LOG.error(tb)

            msg = "Exception : KeyError in update_notification_list_db()."
            LOG.error(msg)

            raise KeyError
Example #11
0
    def update_vm_list_db(self, session, key, value, primary_id):
        """
        VM list table update
        :param :key: Update column name
        :param :value: Updated value
        :param :uuid: VM of uuid (updated narrowing condition of VM list table)
        """

        try:
            # Updated progress to start
            now = datetime.datetime.now()
            update_val = {}
            if key == 'progress' and value == 1:
                update_val['update_at'] = now
                update_val['progress'] = value
            # End the progress([success:2][error:3][skipped old:4])
            elif key == 'progress':
                update_val['update_at'] = now
                update_val['progress'] = value
                update_val['delete_at'] = now
            # Update than progress
            else:
                if hasattr(VmList, key):
                    update_val[key] = value
                else:
                    raise AttributeError
            dbapi.update_vm_list_by_id_dict(session, primary_id, update_val)

        except AttributeError:
            error_type, error_value, traceback_ = sys.exc_info()
            tb_list = traceback.format_tb(traceback_)
            self.rc_util.syslogout(error_type, syslog.LOG_ERR)
            self.rc_util.syslogout(error_value, syslog.LOG_ERR)
            for tb in tb_list:
                self.rc_util.syslogout(tb, syslog.LOG_ERR)

            msg = "Exception : %s is not in attribute of \
            VmList" % (key)
            self.rc_util.syslogout(msg, syslog.LOG_ERR)
            raise AttributeError

        except exc.SQLAlchemyError:

            self.rc_util.syslogout_ex("RecoveryControllerUtilDb_0014",
                                      syslog.LOG_ERR)
            error_type, error_value, traceback_ = sys.exc_info()
            tb_list = traceback.format_tb(traceback_)
            self.rc_util.syslogout(error_type, syslog.LOG_ERR)
            self.rc_util.syslogout(error_value, syslog.LOG_ERR)
            for tb in tb_list:
                self.rc_util.syslogout(tb, syslog.LOG_ERR)

            msg = "Exception : SQLAlchemy.Error in \
            update_vm_list_by_id_dict()."

            self.rc_util.syslogout(msg, syslog.LOG_ERR)

            raise exc.SQLAlchemyError

        except KeyError:

            self.rc_util.syslogout_ex("RecoveryControllerUtilDb_0017",
                                      syslog.LOG_ERR)
            error_type, error_value, traceback_ = sys.exc_info()
            tb_list = traceback.format_tb(traceback_)
            self.rc_util.syslogout(error_type, syslog.LOG_ERR)
            self.rc_util.syslogout(error_value, syslog.LOG_ERR)
            for tb in tb_list:
                self.rc_util.syslogout(tb, syslog.LOG_ERR)

            msg = "Exception : KeyError in update_notification_list_db()."
            self.rc_util.syslogout(msg, syslog.LOG_ERR)

            raise KeyError