summaryrefslogtreecommitdiff
path: root/designateclient
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2017-02-01 16:28:43 +0000
committerGerrit Code Review <review@openstack.org>2017-02-01 16:28:43 +0000
commit5b8cab8079c2eea9f9d084801102ed5b036927fa (patch)
tree0e4cc8547cce17edb06f2d463c9407314d529f10 /designateclient
parentb8ed15c568519081dfea321b0e28845c06148a27 (diff)
parentf265eb18e95a707d99fe4d52a856c6e661b9982f (diff)
downloadpython-designateclient-5b8cab8079c2eea9f9d084801102ed5b036927fa.tar.gz
Merge "Add attribute support to create zone cli"ocata-em2.6.0
Diffstat (limited to 'designateclient')
-rw-r--r--designateclient/v2/cli/zones.py16
-rw-r--r--designateclient/v2/zones.py5
2 files changed, 20 insertions, 1 deletions
diff --git a/designateclient/v2/cli/zones.py b/designateclient/v2/cli/zones.py
index 40c64c9..3782652 100644
--- a/designateclient/v2/cli/zones.py
+++ b/designateclient/v2/cli/zones.py
@@ -31,6 +31,10 @@ LOG = logging.getLogger(__name__)
def _format_zone(zone):
zone.pop('links', None)
zone['masters'] = ", ".join(zone['masters'])
+ attrib = ''
+ for attr in zone['attributes']:
+ attrib += "%s:%s\n" % (attr, zone['attributes'][attr])
+ zone['attributes'] = attrib
def _format_zone_export_record(zone_export_record):
@@ -131,6 +135,7 @@ class CreateZoneCommand(command.ShowOne):
parser.add_argument('--ttl', type=int, help="Time To Live (Seconds)")
parser.add_argument('--description', help="Description")
parser.add_argument('--masters', help="Zone Masters", nargs='+')
+ parser.add_argument('--attributes', help="Zone Attributes", nargs='+')
common.add_all_common_options(parser)
@@ -145,6 +150,17 @@ class CreateZoneCommand(command.ShowOne):
if parsed_args.description:
payload["description"] = parsed_args.description
+ if parsed_args.attributes:
+ payload["attributes"] = {}
+ for attr in parsed_args.attributes:
+ try:
+ k, v = attr.split(':')
+ payload["attributes"][k] = v
+ except ValueError:
+ msg = "Attribute '%s' is in an incorrect format. "\
+ "Attributes are <key>:<value> formated"
+ raise osc_exc.CommandError(msg % attr)
+
if parsed_args.type == 'PRIMARY':
# email is just for PRIMARY.
if not parsed_args.email:
diff --git a/designateclient/v2/zones.py b/designateclient/v2/zones.py
index c960da7..7e862a7 100644
--- a/designateclient/v2/zones.py
+++ b/designateclient/v2/zones.py
@@ -19,7 +19,7 @@ from designateclient.v2 import utils as v2_utils
class ZoneController(V2Controller):
def create(self, name, type_=None, email=None, description=None, ttl=None,
- masters=None):
+ masters=None, attributes=None):
type_ = type_ or "PRIMARY"
data = {
@@ -40,6 +40,9 @@ class ZoneController(V2Controller):
if description is not None:
data["description"] = description
+ if attributes is not None:
+ data["attributes"] = attributes
+
return self._post('/zones', data=data)
def list(self, criterion=None, marker=None, limit=None):