Skip to content

Commit 487e09e

Browse files
authored
Merge pull request #3578 from winiciusallan/update-mac-on-port
network.v2.Port: add support for update mac_address
2 parents af82f8f + 9b8dcd5 commit 487e09e

File tree

4 files changed

+11
-2
lines changed

4 files changed

+11
-2
lines changed

internal/acceptance/openstack/networking/v2/ports_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,11 @@ func TestPortsCRUD(t *testing.T) {
4545
// Update port
4646
newPortName := ""
4747
newPortDescription := ""
48+
newMACAddress := "aa:bb:cc:dd:ee:ff"
4849
updateOpts := ports.UpdateOpts{
4950
Name: &newPortName,
5051
Description: &newPortDescription,
52+
MACAddress: &newMACAddress,
5153
}
5254
newPort, err := ports.Update(context.TODO(), client, port.ID, updateOpts).Extract()
5355
th.AssertNoErr(t, err)
@@ -56,6 +58,7 @@ func TestPortsCRUD(t *testing.T) {
5658

5759
th.AssertEquals(t, newPort.Name, newPortName)
5860
th.AssertEquals(t, newPort.Description, newPortDescription)
61+
th.AssertEquals(t, newPort.MACAddress, newMACAddress)
5962

6063
allPages, err := ports.List(client, nil).AllPages(context.TODO())
6164
th.AssertNoErr(t, err)

openstack/networking/v2/ports/requests.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ type UpdateOpts struct {
197197
AllowedAddressPairs *[]AddressPair `json:"allowed_address_pairs,omitempty"`
198198
PropagateUplinkStatus *bool `json:"propagate_uplink_status,omitempty"`
199199
ValueSpecs *map[string]string `json:"value_specs,omitempty"`
200+
MACAddress *string `json:"mac_address,omitempty"`
200201

201202
// RevisionNumber implements extension:standard-attr-revisions. If != "" it
202203
// will set revision_number=%s. If the revision number does not match, the

openstack/networking/v2/ports/testing/fixtures.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,8 @@ const UpdateRequest = `
409409
],
410410
"security_groups": [
411411
"f0ac4394-7e4a-4409-9701-ba8be283dbc3"
412-
]
412+
],
413+
"mac_address": "fa:16:3e:c9:cb:f4"
413414
}
414415
}
415416
`
@@ -423,7 +424,7 @@ const UpdateResponse = `
423424
"network_id": "a87cc70a-3e15-4acf-8205-9b711a3531b7",
424425
"tenant_id": "d6700c0c9ffa4f1cb322cd4a1f3906fa",
425426
"device_owner": "",
426-
"mac_address": "fa:16:3e:c9:cb:f0",
427+
"mac_address": "fa:16:3e:c9:cb:f4",
427428
"fixed_ips": [
428429
{
429430
"subnet_id": "a0304c3a-4f08-4c43-88af-d796509c97d2",

openstack/networking/v2/ports/testing/requests_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,7 @@ func TestUpdate(t *testing.T) {
538538
})
539539

540540
name := "new_port_name"
541+
newMACAddress := "fa:16:3e:c9:cb:f4"
541542
options := ports.UpdateOpts{
542543
Name: &name,
543544
FixedIPs: []ports.IP{
@@ -547,6 +548,7 @@ func TestUpdate(t *testing.T) {
547548
AllowedAddressPairs: &[]ports.AddressPair{
548549
{IPAddress: "10.0.0.4", MACAddress: "fa:16:3e:c9:cb:f0"},
549550
},
551+
MACAddress: &newMACAddress,
550552
}
551553

552554
s, err := ports.Update(context.TODO(), fake.ServiceClient(fakeServer), "65c0ee9f-d634-4522-8954-51021b570b0d", options).Extract()
@@ -727,6 +729,7 @@ func TestUpdateRevision(t *testing.T) {
727729
})
728730

729731
name := "new_port_name"
732+
newMACAddress := "fa:16:3e:c9:cb:f4"
730733
options := ports.UpdateOpts{
731734
Name: &name,
732735
FixedIPs: []ports.IP{
@@ -736,6 +739,7 @@ func TestUpdateRevision(t *testing.T) {
736739
AllowedAddressPairs: &[]ports.AddressPair{
737740
{IPAddress: "10.0.0.4", MACAddress: "fa:16:3e:c9:cb:f0"},
738741
},
742+
MACAddress: &newMACAddress,
739743
}
740744
_, err := ports.Update(context.TODO(), fake.ServiceClient(fakeServer), "65c0ee9f-d634-4522-8954-51021b570b0d", options).Extract()
741745
th.AssertNoErr(t, err)

0 commit comments

Comments
 (0)