From f57775b8ced7a194eee1a605ed60465985c852ee Mon Sep 17 00:00:00 2001 From: Simon Mayer Date: Tue, 22 Oct 2024 15:55:39 +0200 Subject: [PATCH] Add NTP and DNS server field to partition --- cmd/metal-api/internal/metal/partition.go | 2 ++ cmd/metal-api/internal/service/partition-service.go | 12 ++++++++++++ cmd/metal-api/internal/service/v1/partition.go | 2 ++ 3 files changed, 16 insertions(+) diff --git a/cmd/metal-api/internal/metal/partition.go b/cmd/metal-api/internal/metal/partition.go index 2db7c2f8a..288addc80 100644 --- a/cmd/metal-api/internal/metal/partition.go +++ b/cmd/metal-api/internal/metal/partition.go @@ -7,6 +7,8 @@ type Partition struct { MgmtServiceAddress string `rethinkdb:"mgmtserviceaddr" json:"mgmtserviceaddr"` PrivateNetworkPrefixLength uint8 `rethinkdb:"privatenetworkprefixlength" json:"privatenetworkprefixlength"` Labels map[string]string `rethinkdb:"labels" json:"labels"` + DNSServer DNSServers `rethinkdb:"dns_servers" json:"dns_servers"` + NTPServers NTPServers `rethinkdb:"ntp_servers" json:"ntp_servers"` } // BootConfiguration defines the metal-hammer initrd, kernel and commandline diff --git a/cmd/metal-api/internal/service/partition-service.go b/cmd/metal-api/internal/service/partition-service.go index 5f5dfd7ce..c43c25120 100644 --- a/cmd/metal-api/internal/service/partition-service.go +++ b/cmd/metal-api/internal/service/partition-service.go @@ -205,6 +205,16 @@ func (r *partitionResource) createPartition(request *restful.Request, response * commandLine = *requestPayload.PartitionBootConfiguration.CommandLine } + var dnsServers metal.DNSServers + if len(requestPayload.DNSServers) > 0 { + dnsServers = requestPayload.DNSServers + } + + var ntpServers metal.NTPServers + if len(requestPayload.NTPServers) > 0 { + ntpServers = requestPayload.NTPServers + } + p := &metal.Partition{ Base: metal.Base{ ID: requestPayload.ID, @@ -219,6 +229,8 @@ func (r *partitionResource) createPartition(request *restful.Request, response * KernelURL: kernelURL, CommandLine: commandLine, }, + DNSServer: dnsServers, + NTPServers: ntpServers, } fqn := metal.TopicMachine.GetFQN(p.GetID()) diff --git a/cmd/metal-api/internal/service/v1/partition.go b/cmd/metal-api/internal/service/v1/partition.go index f3304241f..10adf1358 100644 --- a/cmd/metal-api/internal/service/v1/partition.go +++ b/cmd/metal-api/internal/service/v1/partition.go @@ -20,6 +20,8 @@ type PartitionCreateRequest struct { Common PartitionBase PartitionBootConfiguration PartitionBootConfiguration `json:"bootconfig" description:"the boot configuration of this partition"` + DNSServers metal.DNSServers `json:"dns_servers" description:"the dns servers for this partition" optional:"true"` + NTPServers metal.NTPServers `json:"ntp_servers" description:"the ntp servers for this partition" optional:"true"` } type PartitionUpdateRequest struct {