Refactor osc support

This patch refactors the OSC (OpenStackClient) support so that they are
moved out of a sub directory. We will use it as the 'default' CLI while
deprecating the previous shell.

Change-Id: I2553f0f38e5fa30735be63ab00dec4b3a4080ba5
This commit is contained in:
tengqm
2016-03-24 22:30:22 -04:00
parent 80e0751783
commit 735b018198
30 changed files with 90 additions and 104 deletions

View File

@@ -1,33 +0,0 @@
# 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 mock
from openstackclient.tests import utils
from senlinclient.tests.unit.osc import fakes
class FakeClusteringv1Client(object):
def __init__(self, **kwargs):
self.http_client = mock.Mock()
self.http_client.auth_token = kwargs['token']
self.profiles = fakes.FakeResource(None, {})
class TestClusteringv1(utils.TestCommand):
def setUp(self):
super(TestClusteringv1, self).setUp()
self.app.client_manager.clustering = FakeClusteringv1Client(
token=fakes.AUTH_TOKEN,
auth_url=fakes.AUTH_URL
)

View File

@@ -11,10 +11,13 @@
# under the License.
import json
import mock
import requests
import six
import sys
from openstackclient.tests import utils
AUTH_TOKEN = "foobar"
AUTH_URL = "http://0.0.0.0"
@@ -158,3 +161,19 @@ class FakeResponse(requests.Response):
self._content = json.dumps(data)
if not isinstance(self._content, six.binary_type):
self._content = self._content.encode()
class FakeClusteringv1Client(object):
def __init__(self, **kwargs):
self.http_client = mock.Mock()
self.http_client.auth_token = kwargs['token']
self.profiles = FakeResource(None, {})
class TestClusteringv1(utils.TestCommand):
def setUp(self):
super(TestClusteringv1, self).setUp()
self.app.client_manager.clustering = FakeClusteringv1Client(
token=AUTH_TOKEN, auth_url=AUTH_URL
)

View File

@@ -17,8 +17,8 @@ from openstack.cluster.v1 import action as sdk_action
from openstack import exceptions as sdk_exc
from openstackclient.common import exceptions as exc
from senlinclient.osc.v1 import action as osc_action
from senlinclient.tests.unit.osc.v1 import fakes
from senlinclient.tests.unit.v1 import fakes
from senlinclient.v1 import action as osc_action
class TestAction(fakes.TestClusteringv1):

View File

@@ -14,8 +14,8 @@ import mock
from openstack.cluster.v1 import build_info as sdk_build_info
from senlinclient.osc.v1 import build_info as osc_build_info
from senlinclient.tests.unit.osc.v1 import fakes
from senlinclient.tests.unit.v1 import fakes
from senlinclient.v1 import build_info as osc_build_info
class TestBuildInfo(fakes.TestClusteringv1):

View File

@@ -18,8 +18,8 @@ from openstack.cluster.v1 import cluster as sdk_cluster
from openstack import exceptions as sdk_exc
from openstackclient.common import exceptions as exc
from senlinclient.osc.v1 import cluster as osc_cluster
from senlinclient.tests.unit.osc.v1 import fakes
from senlinclient.tests.unit.v1 import fakes
from senlinclient.v1 import cluster as osc_cluster
class TestCluster(fakes.TestClusteringv1):

View File

@@ -14,8 +14,8 @@ import mock
from openstack.cluster.v1 import cluster_policy as sdk_cluster_policy
from senlinclient.osc.v1 import cluster_policy as osc_cluster_policy
from senlinclient.tests.unit.osc.v1 import fakes
from senlinclient.tests.unit.v1 import fakes
from senlinclient.v1 import cluster_policy as osc_cluster_policy
class TestClusterPolicy(fakes.TestClusteringv1):

View File

@@ -17,8 +17,8 @@ from openstack.cluster.v1 import event as sdk_event
from openstack import exceptions as sdk_exc
from openstackclient.common import exceptions as exc
from senlinclient.osc.v1 import event as osc_event
from senlinclient.tests.unit.osc.v1 import fakes
from senlinclient.tests.unit.v1 import fakes
from senlinclient.v1 import event as osc_event
class TestEvent(fakes.TestClusteringv1):

View File

@@ -18,8 +18,8 @@ from openstack.cluster.v1 import node as sdk_node
from openstack import exceptions as sdk_exc
from openstackclient.common import exceptions as exc
from senlinclient.osc.v1 import node as osc_node
from senlinclient.tests.unit.osc.v1 import fakes
from senlinclient.tests.unit.v1 import fakes
from senlinclient.v1 import node as osc_node
class TestNode(fakes.TestClusteringv1):

View File

@@ -18,8 +18,8 @@ from openstack.cluster.v1 import policy as sdk_policy
from openstack import exceptions as sdk_exc
from openstackclient.common import exceptions as exc
from senlinclient.osc.v1 import policy as osc_policy
from senlinclient.tests.unit.osc.v1 import fakes
from senlinclient.tests.unit.v1 import fakes
from senlinclient.v1 import policy as osc_policy
class TestPolicy(fakes.TestClusteringv1):

