Add MAC Address Configuration

This commit is contained in:
2021-01-26 21:16:46 +01:00
parent 42c1c5fa66
commit a260d2fedb
2 changed files with 31 additions and 18 deletions
+25 -7
View File
@@ -104,13 +104,20 @@ class Interface:
route['dst_len'] = r['dst_len']
self.routes.append(route)
def up(self):
def SetAddress(self, address):
self.address = address
if self.ndb:
self.ndb.set('address', self.address).commit()
elif self.ipr:
iproute.link('set', index=self.index, address=self.address)
def Up(self):
if self.ndb:
self.ndb.set('state', 'up').commit()
elif self.ipr:
iproute.link("set", index=self.index, state="up")
def down(self):
def Down(self):
if self.ndb:
self.ndb.set('state', 'down').commit()
elif self.ipr:
@@ -161,6 +168,9 @@ def test_Variable(v1, v2, f):
assert v1 == v2, "{} not equal ({}, {})".format(f, v1, v2)
def test_Interface():
InitializeLibrary('NDB')
InitializeLibrary('IPR')
itf1 = GetInterface('NDB', 'br0')
itf2 = GetInterface('IPR', 'br0')
@@ -173,27 +183,35 @@ def test_Interface():
#test_Interface()
def test_CreateInterface():
InitializeLibrary('NDB')
InitializeLibrary('IPR')
CreateInterface('NDB', 'ndb0', 'veth', 'ndb1')
CreateInterface('IPR', 'ipr0', 'veth', 'ipr1')
itf1 = GetInterface('NDB', 'ndb0')
itf2 = GetInterface('IPR', 'ipr0')
itf1.up();
itf2.up();
itf1.Up();
itf2.Up();
itf3 = GetInterface('NDB', 'ndb1')
itf4 = GetInterface('IPR', 'ipr1')
itf3.up();
itf4.up();
itf3.SetAddress('00:11:22:33:44:55')
itf4.SetAddress('00:11:22:33:44:56')
itf3.Up();
itf4.Up();
AddPort('NDB', 'br0', 'ndb0')
AddPort('IPR', 'br0', 'ipr0')
#test_CreateInterface()
def test_RemoveInterface():
InitializeLibrary('NDB')
InitializeLibrary('IPR')
DelPort('NDB', 'br0', 'ndb0')
DelPort('IPR', 'br0', 'ipr0')