v3 Service CRUD
Change-Id: I5594ce92e99241f95775773233f09170a8a371b1
This commit is contained in:
@@ -16,6 +16,7 @@ import json
|
||||
import logging
|
||||
|
||||
from keystoneclient.v2_0 import client
|
||||
from keystoneclient.v3 import services
|
||||
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
@@ -57,6 +58,8 @@ class Client(client.Client):
|
||||
""" Initialize a new client for the Keystone v2.0 API. """
|
||||
super(Client, self).__init__(endpoint=endpoint, **kwargs)
|
||||
|
||||
self.services = services.ServiceManager(self)
|
||||
|
||||
# NOTE(gabriel): If we have a pre-defined endpoint then we can
|
||||
# get away with lazy auth. Otherwise auth immediately.
|
||||
if endpoint:
|
||||
|
57
keystoneclient/v3/services.py
Normal file
57
keystoneclient/v3/services.py
Normal file
@@ -0,0 +1,57 @@
|
||||
# Copyright 2011 OpenStack LLC.
|
||||
# Copyright 2011 Nebula, Inc.
|
||||
# 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 keystoneclient import base
|
||||
|
||||
|
||||
class Service(base.Resource):
|
||||
"""Represents an Identity service.
|
||||
|
||||
Attributes:
|
||||
* id: a uuid that identifies the service
|
||||
* name: user-facing name of the service (e.g. Keystone)
|
||||
* type: 'compute', 'identity', etc
|
||||
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
class ServiceManager(base.CrudManager):
|
||||
"""Manager class for manipulating Identity services."""
|
||||
resource_class = Service
|
||||
collection_key = 'services'
|
||||
key = 'service'
|
||||
|
||||
def create(self, name, type, **kwargs):
|
||||
return super(ServiceManager, self).create(
|
||||
name=name,
|
||||
type=type,
|
||||
**kwargs)
|
||||
|
||||
def get(self, service):
|
||||
return super(ServiceManager, self).get(
|
||||
service_id=base.getid(service))
|
||||
|
||||
def update(self, service, name=None, type=None, **kwargs):
|
||||
return super(ServiceManager, self).update(
|
||||
service_id=base.getid(service),
|
||||
name=name,
|
||||
type=type,
|
||||
**kwargs)
|
||||
|
||||
def delete(self, service):
|
||||
return super(ServiceManager, self).delete(
|
||||
service_id=base.getid(service))
|
20
tests/v3/test_services.py
Normal file
20
tests/v3/test_services.py
Normal file
@@ -0,0 +1,20 @@
|
||||
import uuid
|
||||
|
||||
from keystoneclient.v3 import services
|
||||
from tests.v3 import utils
|
||||
|
||||
|
||||
class ServiceTests(utils.TestCase, utils.CrudTests):
|
||||
def setUp(self):
|
||||
super(ServiceTests, self).setUp()
|
||||
self.additionalSetUp()
|
||||
self.key = 'service'
|
||||
self.collection_key = 'services'
|
||||
self.model = services.Service
|
||||
self.manager = self.client.services
|
||||
|
||||
def new_ref(self, **kwargs):
|
||||
kwargs = super(ServiceTests, self).new_ref(**kwargs)
|
||||
kwargs.setdefault('name', uuid.uuid4().hex)
|
||||
kwargs.setdefault('type', uuid.uuid4().hex)
|
||||
return kwargs
|
Reference in New Issue
Block a user