예제 #1
0
        public HttpResponseMessage GenerateLinuxIsoConfig(IsoGenOptionsDTO isoOptions)
        {
            new IsoGen(isoOptions).Generate();
            var basePath = HttpContext.Current.Server.MapPath("~") + Path.DirectorySeparatorChar + "private" +
                           Path.DirectorySeparatorChar + "client_iso" + Path.DirectorySeparatorChar;

            if (isoOptions.buildType == "ISO")
            {
                basePath += "clientboot.iso";
            }
            else
            {
                basePath += "clientboot.zip";
            }

            var result = new HttpResponseMessage(HttpStatusCode.OK);
            var stream = new FileStream(basePath, FileMode.Open);

            result.Content = new StreamContent(stream);
            result.Content.Headers.ContentDisposition          = new ContentDispositionHeaderValue("attachment");
            result.Content.Headers.ContentDisposition.FileName = Path.GetFileName(basePath);
            result.Content.Headers.ContentType   = new MediaTypeHeaderValue("application/octet-stream");
            result.Content.Headers.ContentLength = stream.Length;
            return(result);
        }
예제 #2
0
        public IsoGen(IsoGenOptionsDTO isoGenOptions)
        {
            _isoOptions = isoGenOptions;
            if (SettingServices.GetSettingValue(SettingStrings.DebugRequiresLogin) == "No" ||
                SettingServices.GetSettingValue(SettingStrings.OnDemandRequiresLogin) == "No" ||
                SettingServices.GetSettingValue(SettingStrings.RegisterRequiresLogin) == "No" ||
                SettingServices.GetSettingValue(SettingStrings.ClobberRequiresLogin) == "No")
            {
                _userToken = SettingServices.GetSettingValue(SettingStrings.UniversalToken);
            }
            else
            {
                _userToken = "";
            }
            _basePath = HttpContext.Current.Server.MapPath("~") + Path.DirectorySeparatorChar + "private" +
                        Path.DirectorySeparatorChar;
            _rootfsPath = _basePath + "client_iso" + Path.DirectorySeparatorChar + "rootfs" +
                          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;
            _registration = SettingServices.GetSettingValue(SettingStrings.RegistrationEnabled) == "No" ? " skip_registration=true " : string.Empty;

            if (SettingServices.GetSettingValue(SettingStrings.ClobberEnabled) == "1")
            {
                _isClobber      = true;
                _namePromptArg  = SettingServices.GetSettingValue(SettingStrings.ClobberPromptComputerName) == "1" ? " name_prompt=true" : string.Empty;
                _imageProfileId = Convert.ToInt32(SettingServices.GetSettingValue(SettingStrings.ClobberProfileId));
            }
        }
예제 #3
0
        protected void btnGenerate_OnClick(object sender, EventArgs e)
        {
            var isoGenOptions = new IsoGenOptionsDTO();

            isoGenOptions.bootImage = ddlBootImage.Text;
            isoGenOptions.buildType = ddlBuildType.Text;
            isoGenOptions.kernel    = ddlKernel.Text;
            isoGenOptions.arguments = txtKernelArgs.Text;

            var clientboot = Call.WorkflowApi.GenerateLinuxIsoConfig(isoGenOptions);

            Response.Clear();
            var ms = new MemoryStream(clientboot);

            if (ddlBuildType.Text == "ISO")
            {
                Response.ContentType = "application/iso";
                Response.AddHeader("content-disposition", "attachment;filename=clientboot.iso");
            }
            else
            {
                Response.ContentType = "application/zip";
                Response.AddHeader("content-disposition", "attachment;filename=clientboot.zip");
            }

            Response.Buffer = true;
            ms.WriteTo(Response.OutputStream);
            Response.End();
        }
예제 #4
0
 public byte[] GenerateLinuxIsoConfig(IsoGenOptionsDTO isoOptions)
 {
     Request.Method   = Method.POST;
     Request.Resource = string.Format("api/{0}/GenerateLinuxIsoConfig/", Resource);
     Request.AddJsonBody(isoOptions);
     return(_apiRequest.ExecuteRaw(Request));
 }
예제 #5
0
 public IsoGen(IsoGenOptionsDTO isoGenOptions)
 {
     _isoOptions = isoGenOptions;
     if (SettingServices.GetSettingValue(SettingStrings.DebugRequiresLogin) == "No" ||
         SettingServices.GetSettingValue(SettingStrings.OnDemandRequiresLogin) == "No" ||
         SettingServices.GetSettingValue(SettingStrings.RegisterRequiresLogin) == "No")
     {
         _userToken = SettingServices.GetSettingValue(SettingStrings.UniversalToken);
     }
     else
     {
         _userToken = "";
     }
     _basePath = HttpContext.Current.Server.MapPath("~") + Path.DirectorySeparatorChar + "private" +
                 Path.DirectorySeparatorChar;
     _rootfsPath = _basePath + "client_iso" + Path.DirectorySeparatorChar + "rootfs" +
                   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;
 }