diff --git a/doc/source/cli/command-objects/port.rst b/doc/source/cli/command-objects/port.rst index f8e88230f..335c22707 100644 --- a/doc/source/cli/command-objects/port.rst +++ b/doc/source/cli/command-objects/port.rst @@ -28,6 +28,7 @@ Create new port [--enable | --disable] [--mac-address ] [--security-group | --no-security-group] + [--dns-domain ] [--dns-name ] [--allowed-address ip-address=[,mac-address=]] [--qos-policy ] @@ -99,9 +100,14 @@ Create new port Associate no security groups with this port +.. option:: --dns-domain + + Set DNS domain for this port + (requires dns_domain for ports extension) + .. option:: --dns-name - Set DNS name to this port + Set DNS name for this port (requires DNS integration extension) .. option:: --allowed-address ip-address=[,mac-address=] @@ -264,6 +270,7 @@ Set port properties [--security-group ] [--no-security-group] [--enable-port-security | --disable-port-security] + [--dns-domain ] [--dns-name ] [--allowed-address ip-address=[,mac-address=]] [--no-allowed-address] @@ -354,9 +361,14 @@ Set port properties Disable port security for this port +.. option:: --dns-domain + + Set DNS domain for this port + (requires dns_domain for ports extension) + .. option:: --dns-name - Set DNS name to this port + Set DNS name for this port (requires DNS integration extension) .. option:: --allowed-address ip-address=[,mac-address=] diff --git a/openstackclient/network/v2/port.py b/openstackclient/network/v2/port.py index 032e17874..f13ee7b90 100644 --- a/openstackclient/network/v2/port.py +++ b/openstackclient/network/v2/port.py @@ -127,6 +127,8 @@ def _get_attrs(client_manager, parsed_args): if parsed_args.mac_address is not None: attrs['mac_address'] = parsed_args.mac_address + if parsed_args.dns_domain is not None: + attrs['dns_domain'] = parsed_args.dns_domain if parsed_args.dns_name is not None: attrs['dns_name'] = parsed_args.dns_name # It is possible that name is not updated during 'port set' @@ -268,6 +270,12 @@ def _add_updatable_args(parser): metavar='', help=argparse.SUPPRESS, ) + parser.add_argument( + '--dns-domain', + metavar='dns-domain', + help=_("Set DNS domain to this port " + "(requires dns_domain extension for ports)") + ) parser.add_argument( '--dns-name', metavar='dns-name', diff --git a/openstackclient/tests/unit/network/v2/fakes.py b/openstackclient/tests/unit/network/v2/fakes.py index a77cab8b5..4291dd1d6 100644 --- a/openstackclient/tests/unit/network/v2/fakes.py +++ b/openstackclient/tests/unit/network/v2/fakes.py @@ -565,6 +565,7 @@ class FakePort(object): 'device_id': 'device-id-' + uuid.uuid4().hex, 'device_owner': 'compute:nova', 'dns_assignment': [{}], + 'dns_domain': 'dns-domain-' + uuid.uuid4().hex, 'dns_name': 'dns-name-' + uuid.uuid4().hex, 'extra_dhcp_opts': [{}], 'fixed_ips': [{'ip_address': '10.0.0.3', diff --git a/openstackclient/tests/unit/network/v2/test_port.py b/openstackclient/tests/unit/network/v2/test_port.py index 908177ce6..03e1d841b 100644 --- a/openstackclient/tests/unit/network/v2/test_port.py +++ b/openstackclient/tests/unit/network/v2/test_port.py @@ -50,6 +50,7 @@ class TestPort(network_fakes.TestNetworkV2): 'device_id', 'device_owner', 'dns_assignment', + 'dns_domain', 'dns_name', 'extra_dhcp_opts', 'fixed_ips', @@ -78,6 +79,7 @@ class TestPort(network_fakes.TestNetworkV2): fake_port.device_id, fake_port.device_owner, utils.format_list_of_dicts(fake_port.dns_assignment), + fake_port.dns_domain, fake_port.dns_name, utils.format_list_of_dicts(fake_port.extra_dhcp_opts), utils.format_list_of_dicts(fake_port.fixed_ips), @@ -152,6 +154,7 @@ class TestCreatePort(TestPort): '--binding-profile', 'foo=bar', '--binding-profile', 'foo2=bar2', '--network', self._port.network_id, + '--dns-domain', 'example.org', '--dns-name', '8.8.8.8', 'test-port', @@ -169,6 +172,7 @@ class TestCreatePort(TestPort): ('vnic_type', 'macvtap'), ('binding_profile', {'foo': 'bar', 'foo2': 'bar2'}), ('network', self._port.network_id), + ('dns_domain', 'example.org'), ('dns_name', '8.8.8.8'), ('name', 'test-port'), ] @@ -187,6 +191,7 @@ class TestCreatePort(TestPort): 'binding:vnic_type': 'macvtap', 'binding:profile': {'foo': 'bar', 'foo2': 'bar2'}, 'network_id': self._port.network_id, + 'dns_domain': 'example.org', 'dns_name': '8.8.8.8', 'name': 'test-port', }) diff --git a/releasenotes/notes/bug-1714878-46806jv2yv13q054.yaml b/releasenotes/notes/bug-1714878-46806jv2yv13q054.yaml new file mode 100644 index 000000000..a2f376b8c --- /dev/null +++ b/releasenotes/notes/bug-1714878-46806jv2yv13q054.yaml @@ -0,0 +1,8 @@ +--- +features: + - | + Add ``--dns-domain`` option to ``port create`` and ``port set`` commands. + Requires the ``dns_domain for ports`` extension to be enabled. See the + `Neutron DNS integration `_ + documentation for information how to use this. + [Bug `1714878 `_]