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
# modify connection settings
# Target connection is specified by name(i.e. wired1)
# Argument for properties is same explained above.
returncode, stdout, stderr = nm.modify('connection', 'wired1', properties={'ipv4.method':'auto', '+ipv4.dns':('8.8.8.8', '8.8.4.4', '1.1.1.1')})
print(NMCLI_EXIT_STATUS(returncode), stdout.decode('utf8'), stderr.decode('utf8'))

# add a connection
# First argument is for connection name. It is must be specified.
# Argument for properties is same explainded above.
returncode, stdout, stderr = nm.add_connection('bridge', properties={'ifname':'br0', 'con-name':'bridge-br0', 'ipv4.method':'manual', 'ipv4.addresses':'172.18.0.1/16', 'bridge.stp':'no'})
print(NMCLI_EXIT_STATUS(returncode), stdout.decode('utf8'), stderr.decode('utf8'))

# delete connection
# Specify the name of connection to delete.
returncode, stdout, stderr = nm.delete_connection('bridge-br0')
print(NMCLI_EXIT_STATUS(returncode), stdout.decode('utf8'), stderr.decode('utf8'))

# clone connection
# First argument is name of connection to be cloned.
# Second argument is name of new cloned connection.
returncode, stdout, stderr = nm.clone_connection('wired1', 'new-connection')
print(NMCLI_EXIT_STATUS(returncode), stdout.decode('utf8'), stderr.decode('utf8'))
returncode, stdout, stderr = nm.delete_connection('new-connection')

# reload connection
# Reload all connection from disk.
returncode, stdout, stderr = nm.reload_connection()
print(NMCLI_EXIT_STATUS(returncode), stdout.decode('utf8'), stderr.decode('utf8'))

# load connection