summaryrefslogtreecommitdiff
path: root/openstackclient/network/common.py
diff options
context:
space:
mode:
authorPierre Hanselmann <pierre.hanselmann@gmail.com>2017-10-31 15:35:10 +0100
committerJens Harbott <j.harbott@x-ion.de>2018-04-23 08:37:27 +0000
commitb8754e15e7adc9a04587f67c83febaf49b64f18c (patch)
treedab7a03949dbfa5601639e677dbd580a23a3eb1a /openstackclient/network/common.py
parentb59de7b8494ddbde3570780214378cdb2208c482 (diff)
downloadpython-openstackclient-b8754e15e7adc9a04587f67c83febaf49b64f18c.tar.gz
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
Diffstat (limited to 'openstackclient/network/common.py')
-rw-r--r--openstackclient/network/common.py25
1 files changed, 25 insertions, 0 deletions
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):