Skip to content

Commit 0981931

Browse files
ankur-odlstevemar
authored andcommitted
Add --description to Neutron commands
Added simple option for floating ip description when creating a floating ip. Added option for create and set router as well. Partially Implements: blueprint neutron-client-descriptions Partially Implements: blueprint network-commands-options Change-Id: Ib8cd8af449e9ff33b980017b2527a6b196894a00
1 parent ccd2d65 commit 0981931

8 files changed

Lines changed: 60 additions & 2 deletions

File tree

doc/source/command-objects/floating-ip.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Create floating IP
1717
[--port <port>]
1818
[--floating-ip-address <floating-ip-address>]
1919
[--fixed-ip-address <fixed-ip-address>]
20+
[--description <description>]
2021
<network>
2122
2223
.. option:: --subnet <subnet>
@@ -39,6 +40,11 @@ Create floating IP
3940
Fixed IP address mapped to the floating IP
4041
*Network version 2 only*
4142

43+
.. option:: --description <description>
44+
45+
Set floating IP description
46+
*Network version 2 only*
47+
4248
.. describe:: <network>
4349

4450
Network to allocate floating IP from (name or ID)

doc/source/command-objects/router.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ Create new router
6464
[--project <project> [--project-domain <project-domain>]]
6565
[--enable | --disable]
6666
[--distributed]
67+
[--description <description>]
6768
[--availability-zone-hint <availability-zone>]
6869
<name>
6970
@@ -88,6 +89,10 @@ Create new router
8889
8990
Create a distributed router
9091
92+
.. option:: --description <description>
93+
94+
Set router description
95+
9196
.. option:: --availability-zone-hint <availability-zone>
9297
9398
Availability Zone in which to create this router
@@ -186,6 +191,7 @@ Set router properties
186191
[--name <name>]
187192
[--enable | --disable]
188193
[--distributed | --centralized]
194+
[--description <description>]
189195
[--route destination=<subnet>,gateway=<ip-address> | --no-route]
190196
<router>
191197
@@ -209,6 +215,10 @@ Set router properties
209215
210216
Set router to centralized mode (disabled router only)
211217
218+
.. option:: --description <description>
219+
220+
Set router description
221+
212222
.. option:: --route destination=<subnet>,gateway=<ip-address>
213223
214224
Routes associated with the router

openstackclient/network/v2/floating_ip.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ def _get_attrs(client_manager, parsed_args):
5555
if parsed_args.fixed_ip_address:
5656
attrs['fixed_ip_address'] = parsed_args.fixed_ip_address
5757

58+
if parsed_args.description is not None:
59+
attrs['description'] = parsed_args.description
60+
5861
return attrs
5962

6063

@@ -97,6 +100,11 @@ def update_parser_network(self, parser):
97100
dest='fixed_ip_address',
98101
help=_("Fixed IP address mapped to the floating IP")
99102
)
103+
parser.add_argument(
104+
'--description',
105+
metavar='<description>',
106+
help=_('Set floating IP description')
107+
)
100108
return parser
101109

102110
def take_action_network(self, client, parsed_args):

openstackclient/network/v2/router.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ def _get_attrs(client_manager, parsed_args):
8282
if ('availability_zone_hints' in parsed_args
8383
and parsed_args.availability_zone_hints is not None):
8484
attrs['availability_zone_hints'] = parsed_args.availability_zone_hints
85-
85+
if parsed_args.description is not None:
86+
attrs['description'] = parsed_args.description
8687
# "router set" command doesn't support setting project.
8788
if 'project' in parsed_args and parsed_args.project is not None:
8889
identity_client = client_manager.identity
@@ -179,6 +180,11 @@ def get_parser(self, prog_name):
179180
default=False,
180181
help=_("Create a distributed router")
181182
)
183+
parser.add_argument(
184+
'--description',
185+
metavar='<description>',
186+
help=_('Set router description')
187+
)
182188
parser.add_argument(
183189
'--project',
184190
metavar='<project>',
@@ -370,6 +376,11 @@ def get_parser(self, prog_name):
370376
metavar='<name>',
371377
help=_("Set router name")
372378
)
379+
parser.add_argument(
380+
'--description',
381+
metavar='<description>',
382+
help=_('Set router description')
383+
)
373384
admin_group = parser.add_mutually_exclusive_group()
374385
admin_group.add_argument(
375386
'--enable',

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -651,6 +651,7 @@ def create_one_router(attrs=None):
651651
'name': 'router-name-' + uuid.uuid4().hex,
652652
'status': 'ACTIVE',
653653
'admin_state_up': True,
654+
'description': 'router-description-' + uuid.uuid4().hex,
654655
'distributed': False,
655656
'ha': False,
656657
'tenant_id': 'project-id-' + uuid.uuid4().hex,
@@ -970,6 +971,7 @@ def create_one_floating_ip(attrs=None):
970971
'router_id': 'router-id-' + uuid.uuid4().hex,
971972
'port_id': 'port-id-' + uuid.uuid4().hex,
972973
'tenant_id': 'project-id-' + uuid.uuid4().hex,
974+
'description': 'floating-ip-description-' + uuid.uuid4().hex,
973975
}
974976

