Exemplo n.º 1
0
        private static Object GetVariable(ProcessDescription parser, String parameter)
        {
/*
 *          try
 *          {
 *              parameter = parameter.Trim().ToLower();
 *              foreach (ParaItem item in parser.Parameters)
 *              {
 *                  if (parameter.Equals(item.Name.Trim().ToLower()))
 *                  {
 *                      //先屏蔽掉,等控件开发好再换回来
 *                      //return GPManager.CreateObject(item.Type, item.Properties[_XMLTag.g_AttributionVariable]);
 *                      return item.Properties[_XMLTag.g_AttributionVariable];
 *                  }
 *              }
 *          }
 *          catch (Exception ex)
 *          {
 *              IRunningStatusLogger logger = Context.Instance.GetVariable("RunningStatusLogger") as IRunningStatusLogger;
 *              if (null != logger)
 *              {
 *                  logger.Error(_LOG, ex.Message);
 *              }
 *          }
 */
            return(null);
        }
Exemplo n.º 2
0
        private static Boolean IsParameterInProcess(ProcessDescription parser, String parameter)
        {
/*
 *          try
 *          {
 *              parameter = parameter.Trim().ToLower();
 *              List<ParaItem> paras = parser.Parameters;
 *              foreach (ParaItem item in paras)
 *              {
 *                  if (parameter.Equals(item.Name.Trim().ToLower()))
 *                  {
 *                      return true;
 *                  }
 *              }
 *          }
 *          catch (Exception ex)
 *          {
 *              IRunningStatusLogger logger = Context.Instance.GetVariable("RunningStatusLogger") as IRunningStatusLogger;
 *              if (null != logger)
 *              {
 *                  logger.Error(_LOG, ex.Message);
 *              }
 *          }
 */
            return(false);
        }
        private Object Reductor(String key, String value)
        {
            try
            {
                ProcessDescription process = m_processQueue[m_index];
                key = key.Trim().ToLower();

                foreach (ParaItem para in process.Inputs)
                {
                    if (String.Compare(key, para.Name, true) == 0)
                    {
                        return(InstanceManager.Instance.ProcessManager.CreateObject(para.DataType, value));
                    }
                }
            }
            catch (Exception ex)
            {
                IRunningLogger logger = InstanceManager.Instance.Context.GetVariable("RunningStatusLogger") as IRunningLogger;
                if (null != logger)
                {
                    logger.Error(_LOG, ex.Message);
                }
            }

            return(value);
        }
Exemplo n.º 4
0
        //
        // Fabric Runtime environment is not made visible inside the container if RemoveServiceFabricRuntimeAccess is specified.
        //
        private static void PopulateFabricRuntimeEnvironment(
            ContainerConfig containerConfig,
            ProcessDescription processDesc,
            ContainerDescription containerDesc)
        {
            var packageFilePath = string.Empty;

            if (processDesc.EnvVars.ContainsKey(FabricPackageFileNameEnvironment))
            {
                packageFilePath = processDesc.EnvVars[FabricPackageFileNameEnvironment];
            }

            var fabricContainerLogRoot = Path.Combine(Utility.FabricLogRoot, "Containers");
            var fabricContainerRoot    = Path.Combine(fabricContainerLogRoot, containerDesc.ContainerName);

            // Set path to UT file
            // TODO: Bug#9728016 - Disable the bind until windows supports mounting file onto container

#if DotNetCoreClrLinux
            PopulateFabricRuntimeEnvironmentForLinux(
                containerConfig,
                containerDesc,
                processDesc,
                packageFilePath,
                fabricContainerRoot);
#else
            PopulateFabricRuntimeEnvironmentForWindows(
                containerConfig,
                containerDesc,
                processDesc,
                packageFilePath,
                fabricContainerRoot);
#endif
        }
