Skip to content

Commit

Permalink
Add IdentityV3Client for cleanup
Browse files Browse the repository at this point in the history
In identity v3 clients, there is a lot of duplicated code for
setting CONF. This patch adds IdentityV3Client for removing them.

Change-Id: Ib09342d7d831e8ac496efa0d799cd17af3c4a95f
  • Loading branch information
Ken'ichi Ohmichi committed Dec 19, 2014
1 parent c7b08af commit 5e39799
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 61 deletions.
30 changes: 30 additions & 0 deletions tempest/services/identity/v3/json/base.py
@@ -0,0 +1,30 @@
# Copyright 2014 NEC Corporation. All rights reserved.
#
# 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 tempest.common import rest_client
from tempest import config

CONF = config.CONF


class IdentityV3Client(rest_client.RestClient):
"""
Base identity v3 client class
"""

def __init__(self, auth_provider):
super(IdentityV3Client, self).__init__(auth_provider)
self.service = CONF.identity.catalog_type
self.endpoint_url = 'adminURL'
self.api_version = "v3"
13 changes: 2 additions & 11 deletions tempest/services/identity/v3/json/credentials_client.py
Expand Up @@ -15,19 +15,10 @@

import json

from tempest.common import rest_client
from tempest import config
from tempest.services.identity.v3.json import base

CONF = config.CONF


class CredentialsClientJSON(rest_client.RestClient):

def __init__(self, auth_provider):
super(CredentialsClientJSON, self).__init__(auth_provider)
self.service = CONF.identity.catalog_type
self.endpoint_url = 'adminURL'
self.api_version = "v3"
class CredentialsClientJSON(base.IdentityV3Client):

def create_credential(self, access_key, secret_key, user_id, project_id):
"""Creates a credential."""
Expand Down
13 changes: 2 additions & 11 deletions tempest/services/identity/v3/json/endpoints_client.py
Expand Up @@ -15,19 +15,10 @@

import json

from tempest.common import rest_client
from tempest import config
from tempest.services.identity.v3.json import base

CONF = config.CONF


class EndPointClientJSON(rest_client.RestClient):

def __init__(self, auth_provider):
super(EndPointClientJSON, self).__init__(auth_provider)
self.service = CONF.identity.catalog_type
self.endpoint_url = 'adminURL'
self.api_version = "v3"
class EndPointClientJSON(base.IdentityV3Client):

def list_endpoints(self):
"""GET endpoints."""
Expand Down
9 changes: 2 additions & 7 deletions tempest/services/identity/v3/json/identity_client.py
Expand Up @@ -19,17 +19,12 @@
from tempest.common import rest_client
from tempest import config
from tempest import exceptions
from tempest.services.identity.v3.json import base

CONF = config.CONF


class IdentityV3ClientJSON(rest_client.RestClient):

def __init__(self, auth_provider):
super(IdentityV3ClientJSON, self).__init__(auth_provider)
self.service = CONF.identity.catalog_type
self.endpoint_url = 'adminURL'
self.api_version = "v3"
class IdentityV3ClientJSON(base.IdentityV3Client):

def create_user(self, user_name, password=None, project_id=None,
email=None, domain_id='default', **kwargs):
Expand Down
12 changes: 2 additions & 10 deletions tempest/services/identity/v3/json/policy_client.py
Expand Up @@ -16,18 +16,10 @@
import json

from tempest.common import rest_client
from tempest import config
from tempest.services.identity.v3.json import base

CONF = config.CONF


class PolicyClientJSON(rest_client.RestClient):

def __init__(self, auth_provider):
super(PolicyClientJSON, self).__init__(auth_provider)
self.service = CONF.identity.catalog_type
self.endpoint_url = 'adminURL'
self.api_version = "v3"
class PolicyClientJSON(base.IdentityV3Client):

def create_policy(self, blob, type):
"""Creates a Policy."""
Expand Down
13 changes: 2 additions & 11 deletions tempest/services/identity/v3/json/region_client.py
Expand Up @@ -16,19 +16,10 @@
import json
import urllib

from tempest.common import rest_client
from tempest import config
from tempest.services.identity.v3.json import base

CONF = config.CONF


class RegionClientJSON(rest_client.RestClient):

def __init__(self, auth_provider):
super(RegionClientJSON, self).__init__(auth_provider)
self.service = CONF.identity.catalog_type
self.endpoint_url = 'adminURL'
self.api_version = "v3"
class RegionClientJSON(base.IdentityV3Client):

def create_region(self, description, **kwargs):
"""Create region."""
Expand Down
13 changes: 2 additions & 11 deletions tempest/services/identity/v3/json/service_client.py
Expand Up @@ -15,19 +15,10 @@

import json

from tempest.common import rest_client
from tempest import config
from tempest.services.identity.v3.json import base

CONF = config.CONF


class ServiceClientJSON(rest_client.RestClient):

def __init__(self, auth_provider):
super(ServiceClientJSON, self).__init__(auth_provider)
self.service = CONF.identity.catalog_type
self.endpoint_url = 'adminURL'
self.api_version = "v3"
class ServiceClientJSON(base.IdentityV3Client):

def update_service(self, service_id, **kwargs):
"""Updates a service."""
Expand Down

0 comments on commit 5e39799

Please sign in to comment.