1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Update ip_netns.py

add the ability to also list all network namespaces
This commit is contained in:
Sven 2024-06-20 14:28:36 +02:00 committed by GitHub
parent ecb68aa5d2
commit aa25d8fee1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -69,6 +69,13 @@ class Namespace(object):
'''Run ip nents command'''
return self.module.run_command(['ip', 'netns'] + command)
def list(self):
'''List all network namespaces'''
rc, out, err = self.module.run_command(['ip', 'netns', 'list'])
if rc != 0:
self.module.fail_json(msg=to_text(err))
return self.out
def exists(self):
'''Check if the namespace already exists'''
rc, out, err = self.module.run_command(['ip', 'netns', 'list'])