Esempio n. 1
0
    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
Esempio n. 2
0
    def reload(self):
        zkOper = Common_ZkOpers()
        node_infos = []

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

        self.baseOpers(node_infos, OperType.reload)
        result_dict = {
            'message': 'cluster reload processing, please wait for a moment!'
        }
        return result_dict
Esempio n. 3
0
    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
Esempio n. 4
0
    def disable(self):
        zkOper = Common_ZkOpers()
        node_infos = []

        _nodes_list = zkOper.retrieve_nginx_node_list()
        if not _nodes_list:
            raise UserVisiableException(
                "cluster has not node, please check the cluster's node!")

        for _node in _nodes_list:
            info = zkOper.retrieve_nginx_node_info(_node)
            node_infos.append(info)

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