Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions cmd/metal-api/internal/metal/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -378,17 +378,20 @@ func (ms Machines) WithRole(role Role) Machines {

// MachineNetwork stores the Network details of the machine
type MachineNetwork struct {
NetworkID string `rethinkdb:"networkid" json:"networkid"`
Prefixes []string `rethinkdb:"prefixes" json:"prefixes"`
IPs []string `rethinkdb:"ips" json:"ips"`
DestinationPrefixes []string `rethinkdb:"destinationprefixes" json:"destinationprefixes"`
Vrf uint `rethinkdb:"vrf" json:"vrf"`
PrivatePrimary bool `rethinkdb:"privateprimary" json:"privateprimary"`
Private bool `rethinkdb:"private" json:"private"`
ASN uint32 `rethinkdb:"asn" json:"asn"`
Nat bool `rethinkdb:"nat" json:"nat"`
Underlay bool `rethinkdb:"underlay" json:"underlay"`
Shared bool `rethinkdb:"shared" json:"shared"`
NetworkID string `rethinkdb:"networkid" json:"networkid"`
Prefixes []string `rethinkdb:"prefixes" json:"prefixes"`
IPs []string `rethinkdb:"ips" json:"ips"`
DestinationPrefixes []string `rethinkdb:"destinationprefixes" json:"destinationprefixes"`
Vrf uint `rethinkdb:"vrf" json:"vrf"`
PrivatePrimary bool `rethinkdb:"privateprimary" json:"privateprimary"`
Private bool `rethinkdb:"private" json:"private"`
ASN uint32 `rethinkdb:"asn" json:"asn"`
Nat bool `rethinkdb:"nat" json:"nat"`
Underlay bool `rethinkdb:"underlay" json:"underlay"`
Shared bool `rethinkdb:"shared" json:"shared"`
ProjectID string `rethinkdb:"projectid" json:"projectid"`
NetworkTypeV2 NetworkTypeV2 `rethinkdb:"networktype" json:"networktype"`
NATTypeV2 NATType `rethinkdb:"nattype" json:"nattype"`
}

// NetworkType represents the type of a network
Expand Down
3 changes: 3 additions & 0 deletions cmd/metal-api/internal/service/machine-service.go
Original file line number Diff line number Diff line change
Expand Up @@ -1714,6 +1714,9 @@ func makeMachineNetwork(ctx context.Context, ds *datastore.RethinkStore, ipamer
Underlay: n.networkType.Underlay,
Nat: n.network.Nat,
Vrf: n.network.Vrf,
ProjectID: n.network.ProjectID,
NetworkTypeV2: pointer.SafeDeref(n.network.NetworkType),
NATTypeV2: pointer.SafeDeref(n.network.NATType),
}

return &machineNetwork, nil
Expand Down
12 changes: 12 additions & 0 deletions cmd/metal-api/internal/service/v1/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@ type MachineNetwork struct {
//
// Deprecated: can be removed once old machine images without NetworkType are not supported anymore
Underlay bool `json:"underlay" description:"if set to true, this network can be used for underlay communication"`

// The following type are used to get forward compatibility with apiv2
// ProjectID is required to detect the new networktype
ProjectID string `json:"projectid" description:"project of this network, empty string if not project scoped"`
// NetworkTypeV2 is the apiv2 networktype
NetworkTypeV2 metal.NetworkTypeV2 `json:"networktypev2"`
// NatTypeV2 is the apiv2 nattype
NATTypeV2 metal.NATType `json:"nattypev2"`
}

type MachineHardwareBase struct {
Expand Down Expand Up @@ -555,6 +563,10 @@ func NewMachineResponse(m *metal.Machine, s *metal.Size, p *metal.Partition, i *
// FIXME: Both following fields are deprecated and for backward compatibility reasons only
Private: nt.Private,
Underlay: nt.Underlay,

ProjectID: nw.ProjectID,
NetworkTypeV2: nw.NetworkTypeV2,
NATTypeV2: nw.NATTypeV2,
}
networks = append(networks, network)
}
Expand Down
13 changes: 13 additions & 0 deletions spec/metal-api.json
Original file line number Diff line number Diff line change
Expand Up @@ -3258,6 +3258,9 @@
"description": "if set to true, packets leaving this network get masqueraded behind interface ip",
"type": "boolean"
},
"nattypev2": {
"type": "string"
},
"networkid": {
"description": "the networkID of the allocated machine in this vrf",
"type": "string"
Expand All @@ -3266,6 +3269,9 @@
"description": "the network type, types can be looked up in the network package of metal-lib",
"type": "string"
},
"networktypev2": {
"type": "string"
},
"prefixes": {
"description": "the prefixes of this network",
"items": {
Expand All @@ -3277,6 +3283,10 @@
"description": "indicates whether this network is the private network of this machine",
"type": "boolean"
},
"projectid": {
"description": "project of this network, empty string if not project scoped",
"type": "string"
},
"underlay": {
"description": "if set to true, this network can be used for underlay communication",
"type": "boolean"
Expand All @@ -3292,10 +3302,13 @@
"destinationprefixes",
"ips",
"nat",
"nattypev2",
"networkid",
"networktype",
"networktypev2",
"prefixes",
"private",
"projectid",
"underlay",
"vrf"
]
Expand Down
Loading