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
4 changes: 4 additions & 0 deletions cmd/metal-api/internal/service/v1/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ type NetworkImmutable struct {
VrfShared *bool `json:"vrfshared" description:"if set to true, given vrf can be used by multiple networks, which is sometimes useful for network partitioning (default: false)" optional:"true"`
ParentNetworkID *string `json:"parentnetworkid" description:"the id of the parent network" optional:"true"`
AdditionalAnnouncableCIDRs []string `json:"additionalAnnouncableCIDRs,omitempty" description:"list of cidrs which are added to the route maps per tenant private network, these are typically pod- and service cidrs, can only be set for private super networks"`
NetworkType *metal.NetworkTypeV2 `json:"networktype" description:"apiv2 network type"`
NATType *metal.NATType `json:"nattype" description:"apiv2 nat type"`
}

type NetworkConsumption struct {
Expand Down Expand Up @@ -133,6 +135,8 @@ func NewNetworkResponse(network *metal.Network, consumption *NetworkConsumption)
Vrf: &network.Vrf,
ParentNetworkID: parentNetworkID,
AdditionalAnnouncableCIDRs: network.AdditionalAnnouncableCIDRs,
NetworkType: network.NetworkType,
NATType: network.NATType,
},
Consumption: *consumption,
Timestamps: Timestamps{
Expand Down
43 changes: 43 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 Expand Up @@ -3831,6 +3844,14 @@
"description": "if set to true, packets leaving this ipv4 network get masqueraded behind interface ip",
"type": "boolean"
},
"nattype": {
"description": "apiv2 nat type",
"type": "string"
},
"networktype": {
"description": "apiv2 network type",
"type": "string"
},
"parentnetworkid": {
"description": "the id of the parent network",
"type": "string"
Expand Down Expand Up @@ -3876,6 +3897,8 @@
"destinationprefixes",
"id",
"nat",
"nattype",
"networktype",
"prefixes",
"privatesuper",
"underlay"
Expand Down Expand Up @@ -3966,6 +3989,14 @@
"description": "if set to true, packets leaving this ipv4 network get masqueraded behind interface ip",
"type": "boolean"
},
"nattype": {
"description": "apiv2 nat type",
"type": "string"
},
"networktype": {
"description": "apiv2 network type",
"type": "string"
},
"parentnetworkid": {
"description": "the id of the parent network",
"type": "string"
Expand Down Expand Up @@ -3998,6 +4029,8 @@
"required": [
"destinationprefixes",
"nat",
"nattype",
"networktype",
"prefixes",
"privatesuper",
"underlay"
Expand Down Expand Up @@ -4065,6 +4098,14 @@
"description": "if set to true, packets leaving this ipv4 network get masqueraded behind interface ip",
"type": "boolean"
},
"nattype": {
"description": "apiv2 nat type",
"type": "string"
},
"networktype": {
"description": "apiv2 network type",
"type": "string"
},
"parentnetworkid": {
"description": "the id of the parent network",
"type": "string"
Expand Down Expand Up @@ -4115,6 +4156,8 @@
"destinationprefixes",
"id",
"nat",
"nattype",
"networktype",
"prefixes",
"privatesuper",
"underlay",
Expand Down
Loading