Exemplo n.º 5
0
        private static void PopulateLabels(
            ContainerConfig containerConfig,
            ProcessDescription processDesc,
            ContainerDescription containerDesc)
        {
            //
            // Add labels from debug params if any
            //
            var containerLabels = processDesc.DebugParameters.ContainerLabels;

            if (containerLabels != null && containerLabels.Count > 0)
            {
                foreach (var label in containerLabels)
                {
                    var tokens = label.Split(new[] { "=" }, StringSplitOptions.RemoveEmptyEntries);
                    if (tokens != null && tokens.Length != 2)
                    {
                        throw new FabricException(
                                  $"Container label '{label}' specified in debug parameters has incorrect format. Expected format:'<label-key>=<label-value>'",
                                  FabricErrorCode.InvalidOperation);
                    }

                    containerConfig.Labels.Add(tokens[0], tokens[1]);
                }
            }

            // Add the labels present in container description
            if (containerDesc.Labels != null)
            {
                foreach (var label in containerDesc.Labels)
                {
                    containerConfig.Labels.Add(label.Name, label.Value);
                }
            }

            //
            // Add labels from hosting subsystem
            //
            containerConfig.Labels.Add(ApplicationNameLabelKeyName, containerDesc.ApplicationName);
            containerConfig.Labels.Add(ApplicationIdLabelKeyName, containerDesc.ApplicationId);
            containerConfig.Labels.Add(ServiceNameLabelKeyName, containerDesc.ServiceName);
            containerConfig.Labels.Add(CodePackageNameLabelKeyName, containerDesc.CodePackageName);
            containerConfig.Labels.Add(ServicePackageActivationIdLabelKeyName, containerDesc.ServicePackageActivationId);
            containerConfig.Labels.Add(PlatformLabelKeyName, PlatformLabelKeyValue);
            containerConfig.Labels.Add(PartitionIdLabelKeyName, containerDesc.PartitionId);

#if DotNetCoreClrLinux
            containerConfig.Labels.Add(CodePackageInstanceLabelKeyName, Convert.ToString(GetNewContainerInstanceIdAtomic(containerDesc)));
#endif

            var srppQueryFilterValue = $"{containerDesc.ServiceName}_{containerDesc.CodePackageName}_{containerDesc.PartitionId}";
            containerConfig.Labels.Add(SrppQueryFilterLabelKeyName, srppQueryFilterValue);

            var mrppQueryFilterValue = $"{containerDesc.ServiceName}_{containerDesc.CodePackageName}_{containerDesc.ApplicationId}";
            containerConfig.Labels.Add(MrppQueryFilterLabelKeyName, mrppQueryFilterValue);
        }
Exemplo n.º 6
0
        public static ContainerConfig GetContainerConfig(
            ProcessDescription processDesc,
            ContainerDescription containerDesc,
            string dockerVersion)
        {
            var containerConfig = new ContainerConfig
            {
                Image        = processDesc.ExePath,
                Hostname     = containerDesc.HostName,
                Labels       = new Dictionary <string, string>(),
                Env          = new List <string>(),
                ExposedPorts = new Dictionary <string, EmptyStruct>(),
                Tty          = containerDesc.RunInteractive,
                OpenStdin    = containerDesc.RunInteractive,
                HostConfig   = new HostConfig()
                {
                    Binds        = new List <string>(),
                    PortBindings = new Dictionary <string, IList <PortBinding> >(),
                    DNSSearch    = new List <string>(),
                    SecurityOpt  = containerDesc.SecurityOptions,
                    AutoRemove   = containerDesc.AutoRemove,
                    LogConfig    = new LogConfig()
                }
            };

            #if !DotNetCoreClrLinux
            containerConfig.HostConfig.Isolation = containerDesc.IsolationMode.ToString().ToLower();
            #endif

            PopulateLabels(containerConfig, processDesc, containerDesc);

            PopulateProcessEnvironment(containerConfig, processDesc, containerDesc);

            if (!containerDesc.RemoveServiceFabricRuntimeAccess)
            {
                PopulateFabricRuntimeEnvironment(containerConfig, processDesc, containerDesc);
            }

            PopulateVolumes(containerConfig, containerDesc);

            PopulateDebugParameters(containerConfig, processDesc, containerDesc);

            PopulateNetworkSettings(containerConfig, containerDesc);

            PopulateResourceGovernanceSettings(containerConfig, processDesc, dockerVersion);

            PopulateLogConfig(containerConfig, containerDesc);

            AddContainerLogMount(containerConfig, containerDesc);

            return(containerConfig);
        }
