本文整理汇总了C#中Host.IsCustomBootEnabled方法的典型用法代码示例。如果您正苦于以下问题:C# Host.IsCustomBootEnabled方法的具体用法?C# Host.IsCustomBootEnabled怎么用?C# Host.IsCustomBootEnabled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Host
的用法示例。
在下文中一共展示了Host.IsCustomBootEnabled方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Rollback
public void Rollback(Unicast unicast)
{
try
{
using (NpgsqlConnection conn = new NpgsqlConnection(Utility.DBString))
{
NpgsqlCommand cmd = new NpgsqlCommand("unicast_rollback", conn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add(new NpgsqlParameter("@taskName", unicast.HostName));
conn.Open();
cmd.ExecuteNonQuery();
}
}
catch (Exception ex)
{
Logger.Log(ex.ToString());
}
Utility settings = new Utility();
Task task = new Task();
string pxeHostMac = task.MacToPXE(unicast.HostMac);
Host hostFunction = new Host();
if (hostFunction.IsCustomBootEnabled(Task.PXEMacToMac(pxeHostMac)))
{
string mode = settings.GetSettings("PXE Mode");
string proxyDHCP = settings.GetSettings("Proxy Dhcp");
if (proxyDHCP == "Yes")
{
try
{
Utility.MoveFile(settings.GetSettings("Tftp Path") + "proxy" + Path.DirectorySeparatorChar + "bios" + Path.DirectorySeparatorChar + "pxelinux.cfg" + Path.DirectorySeparatorChar + pxeHostMac + ".ipxe.custom", settings.GetSettings("Tftp Path") + "proxy" + Path.DirectorySeparatorChar + "bios" + Path.DirectorySeparatorChar + "pxelinux.cfg" + Path.DirectorySeparatorChar + pxeHostMac + ".ipxe");
}
catch { }
try
{
Utility.MoveFile(settings.GetSettings("Tftp Path") + "proxy" + Path.DirectorySeparatorChar + "bios" + Path.DirectorySeparatorChar + "pxelinux.cfg" + Path.DirectorySeparatorChar + pxeHostMac + ".custom", settings.GetSettings("Tftp Path") + "proxy" + Path.DirectorySeparatorChar + "bios" + Path.DirectorySeparatorChar + "pxelinux.cfg" + Path.DirectorySeparatorChar + pxeHostMac);
}
catch { }
try
{
Utility.MoveFile(settings.GetSettings("Tftp Path") + "proxy" + Path.DirectorySeparatorChar + "efi32" + Path.DirectorySeparatorChar + "pxelinux.cfg" + Path.DirectorySeparatorChar + pxeHostMac + ".ipxe.custom", settings.GetSettings("Tftp Path") + "proxy" + Path.DirectorySeparatorChar + "efi32" + Path.DirectorySeparatorChar + "pxelinux.cfg" + Path.DirectorySeparatorChar + pxeHostMac + ".ipxe");
}
catch { }
try
{
Utility.MoveFile(settings.GetSettings("Tftp Path") + "proxy" + Path.DirectorySeparatorChar + "efi32" + Path.DirectorySeparatorChar + "pxelinux.cfg" + Path.DirectorySeparatorChar + pxeHostMac + ".custom", settings.GetSettings("Tftp Path") + "proxy" + Path.DirectorySeparatorChar + "efi32" + Path.DirectorySeparatorChar + "pxelinux.cfg" + Path.DirectorySeparatorChar + pxeHostMac);
}
catch { }
try
{
Utility.MoveFile(settings.GetSettings("Tftp Path") + "proxy" + Path.DirectorySeparatorChar + "efi64" + Path.DirectorySeparatorChar + "pxelinux.cfg" + Path.DirectorySeparatorChar + pxeHostMac + ".ipxe.custom", settings.GetSettings("Tftp Path") + "proxy" + Path.DirectorySeparatorChar + "efi64" + Path.DirectorySeparatorChar + "pxelinux.cfg" + Path.DirectorySeparatorChar + pxeHostMac + ".ipxe");
}
catch { }
try
{
Utility.MoveFile(settings.GetSettings("Tftp Path") + "proxy" + Path.DirectorySeparatorChar + "efi64" + Path.DirectorySeparatorChar + "pxelinux.cfg" + Path.DirectorySeparatorChar + pxeHostMac + ".custom", settings.GetSettings("Tftp Path") + "proxy" + Path.DirectorySeparatorChar + "efi64" + Path.DirectorySeparatorChar + "pxelinux.cfg" + Path.DirectorySeparatorChar + pxeHostMac);
}
catch { }
}
else
{
try
{
Utility.MoveFile(settings.GetSettings("Tftp Path") + "pxelinux.cfg" + Path.DirectorySeparatorChar + pxeHostMac + ".ipxe.custom", settings.GetSettings("Tftp Path") + "pxelinux.cfg" + Path.DirectorySeparatorChar + pxeHostMac + ".ipxe");
}
catch { }
try
{
Utility.MoveFile(settings.GetSettings("Tftp Path") + "pxelinux.cfg" + Path.DirectorySeparatorChar + pxeHostMac + ".custom", settings.GetSettings("Tftp Path") + "pxelinux.cfg" + Path.DirectorySeparatorChar + pxeHostMac);
}
catch { }
}
}
}
示例2: CancelAll
public void CancelAll()
{
Utility settings = new Utility();
List<String> pxePaths = new List<string>();
pxePaths.Add(settings.GetSettings("Tftp Path") + "pxelinux.cfg" + Path.DirectorySeparatorChar);
pxePaths.Add(settings.GetSettings("Tftp Path") + "proxy" + Path.DirectorySeparatorChar + "bios" + Path.DirectorySeparatorChar + "pxelinux.cfg" + Path.DirectorySeparatorChar);
pxePaths.Add(settings.GetSettings("Tftp Path") + "proxy" + Path.DirectorySeparatorChar + "efi32" + Path.DirectorySeparatorChar + "pxelinux.cfg" + Path.DirectorySeparatorChar);
pxePaths.Add(settings.GetSettings("Tftp Path") + "proxy" + Path.DirectorySeparatorChar + "efi64" + Path.DirectorySeparatorChar + "pxelinux.cfg" + Path.DirectorySeparatorChar);
List<string> doNotRemove = new List<string>();
int counter = 0;
foreach (var pxePath in pxePaths)
{
string[] pxeFiles = Directory.GetFiles(pxePath, "01*");
try
{
foreach (string pxeFile in pxeFiles)
{
string ext = Path.GetExtension(pxeFile);
if (ext != ".custom")
{
Host hostFunction = new Host();
string fileName = Path.GetFileNameWithoutExtension(pxeFile);
bool isCustomBootTemplate = hostFunction.IsCustomBootEnabled(Task.PXEMacToMac(fileName));
if (isCustomBootTemplate)
{
if (File.Exists((pxePath + fileName + ".custom")))
{
Utility.MoveFile(pxePath + fileName + ".custom", pxeFile);
doNotRemove.Add(pxeFile);
}
if (File.Exists((pxePath + fileName + ".ipxe.custom")))
{
Utility.MoveFile(pxePath + fileName + ".ipxe.custom", pxeFile);
doNotRemove.Add(pxeFile);
}
}
else
if (!doNotRemove.Contains(pxeFile))
File.Delete(pxeFile);
}
}
Utility.Message = "Deleted All PXE Files<br>";
}
catch (Exception ex)
{
Logger.Log(ex.ToString());
Utility.Message += "Could Not Delete PXE Files<br>";
}
counter++;
}
try
{
using (NpgsqlConnection conn = new NpgsqlConnection(Utility.DBString))
{
NpgsqlCommand cmd = new NpgsqlCommand("tasks_cancelall", conn);
cmd.CommandType = CommandType.StoredProcedure;
conn.Open();
cmd.ExecuteNonQuery();
}
Utility.Message += "Deleted All Tasks From Database<br>";
}
catch (Exception ex)
{
Logger.Log(ex.ToString());
Utility.Message += "Could Not Delete All Tasks From Database<br>";
}
if (Environment.OSVersion.ToString().Contains("Unix"))
{
for (int x = 1; x < 10; x++)
{
try
{
Process killProc = null;
ProcessStartInfo killProcInfo = new ProcessStartInfo();
killProcInfo.FileName = ("killall");
killProcInfo.Arguments = (" udp-sender udp-receiver");
killProc = Process.Start(killProcInfo);
}
catch
{
}
Thread.Sleep(200);
}
}
else
{
for (int x = 1; x < 10; x++)
{
foreach (Process p in System.Diagnostics.Process.GetProcessesByName("udp-sender"))
{
try
//.........这里部分代码省略.........
示例3: CreatePxeBoot
public bool CreatePxeBoot(Unicast unicast, string direction, string isMulticast, string taskID, int hostID)
{
Utility settings = new Utility();
Task task = new Task();
string pxeHostMac = task.MacToPXE(unicast.HostMac);
string proxyDHCP = settings.GetSettings("Proxy Dhcp");
string biosFile = settings.GetSettings("Proxy Bios File");
string efi32File = settings.GetSettings("Proxy Efi32 File");
string efi64File = settings.GetSettings("Proxy Efi64 File");
string biosPath = null;
string efi32Path = null;
string efi64Path = null;
string biosPathipxe = null;
string efi32Pathipxe = null;
string efi64Pathipxe = null;
string path = null;
string[] lines = null;
string wds_key = null;
if (settings.GetSettings("Server Key Mode") == "Automated")
wds_key = settings.GetSettings("Server Key");
else
wds_key = "";
string mode = settings.GetSettings("PXE Mode");
if (proxyDHCP == "Yes")
{
biosPathipxe = settings.GetSettings("Tftp Path") + "proxy" + Path.DirectorySeparatorChar + "bios" + Path.DirectorySeparatorChar + "pxelinux.cfg" + Path.DirectorySeparatorChar + pxeHostMac + ".ipxe";
string[] biosLinesipxe = {@"#!ipxe",
@"kernel " + "http://"+ settings.GetServerIP() +"/cruciblewds/data/boot/kernels/" + unicast.HostKernel + ".krn" + " initrd=" + unicast.HostBootImage + " root=/dev/ram0 rw ramdisk_size=127000 ip=dhcp imgDirection=" + direction + " consoleblank=0" + " web=" + settings.GetSettings("Web Path") + " WDS_KEY=" + wds_key + " " + settings.GetSettings("Global Host Args") + " " + unicast.HostArguments,
@"imgfetch " + "http://"+ settings.GetServerIP() +"/cruciblewds/data/boot/images/" + unicast.HostBootImage ,
@"boot"};
biosPath = settings.GetSettings("Tftp Path") + "proxy" + Path.DirectorySeparatorChar + "bios" + Path.DirectorySeparatorChar + "pxelinux.cfg" + Path.DirectorySeparatorChar + pxeHostMac;
string[] biosLines = { @"DEFAULT cruciblewds",
@"LABEL cruciblewds", @"KERNEL kernels" + Path.DirectorySeparatorChar + unicast.HostKernel ,
@"APPEND initrd=images" + Path.DirectorySeparatorChar + unicast.HostBootImage + " root=/dev/ram0 rw ramdisk_size=127000 ip=dhcp imgDirection=" + direction + " consoleblank=0" + " web=" + settings.GetSettings("Web Path") + " WDS_KEY=" + wds_key + " " + settings.GetSettings("Global Host Args") + " " + unicast.HostArguments};
efi32Pathipxe = settings.GetSettings("Tftp Path") + "proxy" + Path.DirectorySeparatorChar + "efi32" + Path.DirectorySeparatorChar + "pxelinux.cfg" + Path.DirectorySeparatorChar + pxeHostMac + ".ipxe";
string[] efi32Linesipxe = {@"#!ipxe",
@"kernel " + "http://"+ settings.GetServerIP() +"/cruciblewds/data/boot/kernels/" + unicast.HostKernel + ".krn" + " initrd=" + unicast.HostBootImage + " root=/dev/ram0 rw ramdisk_size=127000 ip=dhcp imgDirection=" + direction + " consoleblank=0" + " web=" + settings.GetSettings("Web Path") + " WDS_KEY=" + wds_key + " " + settings.GetSettings("Global Host Args") + " " + unicast.HostArguments,
@"imgfetch " + "http://"+ settings.GetServerIP() +"/cruciblewds/data/boot/images/" + unicast.HostBootImage ,
@"boot"};
efi32Path = settings.GetSettings("Tftp Path") + "proxy" + Path.DirectorySeparatorChar + "efi32" + Path.DirectorySeparatorChar + "pxelinux.cfg" + Path.DirectorySeparatorChar + pxeHostMac;
string[] efi32Lines = { @"DEFAULT cruciblewds",
@"LABEL cruciblewds", @"KERNEL kernels" + Path.DirectorySeparatorChar + unicast.HostKernel ,
@"APPEND initrd=images" + Path.DirectorySeparatorChar + unicast.HostBootImage + " root=/dev/ram0 rw ramdisk_size=127000 ip=dhcp imgDirection=" + direction + " consoleblank=0" + " web=" + settings.GetSettings("Web Path") + " WDS_KEY=" + wds_key + " " + settings.GetSettings("Global Host Args") + " " + unicast.HostArguments};
efi64Pathipxe = settings.GetSettings("Tftp Path") + "proxy" + Path.DirectorySeparatorChar + "efi64" + Path.DirectorySeparatorChar + "pxelinux.cfg" + Path.DirectorySeparatorChar + pxeHostMac + ".ipxe";
string[] efi64Linesipxe = {@"#!ipxe",
@"kernel " + "http://"+ settings.GetServerIP() +"/cruciblewds/data/boot/kernels/" + unicast.HostKernel + ".krn" + " initrd=" + unicast.HostBootImage + " root=/dev/ram0 rw ramdisk_size=127000 ip=dhcp imgDirection=" + direction + " consoleblank=0" + " web=" + settings.GetSettings("Web Path") + " WDS_KEY=" + wds_key + " " + settings.GetSettings("Global Host Args") + " " + unicast.HostArguments,
@"imgfetch " + "http://"+ settings.GetServerIP() +"/cruciblewds/data/boot/images/" + unicast.HostBootImage ,
@"boot"};
efi64Path = settings.GetSettings("Tftp Path") + "proxy" + Path.DirectorySeparatorChar + "efi64" + Path.DirectorySeparatorChar + "pxelinux.cfg" + Path.DirectorySeparatorChar + pxeHostMac;
string[] efi64Lines = { @"DEFAULT cruciblewds",
@"LABEL cruciblewds", @"KERNEL kernels" + Path.DirectorySeparatorChar + unicast.HostKernel ,
@"APPEND initrd=images" + Path.DirectorySeparatorChar + unicast.HostBootImage + " root=/dev/ram0 rw ramdisk_size=127000 ip=dhcp imgDirection=" + direction + " consoleblank=0" + " web=" + settings.GetSettings("Web Path") + " WDS_KEY=" + wds_key + " " + settings.GetSettings("Global Host Args") + " " + unicast.HostArguments};
if (File.Exists(biosPath))
{
Host hostFunction = new Host();
if (hostFunction.IsCustomBootEnabled(Task.PXEMacToMac(pxeHostMac)))
{
Utility.MoveFile(biosPath, biosPath + ".custom");
}
else
{
Utility.Message = "The PXE File Already Exists";
return false;
}
}
if (File.Exists(biosPathipxe))
{
Host hostFunction = new Host();
if (hostFunction.IsCustomBootEnabled(Task.PXEMacToMac(pxeHostMac)))
{
Utility.MoveFile(settings.GetSettings("Tftp Path") + "proxy" + Path.DirectorySeparatorChar + "bios" + Path.DirectorySeparatorChar + "pxelinux.cfg" + Path.DirectorySeparatorChar + pxeHostMac + ".ipxe", settings.GetSettings("Tftp Path") + "proxy" + Path.DirectorySeparatorChar + "bios" + Path.DirectorySeparatorChar + "pxelinux.cfg" + Path.DirectorySeparatorChar + pxeHostMac + ".ipxe.custom");
}
else
{
Utility.Message = "The PXE File Already Exists";
return false;
}
}
if (File.Exists(efi32Path))
{
Host hostFunction = new Host();
if (hostFunction.IsCustomBootEnabled(Task.PXEMacToMac(pxeHostMac)))
{
Utility.MoveFile(efi32Path, efi32Path + ".custom");
}
else
{
Utility.Message = "The PXE File Already Exists";
return false;
}
//.........这里部分代码省略.........
示例4: CleanPxeBoot
public bool CleanPxeBoot(string pxeHostMac)
{
Utility settings = new Utility();
Host hostFunction = new Host();
string mode = settings.GetSettings("PXE Mode");
bool isCustomBootTemplate = hostFunction.IsCustomBootEnabled(Task.PXEMacToMac(pxeHostMac));
string proxyDHCP = settings.GetSettings("Proxy Dhcp");
string biosFile = settings.GetSettings("Proxy Bios File");
string efi32File = settings.GetSettings("Proxy Efi32 File");
string efi64File = settings.GetSettings("Proxy Efi64 File");
if (proxyDHCP == "Yes")
{
try
{
File.Delete(settings.GetSettings("Tftp Path") + "proxy" + Path.DirectorySeparatorChar + "bios" + Path.DirectorySeparatorChar + "pxelinux.cfg" + Path.DirectorySeparatorChar + pxeHostMac);
if (isCustomBootTemplate)
Utility.MoveFile(settings.GetSettings("Tftp Path") + "proxy" + Path.DirectorySeparatorChar + "bios" + Path.DirectorySeparatorChar + "pxelinux.cfg" + Path.DirectorySeparatorChar + pxeHostMac + ".custom", settings.GetSettings("Tftp Path") + "proxy" + Path.DirectorySeparatorChar + "bios" + Path.DirectorySeparatorChar + "pxelinux.cfg" + Path.DirectorySeparatorChar + pxeHostMac);
File.Delete(settings.GetSettings("Tftp Path") + "proxy" + Path.DirectorySeparatorChar + "bios" + Path.DirectorySeparatorChar + "pxelinux.cfg" + Path.DirectorySeparatorChar + pxeHostMac + ".ipxe");
if (isCustomBootTemplate)
Utility.MoveFile(settings.GetSettings("Tftp Path") + "proxy" + Path.DirectorySeparatorChar + "bios" + Path.DirectorySeparatorChar + "pxelinux.cfg" + Path.DirectorySeparatorChar + pxeHostMac + ".ipxe.custom", settings.GetSettings("Tftp Path") + "proxy" + Path.DirectorySeparatorChar + "bios" + Path.DirectorySeparatorChar + "pxelinux.cfg" + Path.DirectorySeparatorChar + pxeHostMac + ".ipxe");
File.Delete(settings.GetSettings("Tftp Path") + "proxy" + Path.DirectorySeparatorChar + "efi32" + Path.DirectorySeparatorChar + "pxelinux.cfg" + Path.DirectorySeparatorChar + pxeHostMac);
if (isCustomBootTemplate)
Utility.MoveFile(settings.GetSettings("Tftp Path") + "proxy" + Path.DirectorySeparatorChar + "efi32" + Path.DirectorySeparatorChar + "pxelinux.cfg" + Path.DirectorySeparatorChar + pxeHostMac + ".custom", settings.GetSettings("Tftp Path") + "proxy" + Path.DirectorySeparatorChar + "efi32" + Path.DirectorySeparatorChar + "pxelinux.cfg" + Path.DirectorySeparatorChar + pxeHostMac);
File.Delete(settings.GetSettings("Tftp Path") + "proxy" + Path.DirectorySeparatorChar + "efi32" + Path.DirectorySeparatorChar + "pxelinux.cfg" + Path.DirectorySeparatorChar + pxeHostMac + ".ipxe");
if (isCustomBootTemplate)
Utility.MoveFile(settings.GetSettings("Tftp Path") + "proxy" + Path.DirectorySeparatorChar + "efi32" + Path.DirectorySeparatorChar + "pxelinux.cfg" + Path.DirectorySeparatorChar + pxeHostMac + ".ipxe.custom", settings.GetSettings("Tftp Path") + "proxy" + Path.DirectorySeparatorChar + "efi32" + Path.DirectorySeparatorChar + "pxelinux.cfg" + Path.DirectorySeparatorChar + pxeHostMac + ".ipxe");
File.Delete(settings.GetSettings("Tftp Path") + "proxy" + Path.DirectorySeparatorChar + "efi64" + Path.DirectorySeparatorChar + "pxelinux.cfg" + Path.DirectorySeparatorChar + pxeHostMac);
if (isCustomBootTemplate)
Utility.MoveFile(settings.GetSettings("Tftp Path") + "proxy" + Path.DirectorySeparatorChar + "efi64" + Path.DirectorySeparatorChar + "pxelinux.cfg" + Path.DirectorySeparatorChar + pxeHostMac + ".custom", settings.GetSettings("Tftp Path") + "proxy" + Path.DirectorySeparatorChar + "efi64" + Path.DirectorySeparatorChar + "pxelinux.cfg" + Path.DirectorySeparatorChar + pxeHostMac);
File.Delete(settings.GetSettings("Tftp Path") + "proxy" + Path.DirectorySeparatorChar + "efi64" + Path.DirectorySeparatorChar + "pxelinux.cfg" + Path.DirectorySeparatorChar + pxeHostMac + ".ipxe");
if (isCustomBootTemplate)
Utility.MoveFile(settings.GetSettings("Tftp Path") + "proxy" + Path.DirectorySeparatorChar + "efi64" + Path.DirectorySeparatorChar + "pxelinux.cfg" + Path.DirectorySeparatorChar + pxeHostMac + ".ipxe.custom", settings.GetSettings("Tftp Path") + "proxy" + Path.DirectorySeparatorChar + "efi64" + Path.DirectorySeparatorChar + "pxelinux.cfg" + Path.DirectorySeparatorChar + pxeHostMac + ".ipxe");
return true;
}
catch (Exception ex)
{
Logger.Log(ex.ToString());
Utility.Message = "Could Not Delete PXE File";
return false;
}
}
else
{
try
{
if (mode.Contains("ipxe"))
{
File.Delete(settings.GetSettings("Tftp Path") + "pxelinux.cfg" + Path.DirectorySeparatorChar + pxeHostMac + ".ipxe");
if (isCustomBootTemplate)
Utility.MoveFile(settings.GetSettings("Tftp Path") + "pxelinux.cfg" + Path.DirectorySeparatorChar + pxeHostMac + ".ipxe.custom", settings.GetSettings("Tftp Path") + "pxelinux.cfg" + Path.DirectorySeparatorChar + pxeHostMac + ".ipxe");
}
else
{
File.Delete(settings.GetSettings("Tftp Path") + "pxelinux.cfg" + Path.DirectorySeparatorChar + pxeHostMac);
if (isCustomBootTemplate)
Utility.MoveFile(settings.GetSettings("Tftp Path") + "pxelinux.cfg" + Path.DirectorySeparatorChar + pxeHostMac + ".custom", settings.GetSettings("Tftp Path") + "pxelinux.cfg" + Path.DirectorySeparatorChar + pxeHostMac);
}
return true;
}
catch (Exception ex)
{
Logger.Log(ex.ToString());
Utility.Message = "Could Not Delete PXE File";
return false;
}
}
}