examples/do_rpc_async.py
def main(my_space):
    """
    Gets all connected Junos devices from Space. Then invokes the
    <get-commit-information> RPC on all of them asynchronously and waits for
    all those tasks to complete. Then it prints the results from each RPC.
    """
    devices = my_space.device_management.devices.\
              get(filter_={'deviceFamily': 'junos',
                            'connectionStatus': 'up'})

    tm = async.TaskMonitor(my_space, 'test_rpc_q')
    try:
        task_ids = []
        for d in devices:
            print(d.name, d.ipAddr, d.platform)
            result = d.exec_rpc_async.post(
                                           task_monitor=tm,
                                           rpcCommand="<get-commit-information/>"
                                           )

            assert result.id > 0, "Async RPC execution Failed"
            task_ids.append(result.id)

        # Wait for all tasks to complete
        pu_list = tm.wait_for_tasks(task_ids)
        for pu in pu_list:
            assert (pu.state == "DONE" and pu.status == "SUCCESS" and
                    str(pu.percentage) == "100.0")

            # Print the RPC result for each
            print(pu.data)
    finally:
        tm.delete()

    Gets all connected Junos devices from Space. Then invokes the
    <get-commit-information> RPC on all of them asynchronously and waits for
    all those tasks to complete. Then it prints the results from each RPC.
    
Gets all connected Junos devices from Space. Then invokes the
 RPC on all of them asynchronously and waits for
all those tasks to complete. Then it prints the results from each RPC.
Gets all connected Junos devices from Space . Then invokes the RPC on all of them asynchronously and waits for all those tasks to complete . Then it prints the results from each RPC .
def main(my_space):
    devices = my_space.device_management.devices.\
              get(filter_={'deviceFamily': 'junos',
                            'connectionStatus': 'up'})
    tm = async.TaskMonitor(my_space, 'test_rpc_q')
    try:
        task_ids = []
        for d in devices:
            print(d.name, d.ipAddr, d.platform)
            result = d.exec_rpc_async.post(
                                           task_monitor=tm,
                                           rpcCommand="<get-commit-information/>"
                                           )
            assert result.id > 0, "Async RPC execution Failed"
            task_ids.append(result.id)
        pu_list = tm.wait_for_tasks(task_ids)
        for pu in pu_list:
            assert (pu.state == "DONE" and pu.status == "SUCCESS" and
                    str(pu.percentage) == "100.0")
            print(pu.data)
    finally:
        tm.delete()
def main ( my_space ) : devices = my_space . device_management . devices . get ( filter_ = { 'deviceFamily' : 'junos' , 'connectionStatus' : 'up' } ) tm = async . TaskMonitor ( my_space , 'test_rpc_q' ) try : task_ids = [ ] for d in devices : print ( d . name , d . ipAddr , d . platform ) result = d . exec_rpc_async . post ( task_monitor = tm , rpcCommand = "<get-commit-information/>" ) assert result . id > 0 , "Async RPC execution Failed" task_ids . append ( result . id ) pu_list = tm . wait_for_tasks ( task_ids ) for pu in pu_list : assert ( pu . state == "DONE" and pu . status == "SUCCESS" and str ( pu . percentage ) == "100.0" ) print ( pu . data ) finally : tm . delete ( )
Gets all connected Junos devices from Space.
Gets all connected Junos devices from Space .
"""
    Gets all connected Junos devices from Space. Then invokes the
    <get-commit-information> RPC on all of them asynchronously and waits for
    all those tasks to complete. Then it prints the results from each RPC.
    """ # Wait for all tasks to complete # Print the RPC result for each
my_space