Skip to content
This repository was archived by the owner on Aug 1, 2023. It is now read-only.

Commit 0447aca

Browse files
author
Travis Truman
committed
First cut at supporting optional allowed_address_pairs option for Neutron Port update operation
1 parent c70720d commit 0447aca

File tree

3 files changed

+24
-6
lines changed

3 files changed

+24
-6
lines changed

openstack/networking/v2/ports/requests.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -168,12 +168,13 @@ type UpdateOptsBuilder interface {
168168

169169
// UpdateOpts represents the attributes used when updating an existing port.
170170
type UpdateOpts struct {
171-
Name string
172-
AdminStateUp *bool
173-
FixedIPs interface{}
174-
DeviceID string
175-
DeviceOwner string
176-
SecurityGroups []string
171+
Name string
172+
AdminStateUp *bool
173+
FixedIPs interface{}
174+
DeviceID string
175+
DeviceOwner string
176+
SecurityGroups []string
177+
AllowedAddressPairs interface{}
177178
}
178179

179180
// ToPortUpdateMap casts an UpdateOpts struct to a map.
@@ -198,6 +199,9 @@ func (opts UpdateOpts) ToPortUpdateMap() (map[string]interface{}, error) {
198199
if opts.Name != "" {
199200
p["name"] = opts.Name
200201
}
202+
if opts.AllowedAddressPairs != nil {
203+
p["allowed_address_pairs"] = opts.AllowedAddressPairs
204+
}
201205

202206
return map[string]interface{}{"port": p}, nil
203207
}

openstack/networking/v2/ports/requests_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,12 @@ func TestUpdate(t *testing.T) {
251251
"subnet_id": "a0304c3a-4f08-4c43-88af-d796509c97d2",
252252
"ip_address": "10.0.0.3"
253253
}
254+
],
255+
"allowed_address_pairs": [
256+
{
257+
"ip_address": "10.0.0.4",
258+
"mac_address": "fa:16:3e:c9:cb:f0"
259+
}
254260
],
255261
"security_groups": [
256262
"f0ac4394-7e4a-4409-9701-ba8be283dbc3"
@@ -294,6 +300,9 @@ func TestUpdate(t *testing.T) {
294300
IP{SubnetID: "a0304c3a-4f08-4c43-88af-d796509c97d2", IPAddress: "10.0.0.3"},
295301
},
296302
SecurityGroups: []string{"f0ac4394-7e4a-4409-9701-ba8be283dbc3"},
303+
AllowedAddressPairs: []AddressPair{
304+
AddressPair{IPAddress: "10.0.0.4", MACAddress: "fa:16:3e:c9:cb:f0"},
305+
},
297306
}
298307

299308
s, err := Update(fake.ServiceClient(), "65c0ee9f-d634-4522-8954-51021b570b0d", options).Extract()

openstack/networking/v2/ports/results.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ type IP struct {
5151
IPAddress string `mapstructure:"ip_address" json:"ip_address,omitempty"`
5252
}
5353

54+
type AddressPair struct {
55+
IPAddress string `mapstructure:"ip_address" json:"ip_address,omitempty"`
56+
MACAddress string `mapstructure:"mac_address" json:"mac_address"`
57+
}
58+
5459
// Port represents a Neutron port. See package documentation for a top-level
5560
// description of what this is.
5661
type Port struct {

0 commit comments

Comments
 (0)