Ejemplo n.º 1
0
        internal static void SerializeToFile(PushProperties ConfigurationParameters, String FilePath)
        {
            Serializer serializer = new Serializer(YamlDotNet.Serialization.SerializationOptions.EmitDefaults, null);

            StringBuilder builder = new StringBuilder();

            using (TextWriter writer = new StringWriter(builder, CultureInfo.InvariantCulture))
            {
                serializer.Serialize(writer, ConfigurationParameters);
            }

            File.WriteAllText(FilePath, builder.ToString());
        }
Ejemplo n.º 2
0
        public bool Execute()
        {
            logger = new Microsoft.Build.Utilities.TaskLoggingHelper(this);
            logger.LogMessage("Saving configuration to {0}", CFConfigurationFile);

            PushProperties Configuration = new PushProperties();

            Configuration.AppDir       = CFAppPath;
            Configuration.Applications = new Dictionary <string, AppDetails>();
            Configuration.Applications.Add(CFAppPath, new AppDetails()
            {
                Name = CFAppName, Url = CFRoute
            });
            Configuration.AutoscaleInfo = new Autoscale()
            {
                Cpu = new Cpu()
                {
                    MaxCpu = CFMaxCpu, MinCpu = CFMinCpu
                }, Enabled = CFEnabled != null ? CFEnabled: "no", InstancesInfo = new Instances()
                {
                    MaxInstances = CFMaxInstances != 0 ? CFMaxInstances : 1, MinInstances = CFMinInstances != 0 ? CFMinInstances : 1
                }
            };
            Configuration.Disk          = CFDisk != 0 ? CFDisk : 1024;
            Configuration.Instances     = CFInstancesNumber;
            Configuration.Memory        = CFAppMemory;
            Configuration.Name          = CFAppName;
            Configuration.PlacementZone = CFPlacementZone != null ? CFPlacementZone : "default";
            if (CFServiceName != null)
            {
                Configuration.Services = new Dictionary <string, ServiceDetails>();
                Configuration.Services.Add(CFServiceName, new ServiceDetails()
                {
                    Plan = CFServicePlan, Type = CFServiceType
                });
            }

            Configuration.SsoEnabled = CFSsoEnabled != null ? CFSsoEnabled : "no";
            Configuration.Stack      = CFStack;

            Utils.SerializeToFile(Configuration, CFConfigurationFile);

            return(true);
        }
Ejemplo n.º 3
0
        public bool Execute()
        {
            logger = new Microsoft.Build.Utilities.TaskLoggingHelper(this);
            logger.LogMessage("Loading configuration from {0}", CFConfigurationFile);
            try
            {
                Configuration = Utils.DeserializeFromFile(CFConfigurationFile);
                CFStack       = Configuration.Stack;
                CFAppName     = Configuration.Name;
                CFAppPath     = Configuration.AppDir;

                List <string> urlList = new List <string>();
                foreach (var app in Configuration.Applications)
                {
                    if (app.Value.Url.Contains(";"))
                    {
                        string[] appurls = app.Value.Url.Split(';');
                        urlList.AddRange(appurls);
                    }
                    else
                    {
                        urlList.Add(app.Value.Url);
                    }
                }
                foreach (string s in urlList)
                {
                    logger.LogMessage("Loaded url {0}", s);
                }

                CFRoutes = string.Join(";", urlList);

                CFAppMemory    = Configuration.Memory;
                CFAppInstances = Configuration.Instances;
                CFAutoscale    = Utils.Serialize <Autoscale>(Configuration.AutoscaleInfo);
                CFDisk         = Configuration.Disk;

                if (Configuration.Services != null)
                {
                    List <ProvisionedService> servicesList = new List <ProvisionedService>();
                    foreach (var service in Configuration.Services)
                    {
                        servicesList.Add(new ProvisionedService()
                        {
                            Name = service.Key, Plan = service.Value.Plan, Type = service.Value.Type
                        });
                    }

                    CFServices = Utils.Serialize <List <ProvisionedService> >(servicesList);
                }
                CFPlacementZone = Configuration.PlacementZone;
                CFSsoEnabled    = Configuration.SsoEnabled;

                logger.LogMessage("Configuration loaded");
            }
            catch (Exception ex)
            {
                logger.LogErrorFromException(ex);
                throw;
            }

            return(true);
        }
