def test_get_sum_disk_usage(self):
     stateOpers = StateOpers('d-mcl-mcluster-manager-test-n-3')
     result = stateOpers.get_sum_disk_usage()
     print "get_sum_disk_usage: %s" % result
     self.assertNotEqual(result, None, "result not none")
     self.assertNotEqual(result.get('root_mount'), 0, "root_mount > 0")
     self.assertNotEqual(result.get('volumes_mount'), 0,
                         "volumes_mount > 0")
Example #2
0
 def open_containers_under_oom(self, container_name_list):
     result = {}
     containers = self._get_containers(container_name_list)
     for container in containers:
         conl = StateOpers(container)
         ret = conl.open_container_under_oom()
         if not ret:
             raise UserVisiableException(
                 'container %s under oom value open failed' % container)
         result.setdefault(container, ret)
     return result
Example #3
0
 def gather(self):
     container_nodes = self.get_container_nodes()
     res_type = 'diskusage'
     for container_node in container_nodes:
         state_op = StateOpers(container_node.container_name)
         disk_usage = state_op.get_sum_disk_usage()
         node_name = self.con_op.get_container_node_from_container_name(
             container_node.cluster_name, container_node.container_name)
         disk_usage.update({
             'cluster_name': container_node.cluster_name,
             'node_name': node_name
         })
         self.write_to_es(res_type, disk_usage)
Example #4
0
 def gather(self):
     container_nodes = self.get_container_nodes()
     res_type = 'memory'
     for container_node in container_nodes:
         state_op = StateOpers(container_node.container_name)
         memory = state_op.get_memory_stat_item()
         node_name = self.con_op.get_container_node_from_container_name(
             container_node.cluster_name, container_node.container_name)
         memory.update({
             'cluster_name': container_node.cluster_name,
             'node_name': node_name
         })
         self.write_to_es(res_type, memory)
Example #5
0
    def add_containers_memory(self, container_name_list, times=2):
        '''
            times: add memory times, default value is 2
        '''

        add_ret = {}
        containers = self._get_containers(container_name_list)
        for container in containers:
            _inspect = self.docker_opers.inspect_container(container)
            conl = StateOpers(container)
            ret = conl.extend_memory(times)
            add_ret.setdefault(container, ret)

        return add_ret
Example #6
0
    def set_container_cpuset(self, args):

        container_name = args.get('containerName')
        exists = self.check_container_exists(container_name)
        if not exists:
            raise UserVisiableException("container(name:%s) dont's existed!" %
                                        (container_name))
        cpus = args.get('cpus')
        if not cpus:
            raise UserVisiableException("params cpus should be given!")

        add_ret = {}
        state_opers = StateOpers(container_name)
        cpuset_value = state_opers.set_cpuset(cpus)
        add_ret.setdefault(container_name, cpuset_value)
Example #7
0
 def set_containers_disk_bps(self,
                             container_name_list,
                             container_type,
                             method='write',
                             data=0):
     result = {}
     containers = self._get_containers(container_name_list)
     for container in containers:
         stat_op = StateOpers(container)
         ret = stat_op.set_container_disk_bps(container_type, method, data)
         if not ret:
             raise UserVisiableException(
                 'container %s set disk bps failed' % container)
         result.setdefault(container, {'bps': ret})
     return result
Example #8
0
    def set_container_cpushares(self, args):

        container_name = args.get('containerName')
        exists = self.check_container_exists(container_name)
        if not exists:
            raise UserVisiableException("container(name:%s) dont's existed!" %
                                        container_name)
        times = args.get('times')
        if not times:
            raise UserVisiableException("params times should be given!")

        add_ret = {}
        cpushares = 1024 * eval(times)
        state_opers = StateOpers(container_name)
        cpushares_value = state_opers.set_cpushares(int(cpushares))
        add_ret.setdefault(container_name, cpushares_value)

        return add_ret
 def test_get_root_mnt_size(self):
     stateOpers = StateOpers('d-mcl-mcluster-manager-test-n-3')
     result = stateOpers.get_root_mnt_size()
     print "get_root_mnt_size: %s" % result
Example #10
0
 def test_get_oom_kill_disable_value(self):
     stateOpers = StateOpers('d-mcl-mcluster-manager-test-n-3')
     result = stateOpers.get_oom_kill_disable_value()
     print "get_oom_kill_disable_value: %s" % result
Example #11
0
 def test_get_cpuacct_stat_value(self):
     stateOpers = StateOpers('d-mcl-mcluster-manager-test-n-3')
     result = stateOpers.get_cpuacct_stat_value()
     print "get_cpuacct_stat_value: %s" % result
Example #12
0
 def test_get_memory_stat_item(self):
     stateOpers = StateOpers('d-mcl-mcluster-manager-test-n-3')
     result = stateOpers.get_memory_stat_item()
     print "get_memory_stat_item: %s" % result
Example #13
0
 def test_get_memsw_load(self):
     stateOpers = StateOpers('d-mcl-mcluster-manager-test-n-3')
     result = stateOpers.get_memsw_load()
     print "get_memsw_load: %s" % result
Example #14
0
 def test_get_con_limit_memsw(self):
     stateOpers = StateOpers('d-mcl-mcluster-manager-test-n-3')
     result = stateOpers.get_con_limit_memsw()
     print "get_con_limit_memsw: %s" % result
Example #15
0
 def test_get_container_id(self):
     stateOpers = StateOpers('d-mcl-mcluster-manager-test-n-3')
     result = stateOpers.get_container_id()
     print "get_container_id: %s" % result