Skip to content

Commit 85f2afd

Browse files
Jenkinsopenstack-gerrit
authored andcommitted
Merge "Add description field port create & port set"
2 parents 518fbf0 + c99ec28 commit 85f2afd

5 files changed

Lines changed: 72 additions & 40 deletions

File tree

doc/source/command-objects/port.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Create new port
1818
1919
os port create
2020
--network <network>
21+
[--description <description>]
2122
[--fixed-ip subnet=<subnet>,ip-address=<ip-address>]
2223
[--device <device-id>]
2324
[--device-owner <device-owner>]
@@ -34,6 +35,10 @@ Create new port
3435
3536
Network this port belongs to (name or ID)
3637
38+
.. option:: --description <description>
39+
40+
Description of this port
41+
3742
.. option:: --fixed-ip subnet=<subnet>,ip-address=<ip-address>
3843
3944
Desired IP and/or subnet (name or ID) for this port:
@@ -164,6 +169,7 @@ Set port properties
164169
.. code:: bash
165170
166171
os port set
172+
[--description <description>]
167173
[--fixed-ip subnet=<subnet>,ip-address=<ip-address>]
168174
[--no-fixed-ip]
169175
[--device <device-id>]
@@ -178,6 +184,10 @@ Set port properties
178184
[--no-security-group]
179185
<port>
180186
187+
.. option:: --description <description>
188+
189+
Description of this port
190+
181191
.. option:: --fixed-ip subnet=<subnet>,ip-address=<ip-address>
182192
183193
Desired IP and/or subnet (name or ID) for this port:

openstackclient/network/v2/port.py

Lines changed: 47 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ def _get_attrs(client_manager, parsed_args):
109109
'The --host-id option is deprecated, '
110110
'please use --host instead.'
111111
))
112+
if parsed_args.description is not None:
113+
attrs['description'] = parsed_args.description
112114
if parsed_args.fixed_ip is not None:
113115
attrs['fixed_ips'] = parsed_args.fixed_ip
114116
if parsed_args.device:
@@ -180,46 +182,51 @@ def _prepare_fixed_ips(client_manager, parsed_args):
180182

181183

182184
def _add_updatable_args(parser):
183-
# NOTE(dtroyer): --device-id is deprecated in Mar 2016. Do not
184-
# remove before 3.x release or Mar 2017.
185-
device_group = parser.add_mutually_exclusive_group()
186-
device_group.add_argument(
187-
'--device',
188-
metavar='<device-id>',
189-
help=_("Port device ID")
190-
)
191-
device_group.add_argument(
192-
'--device-id',
193-
metavar='<device-id>',
194-
help=argparse.SUPPRESS,
195-
)
196-
parser.add_argument(
197-
'--device-owner',
198-
metavar='<device-owner>',
199-
help=_("Device owner of this port. This is the entity that uses "
200-
"the port (for example, network:dhcp).")
201-
)
202-
parser.add_argument(
203-
'--vnic-type',
204-
metavar='<vnic-type>',
205-
choices=['direct', 'direct-physical', 'macvtap',
206-
'normal', 'baremetal'],
207-
help=_("VNIC type for this port (direct | direct-physical | "
208-
"macvtap | normal | baremetal, default: normal)")
209-
)
210-
# NOTE(dtroyer): --host-id is deprecated in Mar 2016. Do not
211-
# remove before 3.x release or Mar 2017.
212-
host_group = parser.add_mutually_exclusive_group()
213-
host_group.add_argument(
214-
'--host',
215-
metavar='<host-id>',
216-
help=_("Allocate port on host <host-id> (ID only)")
217-
)
218-
host_group.add_argument(
219-
'--host-id',
220-
metavar='<host-id>',
221-
help=argparse.SUPPRESS,
222-
)
185+
parser.add_argument(
186+
'--description',
187+
metavar='<description>',
188+
help=_("Description of this port")
189+
)
190+
# NOTE(dtroyer): --device-id is deprecated in Mar 2016. Do not
191+
# remove before 3.x release or Mar 2017.
192+
device_group = parser.add_mutually_exclusive_group()
193+
device_group.add_argument(
194+
'--device',
195+
metavar='<device-id>',
196+
help=_("Port device ID")
197+
)
198+
device_group.add_argument(
199+
'--device-id',
200+
metavar='<device-id>',
201+
help=argparse.SUPPRESS,
202+
)
203+
parser.add_argument(
204+
'--device-owner',
205+
metavar='<device-owner>',
206+
help=_("Device owner of this port. This is the entity that uses "
207+
"the port (for example, network:dhcp).")
208+
)
209+
parser.add_argument(
210+
'--vnic-type',
211+
metavar='<vnic-type>',
212+
choices=['direct', 'direct-physical', 'macvtap',
213+
'normal', 'baremetal'],
214+
help=_("VNIC type for this port (direct | direct-physical | "
215+
"macvtap | normal | baremetal, default: normal)")
216+
)
217+
# NOTE(dtroyer): --host-id is deprecated in Mar 2016. Do not
218+
# remove before 3.x release or Mar 2017.
219+
host_group = parser.add_mutually_exclusive_group()
220+
host_group.add_argument(
221+
'--host',
222+
metavar='<host-id>',
223+
help=_("Allocate port on host <host-id> (ID only)")
224+
)
225+
host_group.add_argument(
226+
'--host-id',
227+
metavar='<host-id>',
228+
help=argparse.SUPPRESS,
229+
)
223230

