From e7a8687a2c87a507ce25e042014d6a918e95d035 Mon Sep 17 00:00:00 2001 From: Pierre Hanselmann Date: Tue, 31 Oct 2017 15:35:10 +0100 Subject: Add dns-domain support to Network object Add "dns-domain" parameter to Network class. Also check backend extensions and send an error message in case of an argument (like dns-domain) is sent and the extension is missing (dns-integration in this case). Change-Id: I7303658c27d9b9f2d8381ccea0b29e96909cab54 Closes-Bug: 1633214 Partial-Bug: 1547736 (cherry picked from commit b8754e15e7adc9a04587f67c83febaf49b64f18c) --- openstackclient/network/common.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'openstackclient/network/common.py') diff --git a/openstackclient/network/common.py b/openstackclient/network/common.py index 37bf1406..d22b2caa 100644 --- a/openstackclient/network/common.py +++ b/openstackclient/network/common.py @@ -12,6 +12,7 @@ # import abc +import contextlib import logging import openstack.exceptions @@ -24,6 +25,30 @@ from openstackclient.i18n import _ LOG = logging.getLogger(__name__) +_required_opt_extensions_map = { + 'allowed_address_pairs': 'allowed-address-pairs', + 'dns_domain': 'dns-integration', + 'dns_name': 'dns-integration', + 'extra_dhcp_opts': 'extra_dhcp_opt', + 'qos_policy_id': 'qos', + 'security_groups': 'security-groups', +} + + +@contextlib.contextmanager +def check_missing_extension_if_error(client_manager, attrs): + # If specified option requires extension, then try to + # find out if it exists. If it does not exist, + # then an exception with the appropriate message + # will be thrown from within client.find_extension + try: + yield + except openstack.exceptions.HttpException: + for opt, ext in _required_opt_extensions_map.items(): + if opt in attrs: + client_manager.find_extension(ext, ignore_missing=False) + raise + @six.add_metaclass(abc.ABCMeta) class NetworkAndComputeCommand(command.Command): -- cgit v1.2.1