diff options
author | Jenkins <jenkins@review.openstack.org> | 2017-02-01 16:28:43 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2017-02-01 16:28:43 +0000 |
commit | 5b8cab8079c2eea9f9d084801102ed5b036927fa (patch) | |
tree | 0e4cc8547cce17edb06f2d463c9407314d529f10 /designateclient/v2/cli/zones.py | |
parent | b8ed15c568519081dfea321b0e28845c06148a27 (diff) | |
parent | f265eb18e95a707d99fe4d52a856c6e661b9982f (diff) | |
download | python-designateclient-5b8cab8079c2eea9f9d084801102ed5b036927fa.tar.gz |
Diffstat (limited to 'designateclient/v2/cli/zones.py')
-rw-r--r-- | designateclient/v2/cli/zones.py | 16 |
1 files changed, 16 insertions, 0 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: |