Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for display of unique values by attribute lookups #116

Open
jathanism opened this issue Jun 24, 2016 · 0 comments
Open

Allow for display of unique values by attribute lookups #116

jathanism opened this issue Jun 24, 2016 · 0 comments

Comments

@jathanism
Copy link
Contributor

There needs to be a way to display unique attribute values based on an attribute lookup. For example if you have Device.model and Device.hw_type and want to lookup all unique device model values for a given hw_type.

This is not currently possible.

For single values it's as easy as nsot values list -r device -n model (all unique models).

This hard-coded one-liner solves the problem, but let's come up w/ a way to do it officially and not hard-codedly:

#!/bin/bash

SCRIPT_NAME=$0
HW_TYPE=$1

if [ $# -eq 0 ] ; then
    echo -e "usage: ${SCRIPT_NAME} <hw_type>"
    exit 1
fi

CMD="nsot devices list -a 'hw_type=${HW_TYPE}' -g | egrep ' model=' | awk '{print \$2}' | sort | uniq | awk -F'=' '{print \$2}'"
eval $CMD

# Example usage:
# ./models_by_type router
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant