diff --git a/include/pcmki/pcmki_scheduler.h b/include/pcmki/pcmki_scheduler.h index c604a32..f2f3d5b 100644 --- a/include/pcmki/pcmki_scheduler.h +++ b/include/pcmki/pcmki_scheduler.h @@ -107,4 +107,30 @@ extern gboolean show_scores; extern gboolean show_utilization; extern const char *transition_idle_timeout; +/*! + * \internal + * \brief Check whether colocation's left-hand preferences should be considered + * + * \param[in] colocation Colocation constraint + * \param[in] rsc Right-hand instance (normally this will be + * colocation->rsc_rh, which NULL will be treated as, + * but for clones or bundles with multiple instances + * this can be a particular instance) + * + * \return true if colocation influence should be effective, otherwise false + */ +static inline bool +pcmk__colocation_has_influence(const pcmk__colocation_t *colocation, + const pe_resource_t *rsc) +{ + if (rsc == NULL) { + rsc = colocation->rsc_rh; + } + + /* The left hand of a colocation influences the right hand's location + * if the influence option is true, or the right hand is not yet active. + */ + return colocation->influence || (rsc->running_on == NULL); +} + #endif