Skip to content

Add ReservedIpRanges support for DHCP Subnet #1132

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

lxiaopei
Copy link
Contributor

For DHCP Subnet, add support for user to set ReservedIpRanges.

@lxiaopei lxiaopei force-pushed the topic/xl018891/reserve-iprange branch from a6bfc22 to 17b59a0 Compare June 30, 2025 09:44
@codecov-commenter
Copy link

codecov-commenter commented Jun 30, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 73.05%. Comparing base (64f5857) to head (052da73).
Report is 3 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1132      +/-   ##
==========================================
- Coverage   73.88%   73.05%   -0.84%     
==========================================
  Files         137      137              
  Lines       21648    21678      +30     
==========================================
- Hits        15994    15836     -158     
- Misses       4650     4846     +196     
+ Partials     1004      996       -8     
Flag Coverage Δ
unit-tests 73.05% <100.00%> (-0.84%) ⬇️
Files with missing lines Coverage Δ
pkg/nsx/services/subnet/builder.go 86.04% <100.00%> (-2.71%) ⬇️
pkg/nsx/services/subnet/subnet.go 75.00% <100.00%> (+1.26%) ⬆️

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@lxiaopei lxiaopei force-pushed the topic/xl018891/reserve-iprange branch from 17b59a0 to 583109d Compare July 15, 2025 07:19
lxiaopei added 2 commits July 15, 2025 15:23
To support create DHCP static binding when creating NSX Subnet,
need to set reserved IP ranges in DHCPServerAdditionalConfig.
For DHCP Subnet, add support for user to set ReservedIpRanges.

Tests Done:
1. use below yaml to create DHCP Subnet with reservedIPRanges
apiVersion: crd.nsx.vmware.com/v1alpha1
kind: Subnet
metadata:
  name: subneta
spec:
  accessMode: Private
  ipAddresses:
  - 172.26.2.0/28
  subnetDHCPConfig:
    mode: DHCPServer
    dhcpServerAdditionalConfig:
      reservedIPRanges:
      - 172.26.2.4-172.26.2.10
2. check NSX Subnet created:
{
  "ipv4_subnet_size": 32,
  "access_mode": "Private",
  "ip_addresses": [
    "172.26.2.0/28"
  ],
  "advanced_config": {
    "static_ip_allocation": {
      "enabled": false
    },
    "connectivity_state": "CONNECTED",
    "gateway_addresses": [
      "172.26.2.1/28"
    ],
    "dhcp_server_addresses": [
      "172.26.2.2/28"
    ],
    "enable_vlan_extension": false
  },
  "ip_blocks": [
    "/orgs/default/projects/project-quality/infra/ip-blocks/test-exec-ns_ed74aab4-8f0c-4e24-821f-d673220cf1ec-172_26_0_0_16"
  ],
  "subnet_dhcp_config": {
    "mode": "DHCP_SERVER",
    "dhcp_server_additional_config": {
      "reserved_ip_ranges": [
        "172.26.2.4-172.26.2.10"
      ]
    }
  },
  "resource_type": "VpcSubnet",
  "id": "subneta_ade91574-9d72-48c7-bafa-e5eed0500fc6",
  "display_name": "subneta_ade91574-9d72-48c7-bafa-e5eed0500fc6",
  "tags": [
    {
      "scope": "nsx-op/cluster",
      "tag": "f1d7f5f7-8f11-416a-89d2-a0edba3bda24"
    },
    {
      "scope": "nsx-op/version",
      "tag": "1.0.0"
    },
    {
      "scope": "nsx-op/subnet_name",
      "tag": "subneta"
    },
    {
      "scope": "nsx-op/subnet_uid",
      "tag": "ade91574-9d72-48c7-bafa-e5eed0500fc6"
    },
    {
      "scope": "nsx/managed-by",
      "tag": "nsx-op"
    },
    {
      "scope": "nsx-op/vm_namespace_uid",
      "tag": "d1350b85-0406-4efd-868e-96f082f60b29"
    },
    {
      "scope": "nsx-op/vm_namespace",
      "tag": "test-exec-ns"
    },
    {
      "scope": "kubernetes.io/metadata.name",
      "tag": "test-exec-ns"
    },
    {
      "scope": "vSphereClusterID",
      "tag": "f1d7f5f7-8f11-416a-89d2-a0edba3bda24"
    }
  ],
  "path": "/orgs/default/projects/project-quality/vpcs/test-exec-ns_ed74aab4-8f0c-4e24-821f-d673220cf1ec/subnets/subneta_ade91574-9d72-48c7-bafa-e5eed0500fc6"
}
@lxiaopei lxiaopei force-pushed the topic/xl018891/reserve-iprange branch from 583109d to 052da73 Compare July 16, 2025 09:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants