示例#1
0
 def test_one_online(self):
     """The scheduler finds one host online"""
     self.host1.ping()
     container_requests.create('container_foo', self.container_data)
     container_requests.handle(self.host1)
     self.assertEqual(0, container_requests.count())
     containers = list(self.host1.containers.list())
     self.assertEqual(1, len(containers))
     self.assertEqual('container_foo', containers[0])
示例#2
0
 def test_enlisted(self):
     """The scheduler ignores hosts not enlisted"""
     self.host1.ping()
     self.host1.update({'enlisted': False})
     self.host1 = hosts.get(self.host1.name)
     container_requests.create('container_foo', self.container_data)
     container_requests.handle(self.host1)
     self.assertEqual(1, container_requests.count())
     self.assertEqual(0, self.host1.containers.count())
示例#3
0
    def test_mem_total(self):
        """Ensure we honor max_containers"""
        self.host1.ping()
        self.host1.update({'max_containers': 1, 'mem_total': 6})
        self.host2.ping()
        self.host2.update({'max_containers': 1, 'mem_total': 5})
        self.host1 = hosts.get(self.host1.name)

        # create one container, it should go to host1 (more memory)
        container_requests.create('container_foo', self.container_data)
        container_requests.handle(self.host1)
        self.assertEqual(0, container_requests.count())
        self.assertEqual(1, self.host1.containers.count())
示例#4
0
文件: api.py 项目: doanac/cya
def host_get(name):
    h = hosts.get(name)
    if _is_host_authenticated(h):
        h.ping()
        container_requests.handle(h)

    data = h.to_dict()
    data["client_version"] = client_version()
    withcontainers = request.args.get("with_containers") is not None
    if not withcontainers and "containers" in h.data:
        del data["containers"]
    if "api_key" in data:
        del data["api_key"]
    return jsonify(data)
示例#5
0
文件: api.py 项目: doanac/cya
def host_get(name):
    h = hosts.get(name)
    if _is_host_authenticated(h):
        h.ping()
        container_requests.handle(h)

    data = h.to_dict()
    data['client_version'] = client_version()
    withcontainers = request.args.get('with_containers') is not None
    if not withcontainers and 'containers' in h.data:
        del data['containers']
    if 'api_key' in data:
        del data['api_key']
    return jsonify(data)
示例#6
0
    def test_max_containers(self):
        """Ensure we honor max_containers"""
        self.host1.ping()
        self.host1.update({'max_containers': 1})
        self.host1 = hosts.get(self.host1.name)

        # create one container
        container_requests.create('container_foo', self.container_data)
        container_requests.handle(self.host1)
        self.assertEqual(0, container_requests.count())
        self.assertEqual(1, self.host1.containers.count())

        # create 2nd container, will stay stuck in queued
        container_requests.create('container_foo', self.container_data)
        container_requests.handle(self.host1)
        self.assertEqual(1, container_requests.count())
        self.assertEqual(1, self.host1.containers.count())
示例#7
0
 def test_offline(self):
     """The scheduler is okay if everything is offline"""
     container_requests.create('container_foo', self.container_data)
     container_requests.handle(self.host1)
     self.assertEqual(1, container_requests.count())