224231

225232
class CreatePort(command.ShowOne):

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,7 @@ def create_one_port(attrs=None):
430430
'binding:vif_details': {},
431431
'binding:vif_type': 'ovs',
432432
'binding:vnic_type': 'normal',
433+
'description': 'description-' + uuid.uuid4().hex,
433434
'device_id': 'device-id-' + uuid.uuid4().hex,
434435
'device_owner': 'compute:nova',
435436
'dns_assignment': [{}],

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ def _get_common_cols_data(self, fake_port):
4141
'binding_vif_details',
4242
'binding_vif_type',
4343
'binding_vnic_type',
44+
'description',
4445
'device_id',
4546
'device_owner',
4647
'dns_assignment',
@@ -65,6 +66,7 @@ def _get_common_cols_data(self, fake_port):
6566
utils.format_dict(fake_port.binding_vif_details),
6667
fake_port.binding_vif_type,
6768
fake_port.binding_vnic_type,
69+
fake_port.description,
6870
fake_port.device_id,
6971
fake_port.device_owner,
7072
utils.format_list_of_dicts(fake_port.dns_assignment),
@@ -130,6 +132,7 @@ def test_create_full_options(self):
130132
'--mac-address', 'aa:aa:aa:aa:aa:aa',
131133
'--fixed-ip', 'subnet=%s,ip-address=10.0.0.2'
132134
% self.fake_subnet.id,
135+
'--description', self._port.description,
133136
'--device', 'deviceid',
134137
'--device-owner', 'fakeowner',
135138
'--disable',
@@ -146,6 +149,7 @@ def test_create_full_options(self):
146149
'fixed_ip',
147150
[{'subnet': self.fake_subnet.id, 'ip-address': '10.0.0.2'}]
148151
),
152+
('description', self._port.description),
149153
('device', 'deviceid'),
150154
('device_owner', 'fakeowner'),
151155
('disable', True),
@@ -163,6 +167,7 @@ def test_create_full_options(self):
163167
'mac_address': 'aa:aa:aa:aa:aa:aa',
164168
'fixed_ips': [{'subnet_id': self.fake_subnet.id,
165169
'ip_address': '10.0.0.2'}],
170+
'description': self._port.description,
166171
'device_id': 'deviceid',
167172
'device_owner': 'fakeowner',
168173
'admin_state_up': False,
@@ -715,6 +720,7 @@ def test_set_this(self):
715720

716721
def test_set_that(self):
717722
arglist = [
723+
'--description', 'newDescription',
718724
'--enable',
719725
'--vnic-type', 'macvtap',
720726
'--binding-profile', 'foo=bar',
@@ -723,6 +729,7 @@ def test_set_that(self):
723729
self._port.name,
724730
]
725731
verifylist = [
732+
('description', 'newDescription'),
726733
('enable', True),
727734
('vnic_type', 'macvtap'),
728735
('binding_profile', {'foo': 'bar'}),
@@ -739,6 +746,7 @@ def test_set_that(self):
739746
'binding:vnic_type': 'macvtap',
740747
'binding:profile': {'foo': 'bar'},
741748
'binding:host_id': 'binding-host-id-xxxx',
749+
'description': 'newDescription',
742750
'name': 'newName',
743751
}
744752
self.network.update_port.assert_called_once_with(self._port, **attrs)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
features:
3+
- |
4+
Add ``--description`` option to ``port set`` and
5+
``port create`` commands.
6+
[Blueprint :oscbp:`neutron-client-descriptions`]

0 commit comments

Comments
 (0)