summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorliuyahui <liuyh.fnst@fujitsu.com>2021-06-01 15:35:44 +0800
committerEdi Feschiyan <edi.feschiyan@konsulko.com>2021-06-02 10:59:28 +0000
commit1b2a1a37f2f768417055296563c2d34bf4855e8b (patch)
tree7162105e1b773d073695c5cdef399a343cde2e43
parent4999731fd9b70b2a595d7cd800658f65fb16378c (diff)
Add main function to network service module
Bug-AGL: SPEC-3946 Signed-off-by: liuyahui <liuyh.fnst@fujitsu.com> Change-Id: I0abd85dee152817974ca5e77b074d471037a8cf3
-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))