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