diff --git a/designateclient/cli/diagnostics.py b/designateclient/cli/diagnostics.py index 460b30a..847dbdc 100644 --- a/designateclient/cli/diagnostics.py +++ b/designateclient/cli/diagnostics.py @@ -34,46 +34,3 @@ class PingCommand(base.GetCommand): def execute(self, parsed_args): return self.client.diagnostics.ping(parsed_args.service, parsed_args.host) - - -class SyncAllCommand(base.Command): - """ Sync Everything """ - - def execute(self, parsed_args): - self.client.diagnostics.sync_all() - - LOG.info('Synchronization of all domains scheduled') - - -class SyncDomainCommand(base.Command): - """ Sync a single Domain """ - - def get_parser(self, prog_name): - parser = super(SyncDomainCommand, self).get_parser(prog_name) - - parser.add_argument('domain_id', help="Domain ID") - - return parser - - def execute(self, parsed_args): - self.client.diagnostics.sync_domain(parsed_args.domain_id) - - LOG.info('Synchronization of domain scheduled') - - -class SyncRecordCommand(base.Command): - """ Sync a single Record """ - - def get_parser(self, prog_name): - parser = super(SyncRecordCommand, self).get_parser(prog_name) - - parser.add_argument('domain_id', help="Domain ID") - parser.add_argument('record_id', help="Record ID") - - return parser - - def execute(self, parsed_args): - self.client.diagnostics.sync_record(parsed_args.domain_id, - parsed_args.record_id) - - LOG.info('Synchronization of record scheduled') diff --git a/designateclient/cli/sync.py b/designateclient/cli/sync.py new file mode 100644 index 0000000..92bce99 --- /dev/null +++ b/designateclient/cli/sync.py @@ -0,0 +1,62 @@ +# Copyright 2012 Managed I.T. +# +# Author: Kiall Mac Innes +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +import logging +from designateclient.cli import base + +LOG = logging.getLogger(__name__) + + +class SyncAllCommand(base.Command): + """ Sync Everything """ + + def execute(self, parsed_args): + self.client.sync.sync_all() + + LOG.info('Synchronization of all domains scheduled') + + +class SyncDomainCommand(base.Command): + """ Sync a single Domain """ + + def get_parser(self, prog_name): + parser = super(SyncDomainCommand, self).get_parser(prog_name) + + parser.add_argument('domain_id', help="Domain ID") + + return parser + + def execute(self, parsed_args): + self.client.sync.sync_domain(parsed_args.domain_id) + + LOG.info('Synchronization of domain scheduled') + + +class SyncRecordCommand(base.Command): + """ Sync a single Record """ + + def get_parser(self, prog_name): + parser = super(SyncRecordCommand, self).get_parser(prog_name) + + parser.add_argument('domain_id', help="Domain ID") + parser.add_argument('record_id', help="Record ID") + + return parser + + def execute(self, parsed_args): + self.client.sync.sync_record(parsed_args.domain_id, + parsed_args.record_id) + + LOG.info('Synchronization of record scheduled') diff --git a/designateclient/v1/diagnostics.py b/designateclient/v1/diagnostics.py index 6e03e2d..b5c92fb 100644 --- a/designateclient/v1/diagnostics.py +++ b/designateclient/v1/diagnostics.py @@ -25,29 +25,3 @@ class DiagnosticsController(Controller): (service, host)) return response.json() - - def sync_all(self): - """ - Sync Everything - """ - response = self.client.post('/diagnostics/sync/all') - - return response.json() - - def sync_domain(self, domain_id): - """ - Sync Single Domain - """ - response = self.client.post('/diagnostics/sync/domain/%s' % - domain_id) - - return response.json() - - def sync_record(self, domain_id, record_id): - """ - Sync Single Record - """ - response = self.client.post('/diagnostics/sync/record/%s/%s' % - (domain_id, record_id)) - - return response.json() diff --git a/designateclient/v1/sync.py b/designateclient/v1/sync.py new file mode 100644 index 0000000..5e93b57 --- /dev/null +++ b/designateclient/v1/sync.py @@ -0,0 +1,37 @@ +# Copyright 2012 Managed I.T. +# +# Author: Kiall Mac Innes +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +from designateclient.v1.base import Controller + + +class SyncController(Controller): + def sync_all(self): + """ + Sync Everything + """ + self.client.post('/domains/sync') + + def sync_domain(self, domain_id): + """ + Sync Single Domain + """ + self.client.post('/domains/%s/sync' % domain_id) + + def sync_record(self, domain_id, record_id): + """ + Sync Single Record + """ + self.client.post('/domains/%s/records/%s/sync' % + (domain_id, record_id)) diff --git a/setup.cfg b/setup.cfg index 0bca6b0..e55cec9 100644 --- a/setup.cfg +++ b/setup.cfg @@ -35,6 +35,7 @@ designateclient.v1.controllers = domains = designateclient.v1.domains:DomainsController records = designateclient.v1.records:RecordsController servers = designateclient.v1.servers:ServersController + sync = designateclient.v1.sync:SyncController designateclient.cli = domain-list = designateclient.cli.domains:ListDomainsCommand @@ -57,9 +58,10 @@ designateclient.cli = server-delete = designateclient.cli.servers:DeleteServerCommand diagnostics-ping = designateclient.cli.diagnostics:PingCommand - diagnostics-sync-all = designateclient.cli.diagnostics:SyncAllCommand - diagnostics-sync-domain = designateclient.cli.diagnostics:SyncDomainCommand - diagnostics-sync-record = designateclient.cli.diagnostics:SyncRecordCommand + + sync-all = designateclient.cli.sync:SyncAllCommand + sync-domain = designateclient.cli.sync:SyncDomainCommand + sync-record = designateclient.cli.sync:SyncRecordCommand report-count-all = designateclient.cli.reports:CountsCommand report-count-domains = designateclient.cli.reports:DomainCountCommand