2013-05-23 21:00:30 +04:00
|
|
|
# Copyright (c) 2013 Mirantis, Inc.
|
|
|
|
#
|
|
|
|
# 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
|
2013-05-28 16:11:24 +04:00
|
|
|
# under the License.
|
2013-05-23 21:00:30 +04:00
|
|
|
|
|
|
|
from muranoapi import utils
|
2013-05-27 18:44:53 +04:00
|
|
|
from muranoapi.db.services.systemservices import SystemServices
|
|
|
|
from muranoapi.openstack.common import wsgi
|
2013-05-23 21:00:30 +04:00
|
|
|
from muranoapi.openstack.common import log as logging
|
2013-06-04 17:21:32 +04:00
|
|
|
from webob.exc import HTTPNotFound
|
2013-05-23 21:00:30 +04:00
|
|
|
|
|
|
|
log = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
|
|
|
class Controller(object):
|
|
|
|
def index(self, request, environment_id):
|
|
|
|
log.debug(_('AspNetApps:List <EnvId: {0}>'.format(environment_id)))
|
|
|
|
|
2013-05-27 18:44:53 +04:00
|
|
|
session_id = None
|
|
|
|
if hasattr(request, 'context') and request.context.session:
|
|
|
|
session_id = request.context.session
|
2013-05-23 21:00:30 +04:00
|
|
|
|
2013-05-27 18:44:53 +04:00
|
|
|
get = SystemServices.get_services
|
2013-05-23 21:00:30 +04:00
|
|
|
|
2013-05-27 18:44:53 +04:00
|
|
|
services = get(environment_id, 'aspNetApps', session_id)
|
|
|
|
return {'aspNetApps': services}
|
2013-05-23 21:00:30 +04:00
|
|
|
|
|
|
|
@utils.verify_session
|
|
|
|
def create(self, request, environment_id, body):
|
|
|
|
log.debug(_('AspNetApps:Create <EnvId: {0}, Body: {1}>'.
|
|
|
|
format(environment_id, body)))
|
|
|
|
|
2013-05-27 18:44:53 +04:00
|
|
|
session_id = request.context.session
|
|
|
|
create = SystemServices.create_asp_application
|
2013-05-23 21:00:30 +04:00
|
|
|
|
2013-05-27 18:44:53 +04:00
|
|
|
return create(body.copy(), session_id, environment_id)
|
2013-05-23 21:00:30 +04:00
|
|
|
|
|
|
|
@utils.verify_session
|
|
|
|
def delete(self, request, environment_id, app_id):
|
|
|
|
log.debug(_('AspNetApps:Delete <EnvId: {0}, Id: {1}>'.
|
|
|
|
format(environment_id, app_id)))
|
|
|
|
|
2013-05-27 18:44:53 +04:00
|
|
|
session_id = request.context.session
|
|
|
|
delete = SystemServices.delete_service
|
2013-05-23 21:00:30 +04:00
|
|
|
|
2013-06-04 17:21:32 +04:00
|
|
|
try:
|
|
|
|
delete(app_id, 'aspNetApps', session_id, environment_id)
|
|
|
|
except ValueError:
|
|
|
|
raise HTTPNotFound()
|
2013-05-23 21:00:30 +04:00
|
|
|
|
|
|
|
|
|
|
|
def create_resource():
|
|
|
|
return wsgi.Resource(Controller())
|