Merge "Implement bay deletion on api"
This commit is contained in:
commit
2a3b73b9d7
@ -313,6 +313,4 @@ class BaysController(rest.RestController):
|
||||
if self.from_bays:
|
||||
raise exception.OperationNotPermitted
|
||||
|
||||
rpc_bay = objects.Bay.get_by_uuid(pecan.request.context,
|
||||
bay_uuid)
|
||||
rpc_bay.destroy()
|
||||
pecan.request.rpcapi.bay_delete(bay_uuid)
|
||||
|
@ -149,7 +149,9 @@ class Handler(object):
|
||||
osc = clients.OpenStackClients(ctxt)
|
||||
bay = objects.Bay.get_by_uuid(ctxt, uuid)
|
||||
stack_id = bay.stack_id
|
||||
# TODO(yuanying): handle stack status DELETE_IN_PROGRESS
|
||||
osc.heat().stacks.delete(stack_id)
|
||||
# TODO(yuanying): bay.destroy will be triggered by stack status change.
|
||||
bay.destroy()
|
||||
|
||||
return None
|
||||
|
@ -10,6 +10,7 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
from magnum.conductor import api
|
||||
from magnum import objects
|
||||
from magnum.tests.db import base as db_base
|
||||
|
||||
from mock import patch
|
||||
@ -20,6 +21,10 @@ class TestBayController(db_base.DbTestCase):
|
||||
bay.create()
|
||||
return bay
|
||||
|
||||
def mock_bay_destroy(self, bay_uuid):
|
||||
bay = objects.Bay.get_by_uuid({}, bay_uuid)
|
||||
bay.destroy()
|
||||
|
||||
def test_bay_api(self):
|
||||
with patch.object(api.API, 'bay_create') as mock_method:
|
||||
# Create a bay
|
||||
@ -52,6 +57,8 @@ class TestBayController(db_base.DbTestCase):
|
||||
params=params)
|
||||
self.assertEqual(response.status_int, 200)
|
||||
|
||||
with patch.object(api.API, 'bay_delete') as mock_method:
|
||||
mock_method.side_effect = self.mock_bay_destroy
|
||||
# Delete the bay we created
|
||||
response = self.app.delete('/v1/bays/%s' % c.get('uuid'))
|
||||
self.assertEqual(response.status_int, 204)
|
||||
|
Loading…
Reference in New Issue
Block a user