Skip to content

Commit

Permalink
Support network interface attributes (#824)
Browse files Browse the repository at this point in the history
  • Loading branch information
adracus authored Aug 15, 2023
1 parent c9aab5f commit 5c892ce
Show file tree
Hide file tree
Showing 21 changed files with 519 additions and 224 deletions.
2 changes: 2 additions & 0 deletions api/networking/v1alpha1/networkinterface_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ type NetworkInterfaceSpec struct {
Prefixes []PrefixSource `json:"prefixes,omitempty"`
// VirtualIP specifies the virtual ip that should be assigned to this NetworkInterface.
VirtualIP *VirtualIPSource `json:"virtualIP,omitempty"`
// Attributes are provider-specific attributes for the network interface.
Attributes map[string]string `json:"attributes,omitempty"`
}

// IPSource is the definition of how to obtain an IP.
Expand Down
7 changes: 7 additions & 0 deletions api/networking/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions broker/machinebroker/server/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,10 @@ func (s *Server) convertOnmetalNetworkInterfaceAttachment(
}

return &ori.NetworkInterface{
Name: onmetalMachineNic.Name,
NetworkId: onmetalNic.Network.Spec.ProviderID,
Ips: ips,
Name: onmetalMachineNic.Name,
NetworkId: onmetalNic.Network.Spec.ProviderID,
Ips: ips,
Attributes: onmetalNic.NetworkInterface.Spec.Attributes,
}, nil
default:
return nil, fmt.Errorf("unrecognized onmetal machine network interface %#v", onmetalMachineNic)
Expand Down
15 changes: 9 additions & 6 deletions broker/machinebroker/server/machine_networkinterface_attach.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@ import (
)

type OnmetalNetworkInterfaceConfig struct {
Name string
NetworkID string
IPs []commonv1alpha1.IP
Name string
NetworkID string
IPs []commonv1alpha1.IP
Attributes map[string]string
}

func (s *Server) getOnmetalNetworkInterfaceConfig(nic *ori.NetworkInterface) (*OnmetalNetworkInterfaceConfig, error) {
Expand All @@ -46,9 +47,10 @@ func (s *Server) getOnmetalNetworkInterfaceConfig(nic *ori.NetworkInterface) (*O
}

return &OnmetalNetworkInterfaceConfig{
Name: nic.Name,
NetworkID: nic.NetworkId,
IPs: ips,
Name: nic.Name,
NetworkID: nic.NetworkId,
IPs: ips,
Attributes: nic.Attributes,
}, nil
}

Expand Down Expand Up @@ -82,6 +84,7 @@ func (s *Server) createOnmetalNetworkInterface(
MachineRef: s.optionalLocalUIDReference(optOnmetalMachine),
IPFamilies: s.getOnmetalIPsIPFamilies(cfg.IPs),
IPs: s.onmetalIPsToOnmetalIPSources(cfg.IPs),
Attributes: cfg.Attributes,
},
}
log.V(1).Info("Creating onmetal network interface")
Expand Down
5 changes: 5 additions & 0 deletions client-go/applyconfigurations/internal/internal.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions client-go/openapi/zz_generated.openapi.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions docs/api-reference/core.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ ResourceQuotaStatus
</thead>
<tbody><tr><td><p>&#34;machine&#34;</p></td>
<td></td>
</tr><tr><td><p>&#34;volume&#34;</p></td>
<td></td>
</tr></tbody>
</table>
<h3 id="core.api.onmetal.de/v1alpha1.ObjectSelector">ObjectSelector
Expand Down
33 changes: 33 additions & 0 deletions docs/api-reference/networking.md
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,17 @@ VirtualIPSource
<p>VirtualIP specifies the virtual ip that should be assigned to this NetworkInterface.</p>
</td>
</tr>
<tr>
<td>
<code>attributes</code><br/>
<em>
map[string]string
</em>
</td>
<td>
<p>Attributes are provider-specific attributes for the network interface.</p>
</td>
</tr>
</table>
</td>
</tr>
Expand Down Expand Up @@ -1586,6 +1597,17 @@ VirtualIPSource
<p>VirtualIP specifies the virtual ip that should be assigned to this NetworkInterface.</p>
</td>
</tr>
<tr>
<td>
<code>attributes</code><br/>
<em>
map[string]string
</em>
</td>
<td>
<p>Attributes are provider-specific attributes for the network interface.</p>
</td>
</tr>
</tbody>
</table>
<h3 id="networking.api.onmetal.de/v1alpha1.NetworkInterfaceState">NetworkInterfaceState
Expand Down Expand Up @@ -1828,6 +1850,17 @@ VirtualIPSource
<p>VirtualIP specifies the virtual ip that should be assigned to this NetworkInterface.</p>
</td>
</tr>
<tr>
<td>
<code>attributes</code><br/>
<em>
map[string]string
</em>
</td>
<td>
<p>Attributes are provider-specific attributes for the network interface.</p>
</td>
</tr>
</table>
</td>
</tr>
Expand Down
8 changes: 4 additions & 4 deletions docs/api-reference/storage.md
Original file line number Diff line number Diff line change
Expand Up @@ -1630,28 +1630,28 @@ VolumePoolState
</tr>
<tr>
<td>
<code>available</code><br/>
<code>capacity</code><br/>
<em>
<a href="../core/#core.api.onmetal.de/v1alpha1.ResourceList">
github.com/onmetal/onmetal-api/api/core/v1alpha1.ResourceList
</a>
</em>
</td>
<td>
<p>Available list the available capacity of a VolumePool.</p>
<p>Capacity represents the total resources of a machine pool.</p>
</td>
</tr>
<tr>
<td>
<code>used</code><br/>
<code>allocatable</code><br/>
<em>
<a href="../core/#core.api.onmetal.de/v1alpha1.ResourceList">
github.com/onmetal/onmetal-api/api/core/v1alpha1.ResourceList
</a>
</em>
</td>
<td>
<p>Used indicates how much capacity has been used in a VolumePool.</p>
<p>Allocatable represents the resources of a machine pool that are available for scheduling.</p>
</td>
</tr>
</tbody>
Expand Down
25 changes: 16 additions & 9 deletions gen/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -87972,6 +87972,13 @@
"ips"
],
"properties": {
"attributes": {
"description": "Attributes are provider-specific attributes for the network interface.",
"type": "object",
"additionalProperties": {
"type": "string"
}
},
"ipFamilies": {
"description": "IPFamilies defines which IPFamilies this NetworkInterface is supporting",
"type": "array",
Expand Down Expand Up @@ -89241,8 +89248,8 @@
"description": "VolumePoolStatus defines the observed state of VolumePool",
"type": "object",
"properties": {
"available": {
"description": "Available list the available capacity of a VolumePool.",
"allocatable": {
"description": "Allocatable represents the resources of a machine pool that are available for scheduling.",
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/io.k8s.apimachinery.pkg.api.resource.Quantity"
Expand All @@ -89255,6 +89262,13 @@
"$ref": "#/definitions/io.k8s.api.core.v1.LocalObjectReference"
}
},
"capacity": {
"description": "Capacity represents the total resources of a machine pool.",
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/io.k8s.apimachinery.pkg.api.resource.Quantity"
}
},
"conditions": {
"type": "array",
"items": {
Expand All @@ -89263,13 +89277,6 @@
},
"state": {
"type": "string"
},
"used": {
"description": "Used indicates how much capacity has been used in a VolumePool.",
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/io.k8s.apimachinery.pkg.api.resource.Quantity"
}
}
}
},
Expand Down
8 changes: 8 additions & 0 deletions gen/v3/apis__compute.api.onmetal.de__v1alpha1_openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -5007,6 +5007,14 @@
"ips"
],
"properties": {
"attributes": {
"description": "Attributes are provider-specific attributes for the network interface.",
"type": "object",
"additionalProperties": {
"type": "string",
"default": ""
}
},
"ipFamilies": {
"description": "IPFamilies defines which IPFamilies this NetworkInterface is supporting",
"type": "array",
Expand Down
8 changes: 8 additions & 0 deletions gen/v3/apis__networking.api.onmetal.de__v1alpha1_openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -11664,6 +11664,14 @@
"ips"
],
"properties": {
"attributes": {
"description": "Attributes are provider-specific attributes for the network interface.",
"type": "object",
"additionalProperties": {
"type": "string",
"default": ""
}
},
"ipFamilies": {
"description": "IPFamilies defines which IPFamilies this NetworkInterface is supporting",
"type": "array",
Expand Down
28 changes: 14 additions & 14 deletions gen/v3/apis__storage.api.onmetal.de__v1alpha1_openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -8661,8 +8661,8 @@
"description": "VolumePoolStatus defines the observed state of VolumePool",
"type": "object",
"properties": {
"available": {
"description": "Available list the available capacity of a VolumePool.",
"allocatable": {
"description": "Allocatable represents the resources of a machine pool that are available for scheduling.",
"type": "object",
"additionalProperties": {
"default": {},
Expand All @@ -8685,31 +8685,31 @@
]
}
},
"conditions": {
"type": "array",
"items": {
"capacity": {
"description": "Capacity represents the total resources of a machine pool.",
"type": "object",
"additionalProperties": {
"default": {},
"allOf": [
{
"$ref": "#/components/schemas/com.github.onmetal.onmetal-api.api.storage.v1alpha1.VolumePoolCondition"
"$ref": "#/components/schemas/io.k8s.apimachinery.pkg.api.resource.Quantity"
}
]
}
},
"state": {
"type": "string"
},
"used": {
"description": "Used indicates how much capacity has been used in a VolumePool.",
"type": "object",
"additionalProperties": {
"conditions": {
"type": "array",
"items": {
"default": {},
"allOf": [
{
"$ref": "#/components/schemas/io.k8s.apimachinery.pkg.api.resource.Quantity"
"$ref": "#/components/schemas/com.github.onmetal.onmetal-api.api.storage.v1alpha1.VolumePoolCondition"
}
]
}
},
"state": {
"type": "string"
}
}
},
Expand Down
2 changes: 2 additions & 0 deletions internal/apis/networking/networkinterface_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ type NetworkInterfaceSpec struct {
Prefixes []PrefixSource
// VirtualIP specifies the virtual ip that should be assigned to this NetworkInterface.
VirtualIP *VirtualIPSource
// Attributes are provider-specific attributes for the network interface.
Attributes map[string]string
}

// IPSource is the definition of how to obtain an IP.
Expand Down
2 changes: 2 additions & 0 deletions internal/apis/networking/v1alpha1/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 5c892ce

Please sign in to comment.