You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
hbyd_ueba/bin/uninstall.py

41 lines
964 B

5 months ago
# -*-coding:utf-8 -*-
# 组件卸载时执行的脚本
from dataInterface.functions import CFunction
from dataInterface.db.params import CPgSqlParam
def uninstall():
# 组件卸载动作
# 1. 删除任务
remove_task()
# 2.删除数据库schema
uninstall_db_schema()
# 3. 删除kafka topic
delete_kafka_topic()
# 4. 其他操作等
def remove_task():
"""
组件批量注销任务
"""
from appManager.module.global_api import ComponentHelper
ch = ComponentHelper('demo')
ch_ret = ch.remove_task()
def uninstall_db_schema():
''' 删除数据库schema '''
try:
sql = CPgSqlParam("drop schema if exists demo cascade")
CFunction.execute(sql)
except Exception as e:
raise e
# logger.error("delete data schema fail! reason: %s" % e)
def delete_kafka_topic():
from appsUtils.kafkaUtil import KAFKA_API
api = KAFKA_API()
api. delete_topic('topic_name')