Skip to content

Commit

Permalink
Fix: crm_resource: Correctly observe --force when deleting and updati…
Browse files Browse the repository at this point in the history
…ng attributes
  • Loading branch information
beekhof committed Oct 8, 2015
1 parent 2d40a51 commit bd232e3
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions tools/crm_resource_runtime.c
Expand Up @@ -123,8 +123,9 @@ find_resource_attr(cib_t * the_cib, const char *attr, const char *rsc, const cha
xmlNode *xml_search = NULL;
char *xpath_string = NULL;

CRM_ASSERT(value != NULL);
*value = NULL;
if(value) {
*value = NULL;
}

if(the_cib == NULL) {
return -ENOTCONN;
Expand Down Expand Up @@ -176,7 +177,7 @@ find_resource_attr(cib_t * the_cib, const char *attr, const char *rsc, const cha
crm_element_value(child, XML_NVPAIR_ATTR_VALUE), ID(child));
}

} else {
} else if(value) {
const char *tmp = crm_element_value(xml_search, attr);

if (tmp) {
Expand All @@ -198,8 +199,10 @@ find_matching_attr_resource(resource_t * rsc, const char * rsc_id, const char *
char *lookup_id = NULL;
char *local_attr_id = NULL;

if(rsc->parent && do_force == FALSE) {
if(do_force == TRUE) {
return rsc;

} else if(rsc->parent) {
switch(rsc->parent->variant) {
case pe_group:
if (BE_QUIET == FALSE) {
Expand Down Expand Up @@ -270,6 +273,13 @@ cli_resource_update_attribute(const char *rsc_id, const char *attr_set, const ch
return -ENXIO;
}

if(attr_id == NULL
&& do_force == FALSE
&& pcmk_ok != find_resource_attr(
cib, XML_ATTR_ID, uber_parent(rsc)->id, NULL, NULL, NULL, attr_name, NULL)) {
printf("\n");
}

if (safe_str_eq(attr_set_type, XML_TAG_ATTR_SETS)) {
if (do_force == FALSE) {
rc = find_resource_attr(cib, XML_ATTR_ID, uber_parent(rsc)->id,
Expand Down Expand Up @@ -419,6 +429,13 @@ cli_resource_delete_attribute(const char *rsc_id, const char *attr_set, const ch
return -ENXIO;
}

if(attr_id == NULL
&& do_force == FALSE
&& find_resource_attr(
cib, XML_ATTR_ID, uber_parent(rsc)->id, NULL, NULL, NULL, attr_name, NULL) != pcmk_ok) {
printf("\n");
}

if(safe_str_eq(attr_set_type, XML_TAG_META_SETS)) {
rsc = find_matching_attr_resource(rsc, rsc_id, attr_set, attr_id, attr_name, cib, "delete");
}
Expand Down

0 comments on commit bd232e3

Please sign in to comment.