Error during VNF create returns internal error
* When a user runs vnf-create with an invalid template, the client returns am Internal Server Error message instead of something useful. Also the failed VNF device is left in the database and must be manually deleted using vnf-delete * This patchset catches the heatclient.HTTPException and translates it into an HeatClientException subclass of TackerException which is able to be passed back to the client. It also deletes the failed VNF entry from the database so it does not need to be manually cleaned up. * Added device_dict parameter to _create_device_post() call when create_device() receives instance_id "None" from a failed call to _create_device(). This is an error leg that is not normally executed since there should have been an exception from the failed device create call. Closes-Bug: 1468565 Change-Id: Ia2ee8590b7c3bb932328fa0def434ff43e6e52e8
This commit is contained in:
parent
c57103ffa6
commit
8dd49889ad
|
@ -319,3 +319,7 @@ class DeviceIDNotOwnedByTenant(Conflict):
|
|||
|
||||
class InvalidCIDR(BadRequest):
|
||||
message = _("Invalid CIDR %(input)s given as IP prefix")
|
||||
|
||||
|
||||
class HeatClientException(TackerException):
|
||||
message = _("%msg")
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
# @author: Isaku Yamahata, Intel Corporation.
|
||||
# shamelessly many codes are stolen from gbp simplechain_driver.py
|
||||
|
||||
import sys
|
||||
import time
|
||||
import yaml
|
||||
|
||||
|
@ -29,6 +30,7 @@ from heatclient import exc as heatException
|
|||
from keystoneclient.v2_0 import client as ks_client
|
||||
from oslo_config import cfg
|
||||
|
||||
from tacker.common import exceptions
|
||||
from tacker.common import log
|
||||
from tacker.openstack.common import jsonutils
|
||||
from tacker.openstack.common import log as logging
|
||||
|
@ -392,7 +394,12 @@ class HeatClient:
|
|||
'disable_rollback': True})
|
||||
if 'password' in fields.get('template', {}):
|
||||
fields['password'] = fields['template']['password']
|
||||
return self.stacks.create(**fields)
|
||||
|
||||
try:
|
||||
return self.stacks.create(**fields)
|
||||
except heatException.HTTPException:
|
||||
type_, value, tb = sys.exc_info()
|
||||
raise exceptions.HeatClientError(msg=value)
|
||||
|
||||
def delete(self, stack_id):
|
||||
try:
|
||||
|
|
|
@ -305,10 +305,11 @@ class ServiceVMPlugin(vm_db.ServiceResourcePluginDb, ServiceVMMgmtMixin):
|
|||
context=context, device=device_dict)
|
||||
except Exception:
|
||||
with excutils.save_and_reraise_exception():
|
||||
self._mark_device_error(device_id)
|
||||
self.delete_device(context, device_id)
|
||||
|
||||
if instance_id is None:
|
||||
self._create_device_post(context, device_id, None, None)
|
||||
self._create_device_post(context, device_id, None, None,
|
||||
device_dict)
|
||||
return
|
||||
|
||||
device_dict['instance_id'] = instance_id
|
||||
|
|
Loading…
Reference in New Issue