Merge "Handle heat exception in create_stack."
This commit is contained in:
commit
ada23d913c
|
@ -165,7 +165,13 @@ class Handler(object):
|
|||
|
||||
osc = clients.OpenStackClients(context)
|
||||
|
||||
created_stack = _create_stack(context, osc, bay)
|
||||
try:
|
||||
created_stack = _create_stack(context, osc, bay)
|
||||
except Exception as e:
|
||||
if isinstance(e, exc.HTTPBadRequest):
|
||||
raise exception.InvalidParameterValue(message=str(e))
|
||||
else:
|
||||
raise
|
||||
bay.stack_id = created_stack['stack']['id']
|
||||
bay.create()
|
||||
|
||||
|
|
|
@ -12,6 +12,9 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from heatclient import exc
|
||||
|
||||
from magnum.common import exception
|
||||
from magnum.conductor.handlers import bay_k8s_heat
|
||||
from magnum import objects
|
||||
from magnum.openstack.common import loopingcall
|
||||
|
@ -538,3 +541,10 @@ class TestHandler(db_base.DbTestCase):
|
|||
self.bay)
|
||||
bay = objects.Bay.get(self.context, self.bay.uuid)
|
||||
self.assertEqual(bay.node_count, 2)
|
||||
|
||||
@patch('magnum.conductor.handlers.bay_k8s_heat._create_stack')
|
||||
@patch('magnum.common.clients.OpenStackClients')
|
||||
def test_create(self, mock_openstack_client_class, mock_create_stack):
|
||||
mock_create_stack.side_effect = exc.HTTPBadRequest
|
||||
self.assertRaises(exception.InvalidParameterValue,
|
||||
self.handler.bay_create, self.context, self.bay)
|
||||
|
|
Loading…
Reference in New Issue