forked from microsoft/pai
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker_cache.py
More file actions
26 lines (21 loc) · 1.03 KB
/
docker_cache.py
File metadata and controls
26 lines (21 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import copy
class DockerCache(object):
def __init__(self, cluster_conf, service_conf, default_service_conf):
self.cluster_conf = cluster_conf
self.service_conf = dict(default_service_conf, **service_conf)
def validation_pre(self):
machine_list = self.cluster_conf['machine-list']
if len([host for host in machine_list if host.get('pai-master') == 'true']) < 1:
return False, '"pai-master=true" machine is required to deploy the docker-cache service'
return True, None
def run(self):
result = copy.deepcopy(self.service_conf)
machine_list = self.cluster_conf['machine-list']
server_port = self.service_conf['service_nodeport']
master_ip = [host['hostip'] for host in machine_list if host.get('pai-master') == 'true'][0]
result['uri'] = 'http://{0}:{1}'.format(master_ip, server_port)
return result
def validation_post(self, conf):
return True, None