-
Notifications
You must be signed in to change notification settings - Fork 44
Update list_hosts.py #71
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Conversation
Worked with engineering to add support for adding the container count with the host names and also for showing a larger number of hosts. The original script only showed about 10 hosts per environment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
channged comments per conversation with Davide
examples/list_hosts.py
Outdated
hostName = metrics[0] | ||
count = metrics[1] | ||
output.append('%s\t%d' % (hostName, count)) | ||
print '\n'.join(output) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can maybe add here a one liner, would this work?:
print('\n'.join(["%s\t%s" % (data['d'][0], data['d'][1]) for data in res[1]['data']])
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would definitively work.
However, I would avoid patterns that could be a little cryptic, especially in the context of these examples that serve the purpose of documenting what can be done and how. For instance, hostName = metrics[0]
would be unnecessary in most cases, here the goal was to explain that metrics
is an array, and the first element is the hostName
value related to the first metric specified in the list.
Hope this makes sense :-)
examples/list_hosts.py
Outdated
# | ||
# Instantiate the SDC client | ||
sdclient = SdcClient(sdc_token) | ||
metrics = [{"id": "host.hostName"}, {"id": "container.count","aggregations":{"time":"avg","group":"avg"}}] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would write this list in multiple lines, so each metric we are querying is clearer:
metrics = [
{"id": "host.hostName"},
{
"id": "container.count",
"aggregations":{"time":"avg","group":"avg"}
},
]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very good idea.
One thing we should investigate is using a "prettier" configuration that (either manually or automatically) can enforce some guidelines like the one you suggested. As much as I like consistency, I don't like leaving the burden of enforcing consistency in the hands of every developer. Let's work on it outside the scope of this PR ;-)
@dalejrodriguez @figarocorso I made few changes. Could you please review the changes to see if they still make sense? Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@davideschiera I would make this repo flake8 compliant.
Worked with engineering to add support for adding the container count with the host names and also for showing a larger number of hosts. The original script only showed about 10 hosts per environment.