Fixing application template deletion

Deleting an application/service in a environment template
does not work and murano got blocked. This patch solves that
bug.

Closes-Bug: #1587809
Change-Id: I871e3b0eca82c14354b9c7ff2abce90da7cb21b0
This commit is contained in:
visitor 2016-06-01 12:10:32 +02:00
parent 5c8285de1e
commit 1adc59cef3
5 changed files with 56 additions and 1 deletions

View File

@ -325,6 +325,19 @@ Delete application from an environment template
*Response*
::
{
"updated": "2015-01-26T09:12:51",
"services": [],
"name": "template_name",
"created": "2015-01-26T09:12:51",
"tenant_id": "00000000000000000000000000000001",
"version": 0,
"id": "aa9033ca7ce245fca10e38e1c8c4bbf7",
}
+----------------+-----------------------------------------------------------+
| Code | Description |
+================+===========================================================+

View File

@ -177,12 +177,13 @@ class Controller(object):
path=path))
delete_data = core_services.CoreServices.delete_env_template_data
try:
delete_data(env_template_id, path)
result = delete_data(env_template_id, path)
except (KeyError, ValueError):
msg = _('The template does not exist {templ_id}').format(
templ_id=env_template_id)
LOG.exception(msg)
raise exc.HTTPNotFound(msg)
return result
def create_resource():

View File

@ -228,3 +228,4 @@ class CoreServices(object):
utils.TraverseHelper.remove(path, tmp_description)
save_description(tmp_description, env_template_id)
return tmp_description

View File

@ -588,6 +588,7 @@ class TestEnvTemplateApi(tb.ControllerTest, tb.MuranoApiTestCase):
req = self._post('/templates', json.dumps(body))
result = req.get_response(self.api)
self.assertEqual(200, result.status_code)
self.assertEqual(1, len(json.loads(result.body)['services']))
req = self._get('/templates/%s/services' % self.uuids[0])
result = req.get_response(self.api)
@ -603,7 +604,9 @@ class TestEnvTemplateApi(tb.ControllerTest, tb.MuranoApiTestCase):
req = self._delete('/templates/' + self.uuids[0] +
'/services/' + service_id)
result = req.get_response(self.api)
self.assertEqual(200, result.status_code)
self.assertEqual(0, len(json.loads(result.body)['services']))
req = self._get('/templates/' + self.uuids[0] +
'/services/' + service_id)
@ -678,6 +681,41 @@ class TestEnvTemplateApi(tb.ControllerTest, tb.MuranoApiTestCase):
result = req.get_response(self.api)
self.assertEqual(400, result.status_code)
def test_delete_notexisting_service(self):
"""Check deleting a not existing service, return a 404 error."""
self._set_policy_rules(
{'create_env_template': '@',
'delete_env_application': '@'}
)
self.expect_policy_check('create_env_template')
fake_now = timeutils.utcnow()
timeutils.utcnow.override_time = fake_now
body = {
"name": "mytemplate",
"services": [
{
"name": "tomcat",
"port": "8080",
"?": {
"type": "io.murano.apps.apache.Tomcat",
"id": "ID1"
}
}
]
}
req = self._post('/templates', json.dumps(body))
result = req.get_response(self.api)
self.assertEqual(200, result.status_code)
self.assertEqual(1, len(json.loads(result.body)['services']))
req = self._delete('/templates/{0}/services/{1}'.format(self.uuids[0],
"NO_EXIST"))
result = req.get_response(self.api)
self.assertEqual(404, result.status_code)
def test_create_env_notexisting_templatebody(self):
"""Check that an illegal temp name results in an HTTPClientError."""
self._set_policy_rules(

View File

@ -0,0 +1,2 @@
fixes:
- Fix delete application in environment template