public async Task Run(string identityEndpoint, string username, string password, string project, string region) { // Configure authentication var user = new CloudIdentityWithProject { Username = username, Password = password, ProjectName = project }; var identity = new OpenStackIdentityProvider(new Uri(identityEndpoint), user); var networking = new NetworkingService(identity, region); Console.WriteLine("Creating Sample Network... "); var networkDefinition = new NetworkDefinition {Name = "Sample"}; var sampleNetwork = await networking.CreateNetworkAsync(networkDefinition); Console.WriteLine("Adding a subnet to Sample Network..."); var subnetDefinition = new SubnetCreateDefinition(sampleNetwork.Id, IPVersion.IPv4, "192.0.2.0/24") { Name = "Sample" }; var sampleSubnet = await networking.CreateSubnetAsync(subnetDefinition); Console.WriteLine("Attaching a port to Sample Network..."); var portDefinition = new PortCreateDefinition(sampleNetwork.Id) { Name = "Sample" }; var samplePort = await networking.CreatePortAsync(portDefinition); Console.WriteLine("Listing Networks..."); var networks = await networking.ListNetworksAsync(); foreach (Network network in networks) { Console.WriteLine($"{network.Id}\t\t\t{network.Name}"); } Console.WriteLine(); Console.WriteLine("Sample Network Information:"); Console.WriteLine(); Console.WriteLine($"Network Id: {sampleNetwork.Id}"); Console.WriteLine($"Network Name: {sampleNetwork.Name}"); Console.WriteLine($"Network Status: {sampleNetwork.Status}"); Console.WriteLine(); Console.WriteLine($"Subnet Id: {sampleSubnet.Id}"); Console.WriteLine($"Subnet Name: {sampleSubnet.Name}"); Console.WriteLine($"Subnet IPs: {sampleSubnet.AllocationPools.First().Start} - {sampleSubnet.AllocationPools.First().End}"); Console.WriteLine(); Console.WriteLine($"Port Id: {samplePort.Id}"); Console.WriteLine($"Port Name: {samplePort.Name}"); Console.WriteLine($"Port Address: {samplePort.MACAddress}"); Console.WriteLine($"Port Status: {samplePort.Status}"); Console.WriteLine(); Console.WriteLine("Deleting Sample Network..."); await networking.DeletePortAsync(samplePort.Id); await networking.DeleteNetworkAsync(sampleNetwork.Id); }
public NetworkingServiceTests(ITestOutputHelper testLog) { var testOutput = new XunitTraceListener(testLog); Trace.Listeners.Add(testOutput); OpenStackNet.Tracing.Http.Listeners.Add(testOutput); var authenticationProvider = TestIdentityProvider.GetIdentityProvider(); _networkingService = new NetworkingService(authenticationProvider, "RegionOne"); _testData = new NetworkingTestDataManager(_networkingService); }
static void Main(string[] args) { const string region = "RegionOne"; // Configure OpenStack.NET OpenStackNet.Configure(options => options.DefaultTimeout=TimeSpan.FromSeconds(5)); // Authenticate var identityUrl = new Uri("http://example.com"); var user = new CloudIdentityWithProject(); var identity = new OpenStackIdentityProvider(identityUrl, user); identity.Authenticate(); // Use legacy and new providers var legacyNetworking = new CloudNetworksProvider(null, identity); legacyNetworking.ListNetworks(); var networks = new NetworkingService(identity, region); networks.ListNetworks(); var legacyCompute = new CloudServersProvider(null, identity); legacyCompute.ListServers(); var compute = new ComputeService(identity, region); compute.ListServers(); }
public NetworkTests() { _networkingService = new NetworkingService(Stubs.AuthenticationProvider, "region"); }
public NetworkingTestDataManager(NetworkingService networkingService) { _networkingService = networkingService; _testData = new HashSet<object>(); }
public NetworkingTestDataManager(NetworkingService networkingService) { _networkingService = networkingService; _testData = new HashSet <object>(); }
public SubnetTests() { _networkingService = new NetworkingService(Stubs.AuthenticationProvider, "region"); }