Skip to content

Commit d2826e8

Browse files
committed
Allow setting floating IP description
Change-Id: If664bfe3c9fdcb69c7046eb16c5d32602d1b3262 Story: 2007439 Task: 39094
1 parent 8c4ecbe commit d2826e8

2 files changed

Lines changed: 34 additions & 0 deletions

File tree

openstackclient/network/v2/floating_ip.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,11 @@ def get_parser(self, prog_name):
412412
help=_("Fixed IP of the port "
413413
"(required only if port has multiple IPs)")
414414
)
415+
parser.add_argument(
416+
'--description',
417+
metavar='<description>',
418+
help=_('Set floating IP description')
419+
)
415420
qos_policy_group = parser.add_mutually_exclusive_group()
416421
qos_policy_group.add_argument(
417422
'--qos-policy',
@@ -443,6 +448,9 @@ def take_action(self, parsed_args):
443448
if parsed_args.fixed_ip_address:
444449
attrs['fixed_ip_address'] = parsed_args.fixed_ip_address
445450

451+
if parsed_args.description:
452+
attrs['description'] = parsed_args.description
453+
446454
if parsed_args.qos_policy:
447455
attrs['qos_policy_id'] = client.find_qos_policy(
448456
parsed_args.qos_policy, ignore_missing=False).id

openstackclient/tests/unit/network/v2/test_floating_ip_network.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -776,6 +776,32 @@ def test_fixed_ip_option(self):
776776
self.network.update_ip.assert_called_once_with(
777777
self.floating_ip, **attrs)
778778

779+
def test_description_option(self):
780+
arglist = [
781+
self.floating_ip.id,
782+
'--port', self.floating_ip.port_id,
783+
'--description', self.floating_ip.description,
784+
]
785+
verifylist = [
786+
('floating_ip', self.floating_ip.id),
787+
('port', self.floating_ip.port_id),
788+
('description', self.floating_ip.description),
789+
]
790+
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
791+
792+
self.cmd.take_action(parsed_args)
793+
794+
attrs = {
795+
'port_id': self.floating_ip.port_id,
796+
'description': self.floating_ip.description,
797+
}
798+
self.network.find_ip.assert_called_once_with(
799+
self.floating_ip.id,
800+
ignore_missing=False,
801+
)
802+
self.network.update_ip.assert_called_once_with(
803+
self.floating_ip, **attrs)
804+
779805
def test_qos_policy_option(self):
780806
qos_policy = network_fakes.FakeNetworkQosPolicy.create_one_qos_policy()
781807
self.network.find_qos_policy = mock.Mock(return_value=qos_policy)

0 commit comments

Comments
 (0)