def create_or_update(volume: TenantServiceVolume): try: old_volume = TenantServiceVolume.objects.get( service_id=volume.service_id, volume_name=volume.volume_name) volume.ID = old_volume.ID except TenantServiceVolume.DoesNotExist: pass volume.save()
def create_tenant_service_volume(self, **kwargs): tenant_service_volume = TenantServiceVolume(**kwargs) tenant_service_volume.save() return tenant_service_volume