BuildTasksFromDeploymentTemplate() public method

Gets the deployment tasks for the supplied deployment template.
public BuildTasksFromDeploymentTemplate ( string templateFilePath ) : TaskExecutor
templateFilePath string The template file path.
return TaskExecutor
Ejemplo n.º 1
0
        /// <summary>
        /// Performs the request.
        /// </summary>
        /// <param name="arguments">The arguments.</param>
        /// <returns>The async <see cref="Task"/>.</returns>
        private static async Task PerformRequest(Dictionary<string, string> arguments)
        {
            try
            {
                var accountDetails = await CaasAuthentication.Authenticate(
                    arguments["username"],
                    arguments["password"],
                    arguments["region"]);

                var runtimeContext = new RuntimeContext
                {
                    AccountDetails = accountDetails,
                    LogProvider = new ConsoleLogProvider()
                };

                var taskBuilder = new TaskBuilder();

                if (arguments["action"].ToLower() == "deploy")
                {
                    var parametersFile = arguments.ContainsKey("parameters") ? arguments["parameters"] : null;
                    var templateFile = arguments["template"];

                    var taskExecutor = taskBuilder.BuildTasksFromDeploymentTemplate(templateFile, parametersFile);
                    var log = await taskExecutor.Execute(runtimeContext);

                    Console.WriteLine($"Result: {log.Status}");

                    log.SaveToFile(arguments["deploymentlog"]);
                    Console.WriteLine($"Complete! Deployment log written to {arguments["deploymentlog"]}.");

                    if (taskExecutor.Context.OutputParameters != null)
                    {
                        Console.WriteLine("OUTPUT PARAMETERS:");

                        foreach (var param in taskExecutor.Context.OutputParameters)
                        {
                            Console.WriteLine($"{param.Key}: {param.Value}");
                        }
                    }
                }
                else if (arguments["action"].ToLower() == "delete")
                {
                    var deploymentLogFile = arguments["deploymentlog"];

                    var taskExecutor = taskBuilder.BuildTasksFromDeploymentLog(deploymentLogFile);
                    var log = await taskExecutor.Execute(runtimeContext);

                    Console.WriteLine($"Result: {log.Status}");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Begins the processing asynchronously.
        /// </summary>
        /// <returns>The async <see cref="Task"/>.</returns>
        private async Task BeginProcessingAsync()
        {
            var runtimeContext = new RuntimeContext
            {
                AccountDetails = await CaasAuthentication.Authenticate(UserName, Password, Region),
                LogProvider = new ConsoleLogProvider()
            };

            var taskBuilder = new TaskBuilder();
            var taskExecutor = taskBuilder.BuildTasksFromDeploymentTemplate(ResolvePath(Template), ResolvePath(Parameters));
            var log = await taskExecutor.Execute(runtimeContext);

            Console.WriteLine($"Result: {log.Status}");
            WriteLog(log, ResolvePath(DeploymentLog));
            Console.WriteLine($"Complete! Deployment log written to {DeploymentLog}.");

            if (taskExecutor.Context.OutputParameters != null)
            {
                Console.WriteLine("OUTPUT PARAMETERS:");

                foreach (var param in taskExecutor.Context.OutputParameters)
                {
                    Console.WriteLine($"{param.Key}: {param.Value}");
                }
            }
        }