def destroy(self, request, *args, **kwargs): instance = self.get_object() if disabled != instance.operationalState: raise APIException(detail='VNF Package operationalState is not {}'.format(disabled), code=status.HTTP_409_CONFLICT) if not_in_use != instance.usageState: raise APIException(detail='VNF Package usageState is not {}'.format(not_in_use), code=status.HTTP_409_CONFLICT) remove_file('{}{}'.format(vnf_package_base_path, instance.id)) super().destroy(request) return Response(status=status.HTTP_204_NO_CONTENT)
def process_persistent_volume(self, **kwargs): vdu = kwargs['vdu'] client = PersistentVolumeClient(instance_name=self.vnf_instance_name) if vdu.requirements['type_of_storage'] == 'nfs': remove_file("{}{}".format(settings.NFS_PATH, self.vnf_instance_name)) client.handle_delete() elif vdu.requirements['type_of_storage'] == 'local' or vdu.requirements[ 'type_of_storage'] == 'volume': remove_file("{}{}".format(settings.VOLUME_PATH, self.vnf_instance_name)) client.handle_delete() else: raise APIException(detail='storage type only local or nfs', code=status.HTTP_409_CONFLICT)
def destroy(self, request, *args, **kwargs): """ Delete an individual NS descriptor resource. The DELETE method deletes an individual NS descriptor resource. \ An individual NS descriptor resource can only be deleted when there is no NS instance using it \ (i.e. usageState = NOT_IN_USE) and has been disabled already (i.e. operationalState = DISABLED). \ Otherwise, the DELETE method shall fail. """ instance = self.get_object() if disabled != instance.nsdOperationalState: raise APIException(detail='NSD nsdOperationalState is not {}'.format(disabled), code=status.HTTP_409_CONFLICT) if not_in_use != instance.nsdUsageState: raise APIException(detail='NSD nsdUsageState is not {}'.format(not_in_use), code=status.HTTP_409_CONFLICT) remove_file('{}{}'.format(nsd_base_path, instance.id)) super().destroy(request) self.kafka_notification.notify(kwargs['pk'], 'NSD({}) had been delete'.format(kwargs['pk'])) return Response(status=status.HTTP_204_NO_CONTENT)