Exemplo n.º 1
0
        public IActionResult VerifyUploadedTemplate([FromForm] Dictionary <string, string> dict, [FromForm] String templateName)
        {
            templateName = templateName + ".yml";

            String tempPath           = Path.Combine(Program.ComposeTemporaryDir, templateName);
            String fileString         = System.IO.File.ReadAllText(tempPath);
            String writeStatus        = "";
            string finalComposeString = ComposerNew.ReplaceParams(fileString, dict);
            var    filename           = ComposeFileOperationsNew.WriteFileToReadyFolder(finalComposeString, templateName, "test");

            bool verificationResult = false;

            if (filename != "ERR_UNABLE_TO_WRITE_TO_FILE")
            {
                verificationResult = ComposerNew.VerifyContainer(filename);
            }



            if (!verificationResult)
            {
                ComposeFileOperationsNew.RemoveFileFromReadyFolder(filename);
                ComposeFileOperationsNew.RemoveFromReadyList(filename);
                return(View("ErrorPage"));
            }
            else
            {
                ComposeFileOperationsNew.AddToTemplatesFromFile(Path.Combine(Program.ComposeTemporaryDir, templateName), templateName, out writeStatus);
                return(View("SuccessPage"));
            }
        }
Exemplo n.º 2
0
        public IActionResult StartComposeReady()
        {
            //ComposerNew.InitializeLists();
            var composite = ComposerNew.GetSingleCompositeDetail("compose-destination.yml", false);

            return(Ok(composite));
        }
Exemplo n.º 3
0
        public IActionResult ReadyFileDetails([FromQuery] String cName)
        {
            ViewData["cFileName"] = cName;
            CompositeModel composeFileDetails = ComposerNew.GetSingleCompositeDetail(cName, false);

            //String basePath = Path.Combine(Directory.GetCurrentDirectory(), "data/templates/" + cName);
            //String contents = System.IO.File.ReadAllText(basePath);
            return(View(composeFileDetails));
        }
Exemplo n.º 4
0
        //[Route("{cName}")]
        public IActionResult TemplateDetails([FromQuery] String cName)
        {
            ViewData["cFileName"] = cName;
            CompositeModel composeFileDetails = ComposerNew.GetSingleCompositeDetail(cName, true);
            String         basePath           = Path.Combine(Program.ComposeTemplateDir, cName);
            String         contents           = System.IO.File.ReadAllText(basePath);

            String[] parameters = ComposerNew.ExtractParameters(contents);

            ViewData["params"] = parameters;
            return(View(composeFileDetails));
        }
Exemplo n.º 5
0
        public IActionResult CreateCustom([FromForm] Dictionary <string, string> dict, [FromForm] String templateName, [FromForm] String instanceName)
        {
            String tempPath   = Path.Combine(Directory.GetCurrentDirectory(), @"data\templates\" + templateName);
            String fileString = System.IO.File.ReadAllText(tempPath);

            string finalComposeString = ComposerNew.ReplaceParams(fileString, dict);
            var    filename           = ComposeFileOperationsNew.WriteFileToReadyFolder(finalComposeString, templateName, instanceName);

            ComposerNew.StartService(filename);


            return(View("RunComposeFile"));
        }
Exemplo n.º 6
0
        public IActionResult DebugStop([FromQuery] string FileName)
        {
            try
            {
                string result = ComposerNew.StopService(FileName);
                return(Ok(result));
            }
            catch (Exception e)
            {
                Program.logger.Error("ERR_NO_SUCH_RUNNING_COMPOSE_FILE_FOUND: " + FileName);
                Program.logger.Error(e.Message);

                return(NotFound("ERR_NO_SUCH_RUNNING_COMPOSE_FILE_FOUND: " + FileName));
            }
        }
Exemplo n.º 7
0
        public IActionResult RunComposeFile([FromQuery] string cName)
        {
            try
            {
                string result = ComposerNew.StartService(cName);
                ViewData["status"] = result;
                return(View());
            }
            catch (Exception e)
            {
                Program.logger.Error("ERR_NO_SUCH_COMPOSE_FILE_FOUND: " + cName);
                Program.logger.Error(e.Message);

                return(NotFound("ERR_NO_SUCH_COMPOSE_FILE_FOUND: " + cName));
            }
        }
Exemplo n.º 8
0
        public IActionResult StopRunningFile([FromQuery] String FileName)
        {
            try
            {
                string result      = ComposerNew.StopService(FileName);
                var    RunningList = ComposerNew.GetRunningServices();
                return(View("RunningReadyFiles", RunningList));
            }
            catch (Exception e)
            {
                Program.logger.Error("ERR_NO_SUCH_RUNNING_COMPOSE_FILE_FOUND: " + FileName);
                Program.logger.Error(e.Message);

                return(NotFound("ERR_NO_SUCH_RUNNING_COMPOSE_FILE_FOUND: " + FileName));
            }
        }
Exemplo n.º 9
0
        public async Task <IActionResult> UploadFiles(IEnumerable <IFormFile> file, IFormCollection form)
        {
            //full path to file in temp location
            //var filePath = Path.GetTempFileName();

            //foreach (var formFile in file)
            //{
            //    if (formFile.Length > 0)
            //    {
            //        using (var stream = new FileStream(filePath, FileMode.Create))
            //        {
            //            await formFile.CopyToAsync(stream);
            //        }
            //    }
            //}
            String filePath = await ComposerNew.FilePathAsync(file);

            StringValues filename, cFileName;
            bool         result   = false;
            string       contents = System.IO.File.ReadAllText(filePath);

            form.TryGetValue("destFileName", out filename);
            form.TryGetValue("file", out cFileName);
            String[] parameters = ComposerNew.ExtractParameters(contents, out result);

            if (result == false)
            {
                return(View("AddParameters"));
            }

            try
            {
                System.IO.File.WriteAllText(Path.Combine(Program.ComposeTemporaryDir, filename + ".yml"), contents);
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.Message);
            }
            ViewData["fileString"] = contents;
            ViewData["FileName"]   = filename;
            //ViewData["templateName"] = cFileName;
            return(View("AddParameters", parameters));
        }
Exemplo n.º 10
0
 public IActionResult DebugListRunning([FromQuery] string FileName)
 {
     return(Ok(ComposerNew.GetRunningServices()));
 }
Exemplo n.º 11
0
        public IActionResult RunningReadyFiles()
        {
            var RunningList = ComposerNew.GetRunningServices();

            return(View(RunningList));
        }