| 2155 | } |
| 2156 | |
| 2157 | static gboolean |
| 2158 | unpack_simple_rsc_ticket(xmlNode * xml_obj, pe_working_set_t * data_set) |
| 2159 | { |
| 2160 | const char *id = crm_element_value(xml_obj, XML_ATTR_ID); |
| 2161 | const char *ticket_str = crm_element_value(xml_obj, XML_TICKET_ATTR_TICKET); |
| 2162 | const char *loss_policy = crm_element_value(xml_obj, XML_TICKET_ATTR_LOSS_POLICY); |
| 2163 | |
| 2164 | ticket_t *ticket = NULL; |
| 2165 | |
| 2166 | const char *id_lh = crm_element_value(xml_obj, XML_COLOC_ATTR_SOURCE); |
| 2167 | const char *state_lh = crm_element_value(xml_obj, XML_COLOC_ATTR_SOURCE_ROLE); |
| 2168 | const char *instance_lh = crm_element_value(xml_obj, XML_COLOC_ATTR_SOURCE_INSTANCE); |
| 2169 | |
| 2170 | resource_t *rsc_lh = NULL; |
| 2171 | |
| 2172 | if (xml_obj == NULL) { |
| 2173 | crm_config_err("No rsc_ticket constraint object to process."); |
| 2174 | return FALSE; |
| 2175 | } |
| 2176 | |
| 2177 | if (id == NULL) { |
| 2178 | crm_config_err("%s constraint must have an id", crm_element_name(xml_obj)); |
| 2179 | return FALSE; |
| 2180 | } |
| 2181 | |
| 2182 | if (ticket_str == NULL) { |
| 2183 | crm_config_err("Invalid constraint '%s': No ticket specified", id); |
| 2184 | return FALSE; |
| 2185 | } else { |
| 2186 | ticket = g_hash_table_lookup(data_set->tickets, ticket_str); |
| 2187 | } |
| 2188 | |
| 2189 | if (ticket == NULL) { |
| 2190 | crm_config_err("Invalid constraint '%s': No ticket named '%s'", id, ticket_str); |
| 2191 | return FALSE; |
| 2192 | } |
| 2193 | |
| 2194 | if (id_lh == NULL) { |
| 2195 | crm_config_err("Invalid constraint '%s': No resource specified", id); |
| 2196 | return FALSE; |
| 2197 | } else { |
| 2198 | rsc_lh = pe_find_resource(data_set->resources, id_lh); |
| 2199 | } |
| 2200 | |
| 2201 | if (rsc_lh == NULL) { |
| 2202 | crm_config_err("Invalid constraint '%s': No resource named '%s'", id, id_lh); |
| 2203 | return FALSE; |
| 2204 | |
| 2205 | } else if (instance_lh && rsc_lh->variant < pe_clone) { |
| 2206 | crm_config_err |
| 2207 | ("Invalid constraint '%s': Resource '%s' is not a clone but instance %s was requested", |
| 2208 | id, id_lh, instance_lh); |
| 2209 | return FALSE; |
| 2210 | } |
| 2211 | |
| 2212 | if (instance_lh) { |
| 2213 | rsc_lh = find_clone_instance(rsc_lh, instance_lh, data_set); |
| 2214 | if (rsc_lh == NULL) { |
no test coverage detected