Skip to content

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

Merged
merged 4 commits into from
Jan 25, 2019
Merged

Update list_hosts.py #71

merged 4 commits into from
Jan 25, 2019

Conversation

dalejrodriguez
Copy link
Contributor

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.

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.
Copy link
Contributor Author

@dalejrodriguez dalejrodriguez left a 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

hostName = metrics[0]
count = metrics[1]
output.append('%s\t%d' % (hostName, count))
print '\n'.join(output)
Copy link
Contributor

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']])

Copy link
Contributor

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 :-)

#
# Instantiate the SDC client
sdclient = SdcClient(sdc_token)
metrics = [{"id": "host.hostName"}, {"id": "container.count","aggregations":{"time":"avg","group":"avg"}}]
Copy link
Contributor

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"}
    },
]

Copy link
Contributor

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 ;-)

@davideschiera
Copy link
Contributor

@dalejrodriguez @figarocorso I made few changes. Could you please review the changes to see if they still make sense? Thanks!

@dalejrodriguez dalejrodriguez merged commit 09e513e into master Jan 25, 2019
Copy link
Contributor

@figarocorso figarocorso left a 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.

@davideschiera davideschiera deleted the dalejrodriguez-patch-1 branch January 28, 2019 17:26
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants