| 1854 | } |
| 1855 | |
| 1856 | static gboolean |
| 1857 | unpack_colocation_template(xmlNode *xml_obj, xmlNode **expanded_xml, pe_working_set_t *data_set) |
| 1858 | { |
| 1859 | const char *id = NULL; |
| 1860 | const char *id_lh = NULL; |
| 1861 | const char *id_rh = NULL; |
| 1862 | const char *state_lh = NULL; |
| 1863 | const char *state_rh = NULL; |
| 1864 | |
| 1865 | resource_t *rsc_lh = NULL; |
| 1866 | resource_t *rsc_rh = NULL; |
| 1867 | |
| 1868 | xmlNode *template_rsc_set_lh = NULL; |
| 1869 | xmlNode *template_rsc_set_rh = NULL; |
| 1870 | |
| 1871 | xmlNode *new_xml = NULL; |
| 1872 | xmlNode *rsc_set_lh = NULL; |
| 1873 | xmlNode *rsc_set_rh = NULL; |
| 1874 | gboolean any_sets = FALSE; |
| 1875 | |
| 1876 | *expanded_xml = NULL; |
| 1877 | |
| 1878 | if(xml_obj == NULL) { |
| 1879 | crm_config_err("No constraint object to process."); |
| 1880 | return FALSE; |
| 1881 | } |
| 1882 | |
| 1883 | id = crm_element_value(xml_obj, XML_ATTR_ID); |
| 1884 | if(id == NULL) { |
| 1885 | crm_config_err("%s constraint must have an id", crm_element_name(xml_obj)); |
| 1886 | return FALSE; |
| 1887 | } |
| 1888 | |
| 1889 | /* Attempt to expand any template references in possible resource sets. */ |
| 1890 | expand_templates_in_sets(xml_obj, &new_xml, data_set); |
| 1891 | if (new_xml) { |
| 1892 | /* There are resource sets referencing templates. Return with the expanded XML. */ |
| 1893 | crm_log_xml_trace(new_xml, "Expanded rsc_colocation..."); |
| 1894 | *expanded_xml = new_xml; |
| 1895 | return TRUE; |
| 1896 | } |
| 1897 | |
| 1898 | id_lh = crm_element_value(xml_obj, XML_COLOC_ATTR_SOURCE); |
| 1899 | id_rh = crm_element_value(xml_obj, XML_COLOC_ATTR_TARGET); |
| 1900 | if(id_lh == NULL || id_rh == NULL) { |
| 1901 | return TRUE; |
| 1902 | } |
| 1903 | |
| 1904 | rsc_lh = pe_find_resource(data_set->resources, id_lh); |
| 1905 | rsc_rh = pe_find_resource(data_set->resources, id_rh); |
| 1906 | if(rsc_lh && rsc_rh) { |
| 1907 | /* Neither side references any template. */ |
| 1908 | return TRUE; |
| 1909 | } |
| 1910 | |
| 1911 | if (rsc_lh == NULL) { |
| 1912 | gboolean rc = g_hash_table_lookup_extended(data_set->template_rsc_sets, id_lh, |
| 1913 | NULL, (gpointer) &template_rsc_set_lh); |
no test coverage detected