GceCredentials GceCredentialsFromJson(String InString) { try { DataContractJsonSerializer Serializer = new DataContractJsonSerializer(typeof(GceCredentials)); MemoryStream Stream = new MemoryStream(System.Text.UTF8Encoding.UTF8.GetBytes(InString)); GceCredentials Credential = (GceCredentials)Serializer.ReadObject(Stream); return(Credential); } catch (Exception ex) { throw new AutomationException(ex, "Failed to deserialize GceCredentials. Ex {0}"); } }
private string Deployment2GceArgs(string tag = "", string MachineType = "n1-standard-16", string Zone = "us-central1-a", string Region = "NA", int InstanceSize = 1, int InstanceSizeMin = 1, int InstanceSizeMax = 6, string AutoscalerId = "default", string ExtraCliArgs = "", string AppNameStringOverride = "", string HubServerName = "") { int LocalCpuBudget = CpuBudget; UnrealTournamentBuild.UnrealTournamentAppName LocalAppName = AppName; if (!String.IsNullOrEmpty(AppNameStringOverride)) { if (!Enum.IsDefined(typeof(UnrealTournamentBuild.UnrealTournamentAppName), AppNameStringOverride)) { throw new AutomationException("Trying to override AppName to non-existant type: " + AppNameStringOverride); } LocalAppName = (UnrealTournamentBuild.UnrealTournamentAppName)Enum.Parse(typeof(UnrealTournamentBuild.UnrealTournamentAppName), AppNameStringOverride); CommandUtils.Log("Overriding AppName from {0} to {1}", AppName, LocalAppName); } string NetworkId = "default"; string CredentialsFile = "GceUtDevCredentials.txt"; /* This is very confusing. UnrealTournament's live lable is UnrealTournamentDev. */ if (LocalAppName == UnrealTournamentBuild.UnrealTournamentAppName.UnrealTournamentDev) { NetworkId = "unreal-tournament"; CredentialsFile = "GceUtLiveCredentials.txt"; } if (InstanceSize == 0) { InstanceSizeMin = 0; InstanceSizeMax = 0; } else if (InstanceSizeMin > InstanceSize) { InstanceSize = InstanceSizeMin; } string CredentialsFilePath = GetUtilitiesFilePath(CredentialsFile); string CredentialsFileContentsBase64 = ReadFileContents(CredentialsFilePath); string CredentialsFileContents = ConvertFromBase64(CredentialsFileContentsBase64); GceCredentials gceCredentials = GceCredentialsFromJson(CredentialsFileContents); string HTTPCredentialsFilePath = GetUtilitiesFilePath("DeployerAuthBase64.txt"); if (File.Exists(HTTPCredentialsFilePath)) { string HTTPCredentialsFileContentsBase64 = ReadFileContents(HTTPCredentialsFilePath); HTTPAuthBase64 = HTTPCredentialsFileContentsBase64; } Byte[] CliArgBytes; if (HubServerName != "") { CliArgBytes = System.Text.Encoding.UTF8.GetBytes("UnrealTournament ut-entry?game=lobby?ServerName=\"" + HubServerName + "\" -nocore -epicapp=" + LocalAppName.ToString() + " " + ExtraCliArgs); LocalCpuBudget = 32000; } else { CliArgBytes = System.Text.Encoding.UTF8.GetBytes("UnrealTournament ut-entry?game=empty?region=" + Region + " -epicapp=" + LocalAppName.ToString() + " " + ExtraCliArgs); } Byte[] BuildStringBytes = System.Text.Encoding.UTF8.GetBytes(BuildString); string CloudArgs = "epic_game_name=" + GameNameShort + "&" + "epic_game_binary=" + this.GameBinary + "&" + "epic_game_binary_path=" + this.GameBinaryPath + "&" + "epic_game_log_path=" + this.GameLogPath + "&" + "epic_game_saved_path=" + this.GameSavedPath + "&" + "epic_game_max_match_length=" + this.MaxMatchLength.ToString() + "&" + "epic_game_ttl_interval=" + this.TtlInterval.ToString() + "&" + "epic_install_sumo=" + this.InstallSumo + "&" + "epic_game_tag=" + GetTag(LocalAppName, Region, tag) + "&" + "epic_game_version=" + Changelist.ToString() + "&" + "epic_game_region=" + Region + "&" + "epic_game_cpu_budget=" + LocalCpuBudget + "&" + "epic_game_ram_budget=" + RamBudget + "&" + "epic_game_buildstr_base64=" + System.Convert.ToBase64String(BuildStringBytes) + "&" + "epic_game_environment=" + LocalAppName.ToString() + "&" + "epic_instance_size=" + InstanceSize.ToString() + "&" + "epic_instance_min=" + InstanceSizeMin.ToString() + "&" + "epic_instance_max=" + InstanceSizeMax.ToString() + "&" + "epic_autoscaler_id=" + AutoscalerId + "&" + "epic_gce_project_id=" + gceCredentials.project_id + "&" + "epic_gce_base64_credentials=" + CredentialsFileContentsBase64 + "&" + "epic_gce_machine_type=" + MachineType + "&" + "epic_gce_network=" + NetworkId + "&" + "epic_gce_zone=" + Zone + "&" + "epic_game_base64_cli_args=" + System.Convert.ToBase64String(CliArgBytes); return(CloudArgs); }