Ejemplo n.º 4
0
        public bool Execute()
        {
            logger = new Microsoft.Build.Utilities.TaskLoggingHelper(this);
            logger.LogMessage("Loading configuration from {0}", CFConfigurationFile);
            try
            {
                Configuration = Utils.DeserializeFromFile(CFConfigurationFile);
                CFStack = Configuration.Stack;
                CFAppName = Configuration.Name;
                CFAppPath = Configuration.AppDir;

                List<string> urlList = new List<string>();
                foreach (var app in Configuration.Applications)
                {
                    if (app.Value.Url.Contains(";"))
                    {
                        string[] appurls = app.Value.Url.Split(';');
                        urlList.AddRange(appurls);
                    }
                    else
                    {
                        urlList.Add(app.Value.Url);
                    }
                }
                foreach (string s in urlList)
                {
                    logger.LogMessage("Loaded url {0}", s);
                }

                CFRoutes = string.Join(";",urlList);

                CFAppMemory = Configuration.Memory;
                CFAppInstances = Configuration.Instances;
                CFAutoscale = Utils.Serialize<Autoscale>(Configuration.AutoscaleInfo);
                CFDisk = Configuration.Disk;

                if (Configuration.Services != null)
                {
                    List<ProvisionedService> servicesList = new List<ProvisionedService>();
                    foreach (var service in Configuration.Services)
                    {
                        servicesList.Add(new ProvisionedService() { Name = service.Key, Plan = service.Value.Plan, Type = service.Value.Type });
                    }

                    CFServices = Utils.Serialize<List<ProvisionedService>>(servicesList);
                }
                CFPlacementZone = Configuration.PlacementZone;
                CFSsoEnabled = Configuration.SsoEnabled;

                logger.LogMessage("Configuration loaded");
            }
            catch (Exception ex)
            {
                logger.LogErrorFromException(ex);
                throw;
            }

            return true;
        }
Ejemplo n.º 5
0
        public bool Execute()
        {
            logger = new Microsoft.Build.Utilities.TaskLoggingHelper(this);
            logger.LogMessage("Saving configuration to {0}", CFConfigurationFile);

            PushProperties Configuration = new PushProperties();
            Configuration.AppDir = CFAppPath;
            Configuration.Applications = new Dictionary<string, AppDetails>();
            Configuration.Applications.Add(CFAppPath, new AppDetails() { Name = CFAppName, Url = CFRoute });
            Configuration.AutoscaleInfo = new Autoscale() { Cpu = new Cpu() { MaxCpu = CFMaxCpu, MinCpu = CFMinCpu }, Enabled = CFEnabled !=null ? CFEnabled: "no", InstancesInfo = new Instances() { MaxInstances = CFMaxInstances !=0 ? CFMaxInstances : 1, MinInstances = CFMinInstances != 0 ? CFMinInstances : 1 } };
            Configuration.Disk = CFDisk!=0 ? CFDisk : 1024;
            Configuration.Instances = CFInstancesNumber;
            Configuration.Memory = CFAppMemory;
            Configuration.Name = CFAppName;
            Configuration.PlacementZone = CFPlacementZone !=null ? CFPlacementZone : "default";
            if (CFServiceName != null)
            {
                Configuration.Services = new Dictionary<string, ServiceDetails>();
                Configuration.Services.Add(CFServiceName, new ServiceDetails() { Plan = CFServicePlan, Type = CFServiceType });
            }

            Configuration.SsoEnabled = CFSsoEnabled!=null ? CFSsoEnabled : "no";
            Configuration.Stack = CFStack;

            Utils.SerializeToFile(Configuration, CFConfigurationFile);

            return true;
        }