Ejemplo 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)
Ejemplo n.º 2
0
    def __update_cluser_info_to_zk(self, cluster, network_mode, component_type,
                                   component_container_cluster_config):
        sum_count = component_container_cluster_config.sum_count

        _container_cluster_info = {}
        _container_cluster_info.setdefault('containerClusterName', cluster)
        _container_cluster_info.setdefault('containerCount', sum_count)
        _container_cluster_info.setdefault('start_flag', Status.failed)

        zkOper = Container_ZkOpers()
        zkOper.write_container_cluster_info(_container_cluster_info)
Ejemplo n.º 3
0
    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)
Ejemplo n.º 4
0
    def __create_cluser_info_to_zk(self, network_mode, component_type,
                                   component_container_cluster_config):
        containerCount = component_container_cluster_config.nodeCount
        containerClusterName = component_container_cluster_config.container_cluster_name
        use_ip = 'bridge' != network_mode

        _container_cluster_info = {
            'containerCount': containerCount,
            'containerClusterName': containerClusterName,
            'type': component_type,
            'isUseIp': use_ip
        }
        zkOper = Container_ZkOpers()
        zkOper.write_container_cluster_info(_container_cluster_info)