~tnurlygayanov/murano/reliase-0.1a

« back to all changes in this revision

Viewing changes to murano-api/muranoapi/api/v1/active_directories.py

  • Committer: Timur Nurlygayanov
  • Date: 2013-05-30 22:18:42 UTC
  • Revision ID: tnulrygayanov@mirantis.com-20130530221842-8e7xd8e89e99n3xz
murano-0.1a

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#    Copyright (c) 2013 Mirantis, Inc.
 
2
#
 
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
 
6
#
 
7
#         http://www.apache.org/licenses/LICENSE-2.0
 
8
#
 
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
 
13
#    under the License.
 
14
 
 
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
 
19
 
 
20
log = logging.getLogger(__name__)
 
21
 
 
22
 
 
23
class Controller(object):
 
24
    def index(self, request, environment_id):
 
25
        log.debug(_('ActiveDirectory:Index '
 
26
                    '<EnvId: {0}>'.format(environment_id)))
 
27
 
 
28
        session_id = None
 
29
        if hasattr(request, 'context') and request.context.session:
 
30
            session_id = request.context.session
 
31
 
 
32
        get = SystemServices.get_services
 
33
 
 
34
        services = get(environment_id, 'activeDirectories', session_id)
 
35
        return {'activeDirectories': services}
 
36
 
 
37
    @utils.verify_session
 
38
    def create(self, request, environment_id, body):
 
39
        log.debug(_('ActiveDirectory:Create <EnvId: {0}, '
 
40
                    'Body: {1}>'.format(environment_id, body)))
 
41
 
 
42
        session_id = request.context.session
 
43
        create = SystemServices.create_active_directory
 
44
 
 
45
        return create(body.copy(), session_id, environment_id)
 
46
 
 
47
    @utils.verify_session
 
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)))
 
51
 
 
52
        session_id = request.context.session
 
53
        delete = SystemServices.delete_service
 
54
 
 
55
        delete(active_directory_id, 'activeDirectories', session_id,
 
56
               environment_id)
 
57
 
 
58
 
 
59
def create_resource():
 
60
    return wsgi.Resource(Controller())