Exemplo n.º 7
0
        public ProcessDescription GetDescription()
        {
            ProcessDescription process = new ProcessDescription("Calculator", "Calculator", "Basic operations through WPS", "1.1");
            LiteralInput       oper    = new LiteralInput("operator", "operator", "abstract operator", "string", "add");

            oper.AllowedValues.AddRange(new string[] { "add", "sub", "mult", "div" });
            process.inputs.Add(oper);

            process.inputs.Add(new ComplexInput("a", "operand a", "abstract a", new ComplexFormat("text/xml", "uf8", "myschema.xsd")));
            process.inputs.Add(new ComplexInput("b", "operand b", "abstract b", new ComplexFormat("text/xml", "uf8", "myschema.xsd")));
            process.outputs.Add(new ComplexOutput("result", "result of operation as file", "raw abstract result of operation as file", new ComplexFormat("text/xml", "utf8", "myschema.xsd")));
            return(process);
        }
Exemplo n.º 8
0
        private ProcessDescription ProcessDescription(EntityDTO dto)
        {
            ProcessDescription pd = new ProcessDescription()
            {
                ProcessName    = dto.Name,
                Description    = dto.RenderHTML(GlobalStringResource.ProcessDescription, RenderOption.Paragraph),
                Purpose        = dto.RenderHTML(GlobalStringResource.Description, RenderOption.Paragraph),
                Objective      = dto.RenderHTML(GlobalStringResource.ProcessObjective, RenderOption.Paragraph),
                Strategy       = dto.RenderHTML(GlobalStringResource.Strategy, RenderOption.Paragraph),
                DocumentOwners = dto.RenderHTML(GlobalStringResource.DocumentOwners, RenderOption.Break)
            };

            return(pd);
        }
Exemplo n.º 9
0
        private ProcessDescription ParentProcessDescription(int id)
        {
            EntityDTO          parentDto = entityData.GetParentDiagram(id);
            ProcessDescription pd        = new ProcessDescription();

            if (parentDto != null)
            {
                parentDto.ExtractProperties();

                pd.ProcessName = parentDto.RenderAsLink();
                pd.Description = parentDto.RenderHTML(GlobalStringResource.ProcessDescription, RenderOption.Paragraph);
            }

            return(pd);
        }
        protected override Boolean Run(XmlElement state)
        {
            try
            {
                if (!this.IsReady())
                {
                    return false;
                }
                PopInputValue();

                _parameters = this.GetInputValue("Paras") as ParaItem[];
                ModelParameterWizardForm wizard = new ModelParameterWizardForm();
                ProcessDescription[] processQueue = new ProcessDescription[1];
                ProcessDescription item = new ProcessDescription("sample", 1, "sample", "sample");
                item.Inputs = _parameters;
                processQueue[0] = item;

                wizard.ProcessQueue = processQueue;
                if (wizard.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    List<ParameterSet> paras = wizard.ParameterSetList; //这个地方速度慢
                    _para = paras[0];
                }
                else
                {
                    wizard.Close();
                    return false;
                }

                PushOutputValue();
                return true;
            }
             catch (Exception ex)
             {
                 IRunningLogger logger = InstanceManager.Instance.Context.GetVariable("RunningLogger") as IRunningLogger;
                 if (null != logger)
                 {
                     logger.Error("sample.ProcessValidateModelFile", ex.Message);
                 }
             }
             finally
             {

             }

             return false;
        }
