Last active
October 2, 2018 16:18
-
-
Save 0xIslamTaha/54bf24baacb9a37c2b896ad04689c863 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# python3 check_nodes_version.py -f 'kristof-farm' -c 'cb52b076df76c4da6be41999f65f87a047437f30' | |
from jumpscale import j | |
logger = j.logger.get('check_node_commit') | |
import click | |
@click.command() | |
@click.option("-f", "--farm_name", help="farm name to update its zrobot", required=True) | |
@click.option("-c", "--commit_id", help="match with this commit id", default='') | |
def main(farm_name, commit_id): | |
capacity = j.clients.threefold_directory.get(interactive=False) | |
resp = capacity.api.ListCapacity(query_params={'farmer': farm_name})[1] | |
nodes = resp.json() #nodes | |
for node in nodes: | |
capacity_commit_id = node['os_version'].split(' ')[1] | |
addr=node["robot_address"][7:-5] | |
try: | |
node_client=j.clients.zos.get("main", data={"host":addr}) | |
real_node_commit_id = node_client.client.info.version()['revision'] | |
except: | |
logger.error(' {} node robot is off! '.format(addr)) | |
continue | |
if capacity_commit_id != real_node_commit_id: | |
logger.error('{} != {}, node: {}:{}'.format(capacity_commit_id, real_node_commit_id, node['node_id'], addr)) | |
else: | |
logger.info('node: {}:{} is okay'.format(node['node_id'], addr)) | |
if commit_id: | |
if capacity_commit_id != commit_id: | |
logger.error('{} != {}, node: {}:{}, issue in capacity logs'.format(capacity_commit_id, commit_id, node['node_id'], addr)) | |
if real_node_commit_id != commit_id: | |
logger.error('{} != {}, node: {}:{}, issue in real node logs'.format(real_node_commit_id, commit_id, node['node_id'], addr)) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment