/// <inheritdoc cref="NetworkingApiBuilder.UpdateNetworkAsync" />
 public Task<Network> UpdateNetworkAsync(Identifier networkId, NetworkDefinition network, CancellationToken cancellationToken = default(CancellationToken))
 {
     return _networkingApiBuilder
         .UpdateNetworkAsync(networkId, network, cancellationToken)
         .SendAsync()
         .ReceiveJson<Network>();
 }
 /// <inheritdoc cref="NetworkingApiBuilder.UpdateNetworkAsync" />
 public Task <Network> UpdateNetworkAsync(Identifier networkId, NetworkDefinition network, CancellationToken cancellationToken = default(CancellationToken))
 {
     return(_networkingApiBuilder
            .UpdateNetworkAsync(networkId, network, cancellationToken)
            .SendAsync()
            .ReceiveJson <Network>());
 }
 /// <inheritdoc cref="NetworkingApiBuilder.CreateNetworkAsync" />
 public Task<Network> CreateNetworkAsync(NetworkDefinition network, CancellationToken cancellationToken = default(CancellationToken))
 {
     return _networkingApiBuilder
         .CreateNetworkAsync(network, cancellationToken)
         .SendAsync()
         .ReceiveJson<Network>();
 }
 /// <inheritdoc cref="NetworkingApiBuilder.CreateNetworkAsync" />
 public Task <Network> CreateNetworkAsync(NetworkDefinition network, CancellationToken cancellationToken = default(CancellationToken))
 {
     return(_networkingApiBuilder
            .CreateNetworkAsync(network, cancellationToken)
            .SendAsync()
            .ReceiveJson <Network>());
 }
 public async Task<Network> CreateNetwork(NetworkDefinition definition)
 {
     var network = await _cloudNetworkService.CreateNetworkAsync(definition);
     Register(network);
     await Task.Delay(TimeSpan.FromMilliseconds(500));
     return network;
 }
    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 networkService = new CloudNetworkService(identityService, region);

        Console.WriteLine("Creating Sample Network... ");
        var networkDefinition = new NetworkDefinition {Name = "Sample"};
        var sampleNetwork = await networkService.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 networkService.CreateSubnetAsync(subnetDefinition);

        Console.WriteLine("Attaching a port to Sample Network...");
        var portDefinition = new PortCreateDefinition(sampleNetwork.Id)
        {
            Name = "Sample"
        };
        var samplePort = await networkService.CreatePortAsync(portDefinition);

        Console.WriteLine("Listing Networks...");
        var networks = await networkService.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 networkService.DeletePortAsync(samplePort.Id);
        await networkService.DeleteNetworkAsync(sampleNetwork.Id);
    }
Example #7
0
        public async Task <Network> CreateNetwork(NetworkDefinition definition)
        {
            var network = await _cloudNetworkService.CreateNetworkAsync(definition);

            Register(network);
            await Task.Delay(TimeSpan.FromMilliseconds(500));

            return(network);
        }
        public void CreateNetwork()
        {
            using (var httpTest = new HttpTest())
            {
                Identifier networkId = Guid.NewGuid();
                httpTest.RespondWithJson(new Network{Id = networkId});

                var definition = new NetworkDefinition();
                var network = _cloudNetworkService.CreateNetwork(definition);

                httpTest.ShouldHaveCalled("*/networks");
                Assert.NotNull(network);
                Assert.Equal(networkId, network.Id);
            }
        }
        public async void UpdateNetworkTest()
        {
            Network network = await _testData.CreateNetwork();

            var networkUpdate = new NetworkDefinition
            {
                Name = string.Format("{0}-updated", network.Name)
            };

            Trace.WriteLine("Updating the network...");
            network = await _networkingService.UpdateNetworkAsync(network.Id, networkUpdate);

            Trace.WriteLine("Verifying network was updated as requested...");
            Assert.NotNull(network);
            Assert.Equal(networkUpdate.Name, network.Name);
        }
        public async void UpdateNetworkTest()
        {
            Network network = await _testData.CreateNetwork();

            var networkUpdate = new NetworkDefinition
            {
                Name = string.Format("{0}-updated", network.Name)
            };

            Trace.WriteLine("Updating the network...");
            network = await _networkingService.UpdateNetworkAsync(network.Id, networkUpdate);

            Trace.WriteLine("Verifying network was updated as requested...");
            Assert.NotNull(network);
            Assert.Equal(networkUpdate.Name, network.Name);
        }
Example #11
0
        public void CreateNetwork()
        {
            using (var httpTest = new HttpTest())
            {
                Identifier networkId = Guid.NewGuid();
                httpTest.RespondWithJson(new Network {
                    Id = networkId
                });

                var definition = new NetworkDefinition();
                var network    = _cloudNetworkService.CreateNetwork(definition);

                httpTest.ShouldHaveCalled("*/networks");
                Assert.NotNull(network);
                Assert.Equal(networkId, network.Id);
            }
        }
 /// <inheritdoc cref="OpenStack.Synchronous.NetworkingServiceExtensions.UpdateNetwork"/>
 public static Network UpdateNetwork(this CloudNetworkService cloudNetworkService, Identifier networkId, NetworkDefinition network)
 {
     return cloudNetworkService.UpdateNetworkAsync(networkId, network).ForceSynchronous();
 }
 /// <inheritdoc cref="OpenStack.Synchronous.NetworkingServiceExtensions.CreateNetwork"/>
 public static Network CreateNetwork(this CloudNetworkService cloudNetworkService, NetworkDefinition network)
 {
     return cloudNetworkService.CreateNetworkAsync(network).ForceSynchronous();
 }