Esempio n. 1
0
    def test_10_delete_connection(self):
        nm = NMCLI()

        rc, _, _ = nm.delete_connection('dummy-dummy0')
        self.assertEqual(rc, 0)
        _, stdout, _ = nm.list_connections()
        self.assertNotIn(b'dummy-dummy0', stdout)
Esempio n. 2
0
    def test_06_show_connection_0(self):
        nm = NMCLI()
        _, con, _ = nm.list_connections()
        c = con[0].decode('utf8')

        rc, stdout, stderr = nm.show('connection', c, field='all')
        self.assertEqual(rc, 0)
        self.assertEqual(type(stdout), dict)
        self.assertEqual(stdout[b'connection.id'].decode('utf8'), c)
Esempio n. 3
0
# 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')
print(NMCLI_EXIT_STATUS(returncode), stdout, stderr.decode('utf8'))

# modify device settings
# Target device is specified by name(i.e. ens38)