Exemplo n.º 11
0
        private static void PopulateFabricRuntimeEnvironmentForWindows(
            ContainerConfig containerConfig,
            ContainerDescription containerDesc,
            ProcessDescription processDesc,
            string packageFilePath,
            string fabricContainerRoot)
        {
            containerConfig.Env.Add(string.Format("FabricCodePath={0}", HostingConfig.Config.ContainerFabricBinRootFolder));
            containerConfig.Env.Add(string.Format("FabricLogRoot={0}", HostingConfig.Config.ContainerFabricLogRootFolder));

            var appDir = Path.Combine(HostingConfig.Config.ContainerAppDeploymentRootFolder, containerDesc.ApplicationId);

            containerConfig.HostConfig.Binds.Add(
                string.Format("{0}:{1}", Path.GetFullPath(processDesc.AppDirectory), appDir));

            if (!string.IsNullOrWhiteSpace(packageFilePath))
            {
                var configDir = Path.GetDirectoryName(packageFilePath);
                containerConfig.HostConfig.Binds.Add(
                    string.Format(
                        "{0}:{1}:ro",
                        Path.GetFullPath(configDir),
                        HostingConfig.Config.ContainerPackageRootFolder));
            }

            if (!string.IsNullOrWhiteSpace(Utility.FabricCodePath))
            {
                containerConfig.HostConfig.Binds.Add(
                    string.Format(
                        "{0}:{1}:ro",
                        Path.GetFullPath(Utility.FabricCodePath),
                        HostingConfig.Config.ContainerFabricBinRootFolder));
            }

            if (!string.IsNullOrWhiteSpace(fabricContainerRoot))
            {
                containerConfig.HostConfig.Binds.Add(
                    string.Format(
                        "{0}:{1}", // Log folder should be writable.
                        Path.GetFullPath(fabricContainerRoot),
                        HostingConfig.Config.ContainerFabricLogRootFolder));
            }

            // Mount the UT settings file
            // TODO: Bug#9728016 - Disable the bind until windows supports mounting file onto container
        }
Exemplo n.º 12
0
        protected override Boolean Run(XmlElement state)
        {
            try
            {
                if (!this.IsReady())
                {
                    return(false);
                }
                PopInputValue();

                _parameters = this.GetInputValue("Paras") as ParaItem[];
                ModelParameterWizardForm wizard       = new ModelParameterWizardForm();
                ProcessDescription[]     processQueue = new ProcessDescription[1];
                ProcessDescription       item         = new ProcessDescription("sample", 1, "sample", "sample");
                item.Inputs     = _parameters;
                processQueue[0] = item;

                wizard.ProcessQueue = processQueue;
                if (wizard.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    List <ParameterSet> paras = wizard.ParameterSetList; //这个地方速度慢
                    _para = paras[0];
                }
                else
                {
                    wizard.Close();
                    return(false);
                }

                PushOutputValue();
                return(true);
            }
            catch (Exception ex)
            {
                IRunningLogger logger = InstanceManager.Instance.Context.GetVariable("RunningLogger") as IRunningLogger;
                if (null != logger)
                {
                    logger.Error("sample.ProcessValidateModelFile", ex.Message);
                }
            }
            finally
            {
            }

            return(false);
        }
Exemplo n.º 13
0
        private static void PopulateFabricRuntimeEnvironmentForLinux(
            ContainerConfig containerConfig,
            ContainerDescription containerDesc,
            ProcessDescription processDesc,
            string packageFilePath,
            string fabricContainerRoot)
        {
            containerConfig.Env.Add(string.Format("FabricCodePath={0}", Path.GetFullPath(Utility.FabricCodePath)));
            containerConfig.Env.Add(string.Format("FabricLogRoot={0}", fabricContainerRoot));
            containerConfig.Env.Add(string.Format("FabricDataRoot={0}", Path.GetFullPath(Utility.FabricDataRoot)));

            containerConfig.HostConfig.Binds.Add(
                string.Format("{0}:{1}", processDesc.AppDirectory, processDesc.AppDirectory));

            if (!string.IsNullOrWhiteSpace(packageFilePath))
            {
                var configDir = Path.GetDirectoryName(packageFilePath);
                containerConfig.HostConfig.Binds.Add(string.Format("{0}:{1}:ro", configDir, configDir));
            }

            if (!string.IsNullOrWhiteSpace(Utility.FabricCodePath))
            {
                containerConfig.HostConfig.Binds.Add(
                    string.Format(
                        "{0}:{1}:ro",
                        Utility.FabricCodePath,
                        Utility.FabricCodePath));
            }

            if (!string.IsNullOrWhiteSpace(fabricContainerRoot))
            {
                containerConfig.HostConfig.Binds.Add(
                    string.Format("{0}:{1}", fabricContainerRoot, fabricContainerRoot));
            }

            if (processDesc.EnvVars.ContainsKey(RuntimeSslConnectionCertFilePath))
            {
                var certDir = Path.GetDirectoryName(processDesc.EnvVars[RuntimeSslConnectionCertFilePath]);
                containerConfig.HostConfig.Binds.Add(
                    string.Format("{0}:{1}:ro", certDir, certDir));
            }

            // Mount the UT settings file
            // TODO: Bug#9728016 - Disable the bind until windows supports mounting file onto container
        }
