lib/ruby_nsx_cli/nsx_objects/nsx_edge.rb
# Adds a DHCP IP pool agent to the specified edge
# This creates a simple dhcp pool as it only allows a small number of the available options to be specified
#
# @param edge_id [String] Edge ID to add the DHCP pool
# @param ip_range [String] Range of IP addresses to include in the DHCP pool. i.e. 192.168.10.2-192.168.10.62
# @param default_gateway [String] Default gateway for the network that the agent is providing DHCP to
# @param primary_name_server [String] Primary DNS
# @param secondary_name_server [String] Secondary DNS
# @param lease_time [Integer] DHCP lease time. Defaults to 3600
# @return [RestClient::Response] Response from the NSX API
Adds a DHCP IP pool agent to the specified edge
This creates a simple dhcp pool as it only allows a small number of the available options to be specified
Adds a DHCP IP pool agent to the specified edge This creates a simple dhcp pool as it only allows a small number of the available options to be specified
def add_simple_dhcp_pool(edge_id:, ip_range:, subnet_mask:, default_gateway:, domain_name:, primary_name_server:, secondary_name_server:, lease_time:)
      api_endpoint = "/api/4.0/edges/#{edge_id}/dhcp/config/ippools"
      simple_dhcp_pool_hash = {
          :ip_range => ip_range,
          :default_gateway => default_gateway,
          :subnet_mask => subnet_mask,
          :domain_name => domain_name,
          :primary_name_server => primary_name_server,
          :secondary_name_server => secondary_name_server,
          :lease_time => lease_time || 3600
      }
      validate_edge_args(simple_dhcp_pool_hash, edge_id)
      @logger.info("Checking if DHCP IP pool already exists on edge: #{edge_id}")
      if (ip_pool_id = check_simple_dhcp_pool_exists(edge_id, ip_range))
        @logger.info("Skipping DHCP IP Pool - already exists (edgeId: #{edge_id} ipRange: #{ip_range})")
        return ip_pool_id
      end
      simple_dhcp_pool_obj = OpenStruct.new(simple_dhcp_pool_hash)
      payload = render_template('/templates/dhcp/simple-dhcp-pool.xml.erb', simple_dhcp_pool_obj)
      post(:api_endpoint => api_endpoint, :payload => payload)
    end
def add_simple_dhcp_pool ( edge_id : , ip_range : , subnet_mask : , default_gateway : , domain_name : , primary_name_server : , secondary_name_server : , lease_time : ) api_endpoint = "/api/4.0/edges/#{edge_id}/dhcp/config/ippools" simple_dhcp_pool_hash = { :ip_range => ip_range , :default_gateway => default_gateway , :subnet_mask => subnet_mask , :domain_name => domain_name , :primary_name_server => primary_name_server , :secondary_name_server => secondary_name_server , :lease_time => lease_time || 3600 } validate_edge_args ( simple_dhcp_pool_hash , edge_id ) @logger . info ( "Checking if DHCP IP pool already exists on edge: #{edge_id}" ) if ( ip_pool_id = check_simple_dhcp_pool_exists ( edge_id , ip_range ) ) @logger . info ( "Skipping DHCP IP Pool - already exists (edgeId: #{edge_id} ipRange: #{ip_range})" ) return ip_pool_id end simple_dhcp_pool_obj = OpenStruct . new ( simple_dhcp_pool_hash ) payload = render_template ( '/templates/dhcp/simple-dhcp-pool.xml.erb' , simple_dhcp_pool_obj ) post ( :api_endpoint => api_endpoint , :payload => payload ) end
Adds a DHCP IP pool agent to the specified edge
This creates a simple dhcp pool as it only allows a small number of the available options to be specified
Adds a DHCP IP pool agent to the specified edge This creates a simple dhcp pool as it only allows a small number of the available options to be specified
Response from the NSX API
Response from the NSX API
RestClient::Response
edge_id
Edge ID to add the DHCP pool
Edge ID to add the DHCP pool
ip_range
Range of IP addresses to include in the DHCP pool. i.e.
Range of IP addresses to include in the DHCP pool . i . e .
subnet_mask
default_gateway
Default gateway for the network that the agent is providing DHCP to
Default gateway for the network that the agent is providing DHCP to
domain_name
primary_name_server
None
secondary_name_server
None
lease_time
DHCP lease time. Defaults to 3600
DHCP lease time . Defaults to 3600