public RackConnectServiceTests(ITestOutputHelper testLog) { var testOutput = new XunitTraceListener(testLog); Trace.Listeners.Add(testOutput); RackspaceNet.Tracing.Http.Listeners.Add(testOutput); var authenticationProvider = TestIdentityProvider.GetIdentityProvider("RackConnect"); _rackConnectService = new RackConnectService(authenticationProvider, "LON"); _testData = new RackConnectTestDataManager(_rackConnectService, authenticationProvider); }
public async Task Run(string username, string apiKey, string region) { // Configure authentication var identity = new CloudIdentity { Username = username, APIKey = apiKey }; var identityService = new CloudIdentityProvider(identity); var result = identityService.Authenticate(); var serverService = new CloudServersProvider(identity, region, null, null); var rackConnectService = new RackConnectService(identityService, region); // Create a cloud server on your hybrid network Console.WriteLine($"Looking up your RackConnect network in {region}..."); var networks = await rackConnectService.ListNetworksAsync(); var network = networks.FirstOrDefault(); if (network == null) throw new Exception($"You do not have a Hybrid Cloud / RackConnect network configured in the {region} which is required to run this sample."); Console.WriteLine("Creating sample cloud server... "); // Ubuntu 14.04 LTS (Trusty Tahr) (PVHVM) const string ubuntuImageId = "09de0a66-3156-48b4-90a5-1cf25a905207"; // 512MB Standard Instance const string standardFlavorId = "2"; var requestedServer = serverService.CreateServer("sample", ubuntuImageId, standardFlavorId, networks: new string[] {network.Id}); serverService.WaitForServerActive(requestedServer.Id); Console.WriteLine("Allocating a public IP address..."); var ip = await rackConnectService.CreatePublicIPAsync( new PublicIPCreateDefinition {ShouldRetain = true}); await ip.WaitUntilActiveAsync(); Console.WriteLine($"Acquired {ip.PublicIPv4Address}!"); Console.WriteLine("Assigning the public IP to the sample cloud server..."); await ip.AssignAsync(requestedServer.Id); await ip.WaitUntilActiveAsync(); Console.WriteLine("Deleting sample cloud server..."); serverService.DeleteServer(requestedServer.Id); Console.WriteLine("Deallocating the public IP address..."); await ip.DeleteAsync(); }
public NetworkTests() { _rackConnectService = new RackConnectService(Stubs.IdentityService, "region"); }
public PublicIPTests() { _rackConnectService = new RackConnectService(Stubs.IdentityService, "region"); }
public RackConnectTestDataManager(RackConnectService rackConnectService, CloudIdentityProvider authenticationProvider) { _rackConnectService = rackConnectService; _testData = new HashSet<object>(); _serverTestData = new CloudServersTestDataManager(authenticationProvider); }