Use osc_lib instead of cliff

Base classes of commands are defined in cliff,
but have been encapsulated again in osc-lib for
all plugin clients. So use osc-lib instead of
cliff.

Change-Id: I9ec5dc794d8449bc3618889f68993cea734cb0a9
This commit is contained in:
Tang Chen 2016-06-30 17:00:24 +08:00
parent fd118972b0
commit 946bd09935
7 changed files with 50 additions and 62 deletions

View File

@ -16,10 +16,8 @@
import abc import abc
import warnings import warnings
from cliff.command import Command as CliffCommand
from cliff.lister import Lister
from cliff.show import ShowOne
from keystoneauth1 import exceptions as ks_exceptions from keystoneauth1 import exceptions as ks_exceptions
from osc_lib.command import command
import six import six
from designateclient import exceptions from designateclient import exceptions
@ -28,7 +26,7 @@ from designateclient.v1 import Client
@six.add_metaclass(abc.ABCMeta) @six.add_metaclass(abc.ABCMeta)
class Command(CliffCommand): class Command(command.Command):
def run(self, parsed_args): def run(self, parsed_args):
warnings.simplefilter('once', category=DeprecationWarning) warnings.simplefilter('once', category=DeprecationWarning)
@ -109,7 +107,7 @@ class Command(CliffCommand):
return utils.find_resourceid_by_name_or_id(resource_client, name_or_id) return utils.find_resourceid_by_name_or_id(resource_client, name_or_id)
class ListCommand(Command, Lister): class ListCommand(Command, command.Lister):
columns = None columns = None
def post_execute(self, results): def post_execute(self, results):
@ -121,21 +119,21 @@ class ListCommand(Command, Lister):
return [], () return [], ()
class GetCommand(Command, ShowOne): class GetCommand(Command, command.ShowOne):
def post_execute(self, results): def post_execute(self, results):
return list(six.iterkeys(results)), list(six.itervalues(results)) return list(six.iterkeys(results)), list(six.itervalues(results))
class CreateCommand(Command, ShowOne): class CreateCommand(Command, command.ShowOne):
def post_execute(self, results): def post_execute(self, results):
return list(six.iterkeys(results)), list(six.itervalues(results)) return list(six.iterkeys(results)), list(six.itervalues(results))
class UpdateCommand(Command, ShowOne): class UpdateCommand(Command, command.ShowOne):
def post_execute(self, results): def post_execute(self, results):
return list(six.iterkeys(results)), list(six.itervalues(results)) return list(six.iterkeys(results)), list(six.itervalues(results))
class DeleteCommand(Command, ShowOne): class DeleteCommand(Command, command.ShowOne):
def post_execute(self, results): def post_execute(self, results):
return [], [] return [], []

View File

@ -16,9 +16,7 @@
import logging import logging
from cliff import command from osc_lib.command import command
from cliff import lister
from cliff import show
import six import six
from designateclient import utils from designateclient import utils
@ -34,7 +32,7 @@ def _format_blacklist(blacklist):
blacklist.pop('links', None) blacklist.pop('links', None)
class ListBlacklistsCommand(lister.Lister): class ListBlacklistsCommand(command.Lister):
"""List blacklists""" """List blacklists"""
columns = ['id', 'pattern', 'description'] columns = ['id', 'pattern', 'description']
@ -55,7 +53,7 @@ class ListBlacklistsCommand(lister.Lister):
return cols, (utils.get_item_properties(s, cols) for s in data) return cols, (utils.get_item_properties(s, cols) for s in data)
class ShowBlacklistCommand(show.ShowOne): class ShowBlacklistCommand(command.ShowOne):
"""Show blacklist details""" """Show blacklist details"""
def get_parser(self, prog_name): def get_parser(self, prog_name):
@ -75,7 +73,7 @@ class ShowBlacklistCommand(show.ShowOne):
return six.moves.zip(*sorted(six.iteritems(data))) return six.moves.zip(*sorted(six.iteritems(data)))
class CreateBlacklistCommand(show.ShowOne): class CreateBlacklistCommand(command.ShowOne):
"""Create new blacklist""" """Create new blacklist"""
def get_parser(self, prog_name): def get_parser(self, prog_name):
@ -100,7 +98,7 @@ class CreateBlacklistCommand(show.ShowOne):
return six.moves.zip(*sorted(six.iteritems(data))) return six.moves.zip(*sorted(six.iteritems(data)))
class SetBlacklistCommand(show.ShowOne): class SetBlacklistCommand(command.ShowOne):
"""Set blacklist properties""" """Set blacklist properties"""
def get_parser(self, prog_name): def get_parser(self, prog_name):

