def start(self):
        zkOper = Common_ZkOpers()

        existCluster = zkOper.existCluster()
        if not existCluster:
            raise UserVisiableException("Nginx componentCluster does't exist")

        total_nginx_nodes = zkOper.retrieve_nginx_node_list()
        started_nodes = zkOper.retrieve_started_nodes()
        if len(total_nginx_nodes) == len(started_nodes):
            raise UserVisiableException(
                "all nginx nodes have started. No need to start them.")

        logging.info("all nginx nodes: %s" % (total_nginx_nodes))
        to_start_nginx_nodes = list(
            set(total_nginx_nodes) - set(started_nodes))
        logging.info("nginx needed to start: " + str(to_start_nginx_nodes))

        node_infos = []
        for node in to_start_nginx_nodes:
            info = zkOper.retrieve_nginx_node_info(node)
            node_infos.append(info)

        self.baseOpers(node_infos, OperType.start)

        result_dict = {
            'message': 'cluster start processing, please wait for a moment!'
        }
        return result_dict
    def retrieve_cluster_started_status(self):
        zkOper = Common_ZkOpers()
        started_nodes = zkOper.retrieve_started_nodes()
        total_nodes = zkOper.retrieve_nginx_node_list()

        started_nodes_count = len(started_nodes)
        total_nodes_count = len(total_nodes)

        if started_nodes_count == total_nodes_count:
            return ClusterStatus.STARTED
        elif 0 != started_nodes_count:
            return ClusterStatus.STARTED_PART
        else:
            return ClusterStatus.STOP
    def stop(self):
        zkOper = Common_ZkOpers()
        node_infos = []

        started_nodes_list = zkOper.retrieve_started_nodes()
        if not started_nodes_list:
            raise UserVisiableException(
                'cluster has been stopped, no need to do this!')

        for nginx_node in started_nodes_list:
            info = zkOper.retrieve_nginx_node_info(nginx_node)
            node_infos.append(info)

        self.baseOpers(node_infos, OperType.stop)
        result_dict = {
            'message': 'cluster stop processing, please wait for a moment!'
        }
        return result_dict