Exemplo n.º 1
0
        private void Execute(SkytapClient client, SkytapResource template)
        {
            if (string.IsNullOrWhiteSpace(this.ConfigurationName))
            {
                this.LogInformation("Creating environment from {1} template...", template.Name);
            }
            else
            {
                this.LogInformation("Creating {0} environment from {1} template...", this.ConfigurationName, template.Name);
            }

            string configurationId;

            try
            {
                configurationId = client.CreateConfiguration(template.Id);
            }
            catch (WebException ex)
            {
                this.LogError("The environment could not be created: " + ex.Message);
                return;
            }

            this.LogDebug("Environment created (ID={0})", configurationId);

            if (!string.IsNullOrWhiteSpace(this.ConfigurationName))
            {
                this.LogDebug("Setting environment name to {0}...", this.ConfigurationName);
                client.RenameConfiguration(configurationId, this.ConfigurationName);
                this.LogDebug("Environment renamed.");
            }

            if (this.ExportVariables)
            {
                this.SetSkytapVariableValue("EnvironmentId", configurationId);
            }

            this.LogInformation("Environment created.");
        }