View File

@ -16,8 +16,7 @@
import logging import logging
from cliff import lister from osc_lib.command import command
from cliff import show
import six import six
from designateclient import utils from designateclient import utils
@ -43,7 +42,7 @@ def _has_project_id(data):
return False return False
class ListRecordSetsCommand(lister.Lister): class ListRecordSetsCommand(command.Lister):
"""List recordsets""" """List recordsets"""
columns = ['id', 'name', 'type', 'records', 'status', 'action'] columns = ['id', 'name', 'type', 'records', 'status', 'action']
@ -116,7 +115,7 @@ class ListRecordSetsCommand(lister.Lister):
return cols, (utils.get_item_properties(s, cols) for s in data) return cols, (utils.get_item_properties(s, cols) for s in data)
class ShowRecordSetCommand(show.ShowOne): class ShowRecordSetCommand(command.ShowOne):
"""Show recordset details""" """Show recordset details"""
def get_parser(self, prog_name): def get_parser(self, prog_name):
@ -138,7 +137,7 @@ class ShowRecordSetCommand(show.ShowOne):
return six.moves.zip(*sorted(six.iteritems(data))) return six.moves.zip(*sorted(six.iteritems(data)))
class CreateRecordSetCommand(show.ShowOne): class CreateRecordSetCommand(command.ShowOne):
"""Create new recordset""" """Create new recordset"""
def get_parser(self, prog_name): def get_parser(self, prog_name):
@ -172,7 +171,7 @@ class CreateRecordSetCommand(show.ShowOne):
return six.moves.zip(*sorted(six.iteritems(data))) return six.moves.zip(*sorted(six.iteritems(data)))
class SetRecordSetCommand(show.ShowOne): class SetRecordSetCommand(command.ShowOne):
"""Set recordset properties""" """Set recordset properties"""
def get_parser(self, prog_name): def get_parser(self, prog_name):
@ -223,7 +222,7 @@ class SetRecordSetCommand(show.ShowOne):
return six.moves.zip(*sorted(six.iteritems(updated))) return six.moves.zip(*sorted(six.iteritems(updated)))
class DeleteRecordSetCommand(show.ShowOne): class DeleteRecordSetCommand(command.ShowOne):
"""Delete recordset""" """Delete recordset"""
def get_parser(self, prog_name): def get_parser(self, prog_name):

View File

@ -16,9 +16,7 @@
import logging import logging
from cliff import command from osc_lib.command import command
from cliff import lister
from cliff import show
import six import six
from designateclient import utils from designateclient import utils
@ -34,7 +32,7 @@ def _format_floatingip(fip):
fip.pop('links', None) fip.pop('links', None)
class ListFloatingIPCommand(lister.Lister): class ListFloatingIPCommand(command.Lister):
"""List floatingip ptr records""" """List floatingip ptr records"""
columns = ['id', 'ptrdname', 'description', 'ttl'] columns = ['id', 'ptrdname', 'description', 'ttl']
@ -48,7 +46,7 @@ class ListFloatingIPCommand(lister.Lister):
return cols, (utils.get_item_properties(s, cols) for s in data) return cols, (utils.get_item_properties(s, cols) for s in data)
class ShowFloatingIPCommand(show.ShowOne): class ShowFloatingIPCommand(command.ShowOne):
"""Show floatingip ptr record details""" """Show floatingip ptr record details"""
def get_parser(self, prog_name): def get_parser(self, prog_name):
@ -68,7 +66,7 @@ class ShowFloatingIPCommand(show.ShowOne):
return six.moves.zip(*sorted(six.iteritems(data))) return six.moves.zip(*sorted(six.iteritems(data)))
class SetFloatingIPCommand(show.ShowOne): class SetFloatingIPCommand(command.ShowOne):
"""Set floatingip ptr record""" """Set floatingip ptr record"""
def get_parser(self, prog_name): def get_parser(self, prog_name):

