Merge "Add description field port create & port set"
This commit is contained in:
commit
85f2afdad0
@ -18,6 +18,7 @@ Create new port
|
|||||||
|
|
||||||
os port create
|
os port create
|
||||||
--network <network>
|
--network <network>
|
||||||
|
[--description <description>]
|
||||||
[--fixed-ip subnet=<subnet>,ip-address=<ip-address>]
|
[--fixed-ip subnet=<subnet>,ip-address=<ip-address>]
|
||||||
[--device <device-id>]
|
[--device <device-id>]
|
||||||
[--device-owner <device-owner>]
|
[--device-owner <device-owner>]
|
||||||
@ -34,6 +35,10 @@ Create new port
|
|||||||
|
|
||||||
Network this port belongs to (name or ID)
|
Network this port belongs to (name or ID)
|
||||||
|
|
||||||
|
.. option:: --description <description>
|
||||||
|
|
||||||
|
Description of this port
|
||||||
|
|
||||||
.. option:: --fixed-ip subnet=<subnet>,ip-address=<ip-address>
|
.. option:: --fixed-ip subnet=<subnet>,ip-address=<ip-address>
|
||||||
|
|
||||||
Desired IP and/or subnet (name or ID) for this port:
|
Desired IP and/or subnet (name or ID) for this port:
|
||||||
@ -164,6 +169,7 @@ Set port properties
|
|||||||
.. code:: bash
|
.. code:: bash
|
||||||
|
|
||||||
os port set
|
os port set
|
||||||
|
[--description <description>]
|
||||||
[--fixed-ip subnet=<subnet>,ip-address=<ip-address>]
|
[--fixed-ip subnet=<subnet>,ip-address=<ip-address>]
|
||||||
[--no-fixed-ip]
|
[--no-fixed-ip]
|
||||||
[--device <device-id>]
|
[--device <device-id>]
|
||||||
@ -178,6 +184,10 @@ Set port properties
|
|||||||
[--no-security-group]
|
[--no-security-group]
|
||||||
<port>
|
<port>
|
||||||
|
|
||||||
|
.. option:: --description <description>
|
||||||
|
|
||||||
|
Description of this port
|
||||||
|
|
||||||
.. option:: --fixed-ip subnet=<subnet>,ip-address=<ip-address>
|
.. option:: --fixed-ip subnet=<subnet>,ip-address=<ip-address>
|
||||||
|
|
||||||
Desired IP and/or subnet (name or ID) for this port:
|
Desired IP and/or subnet (name or ID) for this port:
|
||||||
|
@ -109,6 +109,8 @@ def _get_attrs(client_manager, parsed_args):
|
|||||||
'The --host-id option is deprecated, '
|
'The --host-id option is deprecated, '
|
||||||
'please use --host instead.'
|
'please use --host instead.'
|
||||||
))
|
))
|
||||||
|
if parsed_args.description is not None:
|
||||||
|
attrs['description'] = parsed_args.description
|
||||||
if parsed_args.fixed_ip is not None:
|
if parsed_args.fixed_ip is not None:
|
||||||
attrs['fixed_ips'] = parsed_args.fixed_ip
|
attrs['fixed_ips'] = parsed_args.fixed_ip
|
||||||
if parsed_args.device:
|
if parsed_args.device:
|
||||||
@ -180,46 +182,51 @@ def _prepare_fixed_ips(client_manager, parsed_args):
|
|||||||
|
|
||||||
|
|
||||||
def _add_updatable_args(parser):
|
def _add_updatable_args(parser):
|
||||||
# NOTE(dtroyer): --device-id is deprecated in Mar 2016. Do not
|
parser.add_argument(
|
||||||
# remove before 3.x release or Mar 2017.
|
'--description',
|
||||||
device_group = parser.add_mutually_exclusive_group()
|
metavar='<description>',
|
||||||
device_group.add_argument(
|
help=_("Description of this port")
|
||||||
'--device',
|
)
|
||||||
metavar='<device-id>',
|
# NOTE(dtroyer): --device-id is deprecated in Mar 2016. Do not
|
||||||
help=_("Port device ID")
|
# remove before 3.x release or Mar 2017.
|
||||||
)
|
device_group = parser.add_mutually_exclusive_group()
|
||||||
device_group.add_argument(
|
device_group.add_argument(
|
||||||
'--device-id',
|
'--device',
|
||||||
metavar='<device-id>',
|
metavar='<device-id>',
|
||||||
help=argparse.SUPPRESS,
|
help=_("Port device ID")
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
device_group.add_argument(
|
||||||
'--device-owner',
|
'--device-id',
|
||||||
metavar='<device-owner>',
|
metavar='<device-id>',
|
||||||
help=_("Device owner of this port. This is the entity that uses "
|
help=argparse.SUPPRESS,
|
||||||
"the port (for example, network:dhcp).")
|
)
|
||||||
)
|
parser.add_argument(
|
||||||
parser.add_argument(
|
'--device-owner',
|
||||||
'--vnic-type',
|
metavar='<device-owner>',
|
||||||
metavar='<vnic-type>',
|
help=_("Device owner of this port. This is the entity that uses "
|
||||||
choices=['direct', 'direct-physical', 'macvtap',
|
"the port (for example, network:dhcp).")
|
||||||
'normal', 'baremetal'],
|
)
|
||||||
help=_("VNIC type for this port (direct | direct-physical | "
|
parser.add_argument(
|
||||||
"macvtap | normal | baremetal, default: normal)")
|
'--vnic-type',
|
||||||
)
|
metavar='<vnic-type>',
|
||||||
# NOTE(dtroyer): --host-id is deprecated in Mar 2016. Do not
|
choices=['direct', 'direct-physical', 'macvtap',
|
||||||
# remove before 3.x release or Mar 2017.
|
'normal', 'baremetal'],
|
||||||
host_group = parser.add_mutually_exclusive_group()
|
help=_("VNIC type for this port (direct | direct-physical | "
|
||||||
host_group.add_argument(
|
"macvtap | normal | baremetal, default: normal)")
|
||||||
'--host',
|
)
|
||||||
metavar='<host-id>',
|
# NOTE(dtroyer): --host-id is deprecated in Mar 2016. Do not
|
||||||
help=_("Allocate port on host <host-id> (ID only)")
|
# remove before 3.x release or Mar 2017.
|
||||||
)
|
host_group = parser.add_mutually_exclusive_group()
|
||||||
host_group.add_argument(
|
host_group.add_argument(
|
||||||
'--host-id',
|
'--host',
|
||||||
metavar='<host-id>',
|
metavar='<host-id>',
|
||||||
help=argparse.SUPPRESS,
|
help=_("Allocate port on host <host-id> (ID only)")
|
||||||
)
|
)
|
||||||
|
host_group.add_argument(
|
||||||
|
'--host-id',
|
||||||
|
metavar='<host-id>',
|
||||||
|
help=argparse.SUPPRESS,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class CreatePort(command.ShowOne):
|
class CreatePort(command.ShowOne):
|
||||||
|
@ -430,6 +430,7 @@ class FakePort(object):
|
|||||||
'binding:vif_details': {},
|
'binding:vif_details': {},
|
||||||
'binding:vif_type': 'ovs',
|
'binding:vif_type': 'ovs',
|
||||||
'binding:vnic_type': 'normal',
|
'binding:vnic_type': 'normal',
|
||||||
|
'description': 'description-' + uuid.uuid4().hex,
|
||||||
'device_id': 'device-id-' + uuid.uuid4().hex,
|
'device_id': 'device-id-' + uuid.uuid4().hex,
|
||||||
'device_owner': 'compute:nova',
|
'device_owner': 'compute:nova',
|
||||||
'dns_assignment': [{}],
|
'dns_assignment': [{}],
|
||||||
|
@ -41,6 +41,7 @@ class TestPort(network_fakes.TestNetworkV2):
|
|||||||
'binding_vif_details',
|
'binding_vif_details',
|
||||||
'binding_vif_type',
|
'binding_vif_type',
|
||||||
'binding_vnic_type',
|
'binding_vnic_type',
|
||||||
|
'description',
|
||||||
'device_id',
|
'device_id',
|
||||||
'device_owner',
|
'device_owner',
|
||||||
'dns_assignment',
|
'dns_assignment',
|
||||||
@ -65,6 +66,7 @@ class TestPort(network_fakes.TestNetworkV2):
|
|||||||
utils.format_dict(fake_port.binding_vif_details),
|
utils.format_dict(fake_port.binding_vif_details),
|
||||||
fake_port.binding_vif_type,
|
fake_port.binding_vif_type,
|
||||||
fake_port.binding_vnic_type,
|
fake_port.binding_vnic_type,
|
||||||
|
fake_port.description,
|
||||||
fake_port.device_id,
|
fake_port.device_id,
|
||||||
fake_port.device_owner,
|
fake_port.device_owner,
|
||||||
utils.format_list_of_dicts(fake_port.dns_assignment),
|
utils.format_list_of_dicts(fake_port.dns_assignment),
|
||||||
@ -130,6 +132,7 @@ class TestCreatePort(TestPort):
|
|||||||
'--mac-address', 'aa:aa:aa:aa:aa:aa',
|
'--mac-address', 'aa:aa:aa:aa:aa:aa',
|
||||||
'--fixed-ip', 'subnet=%s,ip-address=10.0.0.2'
|
'--fixed-ip', 'subnet=%s,ip-address=10.0.0.2'
|
||||||
% self.fake_subnet.id,
|
% self.fake_subnet.id,
|
||||||
|
'--description', self._port.description,
|
||||||
'--device', 'deviceid',
|
'--device', 'deviceid',
|
||||||
'--device-owner', 'fakeowner',
|
'--device-owner', 'fakeowner',
|
||||||
'--disable',
|
'--disable',
|
||||||
@ -146,6 +149,7 @@ class TestCreatePort(TestPort):
|
|||||||
'fixed_ip',
|
'fixed_ip',
|
||||||
[{'subnet': self.fake_subnet.id, 'ip-address': '10.0.0.2'}]
|
[{'subnet': self.fake_subnet.id, 'ip-address': '10.0.0.2'}]
|
||||||
),
|
),
|
||||||
|
('description', self._port.description),
|
||||||
('device', 'deviceid'),
|
('device', 'deviceid'),
|
||||||
('device_owner', 'fakeowner'),
|
('device_owner', 'fakeowner'),
|
||||||
('disable', True),
|
('disable', True),
|
||||||
@ -163,6 +167,7 @@ class TestCreatePort(TestPort):
|
|||||||
'mac_address': 'aa:aa:aa:aa:aa:aa',
|
'mac_address': 'aa:aa:aa:aa:aa:aa',
|
||||||
'fixed_ips': [{'subnet_id': self.fake_subnet.id,
|
'fixed_ips': [{'subnet_id': self.fake_subnet.id,
|
||||||
'ip_address': '10.0.0.2'}],
|
'ip_address': '10.0.0.2'}],
|
||||||
|
'description': self._port.description,
|
||||||
'device_id': 'deviceid',
|
'device_id': 'deviceid',
|
||||||
'device_owner': 'fakeowner',
|
'device_owner': 'fakeowner',
|
||||||
'admin_state_up': False,
|
'admin_state_up': False,
|
||||||
@ -715,6 +720,7 @@ class TestSetPort(TestPort):
|
|||||||
|
|
||||||
def test_set_that(self):
|
def test_set_that(self):
|
||||||
arglist = [
|
arglist = [
|
||||||
|
'--description', 'newDescription',
|
||||||
'--enable',
|
'--enable',
|
||||||
'--vnic-type', 'macvtap',
|
'--vnic-type', 'macvtap',
|
||||||
'--binding-profile', 'foo=bar',
|
'--binding-profile', 'foo=bar',
|
||||||
@ -723,6 +729,7 @@ class TestSetPort(TestPort):
|
|||||||
self._port.name,
|
self._port.name,
|
||||||
]
|
]
|
||||||
verifylist = [
|
verifylist = [
|
||||||
|
('description', 'newDescription'),
|
||||||
('enable', True),
|
('enable', True),
|
||||||
('vnic_type', 'macvtap'),
|
('vnic_type', 'macvtap'),
|
||||||
('binding_profile', {'foo': 'bar'}),
|
('binding_profile', {'foo': 'bar'}),
|
||||||
@ -739,6 +746,7 @@ class TestSetPort(TestPort):
|
|||||||
'binding:vnic_type': 'macvtap',
|
'binding:vnic_type': 'macvtap',
|
||||||
'binding:profile': {'foo': 'bar'},
|
'binding:profile': {'foo': 'bar'},
|
||||||
'binding:host_id': 'binding-host-id-xxxx',
|
'binding:host_id': 'binding-host-id-xxxx',
|
||||||
|
'description': 'newDescription',
|
||||||
'name': 'newName',
|
'name': 'newName',
|
||||||
}
|
}
|
||||||
self.network.update_port.assert_called_once_with(self._port, **attrs)
|
self.network.update_port.assert_called_once_with(self._port, **attrs)
|
||||||
|
@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
features:
|
||||||
|
- |
|
||||||
|
Add ``--description`` option to ``port set`` and
|
||||||
|
``port create`` commands.
|
||||||
|
[Blueprint :oscbp:`neutron-client-descriptions`]
|
Loading…
Reference in New Issue
Block a user