Esempio n. 1
0
    def test_05_show_device_0(self):
        nm = NMCLI()
        _, dev, _ = nm.list_devices()
        d = dev[0].decode('utf8')

        rc, stdout, stderr = nm.show('device', d, field='all')
        self.assertEqual(rc, 0)
        self.assertEqual(type(stdout), dict)
        self.assertEqual(stdout[b'GENERAL.DEVICE'].decode('utf8'), d)
Esempio n. 2
0
    def test_11_delete_device(self):
        nm = NMCLI()

        _, stdout, _ = nm.list_devices()
        if b'dummy0' in stdout:
            rc, _, _ = nm.delete_device('dummy0')
            self.assertEqual(rc, 0)

        self.assertNotIn(b'dummy0', stdout)
Esempio n. 3
0
 def test_04_list_connections(self):
     nm = NMCLI()
     rc, stdout, stderr = nm.list_devices()
     self.assertEqual(rc, 0)
     self.assertEqual(type(stdout), tuple)
Esempio n. 4
0
stderr     : standard error output from 'nmcli'
             empty str is returned when 'nmcli' finished successfully
"""

# show version of 'nmcli'
returncode, stdout, stderr = nm.show_version()
print(stdout)


nm = NMCLI() # return values will be in type of bytes and default LOCALE
# show version of 'nmcli'
returncode, stdout, stderr = nm.show_version()
print(stdout)

# list devices recognised by NetworkManager
returncode, stdout, stderr = nm.list_devices()
print(stdout)

# list connections
returncode, stdout, stderr = nm.list_connections()
print(stdout)

# show device specified by name(i.e. ens33)
# Argument for 'field=' is used to specify what fields should be returned.
# Comma separated str(should be no white space), list or tuple is accepted.
returncode, stdout, stderr = nm.show('device', 'ens33', field='common')
print(NMCLI_EXIT_STATUS(returncode), stdout, stderr.decode('utf8'))

# show connection specified by name(i.e. ens33)
# Argument for 'field' is same explained above.
returncode, stdout, stderr = nm.show('connection', 'ens33', field='connection.id,connection.type')