Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4a9860c

Browse filesBrowse files
authored
[neutron]: introduce Description argument for the portforwarding
1 parent 71268a5 commit 4a9860c
Copy full SHA for 4a9860c

File tree

4 files changed

+18
-11
lines changed
Filter options

4 files changed

+18
-11
lines changed

‎internal/acceptance/openstack/networking/v2/extensions/layer3/layer3.go

Copy file name to clipboardExpand all lines: internal/acceptance/openstack/networking/v2/extensions/layer3/layer3.go
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,9 @@ func CreatePortForwarding(t *testing.T, client *gophercloud.ServiceClient, fipID
7575

7676
fixedIP := portFixedIPs[0]
7777
internalIP := fixedIP.IPAddress
78+
pfDescription := "Test description"
7879
createOpts := &portforwarding.CreateOpts{
80+
Description: pfDescription,
7981
Protocol: "tcp",
8082
InternalPort: 25,
8183
ExternalPort: 2230,

‎internal/acceptance/openstack/networking/v2/extensions/layer3/portforwardings_test.go

Copy file name to clipboardExpand all lines: internal/acceptance/openstack/networking/v2/extensions/layer3/portforwardings_test.go
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,15 @@ func TestLayer3PortForwardingsCreateDelete(t *testing.T) {
5656

5757
pf, err := CreatePortForwarding(t, client, fip.ID, port.ID, port.FixedIPs)
5858
th.AssertNoErr(t, err)
59+
th.AssertEquals(t, pf.Description, "Test description")
5960
defer DeletePortForwarding(t, client, fip.ID, pf.ID)
6061
tools.PrintResource(t, pf)
6162

6263
newPf, err := portforwarding.Get(context.TODO(), client, fip.ID, pf.ID).Extract()
6364
th.AssertNoErr(t, err)
6465

6566
updateOpts := portforwarding.UpdateOpts{
67+
Description: new(string),
6668
Protocol: "udp",
6769
InternalPort: 30,
6870
ExternalPort: 678,
@@ -73,6 +75,7 @@ func TestLayer3PortForwardingsCreateDelete(t *testing.T) {
7375

7476
newPf, err = portforwarding.Get(context.TODO(), client, fip.ID, pf.ID).Extract()
7577
th.AssertNoErr(t, err)
78+
th.AssertEquals(t, newPf.Description, "")
7679

7780
allPages, err := portforwarding.List(client, portforwarding.ListOpts{}, fip.ID).AllPages(context.TODO())
7881
th.AssertNoErr(t, err)

‎openstack/networking/v2/extensions/layer3/portforwarding/requests.go

Copy file name to clipboardExpand all lines: openstack/networking/v2/extensions/layer3/portforwarding/requests.go
+9-11Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ type ListOptsBuilder interface {
1818
// either `asc' or `desc'. Marker and Limit are used for pagination.
1919
type ListOpts struct {
2020
ID string `q:"id"`
21+
Description string `q:"description"`
2122
InternalPortID string `q:"internal_port_id"`
2223
ExternalPort string `q:"external_port"`
2324
InternalIPAddress string `q:"internal_ip_address"`
@@ -63,6 +64,7 @@ func Get(ctx context.Context, c *gophercloud.ServiceClient, floatingIpId string,
6364
// CreateOpts contains all the values needed to create a new port forwarding
6465
// resource. All attributes are required.
6566
type CreateOpts struct {
67+
Description string `json:"description,omitempty"`
6668
InternalPortID string `json:"internal_port_id"`
6769
InternalIPAddress string `json:"internal_ip_address"`
6870
InternalPort int `json:"internal_port"`
@@ -97,22 +99,18 @@ func Create(ctx context.Context, c *gophercloud.ServiceClient, floatingIpId stri
9799

98100
// UpdateOpts contains the values used when updating a port forwarding resource.
99101
type UpdateOpts struct {
100-
InternalPortID string `json:"internal_port_id,omitempty"`
101-
InternalIPAddress string `json:"internal_ip_address,omitempty"`
102-
InternalPort int `json:"internal_port,omitempty"`
103-
ExternalPort int `json:"external_port,omitempty"`
104-
Protocol string `json:"protocol,omitempty"`
102+
Description *string `json:"description,omitempty"`
103+
InternalPortID string `json:"internal_port_id,omitempty"`
104+
InternalIPAddress string `json:"internal_ip_address,omitempty"`
105+
InternalPort int `json:"internal_port,omitempty"`
106+
ExternalPort int `json:"external_port,omitempty"`
107+
Protocol string `json:"protocol,omitempty"`
105108
}
106109

107110
// ToPortForwardingUpdateMap allows UpdateOpts to satisfy the UpdateOptsBuilder
108111
// interface
109112
func (opts UpdateOpts) ToPortForwardingUpdateMap() (map[string]any, error) {
110-
b, err := gophercloud.BuildRequestBody(opts, "port_forwarding")
111-
if err != nil {
112-
return nil, err
113-
}
114-
115-
return b, nil
113+
return gophercloud.BuildRequestBody(opts, "port_forwarding")
116114
}
117115

118116
// UpdateOptsBuilder allows extensions to add additional parameters to the

‎openstack/networking/v2/extensions/layer3/portforwarding/results.go

Copy file name to clipboardExpand all lines: openstack/networking/v2/extensions/layer3/portforwarding/results.go
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ type PortForwarding struct {
99
// The ID of the floating IP port forwarding
1010
ID string `json:"id"`
1111

12+
// A text describing the rule, which helps users to manage/find easily
13+
// theirs rules.
14+
Description string `json:"description"`
15+
1216
// The ID of the Neutron port associated to the floating IP port forwarding.
1317
InternalPortID string `json:"internal_port_id"`
1418

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.