Advertisement
Guest User

Untitled

a guest
Mar 24th, 2018
616
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.02 KB | None | 0 0
  1. using Microsoft.Azure.Management.Fluent;
  2. using Microsoft.Azure.Management.ResourceManager.Fluent;
  3. using Microsoft.Azure.Management.ResourceManager.Fluent.Authentication;
  4. using Microsoft.Azure.Management.ResourceManager.Fluent.Core;
  5. using MinecraftServerRCON;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Fabric;
  9. using System.Fabric.Health;
  10. using System.Linq;
  11. using System.Text;
  12. using System.Threading;
  13. using System.Threading.Tasks;
  14.  
  15. namespace MainCraftFeatures
  16. {
  17. class Program
  18. {
  19. private static Uri ApplicationName = new Uri("fabric:/WordCount");
  20. private static string ServiceManifestName = "WordCount.Service";
  21. private static string NodeName = FabricRuntime.GetNodeContext().NodeName;
  22. private static Timer ReportTimer = new Timer(new TimerCallback(SendReport), null, 30 * 1000, 30 * 1000);
  23. private static FabricClient Client = new FabricClient(new FabricClientSettings() { HealthReportSendInterval = TimeSpan.FromSeconds(0) });
  24. static void Main(string[] args)
  25. {
  26. //var username = "hacker3@OTAPRD409ops.onmicrosoft.com";
  27. //var password = "{{^o5Gw>BFW6";
  28. ////var clientId = "da22f8cd-a867-4ccd-9cc0-d17282424979";
  29. //var logApi = "38371c25-3aa9-4cae-bbe2-467508e6f13c";
  30. //string tenantID = "cc3bc33c-7736-4cd1-80ad-438005696967";
  31. //var environment = AzureEnvironment.AzureUSGovernment;
  32.  
  33.  
  34. //AzureCredentials credentials =
  35. // SdkContext.AzureCredentialsFactory.FromUser(
  36. // username,
  37. // password,
  38. // logApi,
  39. // tenantID,
  40. // environment);
  41.  
  42. //var azure =
  43. // Azure.Authenticate(credentials).WithDefaultSubscription();
  44.  
  45.  
  46. // var clusterAddress = "newhope.eastus.cloudapp.azure.com:19000";
  47. //var serverThumb = "3024A8A50F7746F3FBC647EC14B219F53D01A17A";
  48.  
  49. //var claimsCredential = new ClaimsCredentials();
  50. //claimsCredential.ServerThumbprints.Add(serverThumb);
  51.  
  52.  
  53. //var fabricClient = new FabricClient(clusterAddress);
  54.  
  55. //var services = fabricClient.QueryManager.GetServiceListAsync(new Uri("fabric:/MinecraftService")).Result;
  56.  
  57.  
  58.  
  59.  
  60.  
  61. using (var rcon = RCONClient.INSTANCE)
  62. {
  63. rcon.setupStream(
  64. "ohmywpscluster.westus.cloudapp.azure.com",
  65. password: "cheesesteakjimmys");
  66.  
  67.  
  68. while (true)
  69. {
  70. string command = Console.ReadLine();
  71.  
  72. string answer =
  73. rcon.sendMessage(
  74. RCONMessageType.Command,
  75. command);
  76.  
  77. Console.WriteLine(answer);
  78. }
  79. }
  80. }
  81.  
  82. public static void SendReport(object obj)
  83. {
  84. // Test whether the resource can be accessed from the node
  85. HealthState healthState = this.TestConnectivityToExternalResource();
  86.  
  87. // Send report on deployed service package, as the connectivity is needed by the specific service manifest
  88. // and can be different on different nodes
  89. var deployedServicePackageHealthReport = new DeployedServicePackageHealthReport(
  90. ApplicationName,
  91. ServiceManifestName,
  92. NodeName,
  93. new HealthInformation("ExternalSourceWatcher", "Connectivity", healthState));
  94.  
  95. // TODO: handle exception. Code omitted for snippet brevity.
  96. // Possible exceptions: FabricException with error codes
  97. // FabricHealthStaleReport (non-retryable, the report is already queued on the health client),
  98. // FabricHealthMaxReportsReached (retryable; user should retry with exponential delay until the report is accepted).
  99. Client.HealthManager.ReportHealth(deployedServicePackageHealthReport);
  100. }
  101. }
  102. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement