Support for ASP.NET apps git-based deployment
Change-Id: I73d80c62b1db31c5f0a1e7f8be7a4ed50d857c5c
This commit is contained in:
parent
eeb89e3efe
commit
f9f117b511
@ -77,7 +77,8 @@ def get_env_status(environment_id, session_id):
|
||||
|
||||
is_inprogress = filter(lambda item: item == 'inprogress',
|
||||
get_statuses('activeDirectories') +
|
||||
get_statuses('webServers'))
|
||||
get_statuses('webServers') +
|
||||
get_statuses('aspNetApps'))
|
||||
|
||||
if session_state == 'deploying' and is_inprogress > 1:
|
||||
status = 'inprogress'
|
||||
|
85
muranoapi/api/v1/aspNetApps.py
Normal file
85
muranoapi/api/v1/aspNetApps.py
Normal file
@ -0,0 +1,85 @@
|
||||
# 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
|
||||
# under the License.from oslo.config import cfg
|
||||
|
||||
from muranoapi import utils
|
||||
from muranoapi.api.v1 import save_draft, get_draft, get_service_status
|
||||
from muranoapi.common import uuidutils
|
||||
from muranoapi.openstack.common import wsgi, timeutils
|
||||
from muranoapi.openstack.common import log as logging
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class Controller(object):
|
||||
def index(self, request, environment_id):
|
||||
log.debug(_('AspNetApps:List <EnvId: {0}>'.format(environment_id)))
|
||||
|
||||
draft = prepare_draft(get_draft(environment_id,
|
||||
request.context.session))
|
||||
|
||||
for dc in draft['services']['aspNetApps']:
|
||||
dc['status'] = get_service_status(environment_id,
|
||||
request.context.session, dc)
|
||||
|
||||
return {'aspNetApps': draft['services']['aspNetApps']}
|
||||
|
||||
@utils.verify_session
|
||||
def create(self, request, environment_id, body):
|
||||
log.debug(_('AspNetApps:Create <EnvId: {0}, Body: {1}>'.
|
||||
format(environment_id, body)))
|
||||
|
||||
draft = get_draft(session_id=request.context.session)
|
||||
|
||||
aspNetApp = body.copy()
|
||||
aspNetApp['id'] = uuidutils.generate_uuid()
|
||||
aspNetApp['created'] = str(timeutils.utcnow())
|
||||
aspNetApp['updated'] = str(timeutils.utcnow())
|
||||
|
||||
unit_count = 0
|
||||
for unit in aspNetApp['units']:
|
||||
unit_count += 1
|
||||
unit['id'] = uuidutils.generate_uuid()
|
||||
unit['name'] = aspNetApp['name'] + '_instance_' + str(unit_count)
|
||||
|
||||
draft = prepare_draft(draft)
|
||||
draft['services']['aspNetApps'].append(aspNetApp)
|
||||
save_draft(request.context.session, draft)
|
||||
|
||||
return aspNetApp
|
||||
|
||||
@utils.verify_session
|
||||
def delete(self, request, environment_id, app_id):
|
||||
log.debug(_('AspNetApps:Delete <EnvId: {0}, Id: {1}>'.
|
||||
format(environment_id, app_id)))
|
||||
|
||||
draft = get_draft(session_id=request.context.session)
|
||||
|
||||
elements = [service for service in draft['services']['aspNetApps'] if
|
||||
service['id'] != app_id]
|
||||
draft['services']['aspNetApps'] = elements
|
||||
save_draft(request.context.session, draft)
|
||||
|
||||
|
||||
def prepare_draft(draft):
|
||||
if not 'services' in draft:
|
||||
draft['services'] = {}
|
||||
|
||||
if not 'aspNetApps' in draft['services']:
|
||||
draft['services']['aspNetApps'] = []
|
||||
|
||||
return draft
|
||||
|
||||
|
||||
def create_resource():
|
||||
return wsgi.Resource(Controller())
|
@ -18,6 +18,7 @@ from muranoapi.api.v1 import environments
|
||||
from muranoapi.api.v1 import sessions
|
||||
from muranoapi.api.v1 import active_directories
|
||||
from muranoapi.api.v1 import webservers
|
||||
from muranoapi.api.v1 import aspNetApps
|
||||
|
||||
|
||||
class API(wsgi.Router):
|
||||
@ -105,4 +106,20 @@ class API(wsgi.Router):
|
||||
controller=webServers_resource,
|
||||
action='delete',
|
||||
conditions={'method': ['DELETE']})
|
||||
|
||||
aspNetApps_resource = aspNetApps.create_resource()
|
||||
mapper.connect('/environments/{environment_id}/aspNetApps',
|
||||
controller=aspNetApps_resource,
|
||||
action='index',
|
||||
conditions={'method': ['GET']})
|
||||
mapper.connect('/environments/{environment_id}/aspNetApps',
|
||||
controller=aspNetApps_resource,
|
||||
action='create',
|
||||
conditions={'method': ['POST']})
|
||||
mapper.connect('/environments/{environment_id}/aspNetApps/'
|
||||
'{app_id}',
|
||||
controller=aspNetApps_resource,
|
||||
action='delete',
|
||||
conditions={'method': ['DELETE']})
|
||||
|
||||
super(API, self).__init__(mapper)
|
||||
|
@ -118,6 +118,10 @@ class Controller(object):
|
||||
environment['services']:
|
||||
services += environment['services']['webServers']
|
||||
|
||||
if 'services' in environment and 'aspNetApps' in\
|
||||
environment['services']:
|
||||
services += environment['services']['aspNetApps']
|
||||
|
||||
service = [service for service in services
|
||||
if service['id'] == service_id][0]
|
||||
|
||||
|
@ -79,8 +79,8 @@ class ModelBase(object):
|
||||
|
||||
def to_dict(self):
|
||||
dictionary = self.__dict__.copy()
|
||||
return dict((k, v) for k, v in dictionary.iteritems()
|
||||
if k != '_sa_instance_state')
|
||||
return dict([(k, v) for k, v in dictionary.iteritems()
|
||||
if k != '_sa_instance_state'])
|
||||
|
||||
|
||||
class JsonBlob(TypeDecorator):
|
||||
|
@ -30,6 +30,7 @@ class SanityUnitTests(unittest2.TestCase):
|
||||
|
||||
def test_api(self):
|
||||
router.webservers = MagicMock(create_resource=func_mock)
|
||||
router.aspNetApps = MagicMock(create_resource=func_mock)
|
||||
router.sessions = MagicMock(create_resource=func_mock)
|
||||
router.active_directories = MagicMock(create_resource=func_mock)
|
||||
router.environments = MagicMock(create_resource=func_mock)
|
||||
|
Loading…
Reference in New Issue
Block a user