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
This commit is contained in:
parent
70f1ff375a
commit
74a7c1d9d6
@ -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
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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.
|
||||
|
@ -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,
|
||||
|
@ -0,0 +1,6 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
Add a new option `--description` to
|
||||
``floating ip port forwarding create`` and
|
||||
``floating ip port forwarding set`` commands.
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user