def run(self): self.parse_options() if len(self.args) >= 2: inst_ids = self.args[1:] else: inst_ids = None api = API(self.opt.dir) (status_code, message, topologies_json) = api.instance_list(inst_ids) if status_code != API.STATUS_SUCCESS: self._print_error("Unable to list instances.", message) return 1 else: insts = json.loads(topologies_json) for inst in insts: if self.opt.verbose or self.opt.debug: print json.dumps(inst, indent=2) else: topology = Topology.from_json_dict(inst) reset = Fore.RESET + Style.RESET_ALL print Fore.WHITE + Style.BRIGHT + topology.id + reset + ": " + self._colorize_topology_state( topology.state ) return 0