Exemplo n.º 14
0
        public ProcessDescription GetDescription()
        {
            ProcessDescription process = new ProcessDescription("Add", "Add", "(a + b) through WPS", "1.1");
            LiteralInput       a       = new LiteralInput("a", "operand a", "abstract a", "integer", "88");

            a.MinOccurs = 0;
            a.MaxOccurs = 3;
            //a.AllowedValues.Add("88");
            //a.AllowedValues.Add("6");
            process.inputs.Add(a);
            process.inputs.Add(new LiteralInput("b", "operand b", "abstract b", "integer", "22"));
            process.outputs.Add(new LiteralOutput("sum", "sum of a + b", "abstract sum a + b", "integer"));
            ComplexOutput sumFile = new ComplexOutput("sumFile", "sum of a + b as file", "raw abstract sum a + b", new ComplexFormat("text/xml", "utf8", ""));

            sumFile.Formats.Add(new ComplexFormat("plain/text", "utf8", ""));
            process.outputs.Add(sumFile);
            return(process);
        }
Exemplo n.º 15
0
        /// <summary>
        /// This method is called by the DescribeProcess part of WPS.NET, it must be implemented.
        /// </summary>
        /// <returns>The process description</returns>
        public override ProcessDescription GetDescription()
        {
            ///This is where we create the process description
            ProcessDescription process = new ProcessDescription("AsyncClock", "Async Clock", "Counts a user-defined number of seconds asynchronously (This is an example of async process for developpers)", "1.1");

            ///This check is meant to make sure everything is in it's place so that the process
            ///can be called asynchronously without failing miserably.
            if (this is IAsyncProcess && this.MainAppDomain != null)
            {
                ///Is this process implements IAsyncProcess and if the Main Application Domain is provided,
                ///we can assume that status will be supported (provided status updates are properly coded).
                process.statusSupported = true;

                if (this.BaseUrlToResultPath != String.Empty && this.StoredResultPath != string.Empty)
                {
                    ///If the necessary informations for responses and results storage are provided
                    ///we can enable storage support.
                    process.storeSupported = true;
                }
            }

            ///This is the declaration of the numberOfSeconds parameter
            ///It has 1 minoccurs and 1 maxoccurs, it is mandatory.
            LiteralInput numberOfSeconds = new LiteralInput("numberOfSeconds", "Number of seconds", "The number of seconds this process will count", "integer", "100");

            numberOfSeconds.MinOccurs = 1;
            numberOfSeconds.MaxOccurs = 1;

            ///Dont forget to add the previously created parameter in the inputs collection of the process.
            process.inputs.Add(numberOfSeconds);

            ///A start date should be also specified
            process.processStartDate = this.startDate;

            ///Specify the output of the process
            LiteralOutput output = new LiteralOutput("AsyncClockResult", "Async Clock Result", "A string containing the start datetime and the end datetime", "string");

            output.Value = String.Empty;
            process.outputs.Add(output);

            ///Return the description of the process.
            return(process);
        }
Exemplo n.º 16
0
        private static void PopulateDebugParameters(
            ContainerConfig containerConfig,
            ProcessDescription processDesc,
            ContainerDescription containerDesc)
        {
            var debugParams = processDesc.DebugParameters;

            containerConfig.HostConfig.Binds.AddRange(debugParams.ContainerMountedVolumes);
            containerConfig.Env.AddRange(debugParams.ContainerEnvironmentBlock);

            if (debugParams.ContainerEntryPoints != null &&
                debugParams.ContainerEntryPoints.Count > 0)
            {
                containerConfig.Entrypoint = debugParams.ContainerEntryPoints;
            }
            else if (!string.IsNullOrEmpty(containerDesc.EntryPoint))
            {
                containerConfig.Entrypoint =
                    containerDesc.EntryPoint.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
            }
        }