975977
# Overwrite default attributes.

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ class TestCreateFloatingIPNetwork(TestFloatingIPNetwork):
4949
)
5050

5151
columns = (
52+
'description',
5253
'dns_domain',
5354
'dns_name',
5455
'fixed_ip_address',
@@ -62,6 +63,7 @@ class TestCreateFloatingIPNetwork(TestFloatingIPNetwork):
6263
)
6364

6465
data = (
66+
floating_ip.description,
6567
floating_ip.dns_domain,
6668
floating_ip.dns_name,
6769
floating_ip.fixed_ip_address,
@@ -117,14 +119,16 @@ def test_create_all_options(self):
117119
'--port', self.floating_ip.port_id,
118120
'--floating-ip-address', self.floating_ip.floating_ip_address,
119121
'--fixed-ip-address', self.floating_ip.fixed_ip_address,
122+
'--description', self.floating_ip.description,
120123
self.floating_ip.floating_network_id,
121124
]
122125
verifylist = [
123126
('subnet', self.subnet.id),
124127
('port', self.floating_ip.port_id),
125-
('floating_ip_address', self.floating_ip.floating_ip_address),
126128
('fixed_ip_address', self.floating_ip.fixed_ip_address),
127129
('network', self.floating_ip.floating_network_id),
130+
('description', self.floating_ip.description),
131+
('floating_ip_address', self.floating_ip.floating_ip_address),
128132
]
129133
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
130134

@@ -136,6 +140,7 @@ def test_create_all_options(self):
136140
'floating_ip_address': self.floating_ip.floating_ip_address,
137141
'fixed_ip_address': self.floating_ip.fixed_ip_address,
138142
'floating_network_id': self.floating_ip.floating_network_id,
143+
'description': self.floating_ip.description,
139144
})
140145
self.assertEqual(self.columns, columns)
141146
self.assertEqual(self.data, data)
@@ -269,6 +274,7 @@ class TestShowFloatingIPNetwork(TestFloatingIPNetwork):
269274
floating_ip = network_fakes.FakeFloatingIP.create_one_floating_ip()
270275

271276
columns = (
277+
'description',
272278
'dns_domain',
273279
'dns_name',
274280
'fixed_ip_address',
@@ -282,6 +288,7 @@ class TestShowFloatingIPNetwork(TestFloatingIPNetwork):
282288
)
283289

284290
data = (
291+
floating_ip.description,
285292
floating_ip.dns_domain,
286293
floating_ip.dns_name,
287294
floating_ip.fixed_ip_address,

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ class TestCreateRouter(TestRouter):
119119
'admin_state_up',
120120
'availability_zone_hints',
121121
'availability_zones',
122+
'description',
122123
'distributed',
123124
'external_gateway_info',
124125
'ha',
@@ -132,6 +133,7 @@ class TestCreateRouter(TestRouter):
132133
router._format_admin_state(new_router.admin_state_up),
133134
osc_utils.format_list(new_router.availability_zone_hints),
134135
osc_utils.format_list(new_router.availability_zones),
136+
new_router.description,
135137
new_router.distributed,
136138
router._format_external_gateway_info(new_router.external_gateway_info),
137139
new_router.ha,
@@ -503,12 +505,14 @@ def test_set_this(self):
503505
'--enable',
504506
'--distributed',
505507
'--name', 'noob',
508+
'--description', 'router',
506509
]
507510
verifylist = [
508511
('router', self._router.name),
509512
('enable', True),
510513
('distributed', True),
511514
('name', 'noob'),
515+
('description', 'router'),
512516
]
513517

514518
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@@ -518,6 +522,7 @@ def test_set_this(self):
518522
'admin_state_up': True,
519523
'distributed': True,
520524
'name': 'noob',
525+
'description': 'router',
521526
}
522527
self.network.update_router.assert_called_once_with(
523528
self._router, **attrs)
@@ -681,6 +686,7 @@ class TestShowRouter(TestRouter):
681686
'admin_state_up',
682687
'availability_zone_hints',
683688
'availability_zones',
689+
'description',
684690
'distributed',
685691
'external_gateway_info',
686692
'ha',
@@ -694,6 +700,7 @@ class TestShowRouter(TestRouter):
694700
router._format_admin_state(_router.admin_state_up),
695701
osc_utils.format_list(_router.availability_zone_hints),
696702
osc_utils.format_list(_router.availability_zones),
703+
_router.description,
697704
_router.distributed,
698705
router._format_external_gateway_info(_router.external_gateway_info),
699706
_router.ha,
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
features:
3+
- |
4+
Add ``--description`` option for core network resources. Allows users to
5+
set a description for: ``floating ip create`` and ``router set/create``.
6+
[Blueprint :oscbp:`neutron-client-descriptions`]
7+
[Blueprint :oscbp:`network-commands-options`]

0 commit comments

Comments
 (0)