本文整理汇总了C#中Utility.GetServerIP方法的典型用法代码示例。如果您正苦于以下问题:C# Utility.GetServerIP方法的具体用法?C# Utility.GetServerIP怎么用?C# Utility.GetServerIP使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Utility
的用法示例。
在下文中一共展示了Utility.GetServerIP方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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;
}
//.........这里部分代码省略.........
示例2: ipxelogin
public void ipxelogin()
{
History history = new History();
Utility settings = new Utility();
HttpContext postedContext = HttpContext.Current;
HttpFileCollection Files = postedContext.Request.Files;
string username = (string)postedContext.Request.Form["uname"];
string password = (string)postedContext.Request.Form["pwd"];
string kernel = (string)postedContext.Request.Form["kernel"];
string bootImage = (string)postedContext.Request.Form["bootImage"];
string task = (string)postedContext.Request.Form["task"];
string wds_key = null;
if (settings.GetSettings("Server Key Mode") == "Automated")
wds_key = settings.GetSettings("Server Key");
else
wds_key = "";
string globalHostArgs = settings.GetSettings("Global Host Args");
if (settings.UserLogin(username, password))
{
string lines;
lines = "#!ipxe\r\n";
lines += "kernel " + "http://" + settings.GetServerIP() + "/cruciblewds/data/boot/kernels/" + kernel + ".krn" + " initrd=" + bootImage + " root=/dev/ram0 rw ramdisk_size=127000 ip=dhcp " + " web=" + settings.GetSettings("Web Path") + " WDS_KEY=" + wds_key + " task=" + task + " consoleblank=0 " + globalHostArgs + "\r\n";
lines += "imgfetch " + "http://" + settings.GetServerIP() + "/cruciblewds/data/boot/images/" + bootImage + "\r\n";
lines += "boot";
HttpContext.Current.Response.Write(lines);
history.Event = "Successful Login";
history.Type = "iPXE";
history.EventUser = username;
history.Notes = " Task: " + task;
history.CreateEvent(history);
}
else
{
HttpContext.Current.Response.End();
history.Event = "Failed Login";
history.Type = "iPXE";
history.EventUser = username;
history.Notes = "Password: " + password + " Task: " + task;
history.CreateEvent(history);
}
}
示例3: CreateIpxeMenu
private void CreateIpxeMenu(Settings bootMenu, string kernel, string bootImage, string type)
{
Utility settings = new Utility();
string ipAddress = settings.GetSettings("Server IP");
string webPath = settings.GetSettings("Web Path");
string globalHostArgs = settings.GetSettings("Global Host Args");
string wds_key = null;
if (settings.GetSettings("Server Key Mode") == "Automated")
wds_key = settings.GetSettings("Server Key");
else
wds_key = "";
string path = null;
string lines = null;
lines = "#!ipxe\r\n";
lines += "chain 01-${net0/mac:hexhyp}.ipxe || goto Menu\r\n";
lines += "\r\n";
lines += ":Menu\r\n";
lines += "menu Boot Menu\r\n";
lines += "item boot Boot To Local Machine\r\n";
lines += "item console Client Console\r\n";
lines += "item addhost Add Host\r\n";
lines += "item ond On Demand\r\n";
lines += "item diag Diagnostics\r\n";
lines += "choose --default boot --timeout 5000 target && goto ${target}\r\n";
lines += "\r\n";
lines += ":boot\r\n";
lines += "exit\r\n";
lines += "\r\n";
lines += ":console\r\n";
lines += "set task debug\r\n";
lines += "goto login\r\n";
lines += "\r\n";
lines += ":addhost\r\n";
lines += "set task register\r\n";
lines += "goto login\r\n";
lines += "\r\n";
lines += ":ond\r\n";
lines += "set task ond\r\n";
lines += "goto login\r\n";
lines += "\r\n";
lines += ":diag\r\n";
lines += "set task diag\r\n";
lines += "goto login\r\n";
lines += "\r\n";
lines += ":login\r\n";
lines += "login\r\n";
lines += "params\r\n";
lines += "param uname ${username:uristring}\r\n";
lines += "param pwd ${password:uristring}\r\n";
lines += "param kernel " + kernel + "\r\n";
lines += "param bootImage " + bootImage + "\r\n";
lines += "param task " + "${task}" + "\r\n";
lines += "echo Authenticating\r\n";
lines += "chain --timeout 15000 http://" + settings.GetServerIP() + "/cruciblewds/service/client.asmx/ipxelogin##params || goto Menu\r\n";
if (type == "noprox")
{
path = settings.GetSettings("Tftp Path") + "pxelinux.cfg" + Path.DirectorySeparatorChar + "default.ipxe";
}
else
{
path = settings.GetSettings("Tftp Path") + "proxy" + Path.DirectorySeparatorChar + type + Path.DirectorySeparatorChar + "pxelinux.cfg" + Path.DirectorySeparatorChar + "default.ipxe";
}
try
{
using (StreamWriter file = new StreamWriter(path))
{
file.WriteLine(lines);
file.Close();
Utility.Message = "Successfully Created Default Boot Menu";
}
}
catch (Exception ex)
{
Logger.Log(ex.Message);
Utility.Message = "Could Not Create Boot Menu. Check The Exception Log For More Info.";
return;
}
if (Environment.OSVersion.ToString().Contains("Unix"))
{
Syscall.chmod(path, (FilePermissions.S_IWUSR | FilePermissions.S_IRGRP | FilePermissions.S_IROTH | FilePermissions.S_IRUSR));
}
}