Exemplo n.º 17
0
        private static void PopulateProcessEnvironment(
            ContainerConfig containerConfig,
            ProcessDescription processDesc,
            ContainerDescription containerDesc)
        {
            foreach (var kvPair in processDesc.EnvVars)
            {
                var envVarName  = kvPair.Key;
                var envVarValue = kvPair.Value;

#if !DotNetCoreClrLinux
                if (envVarName.Equals(FabricPackageFileNameEnvironment, StringComparison.OrdinalIgnoreCase))
                {
                    var packageFilePath          = kvPair.Value;
                    var packageFileName          = Path.GetFileName(packageFilePath);
                    var containerPackageFilePath = Path.Combine(HostingConfig.Config.ContainerPackageRootFolder, packageFileName);

                    envVarValue = containerPackageFilePath;
                }
#endif
                containerConfig.Env.Add(string.Format("{0}={1}", envVarName, envVarValue));
            }

            foreach (var setting in processDesc.EncryptedEnvironmentVariables)
            {
                var    value          = setting.Value;
                string decryptedValue = Utility.GetDecryptedValue(value);
                containerConfig.Env.Add(string.Format("{0}={1}", setting.Key, decryptedValue));
            }

            containerConfig.Env.Add(
                string.Format("{0}={1}", ContainerNameEnvironmentVariable, containerDesc.ContainerName));

            containerConfig.Cmd =
                processDesc.Arguments.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
        }
Exemplo n.º 18
0
 private static Boolean IsParameterInProcess(ProcessDescription parser, String parameter)
 {
     /*
     try
     {
         parameter = parameter.Trim().ToLower();
         List<ParaItem> paras = parser.Parameters;
         foreach (ParaItem item in paras)
         {
             if (parameter.Equals(item.Name.Trim().ToLower()))
             {
                 return true;
             }
         }
     }
     catch (Exception ex)
     {
         IRunningStatusLogger logger = Context.Instance.GetVariable("RunningStatusLogger") as IRunningStatusLogger;
         if (null != logger)
         {
             logger.Error(_LOG, ex.Message);
         }
     }
     */
     return false;
 }
Exemplo n.º 19
0
 private static Object GetVariable(ProcessDescription parser, String parameter)
 {
     /*
     try
     {
         parameter = parameter.Trim().ToLower();
         foreach (ParaItem item in parser.Parameters)
         {
             if (parameter.Equals(item.Name.Trim().ToLower()))
             {
                 //先屏蔽掉,等控件开发好再换回来
                 //return GPManager.CreateObject(item.Type, item.Properties[_XMLTag.g_AttributionVariable]);
                 return item.Properties[_XMLTag.g_AttributionVariable];
             }
         }
     }
     catch (Exception ex)
     {
         IRunningStatusLogger logger = Context.Instance.GetVariable("RunningStatusLogger") as IRunningStatusLogger;
         if (null != logger)
         {
             logger.Error(_LOG, ex.Message);
         }
     }
     */
     return null;
 }
 private ProcessDescription ProcessDescription(EntityDTO dto)
 {
     ProcessDescription pd = new ProcessDescription()
     {
         ProcessName = dto.Name,
         Description = dto.RenderHTML(GlobalStringResource.ProcessDescription, RenderOption.Paragraph),
         Purpose = dto.RenderHTML(GlobalStringResource.Description, RenderOption.Paragraph),
         Objective = dto.RenderHTML(GlobalStringResource.ProcessObjective, RenderOption.Paragraph),
         Strategy = dto.RenderHTML(GlobalStringResource.Strategy, RenderOption.Paragraph),
         DocumentOwners = dto.RenderHTML(GlobalStringResource.DocumentOwners, RenderOption.Break)
     };
     return pd;
 }
