diff --git a/tools/vitrage.bash_completion b/tools/vitrage.bash_completion new file mode 100644 index 0000000..ddeb200 --- /dev/null +++ b/tools/vitrage.bash_completion @@ -0,0 +1,56 @@ +_vitrage() +{ + local cur prev words + COMPREPLY=() + _get_comp_words_by_ref -n : cur prev words + + # Command data: + cmds='alarms complete help rca resource topology' + cmds_alarms='list' + cmds_alarms_list='-h --help -f --format -c --column --max-width --noindent --quote' + cmds_complete='-h --help --name --shell' + cmds_help='-h --help' + cmds_rca='show' + cmds_rca_show='-h --help -f --format -c --column --max-width --noindent --variable --prefix' + cmds_resource='list show' + cmds_resource_list='-h --help -f --format -c --column --max-width --noindent --quote --type' + cmds_resource_show='-h --help -f --format -c --column --max-width --noindent --variable --prefix' + cmds_topology='show' + cmds_topology_show='-h --help -f --format -c --column --max-width --noindent --variable --prefix --filter --limit --root --graph-type' + + cmd="" + words[0]="" + completed="${cmds}" + for var in "${words[@]:1}" + do + if [[ ${var} == -* ]] ; then + break + fi + if [ -z "${cmd}" ] ; then + proposed="${var}" + else + proposed="${cmd}_${var}" + fi + local i="cmds_${proposed}" + local comp="${!i}" + if [ -z "${comp}" ] ; then + break + fi + if [[ ${comp} == -* ]] ; then + if [[ ${cur} != -* ]] ; then + completed="" + break + fi + fi + cmd="${proposed}" + completed="${comp}" + done + + if [ -z "${completed}" ] ; then + COMPREPLY=( $( compgen -f -- "$cur" ) $( compgen -d -- "$cur" ) ) + else + COMPREPLY=( $(compgen -W "${completed}" -- ${cur}) ) + fi + return 0 +} +complete -F _vitrage vitrage diff --git a/vitrageclient/v1/cli/rca.py b/vitrageclient/v1/cli/rca.py index 742bc73..1ea5cb7 100644 --- a/vitrageclient/v1/cli/rca.py +++ b/vitrageclient/v1/cli/rca.py @@ -22,6 +22,9 @@ class RcaShow(show.ShowOne): parser.add_argument('alarm_id', help='ID of an alarm') return parser + def formatter_default(self): + return 'json' + def take_action(self, parsed_args): alarm_id = parsed_args.alarm_id alarm = self.app.client.rca.get(alarm_id=alarm_id) diff --git a/vitrageclient/v1/topology.py b/vitrageclient/v1/topology.py index a3b33d5..945019e 100644 --- a/vitrageclient/v1/topology.py +++ b/vitrageclient/v1/topology.py @@ -9,7 +9,6 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. -import json class Topology(object): @@ -28,6 +27,5 @@ class Topology(object): """ params = dict(depth=limit, graph_type=graph_type, - query=json.loads(query) if query else None, - root=root) + query=query, root=root) return self.api.post(self.URL, json=params).json()