Move "sync" commands out of Diagnostics and fix them
This mirrors the layout on the server side. I don't consider this a breaking change, as the existing sync commands were broken to begin with. Change-Id: Id80e148e2a0218d6bd64673bb09c15ab0d98418b
This commit is contained in:
parent
12c57f2809
commit
c0c6e59a17
@ -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')
|
||||
|
62
designateclient/cli/sync.py
Normal file
62
designateclient/cli/sync.py
Normal file
@ -0,0 +1,62 @@
|
||||
# Copyright 2012 Managed I.T.
|
||||
#
|
||||
# Author: Kiall Mac Innes <kiall@managedit.ie>
|
||||
#
|
||||
# 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')
|
@ -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()
|
||||
|
37
designateclient/v1/sync.py
Normal file
37
designateclient/v1/sync.py
Normal file
@ -0,0 +1,37 @@
|
||||
# Copyright 2012 Managed I.T.
|
||||
#
|
||||
# Author: Kiall Mac Innes <kiall@managedit.ie>
|
||||
#
|
||||
# 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))
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user