From 4a9e84be994575146b30bd40a341d5686174eaad Mon Sep 17 00:00:00 2001 From: Tytus Kurek <tytus.kurek@canonical.com> Date: Mon, 4 Sep 2017 08:14:37 +0200 Subject: [PATCH] Add support for "--dns-domain" argument This patchset implements support for "--dns-domain" argument to the following commands: "openstack port create" / "openstack port set". Change-Id: I4bb001054b00a969b74db3bb310e567033bf589b Depends-On: https://review.openstack.org/#/c/500660/ Closes-Bug: #1714878 Partial-Bug: #1704769 --- doc/source/cli/command-objects/port.rst | 16 ++++++++++++++-- openstackclient/network/v2/port.py | 8 ++++++++ openstackclient/tests/unit/network/v2/fakes.py | 1 + .../tests/unit/network/v2/test_port.py | 5 +++++ .../notes/bug-1714878-46806jv2yv13q054.yaml | 8 ++++++++ 5 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 releasenotes/notes/bug-1714878-46806jv2yv13q054.yaml diff --git a/doc/source/cli/command-objects/port.rst b/doc/source/cli/command-objects/port.rst index c2da09b321..c3a9798cf9 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 <mac-address>] [--security-group <security-group> | --no-security-group] + [--dns-domain <dns-domain>] [--dns-name <dns-name>] [--allowed-address ip-address=<ip-address>[,mac-address=<mac-address>]] [--qos-policy <qos-policy>] @@ -95,9 +96,14 @@ Create new port Associate no security groups with this port +.. option:: --dns-domain <dns-name> + + Set DNS domain for this port + (requires dns_domain for ports extension) + .. option:: --dns-name <dns-name> - Set DNS name to this port + Set DNS name for this port (requires DNS integration extension) .. option:: --allowed-address ip-address=<ip-address>[,mac-address=<mac-address>] @@ -256,6 +262,7 @@ Set port properties [--security-group <security-group>] [--no-security-group] [--enable-port-security | --disable-port-security] + [--dns-domain <dns-domain>] [--dns-name <dns-name>] [--allowed-address ip-address=<ip-address>[,mac-address=<mac-address>]] [--no-allowed-address] @@ -346,9 +353,14 @@ Set port properties Disable port security for this port +.. option:: --dns-domain <dns-domain> + + Set DNS domain for this port + (requires dns_domain for ports extension) + .. option:: --dns-name <dns-name> - Set DNS name to this port + Set DNS name for this port (requires DNS integration extension) .. option:: --allowed-address ip-address=<ip-address>[,mac-address=<mac-address>] diff --git a/openstackclient/network/v2/port.py b/openstackclient/network/v2/port.py index 9536fe8687..ea5a04e633 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='<host-id>', 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 bdc1c1fb0e..f13b6b46d7 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 45e1045da0..7cc8ac2897 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 0000000000..a2f376b8c2 --- /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 <https://docs.openstack.org/neutron/latest/admin/config-dns-int.html>`_ + documentation for information how to use this. + [Bug `1714878 <https://bugs.launchpad.net/python-openstackclient/+bug/1714878>`_]