Exemple #1
0
    def insert_vm_list_db(self, session, notification_id,
                          notification_uuid, retry_cnt):
        """
        VM list table registration
        :param :cursor: cursor object
        :param :notification_id: Notification ID
                (used as search criteria for notification list table)
        :param :notification_uuid:VM of uuid
                (used as the registered contents of the VM list table)
        :param :retry_cnt:Retry count
                (used as the registered contents of the VM list table)
        :return :primary_id: The value of LAST_INSERT_ID
        """

        try:
            res = dbapi.get_all_notification_list_by_notification_id(
                session,
                notification_id
            )
            # Todo(sampath): select first and only object from the list
            # log if many records
            notification_recover_to = res[0].recover_to
            notification_recover_by = res[0].recover_by
            vm_item = dbapi.add_vm_list(session,
                                        datetime.datetime.now(),
                                        "0",
                                        notification_uuid,
                                        "0",
                                        str(retry_cnt),
                                        notification_id,
                                        notification_recover_to,
                                        str(notification_recover_by)
                                        )

            self.rc_util.syslogout_ex("RecoveryControllerUtilDb_0001",
                                      syslog.LOG_INFO)
            primary_id = vm_item.id

            return primary_id

        except KeyError:

            self.rc_util.syslogout_ex("RecoveryControllerUtilDb_0002",
                                      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 insert_vm_list_db()."
            self.rc_util.syslogout(msg, syslog.LOG_ERR)

            raise KeyError

        except exc.SQLAlchemyError:
            self.rc_util.syslogout_ex("RecoveryControllerUtilDb_0003",
                                      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 insert_vm_list_db()."
            self.rc_util.syslogout(msg, syslog.LOG_ERR)

            raise exc.SQLAlchemyError

        except:
            self.rc_util.syslogout_ex("RecoveryControllerUtilDb_0004",
                                      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 : Exception in insert_vm_list_db()."
            self.rc_util.syslogout(msg, syslog.LOG_ERR)

            raise
Exemple #2
0
    def insert_vm_list_db(self, session, notification_id,
                          notification_uuid, retry_cnt):
        """
        VM list table registration
        :param :cursor: cursor object
        :param :notification_id: Notification ID
                (used as search criteria for notification list table)
        :param :notification_uuid:VM of uuid
                (used as the registered contents of the VM list table)
        :param :retry_cnt:Retry count
                (used as the registered contents of the VM list table)
        :return :primary_id: The value of LAST_INSERT_ID
        """

        try:
            msg = "Do get_all_notification_list_by_notification_id."
            LOG.info(msg)
            res = dbapi.get_all_notification_list_by_notification_id(
                session,
                notification_id
            )
            msg = "Succeeded in get_all_notification_list_by_notification_id. " \
                + "Return_value = " + str(res)
            LOG.info(msg)
            # Todo(sampath): select first and only object from the list
            # log if many records
            notification_recover_to = res[0].recover_to
            notification_recover_by = res[0].recover_by
            msg = "Do add_vm_list."
            LOG.info(msg)
            vm_item = dbapi.add_vm_list(session,
                                        datetime.datetime.now(),
                                        "0",
                                        notification_uuid,
                                        "0",
                                        str(retry_cnt),
                                        notification_id,
                                        notification_recover_to,
                                        str(notification_recover_by)
                                        )
            msg = "Succeeded in add_vm_list. " \
                + "Return_value = " + str(vm_item)
            LOG.info(msg)

            primary_id = vm_item.id

            return primary_id

        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 insert_vm_list_db()."
            LOG.error(msg)

            raise KeyError

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

            msg = "Exception : sqlalchemy error in insert_vm_list_db()."
            LOG.error(msg)

            raise exc.SQLAlchemyError

        except:
            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 : Exception in insert_vm_list_db()."
            LOG.error(msg)

            raise
Exemple #3
0
    def insert_vm_list_db(self, session, notification_id, notification_uuid,
                          retry_cnt):
        """
        VM list table registration
        :param :cursor: cursor object
        :param :notification_id: Notification ID
                (used as search criteria for notification list table)
        :param :notification_uuid:VM of uuid
                (used as the registered contents of the VM list table)
        :param :retry_cnt:Retry count
                (used as the registered contents of the VM list table)
        :return :primary_id: The value of LAST_INSERT_ID
        """

        try:
            msg = "Do get_all_notification_list_by_notification_id."
            LOG.info(msg)
            res = dbapi.get_all_notification_list_by_notification_id(
                session, notification_id)
            msg = "Succeeded in get_all_notification_list_by_notification_id. " \
                + "Return_value = " + str(res)
            LOG.info(msg)
            # Todo(sampath): select first and only object from the list
            # log if many records
            notification_recover_to = res[0].recover_to
            notification_recover_by = res[0].recover_by
            msg = "Do add_vm_list."
            LOG.info(msg)
            vm_item = dbapi.add_vm_list(session, datetime.datetime.now(),
                                        "0", notification_uuid, "0",
                                        str(retry_cnt), notification_id,
                                        notification_recover_to,
                                        str(notification_recover_by))
            msg = "Succeeded in add_vm_list. " \
                + "Return_value = " + str(vm_item)
            LOG.info(msg)

            primary_id = vm_item.id

            return primary_id

        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 insert_vm_list_db()."
            LOG.error(msg)

            raise KeyError

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

            msg = "Exception : sqlalchemy error in insert_vm_list_db()."
            LOG.error(msg)

            raise exc.SQLAlchemyError

        except:
            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 : Exception in insert_vm_list_db()."
            LOG.error(msg)

            raise
Exemple #4
0
    def insert_vm_list_db(self, session, notification_id, notification_uuid,
                          retry_cnt):
        """
        VM list table registration
        :param :cursor: cursor object
        :param :notification_id: Notification ID
                (used as search criteria for notification list table)
        :param :notification_uuid:VM of uuid
                (used as the registered contents of the VM list table)
        :param :retry_cnt:Retry count
                (used as the registered contents of the VM list table)
        :return :primary_id: The value of LAST_INSERT_ID
        """

        try:
            res = dbapi.get_all_notification_list_by_notification_id(
                session, notification_id)
            # Todo(sampath): select first and only object from the list
            # log if many records
            notification_recover_to = res[0].recover_to
            notification_recover_by = res[0].recover_by
            vm_item = dbapi.add_vm_list(session, datetime.datetime.now(),
                                        "0", notification_uuid, "0",
                                        str(retry_cnt), notification_id,
                                        notification_recover_to,
                                        str(notification_recover_by))

            self.rc_util.syslogout_ex("RecoveryControllerUtilDb_0001",
                                      syslog.LOG_INFO)
            primary_id = vm_item.id

            return primary_id

        except KeyError:

            self.rc_util.syslogout_ex("RecoveryControllerUtilDb_0002",
                                      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 insert_vm_list_db()."
            self.rc_util.syslogout(msg, syslog.LOG_ERR)

            raise KeyError

        except exc.SQLAlchemyError:
            self.rc_util.syslogout_ex("RecoveryControllerUtilDb_0003",
                                      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 insert_vm_list_db()."
            self.rc_util.syslogout(msg, syslog.LOG_ERR)

            raise exc.SQLAlchemyError

        except:
            self.rc_util.syslogout_ex("RecoveryControllerUtilDb_0004",
                                      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 : Exception in insert_vm_list_db()."
            self.rc_util.syslogout(msg, syslog.LOG_ERR)

            raise