View File

@@ -16,8 +16,8 @@ from openstack.cluster.v1 import policy_type as sdk_policy_type
from openstack import exceptions as sdk_exc
from openstackclient.common import exceptions as exc
from senlinclient.osc.v1 import policy_type as osc_policy_type
from senlinclient.tests.unit.osc.v1 import fakes
from senlinclient.tests.unit.v1 import fakes
from senlinclient.v1 import policy_type as osc_policy_type
class TestPolicyType(fakes.TestClusteringv1):

View File

@@ -19,8 +19,8 @@ from openstack import exceptions as sdk_exc
from openstackclient.common import exceptions as exc
from openstackclient.common import utils
from senlinclient.osc.v1 import profile as osc_profile
from senlinclient.tests.unit.osc.v1 import fakes
from senlinclient.tests.unit.v1 import fakes
from senlinclient.v1 import profile as osc_profile
class TestProfile(fakes.TestClusteringv1):

View File

@@ -16,8 +16,8 @@ from openstack.cluster.v1 import profile_type as sdk_profile_type
from openstack import exceptions as sdk_exc
from openstackclient.common import exceptions as exc
from senlinclient.osc.v1 import profile_type as osc_profile_type
from senlinclient.tests.unit.osc.v1 import fakes
from senlinclient.tests.unit.v1 import fakes
from senlinclient.v1 import profile_type as osc_profile_type
class TestProfileType(fakes.TestClusteringv1):

View File

@@ -18,8 +18,8 @@ from openstack.cluster.v1 import receiver as sdk_receiver
from openstack import exceptions as sdk_exc
from openstackclient.common import exceptions as exc
from senlinclient.osc.v1 import receiver as osc_receiver
from senlinclient.tests.unit.osc.v1 import fakes
from senlinclient.tests.unit.v1 import fakes
from senlinclient.v1 import receiver as osc_receiver
class TestReceiver(fakes.TestClusteringv1):

View File

