Add UPS, powersupply and frozen device to random network.
This commit is contained in:
parent
b4f11fcee9
commit
eaae8c84fc
@ -96,7 +96,7 @@ namespace EduNetworkBuilder
|
|||||||
vpn, vpn_encryption, vpn_decryption, ip_address, masquerade, forward, arrived, network_interface}
|
vpn, vpn_encryption, vpn_decryption, ip_address, masquerade, forward, arrived, network_interface}
|
||||||
public enum HowToBreak { PowerOff, EthernetBreak, EthernetCorrupt, EthernetRemoveLink, LockOutSwitch,
|
public enum HowToBreak { PowerOff, EthernetBreak, EthernetCorrupt, EthernetRemoveLink, LockOutSwitch,
|
||||||
WirelessBreakSSID, WirelessBreakKey, DeviceChangeIP, DeviceChangeGW, StaticRouteClear,
|
WirelessBreakSSID, WirelessBreakKey, DeviceChangeIP, DeviceChangeGW, StaticRouteClear,
|
||||||
StaticRouteCorrupt, VLANChange, VPNChangeEndpoint, VPNChangeKey}
|
StaticRouteCorrupt, VLANChange, VPNChangeEndpoint, VPNChangeKey, BreakDevice }
|
||||||
|
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public struct HostNicID //This holds a unique identifier for a network card. Links use this to know what it is connected to
|
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.WirelessBreakKey:
|
||||||
case HowToBreak.WirelessBreakSSID:
|
case HowToBreak.WirelessBreakSSID:
|
||||||
return TraversalTechnology.wireless;
|
return TraversalTechnology.wireless;
|
||||||
|
case HowToBreak.BreakDevice:
|
||||||
|
return TraversalTechnology.any;
|
||||||
}
|
}
|
||||||
return TraversalTechnology.none;
|
return TraversalTechnology.none;
|
||||||
}
|
}
|
||||||
|
@ -139,6 +139,9 @@ namespace EduNetworkBuilder
|
|||||||
case NetTestType.DeviceNeedsUPS:
|
case NetTestType.DeviceNeedsUPS:
|
||||||
toreturn = NB.Translate("NT_TstDescriptNeedsUPS");
|
toreturn = NB.Translate("NT_TstDescriptNeedsUPS");
|
||||||
break;
|
break;
|
||||||
|
case NetTestType.DeviceBlowsUpWithPower:
|
||||||
|
toreturn = NB.Translate("NT_TstDescriptBadPowersupply");
|
||||||
|
break;
|
||||||
case NetTestType.NeedsDefaultGW:
|
case NetTestType.NeedsDefaultGW:
|
||||||
toreturn = NB.Translate("NT_TstDscriptGteway");
|
toreturn = NB.Translate("NT_TstDscriptGteway");
|
||||||
break;
|
break;
|
||||||
@ -229,6 +232,9 @@ namespace EduNetworkBuilder
|
|||||||
case NetTestType.DeviceNeedsUPS:
|
case NetTestType.DeviceNeedsUPS:
|
||||||
toreturn = NB.Translate("NT_TstDescriptNeedsUPS2");
|
toreturn = NB.Translate("NT_TstDescriptNeedsUPS2");
|
||||||
break;
|
break;
|
||||||
|
case NetTestType.DeviceBlowsUpWithPower:
|
||||||
|
toreturn = NB.Translate("NT_TstDescriptBadPowersupply2");
|
||||||
|
break;
|
||||||
case NetTestType.NeedsDefaultGW:
|
case NetTestType.NeedsDefaultGW:
|
||||||
toreturn = NB.Translate("NT_TstDiscriptGteway2");
|
toreturn = NB.Translate("NT_TstDiscriptGteway2");
|
||||||
break;
|
break;
|
||||||
|
@ -2098,6 +2098,7 @@ namespace EduNetworkBuilder
|
|||||||
if (BrokenItems.Contains(WhatBreak)) return 0; //it was already done
|
if (BrokenItems.Contains(WhatBreak)) return 0; //it was already done
|
||||||
NetworkDevice tDevice = null;
|
NetworkDevice tDevice = null;
|
||||||
NetworkLink tLink = null;
|
NetworkLink tLink = null;
|
||||||
|
NetTest tTest = null;
|
||||||
if (What is NetworkDevice) tDevice = (NetworkDevice)What;
|
if (What is NetworkDevice) tDevice = (NetworkDevice)What;
|
||||||
if (What is NetworkLink) tLink = (NetworkLink)What;
|
if (What is NetworkLink) tLink = (NetworkLink)What;
|
||||||
switch(How)
|
switch(How)
|
||||||
@ -2171,6 +2172,39 @@ namespace EduNetworkBuilder
|
|||||||
if (How == HowToBreak.WirelessBreakKey && rndEnd.BreakWirelessKey(tnic.NicName()))
|
if (How == HowToBreak.WirelessBreakKey && rndEnd.BreakWirelessKey(tnic.NicName()))
|
||||||
didit = 2;
|
didit = 2;
|
||||||
break;
|
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)
|
if(didit > 0)
|
||||||
BrokenItems.Add(WhatBreak);
|
BrokenItems.Add(WhatBreak);
|
||||||
@ -2199,6 +2233,9 @@ namespace EduNetworkBuilder
|
|||||||
//Fail if we cannot do it
|
//Fail if we cannot do it
|
||||||
TraversalTechnology WhatNeeded = NB.TechnologyNeededToBreak(How);
|
TraversalTechnology WhatNeeded = NB.TechnologyNeededToBreak(How);
|
||||||
|
|
||||||
|
if (How == HowToBreak.BreakDevice)
|
||||||
|
Console.WriteLine("Trying to break it");
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
while(count < 3)
|
while(count < 3)
|
||||||
{
|
{
|
||||||
|
@ -2021,4 +2021,12 @@
|
|||||||
<value>Needs a UPS</value>
|
<value>Needs a UPS</value>
|
||||||
<comment>NT_TstDescriptNeedsUPS2 = Needs a UPS</comment>
|
<comment>NT_TstDescriptNeedsUPS2 = Needs a UPS</comment>
|
||||||
</data>
|
</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>
|
</root>
|
Loading…
Reference in New Issue
Block a user