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

View File

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