コード例 #1
0
ファイル: NetworkManager.cs プロジェクト: renatotkr/Platform
        public async Task <SubnetInfo> GetSubnetAsync(ResourceProvider provider, string subnetId)
        {
            var subnet = await subnetService.FindAsync(provider, subnetId);;

            if (subnet == null)
            {
                var awsSubnet = await ec2Client.DescribeSubnetAsync(subnetId)
                                ?? throw ResourceError.NotFound(Aws, ResourceTypes.Subnet, subnetId);

                var location = Locations.Get(Aws, awsSubnet.AvailabilityZone);

                var network = await networkService.GetAsync(Aws, awsSubnet.VpcId);;

                var createRequest = new RegisterSubnetRequest(
                    addressBlocks: new[] { awsSubnet.CidrBlock },
                    networkId: network.Id,
                    resource: ManagedResource.Subnet(location, awsSubnet.SubnetId)
                    );

                // TODO: Include the ipv6 address blocks

                // Register the subnet with the platform
                subnet = await subnetService.RegisterAsync(createRequest);;
            }

            return(subnet);
        }
コード例 #2
0
ファイル: SubnetService.cs プロジェクト: renatotkr/Platform
        public async Task <SubnetInfo> RegisterAsync(RegisterSubnetRequest request)
        {
            Ensure.Object(request, nameof(request)); // Validate the request

            // TODO: Get subnetCount from network?

            var subnet = new SubnetInfo(
                id: await db.Subnets.GetNextScopedIdAsync(request.NetworkId),
                addressBlocks: request.AddressBlocks,
                resource: request.Resource
                );

            await db.Subnets.InsertAsync(subnet);

            return(subnet);
        }