Skip to content

Commit 578cd12

Browse files
Jenkinsopenstack-gerrit
authored andcommitted
Merge "Add --description to Neutron commands"
2 parents b0750c7 + 0981931 commit 578cd12

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
@@ -654,6 +654,7 @@ def create_one_router(attrs=None):
654654
'name': 'router-name-' + uuid.uuid4().hex,
655655
'status': 'ACTIVE',
656656
'admin_state_up': True,
657+
'description': 'router-description-' + uuid.uuid4().hex,
657658
'distributed': False,
658659
'ha': False,
659660
'tenant_id': 'project-id-' + uuid.uuid4().hex,
@@ -973,6 +974,7 @@ def create_one_floating_ip(attrs=None):
973974
'router_id': 'router-id-' + uuid.uuid4().hex,
974975
'port_id': 'port-id-' + uuid.uuid4().hex,
975976
'tenant_id': 'project-id-' + uuid.uuid4().hex,
977+
'description': 'floating-ip-description-' + uuid.uuid4().hex,
976978
}
977979

978980
# 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
@@ -118,6 +118,7 @@ class TestCreateRouter(TestRouter):
118118
'admin_state_up',
119119
'availability_zone_hints',
120120
'availability_zones',
121+
'description',
121122
'distributed',
122123
'external_gateway_info',
123124
'ha',
@@ -131,6 +132,7 @@ class TestCreateRouter(TestRouter):
131132
router._format_admin_state(new_router.admin_state_up),
132133
osc_utils.format_list(new_router.availability_zone_hints),
133134
osc_utils.format_list(new_router.availability_zones),
135+
new_router.description,
134136
new_router.distributed,
135137
router._format_external_gateway_info(new_router.external_gateway_info),
136138
new_router.ha,
@@ -502,12 +504,14 @@ def test_set_this(self):
502504
'--enable',
503505
'--distributed',
504506
'--name', 'noob',
507+
'--description', 'router',
505508
]
506509
verifylist = [
507510
('router', self._router.name),
508511
('enable', True),
509512
('distributed', True),
510513
('name', 'noob'),
514+
('description', 'router'),
511515
]
512516

513517
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@@ -517,6 +521,7 @@ def test_set_this(self):
517521
'admin_state_up': True,
518522
'distributed': True,
519523
'name': 'noob',
524+
'description': 'router',
520525
}
521526
self.network.update_router.assert_called_once_with(
522527
self._router, **attrs)
@@ -680,6 +685,7 @@ class TestShowRouter(TestRouter):
680685
'admin_state_up',
681686
'availability_zone_hints',
682687
'availability_zones',
688+
'description',
683689
'distributed',
684690
'external_gateway_info',
685691
'ha',
@@ -693,6 +699,7 @@ class TestShowRouter(TestRouter):
693699
router._format_admin_state(_router.admin_state_up),
694700
osc_utils.format_list(_router.availability_zone_hints),
695701
osc_utils.format_list(_router.availability_zones),
702+
_router.description,
696703
_router.distributed,
697704
router._format_external_gateway_info(_router.external_gateway_info),
698705
_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)