Ejemplo n.º 1
0
        /// <summary>
        /// Gets the set of environment variables that's common to scripts running at the VM level and for game servers.
        /// </summary>
        /// <param name="sessionHostsStartInfo">The details for starting the game servers.</param>
        /// <param name="vmConfiguration">The details for the VM.</param>
        /// <returns>A dictionary of environment variables</returns>
        /// <remarks>This method is expected to be called only after the VM is assigned (i.e sessionHostsStartInfo is not null).</remarks>
        public static IDictionary <string, string> GetCommonEnvironmentVariables(SessionHostsStartInfo sessionHostsStartInfo, VmConfiguration vmConfiguration)
        {
            ArgumentValidator.ThrowIfNull(sessionHostsStartInfo, nameof(sessionHostsStartInfo));
            VmConfiguration.ParseAssignmentId(sessionHostsStartInfo.AssignmentId, out Guid titleId, out Guid deploymentId, out string region);
            var environmentVariables = new Dictionary <string, string>()
            {
                {
                    TitleIdEnvVariable, VmConfiguration.GetPlayFabTitleId(titleId)
                },
                {
                    BuildIdEnvVariable, deploymentId.ToString()
                },
                {
                    RegionEnvVariable, region
                },
                {
                    VmIdEnvVariable, vmConfiguration.VmId
                },
                {
                    PublicIPv4AddressEnvVariable, sessionHostsStartInfo.PublicIpV4Address
                },
                {
                    PublicIPv4AddressEnvVariableV2, sessionHostsStartInfo.PublicIpV4Address
                },
                {
                    FqdnEnvVariable, sessionHostsStartInfo.FQDN
                }
            };

            sessionHostsStartInfo.DeploymentMetadata?.ForEach(x => environmentVariables.Add(x.Key, x.Value));

            return(environmentVariables);
        }
Ejemplo n.º 2
0
        public static void AdaptFolderPathsForLinuxContainersOnWindows(VmConfiguration VmConfiguration)
        {
            // running Linux containers with Docker for Windows requires some "weird" path mapping
            // in the sense that we want to map Linux paths on the container to Windows paths on the host
            // following method call makes sure of that
            VmDirectories vmd = VmConfiguration.VmDirectories;

            vmd.GameSharedContentFolderContainer = replacePathForLinuxContainersOnWindows(vmd.GameSharedContentFolderContainer);
            vmd.GameLogsRootFolderContainer      = replacePathForLinuxContainersOnWindows(vmd.GameLogsRootFolderContainer);
            vmd.CertificateRootFolderContainer   = replacePathForLinuxContainersOnWindows(vmd.CertificateRootFolderContainer);
            vmd.GsdkConfigRootFolderContainer    = replacePathForLinuxContainersOnWindows(vmd.GsdkConfigRootFolderContainer);
            vmd.GsdkConfigFilePathContainer      = replacePathForLinuxContainersOnWindows(vmd.GsdkConfigFilePathContainer);
        }