fix query to the rca

Change-Id: I9d48f540545a47d65cd86cf0e62bf1c335a2bcf1
This commit is contained in:
Eyal 2016-02-11 10:45:31 +02:00
parent a8a74d2f86
commit 36da36c63f
3 changed files with 60 additions and 3 deletions

View File

@ -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

View File

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

View File

@ -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()