@@ -27,57 +27,57 @@ console_scripts =
senlin = senlinclient.shell:main
openstack.cli.extension =
clustering = senlinclient.osc.plugin
clustering = senlinclient.plugin
openstack.clustering.v1 =
cluster_action_list = senlinclient.osc.v1.action:ListAction
cluster_action_show = senlinclient.osc.v1.action:ShowAction
cluster_build_info = senlinclient.osc.v1.build_info:BuildInfo
cluster_check = senlinclient.osc.v1.cluster:CheckCluster
cluster_create = senlinclient.osc.v1.cluster:CreateCluster
cluster_delete = senlinclient.osc.v1.cluster:DeleteCluster
cluster_event_list = senlinclient.osc.v1.event:ListEvent
cluster_event_show = senlinclient.osc.v1.event:ShowEvent
cluster_list = senlinclient.osc.v1.cluster:ListCluster
cluster_members_list = senlinclient.osc.v1.cluster:ClusterNodeList
cluster_members_add = senlinclient.osc.v1.cluster:ClusterNodeAdd
cluster_members_del = senlinclient.osc.v1.cluster:ClusterNodeDel
cluster_node_check = senlinclient.osc.v1.node:CheckNode
cluster_node_create = senlinclient.osc.v1.node:CreateNode
cluster_node_delete = senlinclient.osc.v1.node:DeleteNode
cluster_node_list = senlinclient.osc.v1.node:ListNode
cluster_node_recover = senlinclient.osc.v1.node:RecoverNode
cluster_node_show = senlinclient.osc.v1.node:ShowNode
cluster_node_update = senlinclient.osc.v1.node:UpdateNode
cluster_policy_attach = senlinclient.osc.v1.cluster:ClusterPolicyAttach
cluster_policy_binding_list = senlinclient.osc.v1.cluster_policy:ClusterPolicyList
cluster_policy_binding_show = senlinclient.osc.v1.cluster_policy:ClusterPolicyShow
cluster_policy_binding_update = senlinclient.osc.v1.cluster_policy:ClusterPolicyUpdate
cluster_policy_create = senlinclient.osc.v1.policy:CreatePolicy
cluster_policy_delete = senlinclient.osc.v1.policy:DeletePolicy
cluster_policy_detach = senlinclient.osc.v1.cluster:ClusterPolicyDetach
cluster_policy_list = senlinclient.osc.v1.policy:ListPolicy
cluster_policy_show = senlinclient.osc.v1.policy:ShowPolicy
cluster_policy_type_list = senlinclient.osc.v1.policy_type:PolicyTypeList
cluster_policy_type_show = senlinclient.osc.v1.policy_type:PolicyTypeShow
cluster_policy_update = senlinclient.osc.v1.policy:UpdatePolicy
cluster_profile_create = senlinclient.osc.v1.profile:CreateProfile
cluster_profile_delete = senlinclient.osc.v1.profile:DeleteProfile
cluster_profile_list = senlinclient.osc.v1.profile:ListProfile
cluster_profile_show = senlinclient.osc.v1.profile:ShowProfile
cluster_profile_type_list = senlinclient.osc.v1.profile_type:ProfileTypeList
cluster_profile_type_show = senlinclient.osc.v1.profile_type:ProfileTypeShow
cluster_profile_update = senlinclient.osc.v1.profile:UpdateProfile
cluster_receiver_create = senlinclient.osc.v1.receiver:CreateReceiver
cluster_receiver_delete = senlinclient.osc.v1.receiver:DeleteReceiver
cluster_receiver_list = senlinclient.osc.v1.receiver:ListReceiver
cluster_receiver_show = senlinclient.osc.v1.receiver:ShowReceiver
cluster_recover = senlinclient.osc.v1.cluster:RecoverCluster
cluster_resize = senlinclient.osc.v1.cluster:ResizeCluster
cluster_scale_in = senlinclient.osc.v1.cluster:ScaleInCluster
cluster_scale_out = senlinclient.osc.v1.cluster:ScaleOutCluster
cluster_show = senlinclient.osc.v1.cluster:ShowCluster
cluster_update = senlinclient.osc.v1.cluster:UpdateCluster
cluster_action_list = senlinclient.v1.action:ListAction
cluster_action_show = senlinclient.v1.action:ShowAction
cluster_build_info = senlinclient.v1.build_info:BuildInfo
cluster_check = senlinclient.v1.cluster:CheckCluster
cluster_create = senlinclient.v1.cluster:CreateCluster
cluster_delete = senlinclient.v1.cluster:DeleteCluster
cluster_event_list = senlinclient.v1.event:ListEvent
cluster_event_show = senlinclient.v1.event:ShowEvent
cluster_list = senlinclient.v1.cluster:ListCluster
cluster_members_list = senlinclient.v1.cluster:ClusterNodeList
cluster_members_add = senlinclient.v1.cluster:ClusterNodeAdd
cluster_members_del = senlinclient.v1.cluster:ClusterNodeDel
cluster_node_check = senlinclient.v1.node:CheckNode
cluster_node_create = senlinclient.v1.node:CreateNode
cluster_node_delete = senlinclient.v1.node:DeleteNode
cluster_node_list = senlinclient.v1.node:ListNode
cluster_node_recover = senlinclient.v1.node:RecoverNode
cluster_node_show = senlinclient.v1.node:ShowNode
cluster_node_update = senlinclient.v1.node:UpdateNode
cluster_policy_attach = senlinclient.v1.cluster:ClusterPolicyAttach
cluster_policy_binding_list = senlinclient.v1.cluster_policy:ClusterPolicyList
cluster_policy_binding_show = senlinclient.v1.cluster_policy:ClusterPolicyShow
cluster_policy_binding_update = senlinclient.v1.cluster_policy:ClusterPolicyUpdate
cluster_policy_create = senlinclient.v1.policy:CreatePolicy
cluster_policy_delete = senlinclient.v1.policy:DeletePolicy
cluster_policy_detach = senlinclient.v1.cluster:ClusterPolicyDetach
cluster_policy_list = senlinclient.v1.policy:ListPolicy
cluster_policy_show = senlinclient.v1.policy:ShowPolicy
cluster_policy_type_list = senlinclient.v1.policy_type:PolicyTypeList
cluster_policy_type_show = senlinclient.v1.policy_type:PolicyTypeShow
cluster_policy_update = senlinclient.v1.policy:UpdatePolicy
cluster_profile_create = senlinclient.v1.profile:CreateProfile
cluster_profile_delete = senlinclient.v1.profile:DeleteProfile
cluster_profile_list = senlinclient.v1.profile:ListProfile
cluster_profile_show = senlinclient.v1.profile:ShowProfile
cluster_profile_type_list = senlinclient.v1.profile_type:ProfileTypeList
cluster_profile_type_show = senlinclient.v1.profile_type:ProfileTypeShow
cluster_profile_update = senlinclient.v1.profile:UpdateProfile
cluster_receiver_create = senlinclient.v1.receiver:CreateReceiver
cluster_receiver_delete = senlinclient.v1.receiver:DeleteReceiver
cluster_receiver_list = senlinclient.v1.receiver:ListReceiver
cluster_receiver_show = senlinclient.v1.receiver:ShowReceiver
cluster_recover = senlinclient.v1.cluster:RecoverCluster
cluster_resize = senlinclient.v1.cluster:ResizeCluster
cluster_scale_in = senlinclient.v1.cluster:ScaleInCluster
cluster_scale_out = senlinclient.v1.cluster:ScaleOutCluster
cluster_show = senlinclient.v1.cluster:ShowCluster
cluster_update = senlinclient.v1.cluster:UpdateCluster
[global]
setup-hooks =