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 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
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