Skip to content

Commit

Permalink
replaced "erase/erasure" with "purge" for clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
dcvan24 committed Nov 30, 2018
1 parent bd7f902 commit 67494c0
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 23 deletions.
10 changes: 5 additions & 5 deletions appliance/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,12 @@ async def delete(self, app_id):
application/json:
schema: Error
"""
erase_data = self.get_query_argument('erase_data', False)
if not isinstance(erase_data, bool) and erase_data.lower() not in ('true', 'false'):
purge_data = self.get_query_argument('purge', False)
if not isinstance(purge_data, bool) and purge_data.lower() not in ('true', 'false'):
self.set_status(400)
self.write(error(400, "Unrecognized 'erase_data' value: %s"%erase_data))
self.write(error(400, "Unrecognized 'purge_data' value: %s"%purge_data))
return
erase_data = erase_data and erase_data.lower() == 'true'
status, msg, err = await self.__app_mgr.delete_appliance(app_id, erase_data=erase_data)
purge_data = purge_data and purge_data.lower() == 'true'
status, msg, err = await self.__app_mgr.delete_appliance(app_id, purge_data=purge_data)
self.set_status(status)
self.write(json.dumps(message(msg) if status == 200 else error(err)))
10 changes: 5 additions & 5 deletions appliance/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ def set_container_volume_scope(contrs, vols):
ApplianceScheduleExecutor(app.id, scheduler).start()
return 201, app, None

async def delete_appliance(self, app_id, erase_data=False):
async def delete_appliance(self, app_id, purge_data=False):
vol_mgr = self.__vol_mgr
self.logger.info('Erase data?: %s'%erase_data)
self.logger.debug('Purge data?: %s' % purge_data)
status, app, err = await self.get_appliance(app_id)
if status != 200:
self.logger.error(err)
Expand All @@ -133,8 +133,8 @@ async def delete_appliance(self, app_id, erase_data=False):
# deprovision/delete local persistent volumes if any
if app.data_persistence:
_, local_vols, _ = await vol_mgr.get_local_volumes(appliance=app_id)
resps = await multi([(vol_mgr.erase_local_volume(app_id, v.id)
if erase_data else vol_mgr.deprovision_volume(v))
resps = await multi([(vol_mgr.purge_local_volume(app_id, v.id)
if purge_data else vol_mgr.deprovision_volume(v))
for v in local_vols])
for i, (status, _, err) in enumerate(resps):
if status != 200:
Expand All @@ -152,7 +152,7 @@ async def delete_appliance(self, app_id, erase_data=False):
if status != 200 and status != 404:
self.logger.error(err)
return 207, None, "Failed to deprovision appliance '%s'"%app_id
if erase_data:
if purge_data:
await self.__app_db.delete_appliance(app_id)
ApplianceDeletionChecker(app_id).start()
return status, msg, None
Expand Down
2 changes: 1 addition & 1 deletion volume/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ async def delete(self, app_id, vol_id):
schema: Error
"""
status, msg, err = await self.__vol_mgr.erase_local_volume(app_id, vol_id)
status, msg, err = await self.__vol_mgr.purge_local_volume(app_id, vol_id)
self.set_status(status)
self.write(json_encode(message(msg) if status == 200 else error(err)))

Expand Down
24 changes: 12 additions & 12 deletions volume/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,20 +83,20 @@ async def deprovision_volume(self, vol):
await self.__vol_db.save_volume(vol)
return status, "Persistent volume '%s' has been deprovisioned"%vol.id, None

async def erase_global_volume(self, vol_id):
async def purge_global_volume(self, vol_id):
status, vol, err = await self.get_global_volume(vol_id)
if status != 200:
return status, None, err
if len(vol.used_by) > 0:
return 400, None, "Global persistent volume '%s' is in use by appliance(s): " \
"%s"%(vol_id, vol.used_by)
status, msg, err = await self.__vol_api.delete_global_volume(vol_id, erasure=True)
status, msg, err = await self.__vol_api.delete_global_volume(vol_id, purge=True)
if status != 200:
return status, None, err
await self.__vol_db.delete_volume(vol)
return status, "Persistent volume '%s' has been erased" % vol, None
return status, "Persistent volume '%s' has been purged" % vol, None

async def erase_local_volume(self, app_id, vol_id):
async def purge_local_volume(self, app_id, vol_id):
status, vol, err = await self.get_local_volume(app_id, vol_id, full_blown=True)
if status != 200:
return status, None, err
Expand All @@ -105,11 +105,11 @@ async def erase_local_volume(self, app_id, vol_id):
if len(in_use) > 0:
return 400, None, "Local persistent volume '%s' is in use by container(s): " \
"%s"%(vol_id, list(in_use))
status, msg, err = await self.__vol_api.delete_local_volume(app_id, vol_id, erasure=True)
status, msg, err = await self.__vol_api.delete_local_volume(app_id, vol_id, purge=True)
if status != 200:
return status, None, err
await self.__vol_db.delete_volume(vol)
return status, "Persistent volume '%s' has been erased"%vol, None
return status, "Persistent volume '%s' has been purged"%vol, None

async def get_global_volume(self, vol_id):
status, vol, err = await self._get_volume(self.__vol_db.get_global_volume,
Expand Down Expand Up @@ -187,11 +187,11 @@ async def create_volume(self, vol):
api = config.ceph
return await self.http_cli.post(api.host, api.port, '/fs', dict(vol.to_request()))

async def delete_global_volume(self, vol_id, erasure=False):
return await self._delete_volume(str(vol_id), erasure)
async def delete_global_volume(self, vol_id, purge=False):
return await self._delete_volume(str(vol_id), purge)

async def delete_local_volume(self, app_id, vol_id, erasure=False):
return await self._delete_volume('%s-%s'%(app_id, vol_id), erasure)
async def delete_local_volume(self, app_id, vol_id, purge=False):
return await self._delete_volume('%s-%s' % (app_id, vol_id), purge)

async def _get_volume(self, ext_vol_id):
api = config.ceph
Expand All @@ -200,9 +200,9 @@ async def _get_volume(self, ext_vol_id):
return status, None, err
return status, vol, None

async def _delete_volume(self, ext_vol_id, erasure=False):
async def _delete_volume(self, ext_vol_id, purge=False):
api = config.ceph
return await self.http_cli.delete(api.host, api.port, '/fs/%s?erasure=%s'%(ext_vol_id, erasure))
return await self.http_cli.delete(api.host, api.port, '/fs/%s?purge=%s' % (ext_vol_id, purge))


class VolumeDBManager(Manager):
Expand Down

0 comments on commit 67494c0

Please sign in to comment.