aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pyagl/services/network.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/pyagl/services/network.py b/pyagl/services/network.py
index d56873f..8eae084 100644
--- a/pyagl/services/network.py
+++ b/pyagl/services/network.py
@@ -23,6 +23,9 @@ class NetworkService(AGLBaseService):
service = 'agl-service-network'
parser = AGLBaseService.getparser()
+ parser.add_argument('--state', action='store_true')
+ parser.add_argument('--services', action='store_true')
+
def __init__(self, ip, port=None, service='agl-service-network'):
super().__init__(api='network-manager', ip=ip, port=port, service=service)
@@ -65,3 +68,26 @@ class NetworkService(AGLBaseService):
async def agent_response(self):
pass
+async def main(loop):
+ args = NetworkService.parser.parse_args()
+ nets = await NetworkService(ip=args.ipaddr, port=args.port)
+
+ if args.state:
+ msgid = await nets.state()
+ print(f'Sent status request with messageid {msgid}')
+ resp = await nets.afbresponse()
+ print(resp.data)
+
+ if args.services:
+ msgid = await nets.services()
+ print(f'Sent status request with messageid {msgid}')
+ resp = await nets.afbresponse()
+ print(resp.data)
+
+ if args.listener:
+ for response in nets.listener():
+ print(response)
+
+if __name__ == '__main__':
+ loop = asyncio.get_event_loop()
+ loop.run_until_complete(main(loop))