initial debugging of action code

This commit is contained in:
Tim Young 2018-10-05 08:43:07 -05:00
parent 9c9826ef85
commit a81392ca75
2 changed files with 30 additions and 2 deletions

View File

@ -204,12 +204,14 @@ namespace EduNetworkBuilder
myNet.MarkAsLinked(sourceNL.Dst, sourceNL.GetUniqueIdentifier); myNet.MarkAsLinked(sourceNL.Dst, sourceNL.GetUniqueIdentifier);
myNet.AddItem(ChangedComponent); myNet.AddItem(ChangedComponent);
} }
if(NB.DebugActions) { Console.WriteLine("Changing a component: " + source); }
break; break;
case NBAction.changelocation: case NBAction.changelocation:
if (source != null) if (source != null)
{ {
source.ChangeLocation(Location); source.ChangeLocation(Location);
source.UnHide(); //In case it was hidden source.UnHide(); //In case it was hidden
if (NB.DebugActions) { Console.WriteLine("Changing location for: " + source + " " + Location.X + ":" +Location.Y); }
} }
break; break;
case NBAction.deletecomponent: case NBAction.deletecomponent:
@ -225,6 +227,7 @@ namespace EduNetworkBuilder
myNet.RemoveLinksToNic(nicID); myNet.RemoveLinksToNic(nicID);
} }
myNet.RemoveComponent(source); myNet.RemoveComponent(source);
if (NB.DebugActions) { Console.WriteLine("Deleting a device: " + source); }
} else if(sourceC != null && sourceC is NetworkLink) } else if(sourceC != null && sourceC is NetworkLink)
{ {
if (myNet.ItemIsCritical(sourceC.hostname)) if (myNet.ItemIsCritical(sourceC.hostname))
@ -232,6 +235,7 @@ namespace EduNetworkBuilder
NetworkLink SourceL = (NetworkLink)sourceC; NetworkLink SourceL = (NetworkLink)sourceC;
SourceL.Destroy(); //Mark both ends as being deleted SourceL.Destroy(); //Mark both ends as being deleted
myNet.RemoveComponent(SourceL); //Get rid of this link myNet.RemoveComponent(SourceL); //Get rid of this link
if (NB.DebugActions) { Console.WriteLine("Deleting a link: " + source); }
} }
break; break;
case NBAction.newdevice: case NBAction.newdevice:
@ -251,31 +255,48 @@ namespace EduNetworkBuilder
if (CanDo) if (CanDo)
{ {
ChangedComponent = (NetworkDevice)myNet.AddItem(newItemType, Location); ChangedComponent = (NetworkDevice)myNet.AddItem(newItemType, Location);
if (NB.DebugActions) { Console.WriteLine("Adding a Device: " + source); }
} }
else else
{ {
NB.SetBuilderWindowStatis(NB.Translate("NB_TreePlacementError")); NB.SetBuilderWindowStatis(NB.Translate("NB_TreePlacementError"));
if (NB.DebugActions) { Console.WriteLine("Unable to add device: " + source); }
} }
break; break;
case NBAction.dhcp: case NBAction.dhcp:
if (source != null) if (source != null)
{
source.DHCPRequestFromHere(); source.DHCPRequestFromHere();
if (NB.DebugActions) { Console.WriteLine("Requesting DHCP: " + source); }
}
break; break;
case NBAction.arp: case NBAction.arp:
if (source != null) if (source != null)
{
source.AskArpFromHere(Destination); source.AskArpFromHere(Destination);
if (NB.DebugActions) { Console.WriteLine("Requesting DHCP: " + source); }
}
break; break;
case NBAction.cleararp: case NBAction.cleararp:
if (source != null) if (source != null)
{
source.ClearArps(); source.ClearArps();
if (NB.DebugActions) { Console.WriteLine("Clearing ARP: " + source); }
}
break; break;
case NBAction.ping: case NBAction.ping:
if (source != null) if (source != null)
{
source.PingFromHere(Destination); source.PingFromHere(Destination);
if (NB.DebugActions) { Console.WriteLine("Pinging " + Destination + " from " + source); }
}
break; break;
case NBAction.traceroute: case NBAction.traceroute:
if (source != null) if (source != null)
{
source.TracerouteFromHere(Destination); source.TracerouteFromHere(Destination);
if (NB.DebugActions) { Console.WriteLine("Traceroute: " + Destination+ " from " + source); }
}
break; break;
case NBAction.replace: case NBAction.replace:
if(sourceC is NetworkDevice) if(sourceC is NetworkDevice)
@ -288,6 +309,7 @@ namespace EduNetworkBuilder
myNet.RegisterDeviceReset(source.hostname); //replacing something powers it off myNet.RegisterDeviceReset(source.hostname); //replacing something powers it off
myNet.RegisterDeviceReplaced(source.hostname); //replace it. myNet.RegisterDeviceReplaced(source.hostname); //replace it.
if (NB.DebugActions) { Console.WriteLine("Replacing device: " + source); }
} }
else if (sourceC is NetworkLink) else if (sourceC is NetworkLink)
{ {
@ -300,18 +322,22 @@ namespace EduNetworkBuilder
myNet.RemoveComponent(sourceNL); myNet.RemoveComponent(sourceNL);
NetworkLink nNL = new NetworkLink(sourceID, destID, LinkType.normal); NetworkLink nNL = new NetworkLink(sourceID, destID, LinkType.normal);
myNet.AddItem(nNL); myNet.AddItem(nNL);
if (NB.DebugActions) { Console.WriteLine("Replacing link: " + source); }
} }
} }
break; break;
case NBAction.replaceUPS: case NBAction.replaceUPS:
myNet.RegisterUPSAdded(source.hostname); myNet.RegisterUPSAdded(source.hostname);
if (NB.DebugActions) { Console.WriteLine("Replacing UPS on: " + source); }
break; break;
case NBAction.poweroff: case NBAction.poweroff:
source.PowerOff = true; source.PowerOff = true;
myNet.RegisterDeviceReset(source.hostname); myNet.RegisterDeviceReset(source.hostname);
if (NB.DebugActions) { Console.WriteLine("Powering off: " + source); }
break; break;
case NBAction.poweron: case NBAction.poweron:
source.PowerOff = false; source.PowerOff = false;
if (NB.DebugActions) { Console.WriteLine("Powering on: " + source); }
//We might see about exploding the device here. //We might see about exploding the device here.
break; break;
} }

View File

@ -379,6 +379,8 @@ namespace EduNetworkBuilder
public static int NormalRotation = 5; public static int NormalRotation = 5;
public static int PacketDamageDistance = 25; public static int PacketDamageDistance = 25;
public static bool DebugActions = true;
public static int NumBadPackets = 7; //the number of packets to spray out public static int NumBadPackets = 7; //the number of packets to spray out
public static string AllowedPasswordCharacters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-=!~@#$%^&*()_+{}[]/?<>,."; public static string AllowedPasswordCharacters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-=!~@#$%^&*()_+{}[]/?<>,.";