1
# Copyright (c) 2013 Mirantis, Inc.
3
# Licensed under the Apache License, Version 2.0 (the "License"); you may
4
# not use this file except in compliance with the License. You may obtain
5
# a copy of the License at
7
# http://www.apache.org/licenses/LICENSE-2.0
9
# Unless required by applicable law or agreed to in writing, software
10
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12
# License for the specific language governing permissions and limitations
15
from muranoapi import utils
16
from muranoapi.db.services.systemservices import SystemServices
17
from muranoapi.openstack.common import wsgi
18
from muranoapi.openstack.common import log as logging
20
log = logging.getLogger(__name__)
23
class Controller(object):
24
def index(self, request, environment_id):
25
log.debug(_('ActiveDirectory:Index '
26
'<EnvId: {0}>'.format(environment_id)))
29
if hasattr(request, 'context') and request.context.session:
30
session_id = request.context.session
32
get = SystemServices.get_services
34
services = get(environment_id, 'activeDirectories', session_id)
35
return {'activeDirectories': services}
38
def create(self, request, environment_id, body):
39
log.debug(_('ActiveDirectory:Create <EnvId: {0}, '
40
'Body: {1}>'.format(environment_id, body)))
42
session_id = request.context.session
43
create = SystemServices.create_active_directory
45
return create(body.copy(), session_id, environment_id)
48
def delete(self, request, environment_id, active_directory_id):
49
log.debug(_('ActiveDirectory:Delete <EnvId: {0}, '
50
'Id: {1}>'.format(environment_id, active_directory_id)))
52
session_id = request.context.session
53
delete = SystemServices.delete_service
55
delete(active_directory_id, 'activeDirectories', session_id,
59
def create_resource():
60
return wsgi.Resource(Controller())