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:
parent
ecb68aa5d2
commit
aa25d8fee1
1 changed files with 7 additions and 0 deletions
|
@ -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'])
|
||||
|
|
Loading…
Reference in a new issue