Add UPS, powersupply and frozen device to random network.

This commit is contained in:
Tim Young 2018-02-17 17:11:51 +00:00
parent b4f11fcee9
commit eaae8c84fc
4 changed files with 54 additions and 1 deletions

View File

@ -96,7 +96,7 @@ namespace EduNetworkBuilder
vpn, vpn_encryption, vpn_decryption, ip_address, masquerade, forward, arrived, network_interface}
public enum HowToBreak { PowerOff, EthernetBreak, EthernetCorrupt, EthernetRemoveLink, LockOutSwitch,
WirelessBreakSSID, WirelessBreakKey, DeviceChangeIP, DeviceChangeGW, StaticRouteClear,
StaticRouteCorrupt, VLANChange, VPNChangeEndpoint, VPNChangeKey}
StaticRouteCorrupt, VLANChange, VPNChangeEndpoint, VPNChangeKey, BreakDevice }
[Serializable]
public struct HostNicID //This holds a unique identifier for a network card. Links use this to know what it is connected to
@ -1243,6 +1243,8 @@ namespace EduNetworkBuilder
case HowToBreak.WirelessBreakKey:
case HowToBreak.WirelessBreakSSID:
return TraversalTechnology.wireless;
case HowToBreak.BreakDevice:
return TraversalTechnology.any;
}
return TraversalTechnology.none;
}

View File

@ -139,6 +139,9 @@ namespace EduNetworkBuilder
case NetTestType.DeviceNeedsUPS:
toreturn = NB.Translate("NT_TstDescriptNeedsUPS");
break;
case NetTestType.DeviceBlowsUpWithPower:
toreturn = NB.Translate("NT_TstDescriptBadPowersupply");
break;
case NetTestType.NeedsDefaultGW:
toreturn = NB.Translate("NT_TstDscriptGteway");
break;
@ -229,6 +232,9 @@ namespace EduNetworkBuilder
case NetTestType.DeviceNeedsUPS:
toreturn = NB.Translate("NT_TstDescriptNeedsUPS2");
break;
case NetTestType.DeviceBlowsUpWithPower:
toreturn = NB.Translate("NT_TstDescriptBadPowersupply2");
break;
case NetTestType.NeedsDefaultGW:
toreturn = NB.Translate("NT_TstDiscriptGteway2");
break;

View File

@ -2098,6 +2098,7 @@ namespace EduNetworkBuilder
if (BrokenItems.Contains(WhatBreak)) return 0; //it was already done
NetworkDevice tDevice = null;
NetworkLink tLink = null;
NetTest tTest = null;
if (What is NetworkDevice) tDevice = (NetworkDevice)What;
if (What is NetworkLink) tLink = (NetworkLink)What;
switch(How)
@ -2171,6 +2172,39 @@ namespace EduNetworkBuilder
if (How == HowToBreak.WirelessBreakKey && rndEnd.BreakWirelessKey(tnic.NicName()))
didit = 2;
break;
case HowToBreak.BreakDevice:
//The device can be frozen, have bad power, or need a UPS, or just be burnt
Random rnd = NB.GetRandom();
int i = rnd.Next(4);
if(i==0)
{
How = HowToBreak.BreakDevice;
Data = "frozen";
tTest = new NetTest(What.hostname, What.hostname, NetTestType.DeviceIsFrozen);
NetTests.Add(tTest);
}
else if(i == 1)
{
How = HowToBreak.BreakDevice;
Data = "BlowsUp";
tTest = new NetTest(What.hostname, What.hostname, NetTestType.DeviceBlowsUpWithPower);
NetTests.Add(tTest);
}
else if (i == 2)
{
How = HowToBreak.BreakDevice;
Data = "Needs UPS";
tTest = new NetTest(What.hostname, What.hostname, NetTestType.DeviceNeedsUPS);
NetTests.Add(tTest);
}
else if (i == 3)
{
How = HowToBreak.BreakDevice;
Data = "burnt";
tDevice.IsBurned = true; //Burn the device
}
didit = 1;
break;
}
if(didit > 0)
BrokenItems.Add(WhatBreak);
@ -2199,6 +2233,9 @@ namespace EduNetworkBuilder
//Fail if we cannot do it
TraversalTechnology WhatNeeded = NB.TechnologyNeededToBreak(How);
if (How == HowToBreak.BreakDevice)
Console.WriteLine("Trying to break it");
int count = 0;
while(count < 3)
{

View File

@ -2021,4 +2021,12 @@
<value>Needs a UPS</value>
<comment>NT_TstDescriptNeedsUPS2 = Needs a UPS</comment>
</data>
<data name="NT_TstDescriptBadPowersupply" xml:space="preserve">
<value>hardware problem</value>
<comment>NT_TstDescriptBadPowersupply = hardware problem</comment>
</data>
<data name="NT_TstDescriptBadPowersupply2" xml:space="preserve">
<value>Bad power supply</value>
<comment>NT_TstDescriptBadPowersupply2 = bad power supply</comment>
</data>
</root>