I am running the Facebook Thrift service on my machine. I used a sample code to show its working:
import asyncio
from fbnet.command_runner.thrift_client import AsyncioThriftClient
# Import FCR Thrift Types
from fbnet.command_runner_asyncio.CommandRunner import ttypes as fcr_ttypes
# Import FCR Service Client
from fbnet.command_runner_asyncio.CommandRunner.Command import Client as FcrClient
import getpass
# Device Information
hostname = 'my_vm'
username = 'root'
password = getpass.getpass('%s Password: ' % username)
# Destination device
device = fcr_ttypes.Device(hostname=hostname, username=username, password=password)
async def run(cmd, device):
async with AsyncioThriftClient(FcrClient, 'x.x.x.x',22 ) as client:
res = await client.run(cmd, device)
# type of res is `struct CommandResult`
print(res.output)
loop = asyncio.get_event_loop()
loop.run_until_complete(run('uname -a', device))
However I am getting the following error:
Frame size 1397966893 too large for THeaderProtocol Traceback (most recent call last):
File "pgm1.py", line 28, in loop.run_until_complete(run('uname -a', device))
File "/usr/local/lib/python3.6/asyncio/base_events.py", line 467, in run_until_complete return future.result()
File "pgm1.py", line 23, in run res = await client.run(cmd, device) thrift.transport.TTransport.TTransportException: Connection closed
Any ideas on how to correct this?
1397966893 = 0x5353482D
come from? Some uninitialized variable? – JensG