def take_action(self, parsed_args): ip_addr = self.http_ip http_port = self.http_port cmd_name = self.cmd_name for command in self.cmd_list: if cmd_name in command[1].keys(): tab_url = "http://" + ip_addr + ":" +\ http_port + "/Snh_" + command[0].encode("utf-8") arg_count = 0 if len(command[1].values()[0].values()): tab_url = tab_url + "?" for params in command[1].values()[0].values(): for args in params: args[0] = args[0].encode("utf-8") if arg_count > 0: tab_url = tab_url + "&" tab_url = tab_url + args[0] + "=" if hasattr(parsed_args, args[0]) == True: if getattr(parsed_args, args[0]) != None: tab_url = tab_url + getattr( parsed_args, args[0])[0] arg_count = arg_count + 1 tables = self.web_invoke(tab_url) if tables: doc = xmltodict.parse(tables) OpServerUtils.messages_dict_scrub(doc) print json.dumps(doc, indent=4)
def take_action(self, parsed_args): cmd_name = self.cmd_name for command in self.cmd_list: if cmd_name == command.cli_name: url = self._prepare_query_url(parsed_args, command) result = self.web_invoke(url) if result: output = xmltodict.parse(result) OpServerUtils.messages_dict_scrub(output) print json.dumps(output, indent=4)