From 4437ed83bea6ed402f3d91626b2cea618139a329 Mon Sep 17 00:00:00 2001 From: Tang Chen Date: Mon, 27 Jun 2016 20:14:37 +0800 Subject: [PATCH] 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: I7b64c4dbedf270720f222471d57b9e20ab5a046c --- requirements.txt | 1 - senlinclient/common/format_utils.py | 4 ++-- senlinclient/v1/action.py | 7 +++---- senlinclient/v1/build_info.py | 4 ++-- senlinclient/v1/cluster.py | 14 ++++++-------- senlinclient/v1/cluster_policy.py | 8 +++----- senlinclient/v1/event.py | 7 +++---- senlinclient/v1/node.py | 12 +++++------- senlinclient/v1/policy.py | 12 +++++------- senlinclient/v1/policy_type.py | 4 ++-- senlinclient/v1/profile.py | 12 +++++------- senlinclient/v1/profile_type.py | 4 ++-- senlinclient/v1/receiver.py | 10 ++++------ 13 files changed, 42 insertions(+), 57 deletions(-) diff --git a/requirements.txt b/requirements.txt index 4703cf34..39edb2a9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,7 +4,6 @@ Babel>=2.3.4 # BSD pbr>=1.6 # Apache-2.0 -cliff!=1.16.0,!=1.17.0,>=1.15.0 # Apache-2.0 PrettyTable<0.8,>=0.7 # BSD openstacksdk>=0.8.6 # Apache-2.0 osc-lib>=0.1.0 # Apache-2.0 diff --git a/senlinclient/common/format_utils.py b/senlinclient/common/format_utils.py index 370729de..f7973bc0 100644 --- a/senlinclient/common/format_utils.py +++ b/senlinclient/common/format_utils.py @@ -10,10 +10,10 @@ # License for the specific language governing permissions and limitations # under the License. -from cliff import show +from osc_lib.command import command -class RawFormat(show.ShowOne): +class RawFormat(command.ShowOne): def produce_output(self, parsed_args, column_names, data): if data is None: diff --git a/senlinclient/v1/action.py b/senlinclient/v1/action.py index 1e0187b4..19f68497 100644 --- a/senlinclient/v1/action.py +++ b/senlinclient/v1/action.py @@ -15,9 +15,8 @@ import logging import six -from cliff import lister -from cliff import show from openstack import exceptions as sdk_exc +from osc_lib.command import command from osc_lib import exceptions as exc from osc_lib import utils @@ -25,7 +24,7 @@ from senlinclient.common.i18n import _ from senlinclient.common import utils as senlin_utils -class ListAction(lister.Lister): +class ListAction(command.Lister): """List actions.""" log = logging.getLogger(__name__ + ".ListAction") @@ -109,7 +108,7 @@ class ListAction(lister.Lister): ) -class ShowAction(show.ShowOne): +class ShowAction(command.ShowOne): """Show detailed info about the specified action.""" log = logging.getLogger(__name__ + ".ShowAction") diff --git a/senlinclient/v1/build_info.py b/senlinclient/v1/build_info.py index 9d1b9f36..bba0d89a 100644 --- a/senlinclient/v1/build_info.py +++ b/senlinclient/v1/build_info.py @@ -15,13 +15,13 @@ import logging import six -from cliff import show +from osc_lib.command import command from osc_lib import utils from senlinclient.common import utils as senlin_utils -class BuildInfo(show.ShowOne): +class BuildInfo(command.ShowOne): """Retrieve build information.""" log = logging.getLogger(__name__ + ".BuildInfo") diff --git a/senlinclient/v1/cluster.py b/senlinclient/v1/cluster.py index 3dc77a1b..28378cb3 100644 --- a/senlinclient/v1/cluster.py +++ b/senlinclient/v1/cluster.py @@ -16,10 +16,8 @@ import logging import six import sys -from cliff import command -from cliff import lister -from cliff import show from openstack import exceptions as sdk_exc +from osc_lib.command import command from osc_lib import exceptions as exc from osc_lib import utils @@ -28,7 +26,7 @@ from senlinclient.common.i18n import _LI from senlinclient.common import utils as senlin_utils -class ListCluster(lister.Lister): +class ListCluster(command.Lister): """List the user's clusters.""" log = logging.getLogger(__name__ + ".ListCluster") @@ -106,7 +104,7 @@ class ListCluster(lister.Lister): ) -class ShowCluster(show.ShowOne): +class ShowCluster(command.ShowOne): """Show details of the cluster.""" log = logging.getLogger(__name__ + ".ShowCluster") @@ -142,7 +140,7 @@ def _show_cluster(senlin_client, cluster_id): formatters=formatters) -class CreateCluster(show.ShowOne): +class CreateCluster(command.ShowOne): """Create the cluster.""" log = logging.getLogger(__name__ + ".CreateCluster") @@ -215,7 +213,7 @@ class CreateCluster(show.ShowOne): return _show_cluster(senlin_client, cluster.id) -class UpdateCluster(show.ShowOne): +class UpdateCluster(command.ShowOne): """Update the cluster.""" log = logging.getLogger(__name__ + ".UpdateCluster") @@ -584,7 +582,7 @@ class ClusterPolicyDetach(command.Command): print('Request accepted by action: %s' % resp['action']) -class ClusterNodeList(lister.Lister): +class ClusterNodeList(command.Lister): """List nodes from cluster.""" log = logging.getLogger(__name__ + ".ClusterNodeList") diff --git a/senlinclient/v1/cluster_policy.py b/senlinclient/v1/cluster_policy.py index 21cc111c..466c5178 100644 --- a/senlinclient/v1/cluster_policy.py +++ b/senlinclient/v1/cluster_policy.py @@ -15,16 +15,14 @@ import logging import six -from cliff import command -from cliff import lister -from cliff import show +from osc_lib.command import command from osc_lib import utils from senlinclient.common.i18n import _ from senlinclient.common import utils as senlin_utils -class ClusterPolicyList(lister.Lister): +class ClusterPolicyList(command.Lister): """List policies from cluster.""" log = logging.getLogger(__name__ + ".ClusterPolicyList") @@ -88,7 +86,7 @@ class ClusterPolicyList(lister.Lister): ) -class ClusterPolicyShow(show.ShowOne): +class ClusterPolicyShow(command.ShowOne): """Show a specific policy that is bound to the specified cluster.""" log = logging.getLogger(__name__ + ".ClusterPolicyShow") diff --git a/senlinclient/v1/event.py b/senlinclient/v1/event.py index 8df137d7..d5fa7315 100644 --- a/senlinclient/v1/event.py +++ b/senlinclient/v1/event.py @@ -15,9 +15,8 @@ import logging import six -from cliff import lister -from cliff import show from openstack import exceptions as sdk_exc +from osc_lib.command import command from osc_lib import exceptions as exc from osc_lib import utils @@ -25,7 +24,7 @@ from senlinclient.common.i18n import _ from senlinclient.common import utils as senlin_utils -class ListEvent(lister.Lister): +class ListEvent(command.Lister): """List events.""" log = logging.getLogger(__name__ + ".ListEvent") @@ -106,7 +105,7 @@ class ListEvent(lister.Lister): ) -class ShowEvent(show.ShowOne): +class ShowEvent(command.ShowOne): """Describe the event.""" log = logging.getLogger(__name__ + ".ShowEvent") diff --git a/senlinclient/v1/node.py b/senlinclient/v1/node.py index c9d8813a..c92b01b3 100644 --- a/senlinclient/v1/node.py +++ b/senlinclient/v1/node.py @@ -16,10 +16,8 @@ import logging import six import sys -from cliff import command -from cliff import lister -from cliff import show from openstack import exceptions as sdk_exc +from osc_lib.command import command from osc_lib import exceptions as exc from osc_lib import utils @@ -28,7 +26,7 @@ from senlinclient.common.i18n import _LI from senlinclient.common import utils as senlin_utils -class ListNode(lister.Lister): +class ListNode(command.Lister): """Show list of nodes.""" log = logging.getLogger(__name__ + ".ListNode") @@ -118,7 +116,7 @@ class ListNode(lister.Lister): ) -class ShowNode(show.ShowOne): +class ShowNode(command.ShowOne): """Show detailed info about the specified node.""" log = logging.getLogger(__name__ + ".ShowNode") @@ -167,7 +165,7 @@ def _show_node(senlin_client, node_id, show_details=False): formatters=formatters) -class CreateNode(show.ShowOne): +class CreateNode(command.ShowOne): """Create the node.""" log = logging.getLogger(__name__ + ".CreateNode") @@ -221,7 +219,7 @@ class CreateNode(show.ShowOne): return _show_node(senlin_client, node.id) -class UpdateNode(show.ShowOne): +class UpdateNode(command.ShowOne): """Update the node.""" log = logging.getLogger(__name__ + ".UpdateNode") diff --git a/senlinclient/v1/policy.py b/senlinclient/v1/policy.py index e51bed34..c888f6d9 100644 --- a/senlinclient/v1/policy.py +++ b/senlinclient/v1/policy.py @@ -15,10 +15,8 @@ import logging import sys -from cliff import command -from cliff import lister -from cliff import show from openstack import exceptions as sdk_exc +from osc_lib.command import command from osc_lib import exceptions as exc from osc_lib import utils @@ -27,7 +25,7 @@ from senlinclient.common.i18n import _LI from senlinclient.common import utils as senlin_utils -class ListPolicy(lister.Lister): +class ListPolicy(command.Lister): """List policies that meet the criteria.""" log = logging.getLogger(__name__ + ".ListPolicy") @@ -105,7 +103,7 @@ class ListPolicy(lister.Lister): ) -class ShowPolicy(show.ShowOne): +class ShowPolicy(command.ShowOne): """Show the policy details.""" log = logging.getLogger(__name__ + ".ShowPolicy") @@ -151,7 +149,7 @@ def _show_policy(senlin_client, policy_id): formatters=formatters) -class CreatePolicy(show.ShowOne): +class CreatePolicy(command.ShowOne): """Create a policy.""" log = logging.getLogger(__name__ + ".CreatePolicy") @@ -185,7 +183,7 @@ class CreatePolicy(show.ShowOne): return _show_policy(senlin_client, policy.id) -class UpdatePolicy(show.ShowOne): +class UpdatePolicy(command.ShowOne): """Update a policy.""" log = logging.getLogger(__name__ + ".UpdatePolicy") diff --git a/senlinclient/v1/policy_type.py b/senlinclient/v1/policy_type.py index 465ecba4..e175c657 100644 --- a/senlinclient/v1/policy_type.py +++ b/senlinclient/v1/policy_type.py @@ -15,15 +15,15 @@ import logging import six -from cliff import lister from openstack import exceptions as sdk_exc +from osc_lib.command import command from osc_lib import exceptions as exc from senlinclient.common import format_utils from senlinclient.common.i18n import _ -class PolicyTypeList(lister.Lister): +class PolicyTypeList(command.Lister): """List the available policy types.""" log = logging.getLogger(__name__ + ".PolicyTypeList") diff --git a/senlinclient/v1/profile.py b/senlinclient/v1/profile.py index 6b6b0c1a..56b57d2e 100644 --- a/senlinclient/v1/profile.py +++ b/senlinclient/v1/profile.py @@ -15,10 +15,8 @@ import logging import sys -from cliff import command -from cliff import lister -from cliff import show from openstack import exceptions as sdk_exc +from osc_lib.command import command from osc_lib import exceptions as exc from osc_lib import utils @@ -27,7 +25,7 @@ from senlinclient.common.i18n import _LI from senlinclient.common import utils as senlin_utils -class ShowProfile(show.ShowOne): +class ShowProfile(command.ShowOne): """Show profile details.""" log = logging.getLogger(__name__ + ".ShowProfile") @@ -76,7 +74,7 @@ def _show_profile(senlin_client, profile_id): formatters=formatters) -class ListProfile(lister.Lister): +class ListProfile(command.Lister): """List profiles that meet the criteria.""" log = logging.getLogger(__name__ + ".ListProfile") @@ -207,7 +205,7 @@ class DeleteProfile(command.Command): print('Profile deleted: %s' % parsed_args.profile) -class CreateProfile(show.ShowOne): +class CreateProfile(command.ShowOne): """Create a profile.""" log = logging.getLogger(__name__ + ".CreateProfile") @@ -264,7 +262,7 @@ class CreateProfile(show.ShowOne): return _show_profile(senlin_client, profile_id=profile.id) -class UpdateProfile(show.ShowOne): +class UpdateProfile(command.ShowOne): """Update a profile.""" log = logging.getLogger(__name__ + ".UpdateProfile") diff --git a/senlinclient/v1/profile_type.py b/senlinclient/v1/profile_type.py index b82043bb..dc7cfb0d 100644 --- a/senlinclient/v1/profile_type.py +++ b/senlinclient/v1/profile_type.py @@ -15,14 +15,14 @@ import logging import six -from cliff import lister from openstack import exceptions as sdk_exc +from osc_lib.command import command from osc_lib import exceptions as exc from senlinclient.common import format_utils from senlinclient.common.i18n import _ -class ProfileTypeList(lister.Lister): +class ProfileTypeList(command.Lister): """List the available profile types.""" log = logging.getLogger(__name__ + ".ProfileTypeList") diff --git a/senlinclient/v1/receiver.py b/senlinclient/v1/receiver.py index 58d0758b..79b0e3ee 100644 --- a/senlinclient/v1/receiver.py +++ b/senlinclient/v1/receiver.py @@ -16,10 +16,8 @@ import logging import six import sys -from cliff import command -from cliff import lister -from cliff import show from openstack import exceptions as sdk_exc +from osc_lib.command import command from osc_lib import exceptions as exc from osc_lib import utils @@ -28,7 +26,7 @@ from senlinclient.common.i18n import _LI from senlinclient.common import utils as senlin_utils -class ListReceiver(lister.Lister): +class ListReceiver(command.Lister): """List receivers that meet the criteria.""" log = logging.getLogger(__name__ + ".ListReceiver") @@ -110,7 +108,7 @@ class ListReceiver(lister.Lister): ) -class ShowReceiver(show.ShowOne): +class ShowReceiver(command.ShowOne): """Show the receiver details.""" log = logging.getLogger(__name__ + ".ShowReceiver") @@ -147,7 +145,7 @@ def _show_receiver(senlin_client, receiver_id): formatters=formatters) -class CreateReceiver(show.ShowOne): +class CreateReceiver(command.ShowOne): """Create a receiver.""" log = logging.getLogger(__name__ + ".CreateReceiver")