summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpedro <phpm13@gmail.com>2020-03-23 15:15:59 -0300
committerpedro <phpm13@gmail.com>2020-04-02 13:15:19 -0300
commit74a7c1d9d6efc545676cec1d9efeb2a86c5bc548 (patch)
tree28520d5d51b3dc9c2d86402c4cbe21112e674ceb
parent70f1ff375ac82f8231c259d9bb671293199d0f67 (diff)
downloadpython-openstackclient-74a7c1d9d6efc545676cec1d9efeb2a86c5bc548.tar.gz
Add description field to portforwarding NAT rules
Add the `description` field to Floating IP Port Forwardings Depends-On: https://review.opendev.org/#/c/705038/ Change-Id: I6477368e32570c96cacddba4f86455262e533277 Implements: blueprint portforwarding-description Closes-Bug: #1850818
-rw-r--r--lower-constraints.txt4
-rw-r--r--openstackclient/network/v2/floating_ip_port_forwarding.py20
-rw-r--r--openstackclient/tests/unit/network/v2/fakes.py1
-rw-r--r--openstackclient/tests/unit/network/v2/test_floating_ip_port_forwarding.py15
-rw-r--r--releasenotes/notes/add-description-field-in-port-forwarding-c536e077b243d517.yaml6
-rw-r--r--requirements.txt2
6 files changed, 44 insertions, 4 deletions
diff --git a/lower-constraints.txt b/lower-constraints.txt
index 83e19fe6..acf8d781 100644
--- a/lower-constraints.txt
+++ b/lower-constraints.txt
@@ -24,7 +24,7 @@ fixtures==3.0.0
flake8-import-order==0.13
flake8==2.6.2
future==0.16.0
-futurist==1.2.0
+futurist==2.1.0
gitdb==0.6.4
GitPython==1.0.1
gnocchiclient==3.3.1
@@ -50,7 +50,7 @@ msgpack-python==0.4.0
munch==2.1.0
netaddr==0.7.18
netifaces==0.10.4
-openstacksdk==0.38.0
+openstacksdk==0.44.0
os-client-config==1.28.0
os-service-types==1.7.0
os-testr==1.0.0
diff --git a/openstackclient/network/v2/floating_ip_port_forwarding.py b/openstackclient/network/v2/floating_ip_port_forwarding.py
index f94bcc06..06b3df8b 100644
--- a/openstackclient/network/v2/floating_ip_port_forwarding.py
+++ b/openstackclient/network/v2/floating_ip_port_forwarding.py
@@ -75,6 +75,12 @@ class CreateFloatingIPPortForwarding(command.ShowOne):
required=True,
help=_("The protocol used in the floating IP "
"port forwarding, for instance: TCP, UDP")
+ ),
+ parser.add_argument(
+ '--description',
+ metavar='<description>',
+ help=_("A text to describe/contextualize the use of the "
+ "port forwarding configuration")
)
parser.add_argument(
'floating_ip',
@@ -113,6 +119,9 @@ class CreateFloatingIPPortForwarding(command.ShowOne):
attrs['internal_ip_address'] = parsed_args.internal_ip_address
attrs['protocol'] = parsed_args.protocol
+ if parsed_args.description is not None:
+ attrs['description'] = parsed_args.description
+
obj = client.create_floating_ip_port_forwarding(
floating_ip.id,
**attrs
@@ -212,6 +221,7 @@ class ListFloatingIPPortForwarding(command.Lister):
'internal_port',
'external_port',
'protocol',
+ 'description',
)
headers = (
'ID',
@@ -220,6 +230,7 @@ class ListFloatingIPPortForwarding(command.Lister):
'Internal Port',
'External Port',
'Protocol',
+ 'Description',
)
query = {}
@@ -296,6 +307,12 @@ class SetFloatingIPPortForwarding(command.Command):
metavar='<protocol>',
choices=['tcp', 'udp'],
help=_("The IP protocol used in the floating IP port forwarding")
+ ),
+ parser.add_argument(
+ '--description',
+ metavar='<description>',
+ help=_("A text to describe/contextualize the use of "
+ "the port forwarding configuration")
)
return parser
@@ -332,6 +349,9 @@ class SetFloatingIPPortForwarding(command.Command):
if parsed_args.protocol:
attrs['protocol'] = parsed_args.protocol
+ if parsed_args.description is not None:
+ attrs['description'] = parsed_args.description
+
client.update_floating_ip_port_forwarding(
floating_ip.id, parsed_args.port_forwarding_id, **attrs)
diff --git a/openstackclient/tests/unit/network/v2/fakes.py b/openstackclient/tests/unit/network/v2/fakes.py
index a553f501..cc598834 100644
--- a/openstackclient/tests/unit/network/v2/fakes.py
+++ b/openstackclient/tests/unit/network/v2/fakes.py
@@ -1843,6 +1843,7 @@ class FakeFloatingIPPortForwarding(object):
'internal_port': randint(1, 65535),
'external_port': randint(1, 65535),
'protocol': 'tcp',
+ 'description': 'some description',
}
# Overwrite default attributes.
diff --git a/openstackclient/tests/unit/network/v2/test_floating_ip_port_forwarding.py b/openstackclient/tests/unit/network/v2/test_floating_ip_port_forwarding.py
index ea6cdd26..1028c18a 100644
--- a/openstackclient/tests/unit/network/v2/test_floating_ip_port_forwarding.py
+++ b/openstackclient/tests/unit/network/v2/test_floating_ip_port_forwarding.py
@@ -62,6 +62,7 @@ class TestCreateFloatingIPPortForwarding(TestFloatingIPPortForwarding):
self.app, self.namespace)
self.columns = (
+ 'description',
'external_port',
'floatingip_id',
'id',
@@ -73,6 +74,7 @@ class TestCreateFloatingIPPortForwarding(TestFloatingIPPortForwarding):
)
self.data = (
+ self.new_port_forwarding.description,
self.new_port_forwarding.external_port,
self.new_port_forwarding.floatingip_id,
self.new_port_forwarding.id,
@@ -102,6 +104,8 @@ class TestCreateFloatingIPPortForwarding(TestFloatingIPPortForwarding):
self.new_port_forwarding.floatingip_id,
'--internal-ip-address',
self.new_port_forwarding.internal_ip_address,
+ '--description',
+ self.new_port_forwarding.description,
]
verifylist = [
('port', self.new_port_forwarding.internal_port_id),
@@ -111,6 +115,7 @@ class TestCreateFloatingIPPortForwarding(TestFloatingIPPortForwarding):
('floating_ip', self.new_port_forwarding.floatingip_id),
('internal_ip_address', self.new_port_forwarding.
internal_ip_address),
+ ('description', self.new_port_forwarding.description),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
columns, data = self.cmd.take_action(parsed_args)
@@ -126,6 +131,7 @@ class TestCreateFloatingIPPortForwarding(TestFloatingIPPortForwarding):
'internal_port_id': self.new_port_forwarding.
internal_port_id,
'protocol': self.new_port_forwarding.protocol,
+ 'description': self.new_port_forwarding.description,
})
self.assertEqual(self.columns, columns)
self.assertEqual(self.data, data)
@@ -251,7 +257,8 @@ class TestListFloatingIPPortForwarding(TestFloatingIPPortForwarding):
'Internal IP Address',
'Internal Port',
'External Port',
- 'Protocol'
+ 'Protocol',
+ 'Description',
)
def setUp(self):
@@ -273,6 +280,7 @@ class TestListFloatingIPPortForwarding(TestFloatingIPPortForwarding):
port_forwarding.internal_port,
port_forwarding.external_port,
port_forwarding.protocol,
+ port_forwarding.description,
))
self.network.floating_ip_port_forwardings = mock.Mock(
return_value=self.port_forwardings
@@ -393,6 +401,7 @@ class TestSetFloatingIPPortForwarding(TestFloatingIPPortForwarding):
'--internal-protocol-port', '100',
'--external-protocol-port', '200',
'--protocol', 'tcp',
+ '--description', 'some description',
self._port_forwarding.floatingip_id,
self._port_forwarding.id,
]
@@ -402,6 +411,7 @@ class TestSetFloatingIPPortForwarding(TestFloatingIPPortForwarding):
('internal_protocol_port', 100),
('external_protocol_port', 200),
('protocol', 'tcp'),
+ ('description', 'some description'),
('floating_ip', self._port_forwarding.floatingip_id),
('port_forwarding_id', self._port_forwarding.id),
]
@@ -415,6 +425,7 @@ class TestSetFloatingIPPortForwarding(TestFloatingIPPortForwarding):
'internal_port': 100,
'external_port': 200,
'protocol': 'tcp',
+ 'description': 'some description',
}
self.network.update_floating_ip_port_forwarding.assert_called_with(
self._port_forwarding.floatingip_id,
@@ -428,6 +439,7 @@ class TestShowFloatingIPPortForwarding(TestFloatingIPPortForwarding):
# The port forwarding to show.
columns = (
+ 'description',
'external_port',
'floatingip_id',
'id',
@@ -450,6 +462,7 @@ class TestShowFloatingIPPortForwarding(TestFloatingIPPortForwarding):
)
)
self.data = (
+ self._port_forwarding.description,
self._port_forwarding.external_port,
self._port_forwarding.floatingip_id,
self._port_forwarding.id,
diff --git a/releasenotes/notes/add-description-field-in-port-forwarding-c536e077b243d517.yaml b/releasenotes/notes/add-description-field-in-port-forwarding-c536e077b243d517.yaml
new file mode 100644
index 00000000..6df5bb3a
--- /dev/null
+++ b/releasenotes/notes/add-description-field-in-port-forwarding-c536e077b243d517.yaml
@@ -0,0 +1,6 @@
+---
+features:
+ - |
+ Add a new option `--description` to
+ ``floating ip port forwarding create`` and
+ ``floating ip port forwarding set`` commands.
diff --git a/requirements.txt b/requirements.txt
index f7a12dae..b6f97b4d 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -6,7 +6,7 @@ six>=1.10.0 # MIT
Babel!=2.4.0,>=2.3.4 # BSD
cliff!=2.9.0,>=2.8.0 # Apache-2.0
-openstacksdk>=0.38.0 # Apache-2.0
+openstacksdk>=0.44.0 # Apache-2.0
osc-lib>=2.0.0 # Apache-2.0
oslo.i18n>=3.15.3 # Apache-2.0
oslo.utils>=3.33.0 # Apache-2.0