def set_cluster(self, config_file, key=None):
"""
Load a config file to the registry and make it a cluster
:param config_file: Path to the config file to be loaded
:param key: Key that identifies the cluster
:return: Key that identifies the cluster. It can be generated if it is
not given as a parameter. Use only while debugging.
"""
with open(config_file) as f:
cluster = f.read()
arguments = {
'method': 'new_cluster',
'description': cluster
}
if key:
arguments['key'] = key
client = HTTPClient()
response = client.fetch('{}/cluster?{}'.format(
self.uri, parse.urlencode(arguments)),
headers={'Key': self.uk}
)
if response.code == 200:
return response.body.decode('utf-8')
else:
raise ValueError(response.body.decode('utf-8'))
评论列表
文章目录