+def status(application: Application) -> str:
+ unit_status = []
+ for unit in application.units:
+ unit_status.append(unit.workload_status)
+ return derive_status(unit_status)
+
+
+def entity_ready(entity: ModelEntity) -> bool:
+ entity_type = entity.entity_type
+ if entity_type == "machine":
+ return entity.agent_status in ["started"]
+ elif entity_type == "action":
+ return entity.status in ["completed", "failed", "cancelled"]
+ elif entity_type == "application":
+ # Workaround for bug: https://github.com/juju/python-libjuju/issues/441
+ return status(entity) in ["active", "blocked"]
+ else:
+ raise EntityInvalidException("Unknown entity type: {}".format(entity_type))
+
+