is there a way to send a single command and receive a response? for example yeti-cli 127.0.0.1:7080 core.show.version .
I’d need something like that.
Thanks!
I’m not an expert of python but here there is a class adapted for the single call request type:
class CommandLineCall:
def rpc_do_dotted(self,addr, method, args, verbose = False):
method = method.rstrip('.')
for i,a in enumerate(args):
if a=='empty':
args[i] = ''
j = JsonRpcProxy(addr,5)
return j.call_remote(method,args,verbose)
if __name__ == '__main__':
try:
addr = sys.argv[1]
except:
addr = False
try:
command = sys.argv[2]
except:
command = False
try:
parameters = sys.argv[3]
except:
parameters = []
try:
if (addr and command):
data = CommandLineCall().rpc_do_dotted(addr,command,parameters)
print(data)
else:
print('interactive mode')
syslog.syslog("Session started")
print('yeti-cli version {}'.format(__version__))
Shell().cmdloop()
except IOError as e:
print(e)
except KeyboardInterrupt as e:
print('')
it’s a first simple prototype, I can only get informations from remote nodes but I’m not able to pass parameters right now.
Command line example:
# yeti-cli 127.0.0.1 yeti.show.calls.count
190
I made the class in a way it can be merged on the current project if you need, but it needs to be revised and fixed for errors handling I guess.
Hope you’ll appreciate
ok, done, I made a new file yeti-cmd just for this kind of use, in this way you can move just this file in every server you want without dependencies problem