+ if application_to_delete == application_name:
+ # destroy the application
+ await libjuju.destroy_application(
+ model_name=model_name,
+ application_name=application_name,
+ total_timeout=total_timeout,
+ )
+ # if model is empty delete it
+ controller = await libjuju.get_controller()
+ model = await libjuju.get_model(
+ controller=controller,
+ model_name=model_name,
+ )
+ if not model.applications:
+ self.log.info("Model {} is empty, deleting it".format(model_name))
+ await libjuju.destroy_model(
+ model_name=model_name,
+ total_timeout=total_timeout,
+ )
+ elif not scaling_in: