Skip to content

Commit

Permalink
Add NTP and DNS server field to partition
Browse files Browse the repository at this point in the history
  • Loading branch information
simcod committed Oct 22, 2024
1 parent 9973d7c commit f57775b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions cmd/metal-api/internal/metal/partition.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions cmd/metal-api/internal/service/partition-service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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())
Expand Down
2 changes: 2 additions & 0 deletions cmd/metal-api/internal/service/v1/partition.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit f57775b

Please sign in to comment.