Esempio n. 1
0
    def do_when_remove_cluster(self):
        def check():
            for container_node in self.container_nodes:
                container_status = zk_opers.retrieve_container_status_value(
                    self.cluster, container_node)
                if container_status.get('status') != Status.destroyed:
                    return
            return True

        zk_opers = Container_ZkOpers()
        ret = handleTimeout(check, (50, 4))
        if not ret:
            raise CommonException(
                'remove containers %s in containerCluster:%s failed' %
                (self.containers, self.cluster))
        for container_node in self.container_nodes:
            logging.info('do delete container node :%s info in zookeeper' %
                         container_node)
            zk_opers.delete_container_node(self.cluster, container_node)

        cluster_info = zk_opers.retrieve_container_cluster_info(self.cluster)
        node_count = cluster_info.get('containerCount')
        _node_count = int(node_count) - len(self.containers)
        cluster_info.update({'containerCount': _node_count})
        cluster_info.update({'start_flag': Status.succeed})
        zk_opers.write_container_cluster_info(cluster_info)
 def do_when_remove_cluster(self):
     zkOper = Container_ZkOpers()
     cluster_info = zkOper.retrieve_container_cluster_info(self.cluster)
     use_ip = cluster_info.get('isUseIp')
     if use_ip:
         container_ip_list = zkOper.retrieve_container_list(self.cluster)
         logging.info('container_ip_list:%s' % str(container_ip_list))
         zkOper.recover_ips_to_pool(container_ip_list)
    def update_zk_info_when_process_complete(self,
                                             cluster,
                                             create_result='failed',
                                             error_msg=''):

        zkOper = Container_ZkOpers()
        _container_cluster_info = zkOper.retrieve_container_cluster_info(
            cluster)
        _container_cluster_info['start_flag'] = create_result
        _container_cluster_info['error_msg'] = error_msg
        _container_cluster_info['containerClusterName'] = cluster
        zkOper.write_container_cluster_info(_container_cluster_info)
Esempio n. 4
0
    def get_container_node_from_container_name(self, cluster, container_name):
        con_node = ''
        zkOper = Container_ZkOpers()
        cluster_info = zkOper.retrieve_container_cluster_info(cluster)
        use_ip = cluster_info.get('isUseIp')
        if use_ip:
            container_node_list = zkOper.retrieve_container_list(cluster)
            for container_node in container_node_list:
                container_info = zkOper.retrieve_container_node_value(
                    cluster, container_node)
                inspect = container_info.get('inspect')
                con = Container_Model(inspect=inspect)
                con_name = con.name()
                if container_name == con_name:
                    con_node = container_node
                    break
        else:
            con_node = container_name

        return con_node
Esempio n. 5
0
 def __sum_count(self, cluster, node_count):
     zk_oper = Container_ZkOpers()
     cluster_info = zk_oper.retrieve_container_cluster_info(cluster)
     container_count = cluster_info.get('containerCount')
     return int(node_count) + int(container_count)