Correct handling of network lists

This commit is contained in:
Joshua Boniface 2018-09-24 01:34:20 -04:00
parent cf9785149b
commit 903e94b519
2 changed files with 6 additions and 1 deletions

View File

@ -96,6 +96,8 @@ class RouterInstance():
def updatenetworklist(self, s_network): def updatenetworklist(self, s_network):
self.s_network = s_network self.s_network = s_network
for network in s_network:
self.network_list.append(network.getvni())
# Flush all VMs on the host # Flush all VMs on the host
def set_secondary(self): def set_secondary(self):
@ -133,7 +135,7 @@ class RouterInstance():
# Display router information to the terminal # Display router information to the terminal
ansiiprint.echo('{}{} keepalive{}'.format(ansiiprint.purple(), self.name, ansiiprint.end()), '', 't') ansiiprint.echo('{}{} keepalive{}'.format(ansiiprint.purple(), self.name, ansiiprint.end()), '', 't')
ansiiprint.echo('{0}Active networks:{1} {2} {0}Free memory [MiB]:{1} {3} {0}Used memory [MiB]:{1} {4} {0}Load:{1} {5}'.format(ansiiprint.bold(), ansiiprint.end(), self.networks_count, self.memfree, self.memused, self.cpuload), '', 'c') ansiiprint.echo('{0}Active networks:{1} {2} {0}Free memory [MiB]:{1} {3} {0}Used memory [MiB]:{1} {4} {0}Load:{1} {5}'.format(ansiiprint.bold(), ansiiprint.end(), self.network_list, self.memfree, self.memused, self.cpuload), '', 'c')
# Update our local router lists # Update our local router lists
for router_name in self.t_router: for router_name in self.t_router:

View File

@ -74,6 +74,9 @@ class VXNetworkInstance():
if data != None and self.dhcp_flag != data.decode('ascii'): if data != None and self.dhcp_flag != data.decode('ascii'):
self.dhcp_flag = ( data.decode('ascii') == 'True' ) self.dhcp_flag = ( data.decode('ascii') == 'True' )
def getvni(self):
return self.vni
def createNetwork(self): def createNetwork(self):
ansiiprint.echo('Creating VNI {} device on interface {}'.format(self.vni, self.vni_dev), '', 'o') ansiiprint.echo('Creating VNI {} device on interface {}'.format(self.vni, self.vni_dev), '', 'o')
common.run_os_command('ip link add {} type vxlan id {} dstport 4789 dev {}'.format(self.vxlan_nic, self.vni, self.vni_dev)) common.run_os_command('ip link add {} type vxlan id {} dstport 4789 dev {}'.format(self.vxlan_nic, self.vni, self.vni_dev))