View File

@ -16,8 +16,7 @@
import logging import logging
from cliff import lister from osc_lib.command import command
from cliff import show
import six import six
from designateclient import utils from designateclient import utils
@ -36,7 +35,7 @@ def _format_status(status):
return status return status
class ListServiceStatusesCommand(lister.Lister): class ListServiceStatusesCommand(command.Lister):
"""List service statuses""" """List service statuses"""
columns = ['id', 'hostname', 'service_name', 'status', 'stats', columns = ['id', 'hostname', 'service_name', 'status', 'stats',
@ -74,7 +73,7 @@ class ListServiceStatusesCommand(lister.Lister):
return cols, (utils.get_item_properties(s, cols) for s in data) return cols, (utils.get_item_properties(s, cols) for s in data)
class ShowServiceStatusCommand(show.ShowOne): class ShowServiceStatusCommand(command.ShowOne):
"""Show service status details""" """Show service status details"""
def get_parser(self, prog_name): def get_parser(self, prog_name):

View File

@ -16,9 +16,7 @@
import logging import logging
from cliff import command from osc_lib.command import command
from cliff import lister
from cliff import show
import six import six
from designateclient import utils from designateclient import utils
@ -34,7 +32,7 @@ def _format_tld(tld):
tld.pop('links', None) tld.pop('links', None)
class ListTLDsCommand(lister.Lister): class ListTLDsCommand(command.Lister):
"""List tlds""" """List tlds"""
columns = ['id', 'name', 'description'] columns = ['id', 'name', 'description']
@ -60,7 +58,7 @@ class ListTLDsCommand(lister.Lister):
return cols, (utils.get_item_properties(s, cols) for s in data) return cols, (utils.get_item_properties(s, cols) for s in data)
class ShowTLDCommand(show.ShowOne): class ShowTLDCommand(command.ShowOne):
"""Show tld details""" """Show tld details"""
def get_parser(self, prog_name): def get_parser(self, prog_name):
@ -80,7 +78,7 @@ class ShowTLDCommand(show.ShowOne):
return six.moves.zip(*sorted(six.iteritems(data))) return six.moves.zip(*sorted(six.iteritems(data)))
class CreateTLDCommand(show.ShowOne): class CreateTLDCommand(command.ShowOne):
"""Create new tld""" """Create new tld"""
def get_parser(self, prog_name): def get_parser(self, prog_name):
@ -101,7 +99,7 @@ class CreateTLDCommand(show.ShowOne):
return six.moves.zip(*sorted(six.iteritems(data))) return six.moves.zip(*sorted(six.iteritems(data)))
class SetTLDCommand(show.ShowOne): class SetTLDCommand(command.ShowOne):
"""Set tld properties""" """Set tld properties"""
def get_parser(self, prog_name): def get_parser(self, prog_name):

View File

@ -16,9 +16,7 @@
import logging import logging
from cliff import command from osc_lib.command import command
from cliff import lister
from cliff import show
from osc_lib import exceptions as osc_exc from osc_lib import exceptions as osc_exc
import six import six
@ -43,7 +41,7 @@ def _format_zone_import_record(zone_import_record):
zone_import_record.pop('links', None) zone_import_record.pop('links', None)
class ListZonesCommand(lister.Lister): class ListZonesCommand(command.Lister):
"""List zones""" """List zones"""
columns = ['id', 'name', 'type', 'serial', 'status', 'action'] columns = ['id', 'name', 'type', 'serial', 'status', 'action']
@ -99,7 +97,7 @@ class ListZonesCommand(lister.Lister):
return cols, (utils.get_item_properties(s, cols) for s in data) return cols, (utils.get_item_properties(s, cols) for s in data)
class ShowZoneCommand(show.ShowOne): class ShowZoneCommand(command.ShowOne):
"""Show zone details""" """Show zone details"""
def get_parser(self, prog_name): def get_parser(self, prog_name):
@ -121,7 +119,7 @@ class ShowZoneCommand(show.ShowOne):
return six.moves.zip(*sorted(six.iteritems(data))) return six.moves.zip(*sorted(six.iteritems(data)))
class CreateZoneCommand(show.ShowOne): class CreateZoneCommand(command.ShowOne):
"""Create new zone""" """Create new zone"""
def get_parser(self, prog_name): def get_parser(self, prog_name):
@ -172,7 +170,7 @@ class CreateZoneCommand(show.ShowOne):
return six.moves.zip(*sorted(six.iteritems(data))) return six.moves.zip(*sorted(six.iteritems(data)))
class SetZoneCommand(show.ShowOne): class SetZoneCommand(command.ShowOne):
"""Set zone properties""" """Set zone properties"""
def get_parser(self, prog_name): def get_parser(self, prog_name):
@ -217,7 +215,7 @@ class SetZoneCommand(show.ShowOne):
return six.moves.zip(*sorted(six.iteritems(updated))) return six.moves.zip(*sorted(six.iteritems(updated)))
class DeleteZoneCommand(show.ShowOne): class DeleteZoneCommand(command.ShowOne):
"""Delete zone""" """Delete zone"""
def get_parser(self, prog_name): def get_parser(self, prog_name):
@ -282,7 +280,7 @@ class AXFRZoneCommand(command.Command):
{"zone_id": parsed_args.id}) {"zone_id": parsed_args.id})
class CreateTransferRequestCommand(show.ShowOne): class CreateTransferRequestCommand(command.ShowOne):
"""Create new zone transfer request""" """Create new zone transfer request"""
def get_parser(self, prog_name): def get_parser(self, prog_name):
@ -309,7 +307,7 @@ class CreateTransferRequestCommand(show.ShowOne):
return six.moves.zip(*sorted(six.iteritems(data))) return six.moves.zip(*sorted(six.iteritems(data)))
class ListTransferRequestsCommand(lister.Lister): class ListTransferRequestsCommand(command.Lister):
"""List Zone Transfer Requests""" """List Zone Transfer Requests"""
columns = ['id', 'zone_id', 'zone_name', 'project_id', columns = ['id', 'zone_id', 'zone_name', 'project_id',
@ -333,7 +331,7 @@ class ListTransferRequestsCommand(lister.Lister):
return cols, (utils.get_item_properties(s, cols) for s in data) return cols, (utils.get_item_properties(s, cols) for s in data)
class ShowTransferRequestCommand(show.ShowOne): class ShowTransferRequestCommand(command.ShowOne):
"""Show Zone Transfer Request Details""" """Show Zone Transfer Request Details"""
def get_parser(self, prog_name): def get_parser(self, prog_name):
@ -354,7 +352,7 @@ class ShowTransferRequestCommand(show.ShowOne):
return six.moves.zip(*sorted(six.iteritems(data))) return six.moves.zip(*sorted(six.iteritems(data)))
class SetTransferRequestCommand(show.ShowOne): class SetTransferRequestCommand(command.ShowOne):
"""Set a Zone Transfer Request""" """Set a Zone Transfer Request"""
def get_parser(self, prog_name): def get_parser(self, prog_name):
@ -405,7 +403,7 @@ class DeleteTransferRequestCommand(command.Command):
LOG.info('Zone Transfer %s was deleted', parsed_args.id) LOG.info('Zone Transfer %s was deleted', parsed_args.id)
class AcceptTransferRequestCommand(show.ShowOne): class AcceptTransferRequestCommand(command.ShowOne):
"""Accept a Zone Transfer Request""" """Accept a Zone Transfer Request"""
def get_parser(self, prog_name): def get_parser(self, prog_name):
@ -430,7 +428,7 @@ class AcceptTransferRequestCommand(show.ShowOne):
return six.moves.zip(*sorted(six.iteritems(data))) return six.moves.zip(*sorted(six.iteritems(data)))
class ListTransferAcceptsCommand(lister.Lister): class ListTransferAcceptsCommand(command.Lister):
"""List Zone Transfer Accepts""" """List Zone Transfer Accepts"""
columns = ['id', 'zone_id', 'project_id', columns = ['id', 'zone_id', 'project_id',
@ -454,7 +452,7 @@ class ListTransferAcceptsCommand(lister.Lister):
return cols, (utils.get_item_properties(s, cols) for s in data) return cols, (utils.get_item_properties(s, cols) for s in data)
class ShowTransferAcceptCommand(show.ShowOne): class ShowTransferAcceptCommand(command.ShowOne):
"""Show Zone Transfer Accept""" """Show Zone Transfer Accept"""
def get_parser(self, prog_name): def get_parser(self, prog_name):
@ -475,7 +473,7 @@ class ShowTransferAcceptCommand(show.ShowOne):
return six.moves.zip(*sorted(six.iteritems(data))) return six.moves.zip(*sorted(six.iteritems(data)))
class ExportZoneCommand(show.ShowOne): class ExportZoneCommand(command.ShowOne):
"""Export a Zone""" """Export a Zone"""
def get_parser(self, prog_name): def get_parser(self, prog_name):
@ -500,7 +498,7 @@ class ExportZoneCommand(show.ShowOne):
return six.moves.zip(*sorted(six.iteritems(data))) return six.moves.zip(*sorted(six.iteritems(data)))
class ListZoneExportsCommand(lister.Lister): class ListZoneExportsCommand(command.Lister):
"""List Zone Exports""" """List Zone Exports"""
columns = [ columns = [
@ -529,7 +527,7 @@ class ListZoneExportsCommand(lister.Lister):
for s in data['exports']) for s in data['exports'])
class ShowZoneExportCommand(show.ShowOne): class ShowZoneExportCommand(command.ShowOne):
"""Show a Zone Export""" """Show a Zone Export"""
def get_parser(self, prog_name): def get_parser(self, prog_name):
@ -575,7 +573,7 @@ class DeleteZoneExportCommand(command.Command):
LOG.info('Zone Export %s was deleted', parsed_args.zone_export_id) LOG.info('Zone Export %s was deleted', parsed_args.zone_export_id)
class ShowZoneExportFileCommand(show.ShowOne): class ShowZoneExportFileCommand(command.ShowOne):
"""Show the zone file for the Zone Export""" """Show the zone file for the Zone Export"""
def get_parser(self, prog_name): def get_parser(self, prog_name):
@ -597,7 +595,7 @@ class ShowZoneExportFileCommand(show.ShowOne):
return ['data'], [data] return ['data'], [data]
class ImportZoneCommand(show.ShowOne): class ImportZoneCommand(command.ShowOne):
"""Import a Zone from a file on the filesystem""" """Import a Zone from a file on the filesystem"""
def get_parser(self, prog_name): def get_parser(self, prog_name):
@ -626,7 +624,7 @@ class ImportZoneCommand(show.ShowOne):
return six.moves.zip(*sorted(six.iteritems(data))) return six.moves.zip(*sorted(six.iteritems(data)))
class ListZoneImportsCommand(lister.Lister): class ListZoneImportsCommand(command.Lister):
"""List Zone Imports""" """List Zone Imports"""
columns = [ columns = [
@ -656,7 +654,7 @@ class ListZoneImportsCommand(lister.Lister):
for s in data['imports']) for s in data['imports'])
class ShowZoneImportCommand(show.ShowOne): class ShowZoneImportCommand(command.ShowOne):
"""Show a Zone Import""" """Show a Zone Import"""
def get_parser(self, prog_name): def get_parser(self, prog_name):