def get_cluster_zk(self, cluster_name): cluster_zk_info = {} zkOper = Requests_ZkOpers() container_ip_list = zkOper.retrieve_container_list(cluster_name) for container_ip in container_ip_list: container_node = {} create_info = zkOper.retrieve_container_node_value( cluster_name, container_ip) status = zkOper.retrieve_container_status_value( cluster_name, container_ip) container_node.setdefault('container_info', create_info) container_node.setdefault('status', status) cluster_zk_info.setdefault(container_ip, container_node) return cluster_zk_info
def __cluster_created_info(self, cluster): zkOper = Requests_ZkOpers() message_list = [] container_node_list = zkOper.retrieve_container_list(cluster) result = {} for container_node in container_node_list: container_node_value = zkOper.retrieve_container_node_value( cluster, container_node) con = Container_Model() create_info = con.create_info(container_node_value) message_list.append(create_info) result.setdefault('containers', message_list) return result
def __created_info(self, cluster, container_names=[]): zkOper = Requests_ZkOpers() message_list, container_nodes = [], [] if container_names: for container_name in container_names: container_node = self.container_opers.get_container_node_from_container_name( cluster, container_name) if not container_node: raise UserVisiableException('container :%s not existed' % container_name) container_nodes.append(container_node) else: container_nodes = zkOper.retrieve_container_list(cluster) result = {} for container_node in container_nodes: container_node_value = zkOper.retrieve_container_node_value( cluster, container_node) con = Container_Model() create_info = con.create_info(container_node_value) message_list.append(create_info) result.setdefault('containers', message_list) return result