Skip to content

Commit 43f6b95

Browse files
Jenkinsopenstack-gerrit
authored andcommitted
Merge "Add --description to Create/Set Network"
2 parents a83f3c8 + 88be7dd commit 43f6b95

4 files changed

Lines changed: 37 additions & 0 deletions

File tree

doc/source/command-objects/network.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Create new network
2323
[--project <project> [--project-domain <project-domain>]]
2424
[--enable | --disable]
2525
[--share | --no-share]
26+
[--description <description>]
2627
[--availability-zone-hint <availability-zone>]
2728
[--enable-port-security | --disable-port-security]
2829
[--external [--default | --no-default] | --internal]
@@ -65,6 +66,10 @@ Create new network
6566
6667
Do not share the network between projects
6768
69+
.. option:: --description <description>
70+
71+
Set network description
72+
6873
.. option:: --availability-zone-hint <availability-zone>
6974
7075
Availability Zone in which to create this network
@@ -206,6 +211,7 @@ Set network properties
206211
[--name <name>]
207212
[--enable | --disable]
208213
[--share | --no-share]
214+
[--description <description>]
209215
[--enable-port-security | --disable-port-security]
210216
[--external [--default | --no-default] | --internal]
211217
[--provider-network-type <provider-network-type>]
@@ -234,6 +240,10 @@ Set network properties
234240
235241
Do not share the network between projects
236242
243+
.. option:: --description <description>
244+
245+
Set network description
246+
237247
.. option:: --enable-port-security
238248
239249
Enable port security by default for ports created on

openstackclient/network/v2/network.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ def _get_attrs(client_manager, parsed_args):
7878
parsed_args.availability_zone_hints is not None:
7979
attrs['availability_zone_hints'] = parsed_args.availability_zone_hints
8080

81+
# set description
82+
if parsed_args.description:
83+
attrs['description'] = parsed_args.description
84+
8185
# update_external_network_options
8286
if parsed_args.internal:
8387
attrs['router:external'] = False
@@ -191,6 +195,11 @@ def update_parser_network(self, parser):
191195
metavar='<project>',
192196
help=_("Owner's project (name or ID)")
193197
)
198+
parser.add_argument(
199+
'--description',
200+
metavar='<description>',
201+
help=_("Set network description")
202+
)
194203
identity_common.add_project_domain_option_to_parser(parser)
195204
parser.add_argument(
196205
'--availability-zone-hint',
@@ -420,6 +429,11 @@ def get_parser(self, prog_name):
420429
action='store_true',
421430
help=_("Do not share the network between projects")
422431
)
432+
parser.add_argument(
433+
'--description',
434+
metavar="<description",
435+
help=_("Set network description")
436+
)
423437
port_security_group = parser.add_mutually_exclusive_group()
424438
port_security_group.add_argument(
425439
'--enable-port-security',

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ def create_one_network(attrs=None):
285285
'id': 'network-id-' + uuid.uuid4().hex,
286286
'name': 'network-name-' + uuid.uuid4().hex,
287287
'status': 'ACTIVE',
288+
'description': 'network-description-' + uuid.uuid4().hex,
288289
'tenant_id': 'project-id-' + uuid.uuid4().hex,
289290
'admin_state_up': True,
290291
'shared': False,

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ class TestCreateNetworkIdentityV3(TestNetwork):
5757
'admin_state_up',
5858
'availability_zone_hints',
5959
'availability_zones',
60+
'description',
6061
'id',
6162
'is_default',
6263
'name',
@@ -73,6 +74,7 @@ class TestCreateNetworkIdentityV3(TestNetwork):
7374
network._format_admin_state(_network.admin_state_up),
7475
utils.format_list(_network.availability_zone_hints),
7576
utils.format_list(_network.availability_zones),
77+
_network.description,
7678
_network.id,
7779
_network.is_default,
7880
_network.name,
@@ -129,6 +131,7 @@ def test_create_all_options(self):
129131
arglist = [
130132
"--disable",
131133
"--share",
134+
"--description", self._network.description,
132135
"--project", self.project.name,
133136
"--project-domain", self.domain.name,
134137
"--availability-zone-hint", "nova",
@@ -143,6 +146,7 @@ def test_create_all_options(self):
143146
verifylist = [
144147
('disable', True),
145148
('share', True),
149+
('description', self._network.description),
146150
('project', self.project.name),
147151
('project_domain', self.domain.name),
148152
('availability_zone_hints', ["nova"]),
@@ -164,6 +168,7 @@ def test_create_all_options(self):
164168
'availability_zone_hints': ["nova"],
165169
'name': self._network.name,
166170
'shared': True,
171+
'description': self._network.description,
167172
'tenant_id': self.project.id,
168173
'is_default': True,
169174
'router:external': True,
@@ -216,6 +221,7 @@ class TestCreateNetworkIdentityV2(TestNetwork):
216221
'admin_state_up',
217222
'availability_zone_hints',
218223
'availability_zones',
224+
'description',
219225
'id',
220226
'is_default',
221227
'name',
@@ -232,6 +238,7 @@ class TestCreateNetworkIdentityV2(TestNetwork):
232238
network._format_admin_state(_network.admin_state_up),
233239
utils.format_list(_network.availability_zone_hints),
234240
utils.format_list(_network.availability_zones),
241+
_network.description,
235242
_network.id,
236243
_network.is_default,
237244
_network.name,
@@ -532,6 +539,7 @@ def test_set_this(self):
532539
'--enable',
533540
'--name', 'noob',
534541
'--share',
542+
'--description', self._network.description,
535543
'--external',
536544
'--default',
537545
'--provider-network-type', 'vlan',
@@ -543,6 +551,7 @@ def test_set_this(self):
543551
verifylist = [
544552
('network', self._network.name),
545553
('enable', True),
554+
('description', self._network.description),
546555
('name', 'noob'),
547556
('share', True),
548557
('external', True),
@@ -560,6 +569,7 @@ def test_set_this(self):
560569
attrs = {
561570
'name': 'noob',
562571
'admin_state_up': True,
572+
'description': self._network.description,
563573
'shared': True,
564574
'router:external': True,
565575
'is_default': True,
@@ -624,6 +634,7 @@ class TestShowNetwork(TestNetwork):
624634
'admin_state_up',
625635
'availability_zone_hints',
626636
'availability_zones',
637+
'description',
627638
'id',
628639
'is_default',
629640
'name',
@@ -640,6 +651,7 @@ class TestShowNetwork(TestNetwork):
640651
network._format_admin_state(_network.admin_state_up),
641652
utils.format_list(_network.availability_zone_hints),
642653
utils.format_list(_network.availability_zones),
654+
_network.description,
643655
_network.id,
644656
_network.is_default,
645657
_network.name,

0 commit comments

Comments
 (0)