Skip to content

Commit 67fdd10

Browse files
authored
Merge pull request #618 from winiciusallan/port-macaddress
Port: add MACAddress field
2 parents d6300a3 + 28691b3 commit 67fdd10

14 files changed

Lines changed: 66 additions & 3 deletions

File tree

api/v1alpha1/port_types.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ type PortFilter struct {
4141
// +optional
4242
AdminStateUp *bool `json:"adminStateUp,omitempty"`
4343

44+
// macAddress is the MAC address of the port.
45+
// +kubebuilder:validation:MaxLength=32
46+
// +optional
47+
MACAddress string `json:"macAddress,omitempty"`
48+
4449
FilterByNeutronTags `json:",inline"`
4550
}
4651

@@ -170,6 +175,11 @@ type PortResourceSpec struct {
170175
// +optional
171176
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="projectRef is immutable"
172177
ProjectRef *KubernetesNameRef `json:"projectRef,omitempty"`
178+
179+
// macAddress is the MAC address of the port.
180+
// +kubebuilder:validation:MaxLength=32
181+
// +optional
182+
MACAddress string `json:"macAddress,omitempty"`
173183
}
174184

175185
type PortResourceStatus struct {

cmd/models-schema/zz_generated.openapi.go

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/openstack.k-orc.cloud_ports.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@ spec:
105105
maxLength: 255
106106
minLength: 1
107107
type: string
108+
macAddress:
109+
description: macAddress is the MAC address of the port.
110+
maxLength: 32
111+
type: string
108112
name:
109113
description: name of the existing resource
110114
maxLength: 255
@@ -294,6 +298,10 @@ spec:
294298
maxLength: 255
295299
minLength: 1
296300
type: string
301+
macAddress:
302+
description: macAddress is the MAC address of the port.
303+
maxLength: 32
304+
type: string
297305
name:
298306
description: name is a human-readable name of the port. If not
299307
set, the object's name will be used.

internal/controllers/port/actuator.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ func (actuator portActuator) ListOSResourcesForImport(ctx context.Context, obj o
141141
NotTags: tags.Join(filter.NotTags),
142142
NotTagsAny: tags.Join(filter.NotTagsAny),
143143
AdminStateUp: filter.AdminStateUp,
144+
MACAddress: filter.MACAddress,
144145
}
145146

146147
return actuator.osClient.ListPort(ctx, listOpts), nil
@@ -197,6 +198,7 @@ func (actuator portActuator) CreateResource(ctx context.Context, obj *orcv1alpha
197198
Description: string(ptr.Deref(resource.Description, "")),
198199
ProjectID: projectID,
199200
AdminStateUp: resource.AdminStateUp,
201+
MACAddress: resource.MACAddress,
200202
}
201203

202204
if len(resource.AllowedAddressPairs) > 0 {

internal/controllers/port/status.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,7 @@ func (portStatusWriter) ApplyResourceStatus(log logr.Logger, osResource *osResou
7272
WithPortSecurityEnabled(osResource.PortSecurityEnabled).
7373
WithRevisionNumber(int64(osResource.RevisionNumber)).
7474
WithCreatedAt(metav1.NewTime(osResource.CreatedAt)).
75-
WithUpdatedAt(metav1.NewTime(osResource.UpdatedAt)).
76-
WithAdminStateUp(osResource.AdminStateUp)
75+
WithUpdatedAt(metav1.NewTime(osResource.UpdatedAt))
7776

7877
if osResource.Description != "" {
7978
resourceStatus.WithDescription(osResource.Description)

internal/controllers/port/tests/port-create-full/00-assert.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ status:
1515
propagateUplinkStatus: false
1616
status: DOWN
1717
vnicType: direct
18+
macAddress: fa:16:3e:23:fd:d7
1819
tags:
1920
- tag1
2021
---
@@ -41,7 +42,6 @@ assertAll:
4142
- celExpr: "port.status.id != ''"
4243
- celExpr: "port.status.resource.createdAt != ''"
4344
- celExpr: "port.status.resource.updatedAt != ''"
44-
- celExpr: "port.status.resource.macAddress != ''"
4545
- celExpr: "port.status.resource.revisionNumber > 0"
4646
- celExpr: "port.status.resource.fixedIPs[0].subnetID == subnet.status.id"
4747
- celExpr: "port.status.resource.fixedIPs[0].ip == '192.168.155.122'"

internal/controllers/port/tests/port-create-full/00-create-resource.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,3 +84,4 @@ spec:
8484
portSecurity: Enabled
8585
vnicType: direct
8686
projectRef: port-create-full
87+
macAddress: fa:16:3e:23:fd:d7

internal/controllers/port/tests/port-import/00-import-resource.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@ spec:
1313
name: port-import-external
1414
description: Port from "port-import" test
1515
adminStateUp: false
16+
macAddress: fa:16:3e:23:fd:d7
1617
tags:
1718
- tag1

internal/controllers/port/tests/port-import/02-assert.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,6 @@ status:
3131
name: port-import-external
3232
description: Port from "port-import" test
3333
adminStateUp: false
34+
macAddress: fa:16:3e:23:fd:d7
3435
tags:
3536
- tag1

internal/controllers/port/tests/port-import/02-create-resource.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@ spec:
1212
networkRef: port-import
1313
description: Port from "port-import" test
1414
adminStateUp: false
15+
macAddress: fa:16:3e:23:fd:d7
1516
tags:
1617
- tag1

0 commit comments

Comments
 (0)