-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added sliders for switching NIC state. Also added post-restart sync w…
…ith interface listing in vmanager, so interfaces now correctly show which type they are. Also added special case columns on table() so that custom elements can be injected into particular columns.
- Loading branch information
Showing
9 changed files
with
324 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import json | ||
from os.path import isdir, isfile | ||
|
||
def get_overview(): | ||
response = {'vnics' : {}, 'interfaces' : {}, 'routers' : {}, 'switches' : {}} | ||
for nic_name in vmanager.nics: | ||
response['vnics'][nic_name] = { | ||
'ip' : vmanager.nics[nic_name].ip, | ||
'MAC' : vmanager.nics[nic_name].mac, | ||
'state' : vmanager.nics[nic_name].state, | ||
'gateway' : vmanager.nics[nic_name].ports['sink_name'], | ||
'routes' : None, | ||
'connected_to' : None | ||
} | ||
|
||
for nic_name in vmanager.interfaces: | ||
response['interfaces'][nic_name] = vmanager.interfaces[nic_name] | ||
|
||
for nic_name in vmanager.routers: | ||
response['routers'][nic_name] = vmanager.routers[nic_name] | ||
|
||
for nic_name in vmanager.switches: | ||
response['switches'][nic_name] = vmanager.switches[nic_name] | ||
|
||
return response | ||
|
||
class parser(): | ||
def process(self, path, client, data, headers, fileno, addr, *args, **kwargs): | ||
print('### nic ###\n', data, client) | ||
|
||
if 'state' in data and 'target' in data: | ||
if data['target'] in vmanager.nics: | ||
if data['state']: | ||
vmanager.nics[data['target']].up() | ||
else: | ||
vmanager.nics[data['target']].down() | ||
elif data['target'] in vmanager.interfaces: | ||
if data['state']: | ||
vmanager.interfaces[data['target']].up() | ||
else: | ||
vmanager.interfaces[data['target']].down() | ||
elif data['target'] in vmanager.routers: | ||
if data['state']: | ||
vmanager.routers[data['target']].up() | ||
else: | ||
vmanager.routers[data['target']].down() | ||
elif data['target'] in vmanager.switches: | ||
if data['state']: | ||
vmanager.switches[data['target']].up() | ||
else: | ||
vmanager.switches[data['target']].down() | ||
else: | ||
print(f'[N] Could not locate {data["target"]}') | ||
|
||
return get_overview() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,34 @@ | ||
import json | ||
from os.path import isdir, isfile | ||
|
||
def get_overview(): | ||
response = {'vnics' : {}, 'interfaces' : {}, 'routers' : {}, 'switches' : {}} | ||
for nic_name in vmanager.nics: | ||
response['vnics'][nic_name] = { | ||
'ip' : vmanager.nics[nic_name].ip, | ||
'MAC' : vmanager.nics[nic_name].mac, | ||
'state' : vmanager.nics[nic_name].state, | ||
'gateway' : vmanager.nics[nic_name].ports['sink_name'], | ||
'routes' : None, | ||
'connected_to' : None | ||
} | ||
|
||
for nic_name in vmanager.interfaces: | ||
response['interfaces'][nic_name] = vmanager.interfaces[nic_name] | ||
|
||
for nic_name in vmanager.routers: | ||
response['routers'][nic_name] = vmanager.routers[nic_name] | ||
|
||
for nic_name in vmanager.switches: | ||
response['switches'][nic_name] = vmanager.switches[nic_name] | ||
|
||
return response | ||
|
||
class parser(): | ||
def process(self, path, client, data, headers, fileno, addr, *args, **kwargs): | ||
print('### router ###\n', data, client) | ||
|
||
if 'new' in data: | ||
vmanager.Router(trunk=data['new']['trunk'], ifname=data['new']['name']) | ||
vmanager.Router(trunk=data['new']['trunk'], ifname=data['new']['name']) | ||
|
||
return get_overview() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,34 @@ | ||
import json | ||
from os.path import isdir, isfile | ||
|
||
def get_overview(): | ||
response = {'vnics' : {}, 'interfaces' : {}, 'routers' : {}, 'switches' : {}} | ||
for nic_name in vmanager.nics: | ||
response['vnics'][nic_name] = { | ||
'ip' : vmanager.nics[nic_name].ip, | ||
'MAC' : vmanager.nics[nic_name].mac, | ||
'state' : vmanager.nics[nic_name].state, | ||
'gateway' : vmanager.nics[nic_name].ports['sink_name'], | ||
'routes' : None, | ||
'connected_to' : None | ||
} | ||
|
||
for nic_name in vmanager.interfaces: | ||
response['interfaces'][nic_name] = vmanager.interfaces[nic_name] | ||
|
||
for nic_name in vmanager.routers: | ||
response['routers'][nic_name] = vmanager.routers[nic_name] | ||
|
||
for nic_name in vmanager.switches: | ||
response['switches'][nic_name] = vmanager.switches[nic_name] | ||
|
||
return response | ||
|
||
class parser(): | ||
def process(self, path, client, data, headers, fileno, addr, *args, **kwargs): | ||
print('### switch ###\n', data, client) | ||
|
||
if 'new' in data: | ||
vmanager.Switch(data['new']['name']) | ||
vmanager.Switch(data['new']['name']) | ||
|
||
return get_overview() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,34 @@ | ||
import json | ||
from os.path import isdir, isfile | ||
|
||
def get_overview(): | ||
response = {'vnics' : {}, 'interfaces' : {}, 'routers' : {}, 'switches' : {}} | ||
for nic_name in vmanager.nics: | ||
response['vnics'][nic_name] = { | ||
'ip' : vmanager.nics[nic_name].ip, | ||
'MAC' : vmanager.nics[nic_name].mac, | ||
'state' : vmanager.nics[nic_name].state, | ||
'gateway' : vmanager.nics[nic_name].ports['sink_name'], | ||
'routes' : None, | ||
'connected_to' : None | ||
} | ||
|
||
for nic_name in vmanager.interfaces: | ||
response['interfaces'][nic_name] = vmanager.interfaces[nic_name] | ||
|
||
for nic_name in vmanager.routers: | ||
response['routers'][nic_name] = vmanager.routers[nic_name] | ||
|
||
for nic_name in vmanager.switches: | ||
response['switches'][nic_name] = vmanager.switches[nic_name] | ||
|
||
return response | ||
|
||
class parser(): | ||
def process(self, path, client, data, headers, fileno, addr, *args, **kwargs): | ||
print('### nic ###\n', data, client) | ||
|
||
if 'new' in data: | ||
vmanager.VirtualNic(data['new']['name']) | ||
vmanager.VirtualNic(data['new']['name']) | ||
|
||
return get_overview() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
.onoffswitch { | ||
position: relative; width: 90px; | ||
-webkit-user-select:none; -moz-user-select:none; -ms-user-select: none; | ||
} | ||
.onoffswitch-checkbox { | ||
display: none; | ||
} | ||
.onoffswitch-label { | ||
display: block; overflow: hidden; cursor: pointer; | ||
border: 2px solid #999999; border-radius: 20px; | ||
} | ||
.onoffswitch-inner { | ||
display: block; width: 200%; margin-left: -100%; | ||
transition: margin 0.3s ease-in 0s; | ||
} | ||
.onoffswitch-inner:before, .onoffswitch-inner:after { | ||
display: block; float: left; width: 50%; height: 30px; padding: 0; line-height: 30px; | ||
font-size: 14px; color: white; font-family: Trebuchet, Arial, sans-serif; font-weight: bold; | ||
box-sizing: border-box; | ||
} | ||
.onoffswitch-inner:before { | ||
content: "Up"; | ||
padding-left: 10px; | ||
background-color: #34A7C1; color: #FFFFFF; | ||
} | ||
.onoffswitch-inner:after { | ||
content: "Down"; | ||
padding-right: 10px; | ||
background-color: #EEEEEE; color: #999999; | ||
text-align: right; | ||
} | ||
.onoffswitch-switch { | ||
display: block; width: 18px; margin: 6px; | ||
background: #FFFFFF; | ||
position: absolute; top: 0; bottom: 0; | ||
right: 56px; | ||
border: 2px solid #999999; border-radius: 20px; | ||
transition: all 0.3s ease-in 0s; | ||
} | ||
.onoffswitch-checkbox:checked + .onoffswitch-label .onoffswitch-inner { | ||
margin-left: 0; | ||
} | ||
.onoffswitch-checkbox:checked + .onoffswitch-label .onoffswitch-switch { | ||
right: 0px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.