def _teardown_server(): # NOTE(vponomaryov): Verify that there are no dependent shares. # Without this verification we can get here exception in next case: # share-server-delete API was called after share creation scheduled # and share_server reached ACTIVE status, but before update # of share_server_id field for share. If so, after lock realese # this method starts executing when amount of dependent shares # has been changed. shares = self.db.share_get_all_by_share_server( context, share_server['id']) if shares: raise exception.ShareServerInUse( share_server_id=share_server['id']) self.db.share_server_update(context, share_server['id'], {'status': constants.STATUS_DELETING}) sec_services = self.db.share_network_get( context, share_server['share_network_id'])['security_services'] try: LOG.debug("Deleting share server") self.driver.teardown_server(share_server['backend_details'], security_services=sec_services) except Exception: with excutils.save_and_reraise_exception(): LOG.error(_LE("Share server %s failed on deletion."), share_server['id']) self.db.share_server_update( context, share_server['id'], {'status': constants.STATUS_ERROR}) else: self.db.share_server_delete(context, share_server['id'])
def delete_share_server(self, context, server): """Delete share server.""" policy.check_policy(context, 'share_server', 'delete', server) shares = self.db.share_get_all_by_share_server(context, server['id']) if shares: raise exception.ShareServerInUse(share_server_id=server['id']) # NOTE(vponomaryov): There is no share_server status update here, # it is intentional. # Status will be changed in manila.share.manager after verification # for race condition between share creation on server # and server deletion. self.share_rpcapi.delete_share_server(context, server)
def delete_share_server(self, context, server): """Delete share server.""" policy.check_policy(context, 'share_server', 'delete', server) shares = self.db.share_instances_get_all_by_share_server( context, server['id']) if shares: raise exception.ShareServerInUse(share_server_id=server['id']) cgs = self.db.consistency_group_get_all_by_share_server( context, server['id']) if cgs: LOG.error(_LE("share server '%(ssid)s' in use by CGs"), {'ssid': server['id']}) raise exception.ShareServerInUse(share_server_id=server['id']) # NOTE(vponomaryov): There is no share_server status update here, # it is intentional. # Status will be changed in manila.share.manager after verification # for race condition between share creation on server # and server deletion. self.share_rpcapi.delete_share_server(context, server)
def _teardown_server(): # NOTE(vponomaryov): Verify that there are no dependent shares. # Without this verification we can get here exception in next case: # share-server-delete API was called after share creation scheduled # and share_server reached ACTIVE status, but before update # of share_server_id field for share. If so, after lock realese # this method starts executing when amount of dependent shares # has been changed. server_id = share_server['id'] shares = self.db.share_get_all_by_share_server(context, server_id) if shares: raise exception.ShareServerInUse(share_server_id=server_id) if 'backend_details' not in share_server: server_details = self.db.share_server_backend_details_get( context, server_id) else: server_details = share_server['backend_details'] self.db.share_server_update(context, server_id, {'status': constants.STATUS_DELETING}) try: LOG.debug("Deleting share server '%s'", server_id) security_services = [] for ss_name in constants.SECURITY_SERVICES_ALLOWED_TYPES: ss = server_details.get('security_service_' + ss_name) if ss: security_services.append(jsonutils.loads(ss)) self.driver.teardown_server( server_details=server_details, security_services=security_services) except Exception: with excutils.save_and_reraise_exception(): LOG.error( _LE("Share server '%s' failed on deletion."), server_id) self.db.share_server_update( context, server_id, {'status': constants.STATUS_ERROR}) else: self.db.share_server_delete(context, share_server['id'])
def raise_not_share_server_in_use(*args, **kwargs): raise exception.ShareServerInUse(share_server_id=share_server_id)