Fix a bug where resetting a switch did not reset the vlans on the switch

This commit is contained in:
Tim Young 2018-10-17 14:38:42 -05:00
parent f2c2f9bb96
commit 17b127d69d
5 changed files with 23 additions and 6 deletions

View File

@ -340,6 +340,12 @@ namespace EduNetworkBuilder
if (NB.DebugActions) { Console.WriteLine("Powering on: " + source.hostname); } if (NB.DebugActions) { Console.WriteLine("Powering on: " + source.hostname); }
//We might see about exploding the device here. //We might see about exploding the device here.
break; break;
case NBAction.reset:
source.ClearIPs(); //reset the device - IPs and VLANs
if (NB.DebugActions) { Console.WriteLine("Resetting: " + source.hostname); }
//We might see about exploding the device here.
break;
} }
} }
} }

View File

@ -106,7 +106,7 @@ namespace EduNetworkBuilder
StaticRouteCorrupt, VLANChange, VPNChangeEndpoint, VPNChangeKey, BreakDevice } StaticRouteCorrupt, VLANChange, VPNChangeEndpoint, VPNChangeKey, BreakDevice }
public enum NBAction { none, newdevice, changelocation, changecomponent, deletecomponent, public enum NBAction { none, newdevice, changelocation, changecomponent, deletecomponent,
ping, traceroute, arp, cleararp, dhcp, ping, traceroute, arp, cleararp, dhcp,
replaceUPS, replace, poweroff, poweron, replaceUPS, replace, poweroff, poweron, reset,
} }
[Serializable] [Serializable]
@ -1529,6 +1529,16 @@ namespace EduNetworkBuilder
AC.DoAction(); AC.DoAction();
} }
public static void DoActionResetDevice(int HostID)
{
ActionClass AC = new ActionClass();
AC.Action = NBAction.reset;
AC.SourceID = HostID;
RegisterAction(AC);
AC.DoAction();
}
public static void DoActionReplaceDeviceUPS(int HostID) public static void DoActionReplaceDeviceUPS(int HostID)
{ {
ActionClass AC = new ActionClass(); ActionClass AC = new ActionClass();

View File

@ -1350,7 +1350,8 @@ namespace EduNetworkBuilder
private void pbNetworkView_Reset_Click(object sender, EventArgs e) private void pbNetworkView_Reset_Click(object sender, EventArgs e)
{ {
if (ItemClickedOn == null) return; if (ItemClickedOn == null) return;
ItemClickedOn.ClearIPs(); //reset the device //ItemClickedOn.ClearIPs(); //reset the device
NB.DoActionResetDevice(ItemClickedOn.GetUniqueIdentifier);
UpdateVisuals(); UpdateVisuals();
} }

View File

@ -917,7 +917,8 @@ namespace EduNetworkBuilder
{ {
if (myNicType != NicType.lo) if (myNicType != NicType.lo)
{ {
nf.myIP = new NB_IPAddress(NB.ZeroIPString); if(myNicType != NicType.port)
nf.myIP = new NB_IPAddress(NB.ZeroIPString); //do not do this for ports (have no IP)
nf.SetVLANTag(1, VLANTagType.Untagged); nf.SetVLANTag(1, VLANTagType.Untagged);
} }
} }

View File

@ -3138,7 +3138,7 @@ namespace EduNetworkBuilder
} }
/// <summary> /// <summary>
/// Clear out all the IP addresses on the device /// Clear out all the IP addresses and VLANs on the device
/// </summary> /// </summary>
public void ClearIPs() public void ClearIPs()
{ {
@ -3147,8 +3147,7 @@ namespace EduNetworkBuilder
DefaultGW = new NB_IPAddress(NB.ZeroIPString); DefaultGW = new NB_IPAddress(NB.ZeroIPString);
foreach(NetworkCard nic in NICs) foreach(NetworkCard nic in NICs)
{ {
if(nic.GetNicType != NicType.port) nic.ClearIPs(); //Clear IPs and reset all vlans.
nic.ClearIPs();
} }
} }