3 . ${CIRROS_LIB:=/lib/cirros/shlib_cirros} ||
4 { echo "failed to read ${CIRROS_LIB}" 1>&2; exit 1; }
8 Usage: ${0##*/} command [options]
11 datasource: list the datasource name
12 dsmode: list the datasource mode ('net', or 'local')
13 available: list available fields for datasource
19 local short_opts="hqv"
20 local long_opts="help,quiet,verbose"
22 getopt_out=$(getopt --name "${0##*/}" \
23 --options "${short_opts}" --long "${long_opts}" -- "$@") &&
24 eval set -- "${getopt_out}" ||
25 { bad_Usage; return; }
27 local cur="" next="" command="" VERBOSITY
28 while [ $# -ne 0 ]; do
31 -h|--help) Usage ; exit 0;;
32 -v|--verbose) VERBOSITY=$((${VERBOSITY}+1));;
33 -q|--quiet) VERBOSITY=0;;
39 [ $# -ne 0 ] || { bad_Usage "must provide arguments"; return; }
41 local command="$1" dsname="" dsmode="" start_d="$PWD"
44 { debug 1 "no datasource"; return 1; }
45 dsname="${_DATASOURCE_NAME}"
46 dsmode="${_DATASOURCE_MODE}"
48 if [ "$command" = "datasource" ]; then
50 { error "confused by '$2' to mode $command"; return 1; }
53 elif [ "$command" = "dsmode" ]; then
55 { error "confused by '$2' to mode $command"; return 1; }
58 elif [ "$command" = "available" ]; then
60 { error "confused by '$2' to mode $command"; return 1; }
62 { error "failed to list items"; return 1; }
65 elif [ "$command" = "get" ]; then
66 [ "$#" -eq 2 ] || fail "can only query 1 item at a time"
70 error "unknown command '$command'"
78 # vi: ts=4 noexpandtab