Exemplo n.º 21
0
        private static void PopulateResourceGovernanceSettings(
            ContainerConfig containerConfig,
            ProcessDescription processDesc,
            string dockerVersion)
        {
            var resourceGovPolicy = processDesc.ResourceGovernancePolicy;

            if (resourceGovPolicy.MemoryInMB > 0)
            {
                containerConfig.HostConfig.Memory = resourceGovPolicy.MemoryInMB * MegaBytesToBytesMultiplier;
            }

            if (resourceGovPolicy.MemorySwapInMB > 0)
            {
                var swapMemory = (long)(resourceGovPolicy.MemorySwapInMB) * 1024 * 1024;
                containerConfig.HostConfig.MemorySwap = Math.Min(swapMemory, Int64.MaxValue);
            }

            if (resourceGovPolicy.MemoryReservationInMB > 0)
            {
                containerConfig.HostConfig.MemoryReservation = (resourceGovPolicy.MemoryReservationInMB) * MegaBytesToBytesMultiplier;
            }

            if (resourceGovPolicy.CpuShares > 0)
            {
                containerConfig.HostConfig.CPUShares = resourceGovPolicy.CpuShares;
            }

            if (resourceGovPolicy.DiskQuotaInMB > 0)
            {
                containerConfig.HostConfig.DiskQuota = resourceGovPolicy.DiskQuotaInMB * MegaBytesToBytesMultiplier;
            }
#if DotNetCoreClrLinux
            // Note this is Linux specific and docker on windows will error out if this is set.
            if (resourceGovPolicy.KernelMemoryInMB > 0)
            {
                containerConfig.HostConfig.KernelMemory = resourceGovPolicy.KernelMemoryInMB * MegaBytesToBytesMultiplier;
            }

            // Note this is Linux specific, however, docker will NOT error out if specified.  It is simply ignored.
            if (resourceGovPolicy.ShmSizeInMB > 0)
            {
                containerConfig.HostConfig.ShmSize = resourceGovPolicy.ShmSizeInMB * MegaBytesToBytesMultiplier;
            }
#endif
            if (!string.IsNullOrEmpty(resourceGovPolicy.CpusetCpus))
            {
                containerConfig.HostConfig.CpusetCpus = resourceGovPolicy.CpusetCpus;
            }

            if (resourceGovPolicy.NanoCpus > 0)
            {
                var nanoCpus = resourceGovPolicy.NanoCpus;

#if !DotNetCoreClrLinux
                if (!IsNewDockerVersion(dockerVersion))
                {
                    //
                    // For Windows OS we are going to consider all the active processors from the system
                    // in order to scale the minimum number of NanoCpus to at least 1% of total cpu for
                    // older docker versions
                    //
                    var minNumOfNanoCpus = (ulong)(Environment.ProcessorCount) * DockerNanoCpuMultiplier / 100;
                    nanoCpus = Math.Max(minNumOfNanoCpus, nanoCpus);
                }
#endif
                containerConfig.HostConfig.NanoCPUs = nanoCpus;
            }

            containerConfig.HostConfig.CPUPercent         = resourceGovPolicy.CpuPercent;
            containerConfig.HostConfig.IOMaximumIOps      = resourceGovPolicy.MaximumIOps;
            containerConfig.HostConfig.IOMaximumBandwidth = resourceGovPolicy.MaximumIOBytesps;
            containerConfig.HostConfig.BlkioWeight        = resourceGovPolicy.BlockIOWeight;

            // Adjust conflicting fields for JSON serialization
            if (containerConfig.HostConfig.NanoCPUs > 0)
            {
                containerConfig.HostConfig.CPUShares  = 0;
                containerConfig.HostConfig.CPUPercent = 0;
                containerConfig.HostConfig.CpusetCpus = null;
            }
        }
        private ProcessDescription ParentProcessDescription(int id)
        {
            EntityDTO parentDto = entityData.GetParentDiagram(id);
            ProcessDescription pd = new ProcessDescription();
            if(parentDto != null)
            {
                parentDto.ExtractProperties();

                pd.ProcessName = parentDto.RenderAsLink();
                pd.Description = parentDto.RenderHTML(GlobalStringResource.ProcessDescription, RenderOption.Paragraph);
            }

            return pd;
        }