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
This commit is contained in:
Tytus Kurek 2017-09-04 08:14:37 +02:00 committed by Dean Troyer
parent de2af66c16
commit 4a9e84be99
5 changed files with 36 additions and 2 deletions

View File

@ -28,6 +28,7 @@ Create new port
[--enable | --disable] [--enable | --disable]
[--mac-address <mac-address>] [--mac-address <mac-address>]
[--security-group <security-group> | --no-security-group] [--security-group <security-group> | --no-security-group]
[--dns-domain <dns-domain>]
[--dns-name <dns-name>] [--dns-name <dns-name>]
[--allowed-address ip-address=<ip-address>[,mac-address=<mac-address>]] [--allowed-address ip-address=<ip-address>[,mac-address=<mac-address>]]
[--qos-policy <qos-policy>] [--qos-policy <qos-policy>]
@ -95,9 +96,14 @@ Create new port
Associate no security groups with this 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> .. option:: --dns-name <dns-name>
Set DNS name to this port Set DNS name for this port
(requires DNS integration extension) (requires DNS integration extension)
.. option:: --allowed-address ip-address=<ip-address>[,mac-address=<mac-address>] .. option:: --allowed-address ip-address=<ip-address>[,mac-address=<mac-address>]
@ -256,6 +262,7 @@ Set port properties
[--security-group <security-group>] [--security-group <security-group>]
[--no-security-group] [--no-security-group]
[--enable-port-security | --disable-port-security] [--enable-port-security | --disable-port-security]
[--dns-domain <dns-domain>]
[--dns-name <dns-name>] [--dns-name <dns-name>]
[--allowed-address ip-address=<ip-address>[,mac-address=<mac-address>]] [--allowed-address ip-address=<ip-address>[,mac-address=<mac-address>]]
[--no-allowed-address] [--no-allowed-address]
@ -346,9 +353,14 @@ Set port properties
Disable port security for this port 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> .. option:: --dns-name <dns-name>
Set DNS name to this port Set DNS name for this port
(requires DNS integration extension) (requires DNS integration extension)
.. option:: --allowed-address ip-address=<ip-address>[,mac-address=<mac-address>] .. option:: --allowed-address ip-address=<ip-address>[,mac-address=<mac-address>]

View File

@ -127,6 +127,8 @@ def _get_attrs(client_manager, parsed_args):
if parsed_args.mac_address is not None: if parsed_args.mac_address is not None:
attrs['mac_address'] = parsed_args.mac_address 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: if parsed_args.dns_name is not None:
attrs['dns_name'] = parsed_args.dns_name attrs['dns_name'] = parsed_args.dns_name
# It is possible that name is not updated during 'port set' # It is possible that name is not updated during 'port set'
@ -268,6 +270,12 @@ def _add_updatable_args(parser):
metavar='<host-id>', metavar='<host-id>',
help=argparse.SUPPRESS, 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( parser.add_argument(
'--dns-name', '--dns-name',
metavar='dns-name', metavar='dns-name',

View File

@ -565,6 +565,7 @@ class FakePort(object):
'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': [{}],
'dns_domain': 'dns-domain-' + uuid.uuid4().hex,
'dns_name': 'dns-name-' + uuid.uuid4().hex, 'dns_name': 'dns-name-' + uuid.uuid4().hex,
'extra_dhcp_opts': [{}], 'extra_dhcp_opts': [{}],
'fixed_ips': [{'ip_address': '10.0.0.3', 'fixed_ips': [{'ip_address': '10.0.0.3',

View File

@ -50,6 +50,7 @@ class TestPort(network_fakes.TestNetworkV2):
'device_id', 'device_id',
'device_owner', 'device_owner',
'dns_assignment', 'dns_assignment',
'dns_domain',
'dns_name', 'dns_name',
'extra_dhcp_opts', 'extra_dhcp_opts',
'fixed_ips', 'fixed_ips',
@ -78,6 +79,7 @@ class TestPort(network_fakes.TestNetworkV2):
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),
fake_port.dns_domain,
fake_port.dns_name, fake_port.dns_name,
utils.format_list_of_dicts(fake_port.extra_dhcp_opts), utils.format_list_of_dicts(fake_port.extra_dhcp_opts),
utils.format_list_of_dicts(fake_port.fixed_ips), utils.format_list_of_dicts(fake_port.fixed_ips),
@ -152,6 +154,7 @@ class TestCreatePort(TestPort):
'--binding-profile', 'foo=bar', '--binding-profile', 'foo=bar',
'--binding-profile', 'foo2=bar2', '--binding-profile', 'foo2=bar2',
'--network', self._port.network_id, '--network', self._port.network_id,
'--dns-domain', 'example.org',
'--dns-name', '8.8.8.8', '--dns-name', '8.8.8.8',
'test-port', 'test-port',
@ -169,6 +172,7 @@ class TestCreatePort(TestPort):
('vnic_type', 'macvtap'), ('vnic_type', 'macvtap'),
('binding_profile', {'foo': 'bar', 'foo2': 'bar2'}), ('binding_profile', {'foo': 'bar', 'foo2': 'bar2'}),
('network', self._port.network_id), ('network', self._port.network_id),
('dns_domain', 'example.org'),
('dns_name', '8.8.8.8'), ('dns_name', '8.8.8.8'),
('name', 'test-port'), ('name', 'test-port'),
] ]
@ -187,6 +191,7 @@ class TestCreatePort(TestPort):
'binding:vnic_type': 'macvtap', 'binding:vnic_type': 'macvtap',
'binding:profile': {'foo': 'bar', 'foo2': 'bar2'}, 'binding:profile': {'foo': 'bar', 'foo2': 'bar2'},
'network_id': self._port.network_id, 'network_id': self._port.network_id,
'dns_domain': 'example.org',
'dns_name': '8.8.8.8', 'dns_name': '8.8.8.8',
'name': 'test-port', 'name': 'test-port',
}) })

View File

@ -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>`_]