Node info moved to API
This commit is contained in:
parent
3d178304f1
commit
28a0ce772b
|
@ -49,7 +49,6 @@ def node_coordinator_state(config, node, action):
|
||||||
API schema: {"message": "{data}"}
|
API schema: {"message": "{data}"}
|
||||||
"""
|
"""
|
||||||
request_uri = get_request_uri(config, '/node/{node}/coordinator-state'.format(node=node))
|
request_uri = get_request_uri(config, '/node/{node}/coordinator-state'.format(node=node))
|
||||||
|
|
||||||
response = requests.post(
|
response = requests.post(
|
||||||
request_uri,
|
request_uri,
|
||||||
params={'state': action}
|
params={'state': action}
|
||||||
|
@ -82,7 +81,6 @@ def node_domain_state(config, node, action, wait):
|
||||||
API schema: {"message": "{data}"}
|
API schema: {"message": "{data}"}
|
||||||
"""
|
"""
|
||||||
request_uri = get_request_uri(config, '/node/{node}/domain-state'.format(node=node))
|
request_uri = get_request_uri(config, '/node/{node}/domain-state'.format(node=node))
|
||||||
|
|
||||||
response = requests.post(
|
response = requests.post(
|
||||||
request_uri,
|
request_uri,
|
||||||
params={'state': action, 'wait': wait}
|
params={'state': action, 'wait': wait}
|
||||||
|
@ -106,6 +104,35 @@ def node_domain_state(config, node, action, wait):
|
||||||
|
|
||||||
return retstatus, response.json()['message']
|
return retstatus, response.json()['message']
|
||||||
|
|
||||||
|
def node_info(config, node):
|
||||||
|
"""
|
||||||
|
Get information about node
|
||||||
|
|
||||||
|
API endpoint: GET /api/v1/node/{node}
|
||||||
|
API arguments:
|
||||||
|
API schema: {json_data_object}
|
||||||
|
"""
|
||||||
|
request_uri = get_request_uri(config, '/node/{node}'.format(node=node))
|
||||||
|
response = requests.get(
|
||||||
|
request_uri
|
||||||
|
)
|
||||||
|
|
||||||
|
if config['debug']:
|
||||||
|
print(
|
||||||
|
'API endpoint: GET {}'.format(request_uri)
|
||||||
|
)
|
||||||
|
print(
|
||||||
|
'Response code: {}'.format(response.status_code)
|
||||||
|
)
|
||||||
|
print(
|
||||||
|
'Response headers: {}'.format(response.headers)
|
||||||
|
)
|
||||||
|
|
||||||
|
if response.status_code == 200:
|
||||||
|
return True, response.json()
|
||||||
|
else:
|
||||||
|
return False, response.json()['message']
|
||||||
|
|
||||||
#
|
#
|
||||||
# Output display functions
|
# Output display functions
|
||||||
#
|
#
|
||||||
|
|
|
@ -42,7 +42,7 @@ myhostname = socket.gethostname().split('.')[0]
|
||||||
zk_host = ''
|
zk_host = ''
|
||||||
|
|
||||||
config = dict()
|
config = dict()
|
||||||
config['debug'] = True
|
config['debug'] = False
|
||||||
config['api_scheme'] = 'http'
|
config['api_scheme'] = 'http'
|
||||||
config['api_host'] = 'localhost:7370'
|
config['api_host'] = 'localhost:7370'
|
||||||
config['api_prefix'] = '/api/v1'
|
config['api_prefix'] = '/api/v1'
|
||||||
|
@ -169,17 +169,11 @@ def node_info(node, long_output):
|
||||||
Show information about node NODE. If unspecified, defaults to this host.
|
Show information about node NODE. If unspecified, defaults to this host.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
zk_conn = pvc_common.startZKConnection(zk_host)
|
retcode, retdata = pvc_node.node_info(config, node)
|
||||||
retcode, retdata = pvc_node.get_info(zk_conn, node)
|
|
||||||
if retcode:
|
if retcode:
|
||||||
pvc_node.format_info(retdata, long_output)
|
pvc_node.format_info(retdata, long_output)
|
||||||
if long_output:
|
|
||||||
click.echo('{}Virtual machines on node:{}'.format(ansiprint.bold(), ansiprint.end()))
|
|
||||||
click.echo('')
|
|
||||||
pvc_vm.get_list(zk_conn, node, None, None, None)
|
|
||||||
click.echo('')
|
|
||||||
retdata = ''
|
retdata = ''
|
||||||
cleanup(retcode, retdata, zk_conn)
|
cleanup(retcode, retdata)
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# pvc node list
|
# pvc node list
|
||||||
|
@ -1811,7 +1805,11 @@ def init_cluster(yes):
|
||||||
'-z', '--zookeeper', '_zk_host', envvar='PVC_ZOOKEEPER', default=None,
|
'-z', '--zookeeper', '_zk_host', envvar='PVC_ZOOKEEPER', default=None,
|
||||||
help='Zookeeper connection string.'
|
help='Zookeeper connection string.'
|
||||||
)
|
)
|
||||||
def cli(_zk_host):
|
@click.option(
|
||||||
|
'-v', '--debug', '_debug', envvar='PVC_DEBUG', is_flag=True, default=False,
|
||||||
|
help='Additional debug details.'
|
||||||
|
)
|
||||||
|
def cli(_zk_host, _debug):
|
||||||
"""
|
"""
|
||||||
Parallel Virtual Cluster CLI management tool
|
Parallel Virtual Cluster CLI management tool
|
||||||
|
|
||||||
|
@ -1838,6 +1836,8 @@ def cli(_zk_host):
|
||||||
|
|
||||||
global zk_host
|
global zk_host
|
||||||
zk_host = _zk_host
|
zk_host = _zk_host
|
||||||
|
global config
|
||||||
|
config['debug'] = _debug
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
Loading…
Reference in New Issue