#!/usr/bin/env python
# -*- coding: utf-8 -*-
from utils.common.message import Message
from utils.DBAdapter.DBConnector import BaseOps
from utils.common.fic_base import StepBaseInterface
from plugins.DistributedStorage.logic.InstallOperate import InstallOperate
from plugins.DistributedStorage.utils.iterm.ParameterGain import ParamsGain
from plugins.DistributedStorage.implement.TC_Reg_Account_To_Unify_Pwd import RegAccountToUnifyPwd


class RegAccountToUnifyPwdInterface(StepBaseInterface):
    def __init__(self, project_id, pod_id):
        self.project_id = project_id
        self.pod_id = pod_id
        self.db = BaseOps()
        self.fs_args = ParamsGain(self.project_id, self.pod_id, self.db).get_business_separate_args()
        self.fs_args['sub_component_name'] = 'Business Separated Storage'
        self.install_opr = InstallOperate(self.project_id, self.pod_id, self.fs_args)
        self.fs_args['az_id'] = self.install_opr.get_az_id('DistributedStorageBusiness')
        self.fs_args['vm_boolean'] = True
        self.fs_args['osd_boolean'] = True
        self.RegAccountToUnifyPwd = RegAccountToUnifyPwd(project_id, pod_id, self.fs_args)

    def pre_check(self, project_id, pod_id):
        """
        插件内部接口：创建存储池，该接口由execute接口调用，工具框架不会直接调用此接口。
        :param project_id:
        :param pod_id:
        :return:
        """
        return Message()

    def execute(self, project_id, pod_id):
        """
        标准调用接口：执行安装前预检查&安装&配置
        :param project_id:
        :param pod_id:
        :return:Message类对象
        """
        return self.RegAccountToUnifyPwd.procedure()

    def rollback(self, project_id, pod_id):
        """
        标准调用接口：执行回滚
        :param project_id:
        :param pod_id:
        :return:Message类对象
        """
        return Message()

    def retry(self, project_id, pod_id):
        """
        标准调用接口：重试
        :return: Message类对象
        """
        return self.execute(project_id, pod_id)

    def check(self, project_id, pod_id):
        """
        标准调用接口：重试
        :param project_id:
        :param pod_id:
        :return:
        """
        return Message()
