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)
{
List<NicType> WhatToAdd = new List<NicType>();
Network tnet = NB.GetNetwork();
NetworkCard tnic = null;
//generate a new nic and add it to the device
if (ClonedItem.GetType().ToString() == "EduNetworkBuilder.NetworkDevice")
{
@ -314,7 +316,7 @@ namespace EduNetworkBuilder
}
if (WhatToAdd.Count == 1)
{
ndCLonedItem.AddNic(WhatToAdd[0]);
tnic = ndCLonedItem.AddNic(WhatToAdd[0]);
}
if(WhatToAdd.Count > 1)
{
@ -352,9 +354,11 @@ namespace EduNetworkBuilder
QuestionForm.ShowDialog();
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();
}

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)
{
foreach (NetTest one in NetTests)

View File

@ -184,13 +184,35 @@ namespace EduNetworkBuilder
}
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;
int count = CountNics(TheType);
int count = FirstEmptySlot(TheType);
tnic = new NetworkCard(count, GetUniqueIdentifier, hostname, TheType);
NICs.Add(tnic);
ApplyRulesToDevice();
return tnic;
}
private void ApplyRulesToDevice()
{
@ -984,7 +1006,7 @@ namespace EduNetworkBuilder
Network theNet = NB.GetNetwork();
if(!theNet.ItemIsLocked(hostname,NICs[index].NicName(),NetTestType.LockNic))
{
if (theNet != null) theNet.RemoveLinksToNic(NICs[index].myID);
if (theNet != null) theNet.RemoveLinksToNic(NICs[index].myID);
NICs.RemoveAt(index);
}
else