Mark the nic spray fixed once the nic has been re-added. They should still add a test to make sure the IP has been put back, etc. Also fixed an issue with duplicate nic names.

This commit is contained in:
Tim Young 2018-03-24 09:34:06 -05:00
parent 10ef0a426f
commit d8a5a8169c
3 changed files with 41 additions and 6 deletions

View File

@ -289,6 +289,8 @@ namespace EduNetworkBuilder
private void btnNicPlus_Click(object sender, EventArgs e) private void btnNicPlus_Click(object sender, EventArgs e)
{ {
List<NicType> WhatToAdd = new List<NicType>(); List<NicType> WhatToAdd = new List<NicType>();
Network tnet = NB.GetNetwork();
NetworkCard tnic = null;
//generate a new nic and add it to the device //generate a new nic and add it to the device
if (ClonedItem.GetType().ToString() == "EduNetworkBuilder.NetworkDevice") if (ClonedItem.GetType().ToString() == "EduNetworkBuilder.NetworkDevice")
{ {
@ -314,7 +316,7 @@ namespace EduNetworkBuilder
} }
if (WhatToAdd.Count == 1) if (WhatToAdd.Count == 1)
{ {
ndCLonedItem.AddNic(WhatToAdd[0]); tnic = ndCLonedItem.AddNic(WhatToAdd[0]);
} }
if(WhatToAdd.Count > 1) if(WhatToAdd.Count > 1)
{ {
@ -352,9 +354,11 @@ namespace EduNetworkBuilder
QuestionForm.ShowDialog(); QuestionForm.ShowDialog();
if(cbQuestions.SelectedIndex >=0) if(cbQuestions.SelectedIndex >=0)
{ {
ndCLonedItem.AddNic(WhatToAdd[cbQuestions.SelectedIndex]); tnic = ndCLonedItem.AddNic(WhatToAdd[cbQuestions.SelectedIndex]);
} }
} }
if(tnet != null)
tnet.RegisterNICAdded(ndCLonedItem.hostname, tnic.NicName());
} }
UpdateForm(); UpdateForm();
} }

View File

@ -2003,7 +2003,16 @@ namespace EduNetworkBuilder
} }
} }
} }
public void RegisterNICAdded(string source, string nicname)
{
foreach (NetTest one in NetTests)
{
if (one.sHost == source && one.TheTest == NetTestType.DeviceNICSprays && one.dHost == nicname)
{
one.SetDone();
}
}
}
public void RegisterUPSAdded(string source) public void RegisterUPSAdded(string source)
{ {
foreach (NetTest one in NetTests) foreach (NetTest one in NetTests)

View File

@ -184,13 +184,35 @@ namespace EduNetworkBuilder
} }
return count; return count;
} }
public void AddNic(NicType TheType = NicType.eth) public int FirstEmptySlot(NicType TheType)
{
int count = 0;
while (true)
{
bool found = false;
string tname = TheType.ToString() + count.ToString();
foreach (NetworkCard nic in NICs)
{
if(nic.NicName() == tname)
{
found = true;
break;
}
}
if (!found)
return count;
count++;
}
}
public NetworkCard AddNic(NicType TheType = NicType.eth)
{ {
NetworkCard tnic; NetworkCard tnic;
int count = CountNics(TheType); int count = FirstEmptySlot(TheType);
tnic = new NetworkCard(count, GetUniqueIdentifier, hostname, TheType); tnic = new NetworkCard(count, GetUniqueIdentifier, hostname, TheType);
NICs.Add(tnic); NICs.Add(tnic);
ApplyRulesToDevice(); ApplyRulesToDevice();
return tnic;
} }
private void ApplyRulesToDevice() private void ApplyRulesToDevice()
{ {