public byte [] RunAllServers(DtoIsoGenOptions isoOptions) { var uow = new UnitOfWork(); var tftpComServers = uow.ClientComServerRepository.Get(x => x.IsTftpServer); EntityClientComServer tftpInfoServer; if (tftpComServers.Count == 0) { Logger.Error("No Tftp Servers Are Currently Enabled To Generate ISO"); return(null); } if (tftpComServers.Count > 1) { tftpInfoServer = tftpComServers.Where(x => x.IsTftpInfoServer).FirstOrDefault(); if (tftpInfoServer == null) { Logger.Error("No Tftp Servers Are Currently Set As The Information Server. Unable To Generate ISO"); return(null); } } else { tftpInfoServer = tftpComServers.First(); } //Connect To Client Com Server var intercomKey = ServiceSetting.GetSettingValue(SettingStrings.IntercomKeyEncrypted); var decryptedKey = new EncryptionServices().DecryptText(intercomKey); var result = new APICall().ClientComServerApi.GenerateISO(tftpInfoServer.Url, "", decryptedKey, isoOptions); return(result); }
public byte[] GenerateIso(DtoIsoGenOptions isoOptions) { Request.Method = Method.POST; Request.Resource = string.Format("{0}/GenerateISO/", Resource); Request.AddJsonBody(isoOptions); return(_apiRequest.ExecuteRaw(Request)); }
public byte[] GenerateISO(string url, string serverName, string interComKey, DtoIsoGenOptions isoOptions) { Request.Method = Method.POST; Request.AddJsonBody(isoOptions); Request.Resource = string.Format("Imaging/GenerateISO"); return(new ApiRequest(new Uri(url)).ExecuteRaw(Request)); }
public HttpResponseMessage GenerateISO(DtoIsoGenOptions isoOptions) { var iso = new IsoGenerator().Create(isoOptions); var dataStream = new MemoryStream(iso); var result = new HttpResponseMessage(HttpStatusCode.OK); result.Content = new StreamContent(dataStream); result.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment"); result.Content.Headers.ContentDisposition.FileName = "clientboot.iso"; result.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream"); result.Content.Headers.ContentLength = dataStream.Length; return(result); }
protected void buttonUpdate_Click(object sender, EventArgs e) { var isoGenOptions = new DtoIsoGenOptions(); isoGenOptions.bootImage = ddlBootImage.Text; isoGenOptions.kernel = ddlKernel.Text; isoGenOptions.arguments = txtKernelArgs.Text; isoGenOptions.clusterId = Convert.ToInt32(ddlCluster.SelectedValue); isoGenOptions.useSecureBoot = chkSecureBoot.Checked; var clientboot = Call.SettingApi.GenerateIso(isoGenOptions); Response.Clear(); var ms = new MemoryStream(clientboot); Response.ContentType = "application/iso"; Response.AddHeader("content-disposition", "attachment;filename=clientboot.iso"); Response.Buffer = true; ms.WriteTo(Response.OutputStream); Response.End(); }
public byte[] Create(DtoIsoGenOptions isoOptions) { var uow = new UnitOfWork(); _isoOptions = isoOptions; var mode = ServiceSetting.GetSettingValue(SettingStrings.PxeBootloader); var imageServers = new List <DtoClientComServers>(); var defaultCluster = uow.ComServerClusterRepository.GetFirstOrDefault(x => x.IsDefault); if (isoOptions.clusterId == -1) { imageServers = uow.ComServerClusterServerRepository.GetImagingClusterServers(defaultCluster.Id); } else { imageServers = uow.ComServerClusterServerRepository.GetImagingClusterServers(isoOptions.clusterId); } if (imageServers == null) { Logger.Error($"No Image Servers Found For This Cluster"); return(null); } if (imageServers.Count == 0) { Logger.Error($"No Image Servers Found For This Cluster"); return(null); } var guid = ConfigurationManager.AppSettings["ComServerUniqueId"]; _thisComServer = new ServiceClientComServer().GetServerByGuid(guid); if (_thisComServer == null) { Logger.Error($"Com Server With Guid {guid} Not Found"); return(null); } var webRequiresLogin = ServiceSetting.GetSettingValue(SettingStrings.WebTasksRequireLogin); var consoleRequiresLogin = ServiceSetting.GetSettingValue(SettingStrings.ConsoleTasksRequireLogin); var globalToken = ServiceSetting.GetSettingValue(SettingStrings.GlobalImagingToken); if (webRequiresLogin.Equals("False") || consoleRequiresLogin.Equals("False")) { _userToken = globalToken; } else { _userToken = ""; } _globalComputerArgs = ServiceSetting.GetSettingValue(SettingStrings.GlobalImagingArguments); _webPath = "\""; foreach (var imageServer in imageServers) { var url = new ServiceClientComServer().GetServer(imageServer.ComServerId).Url; _webPath += url + "clientimaging/ "; //adds a space delimiter } _webPath = _webPath.Trim(' '); _webPath += "\""; _basePath = HttpContext.Current.Server.MapPath("~") + "private" + Path.DirectorySeparatorChar; _rootfsPath = _basePath + "client_iso" + Path.DirectorySeparatorChar + "rootfs" + Path.DirectorySeparatorChar; if (isoOptions.useSecureBoot) { _grubPath = _basePath + "client_iso" + Path.DirectorySeparatorChar + "grub_binaries" + Path.DirectorySeparatorChar + "signed" + Path.DirectorySeparatorChar; } else { _grubPath = _basePath + "client_iso" + Path.DirectorySeparatorChar + "grub_binaries" + Path.DirectorySeparatorChar + "unsigned" + Path.DirectorySeparatorChar; } _buildPath = _basePath + "client_iso" + Path.DirectorySeparatorChar + "build-tmp"; _outputPath = _basePath + "client_iso" + Path.DirectorySeparatorChar; _configOutPath = _basePath + "client_iso" + Path.DirectorySeparatorChar + "config" + Path.DirectorySeparatorChar; Generate(); var file = File.ReadAllBytes(_basePath + "client_iso" + Path.DirectorySeparatorChar + "clientboot.iso"); return(file); }