Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Refactor: Fencing: Re-use the policy engine libraries for filtering d…

…evices
  • Loading branch information...
commit 3cb953339d5200ba3d27b8088461778529bc0074 1 parent 8b68805
Andrew Beekhof authored March 13, 2013
17  fencing/Makefile.am
@@ -5,19 +5,19 @@
5 5
 # modify it under the terms of the GNU General Public License
6 6
 # as published by the Free Software Foundation; either version 2
7 7
 # of the License, or (at your option) any later version.
8  
-# 
  8
+#
9 9
 # This program is distributed in the hope that it will be useful,
10 10
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 12
 # GNU General Public License for more details.
13  
-# 
  13
+#
14 14
 # You should have received a copy of the GNU General Public License
15 15
 # along with this program; if not, write to the Free Software
16 16
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
17 17
 #
18 18
 MAINTAINERCLEANFILES = Makefile.in
19 19
 
20  
-SUBDIRS = 
  20
+SUBDIRS =
21 21
 
22 22
 ## binary progs
23 23
 testdir			= $(datadir)/$(PACKAGE)/tests/fencing
@@ -31,8 +31,8 @@ sbin_SCRIPTS   = fence_legacy fence_pcmk
31 31
 
32 32
 noinst_HEADERS = internal.h
33 33
 
34  
-man7_MANS      = 
35  
-man8_MANS      = 
  34
+man7_MANS      =
  35
+man8_MANS      =
36 36
 
37 37
 if BUILD_XML_HELP
38 38
 man7_MANS +=	stonithd.7
@@ -44,7 +44,7 @@ stonithd.7:	stonithd.xml
44 44
 endif
45 45
 
46 46
 if BUILD_HELP
47  
-man8_MANS +=	$(sbin_PROGRAMS:%=%.8) $(sbin_SCRIPTS:%=%.8) 
  47
+man8_MANS +=	$(sbin_PROGRAMS:%=%.8) $(sbin_SCRIPTS:%=%.8)
48 48
 %.8:	%
49 49
 	echo Creating $@
50 50
 	chmod a+x $<
@@ -67,6 +67,7 @@ stonith_admin_LDADD	= $(top_builddir)/lib/common/libcrmcommon.la	\
67 67
 			$(top_builddir)/lib/fencing/libstonithd.la	\
68 68
 			$(CRYPTOLIB) $(CLUSTERLIBS)
69 69
 
  70
+stonithd_CFLAGS		= -I$(top_srcdir)/pengine
70 71
 stonithd_SOURCES	= main.c commands.c remote.c
71 72
 if BUILD_STONITH_CONFIG
72 73
 BUILT_SOURCES 		= standalone_config.h
@@ -74,7 +75,7 @@ BUILT_SOURCES 		= standalone_config.h
74 75
 stonithd_SOURCES	+= standalone_config.c config.y config.l
75 76
 stonithd_AM_LFLAGS 	= -o$(LEX_OUTPUT_ROOT).c
76 77
 
77  
-# lex/yacc issues: 
  78
+# lex/yacc issues:
78 79
 
79 80
 endif
80 81
 stonithd_YFLAGS 	= -d
@@ -82,6 +83,8 @@ stonithd_YFLAGS 	= -d
82 83
 stonithd_LDADD		= $(top_builddir)/lib/common/libcrmcommon.la	\
83 84
 			$(top_builddir)/lib/cluster/libcrmcluster.la	\
84 85
 			$(top_builddir)/lib/fencing/libstonithd.la	\
  86
+			$(top_builddir)/lib/pengine/libpe_status.la	\
  87
+			$(top_builddir)/pengine/libpengine.la	\
85 88
 			$(CRYPTOLIB) $(CLUSTERLIBS)
86 89
 
87 90
 CFLAGS			= $(CFLAGS_COPY:-Werror=)
286  fencing/main.c
@@ -42,6 +42,8 @@
42 42
 #include <crm/common/mainloop.h>
43 43
 
44 44
 #include <crm/cib/internal.h>
  45
+#include <crm/pengine/status.h>
  46
+#include <allocate.h>
45 47
 
46 48
 #include <internal.h>
47 49
 
@@ -495,141 +497,6 @@ remove_fencing_topology(xmlXPathObjectPtr xpathObj)
495 497
     }
496 498
 }
497 499
 
498  
-static bool filter_cib_device(const char *rsc_id, xmlNode *device)
499  
-{
500  
-    int max = 0, lpc = 0;
501  
-    char *rule_path = NULL;
502  
-    const char *parent = NULL;
503  
-    xmlXPathObjectPtr rules = NULL;
504  
-
505  
-    xmlNode *attr;
506  
-    xmlNode *attributes = NULL;
507  
-
508  
-    while(strcmp(XML_CIB_TAG_RESOURCES, (const char *)device->parent->name) != 0) {
509  
-        device = device->parent;
510  
-    }
511  
-
512  
-    parent = ID(device);
513  
-    crm_trace("Testing target role for %s", parent);
514  
-    attributes = find_xml_node(device, XML_TAG_META_SETS, FALSE);
515  
-    for (attr = __xml_first_child(attributes); attr; attr = __xml_next(attr)) {
516  
-        const char *name = crm_element_value(attr, XML_NVPAIR_ATTR_NAME);
517  
-        const char *value = crm_element_value(attr, XML_NVPAIR_ATTR_VALUE);
518  
-
519  
-        if (name
520  
-            && value
521  
-            && strcmp(XML_RSC_ATTR_TARGET_ROLE, name) == 0
522  
-            && strcmp(RSC_STOPPED, value) == 0) {
523  
-            crm_info("Device %s has been disabled", rsc_id);
524  
-            return TRUE;
525  
-        }
526  
-    }
527  
-
528  
-    rule_path = g_strdup_printf("//" XML_CONS_TAG_RSC_LOCATION "[@rsc='%s' and @node='%s' and @"XML_RULE_ATTR_SCORE"='-INFINITY']", rsc_id, stonith_our_uname);
529  
-    crm_trace("Testing simple constraint: %s", rule_path);
530  
-    rules = xpath_search(local_cib, rule_path);
531  
-    free(rule_path);
532  
-    if (rules && rules->nodesetval && rules->nodesetval->nodeNr) {
533  
-        crm_info("Device %s has been disabled on %s with %d simple location constraints", rsc_id, stonith_our_uname, rules->nodesetval->nodeNr);
534  
-        xmlXPathFreeObject(rules);
535  
-        return TRUE;
536  
-    }
537  
-
538  
-    rule_path = g_strdup_printf("//" XML_CONS_TAG_RSC_LOCATION "[@rsc='%s']//"XML_TAG_RULE"[@"XML_RULE_ATTR_SCORE"='-INFINITY']//"XML_TAG_EXPRESSION, rsc_id);
539  
-    crm_trace("Testing rule-based constraint: %s", rule_path);
540  
-    rules = xpath_search(local_cib, rule_path);
541  
-    free(rule_path);
542  
-
543  
-    if (rules && rules->nodesetval) {
544  
-        max = rules->nodesetval->nodeNr;
545  
-    }
546  
-
547  
-    for (lpc = 0; lpc < max; lpc++) {
548  
-        xmlNode *match = getXpathResult(rules, lpc);
549  
-        const char *attr = crm_element_value(match, XML_EXPR_ATTR_ATTRIBUTE);
550  
-        const char *op = crm_element_value(match, XML_EXPR_ATTR_OPERATION);
551  
-        const char *value = crm_element_value(match, XML_EXPR_ATTR_VALUE);
552  
-
553  
-        if(!attr || !op || !value){
554  
-            continue;
555  
-
556  
-        } else if(strcmp("#uname", attr) != 0) {
557  
-            continue;
558  
-
559  
-        } else if(strcmp("eq", op) == 0 && strcmp(value, stonith_our_uname) == 0) {
560  
-            crm_info("Device %s has been disabled on %s by 'eq' expression %s", rsc_id, stonith_our_uname, ID(match));
561  
-            xmlXPathFreeObject(rules);
562  
-            return TRUE;
563  
-
564  
-        } else if(strcmp("ne", op) == 0 && strcmp(value, stonith_our_uname) != 0) {
565  
-            crm_info("Device %s has been disabled on %s by 'ne' expression %s", rsc_id, stonith_our_uname, ID(match));
566  
-            xmlXPathFreeObject(rules);
567  
-            return TRUE;
568  
-        }
569  
-    }
570  
-    crm_trace("All done");
571  
-    return FALSE;
572  
-}
573  
-
574  
-static void
575  
-update_cib_device(xmlNode *device, gboolean force)
576  
-{
577  
-    const char *rsc_id = NULL;
578  
-    const char *agent = NULL;
579  
-    const char *provider = NULL;
580  
-    stonith_key_value_t *params = NULL;
581  
-    xmlNode *attributes;
582  
-    xmlNode *attr;
583  
-    xmlNode *data;
584  
-
585  
-    CRM_CHECK(device != NULL, return);
586  
-
587  
-    rsc_id = crm_element_value(device, XML_ATTR_ID);
588  
-    stonith_device_remove(rsc_id, TRUE);
589  
-
590  
-    if(filter_cib_device(rsc_id, device) == FALSE) {
591  
-        agent = crm_element_value(device, XML_EXPR_ATTR_TYPE);
592  
-        provider = crm_element_value(device, XML_AGENT_ATTR_PROVIDER);
593  
-
594  
-        attributes = find_xml_node(device, XML_TAG_ATTR_SETS, FALSE);
595  
-        for (attr = __xml_first_child(attributes); attr; attr = __xml_next(attr)) {
596  
-            const char *name = crm_element_value(attr, XML_NVPAIR_ATTR_NAME);
597  
-            const char *value = crm_element_value(attr, XML_NVPAIR_ATTR_VALUE);
598  
-
599  
-            if (!name || !value) {
600  
-                continue;
601  
-            }
602  
-            params = stonith_key_value_add(params, name, value);
603  
-        }
604  
-
605  
-        data = create_device_registration_xml(rsc_id, provider, agent, params);
606  
-
607  
-        stonith_device_register(data, NULL, TRUE);
608  
-    }
609  
-}
610  
-
611  
-static void
612  
-register_cib_devices(xmlXPathObjectPtr xpathObj, gboolean force)
613  
-{
614  
-    int max = 0, lpc = 0;
615  
-
616  
-    if (xpathObj && xpathObj->nodesetval) {
617  
-        max = xpathObj->nodesetval->nodeNr;
618  
-    }
619  
-
620  
-    for (lpc = 0; lpc < max; lpc++) {
621  
-        xmlNode *match = getXpathResult(xpathObj, lpc);
622  
-        const char *rsc_id = crm_element_value(match, XML_ATTR_ID);
623  
-        const char *standard = crm_element_value(match, XML_AGENT_ATTR_CLASS);
624  
-
625  
-        if (strcmp("stonith", standard) == 0) {
626  
-            char *device_path = g_strdup_printf("//%s[@id='%s']", XML_CIB_TAG_RESOURCE, rsc_id);
627  
-            xmlNode *device = get_xpath_object(device_path, local_cib, LOG_ERR);
628  
-            update_cib_device(device, force);
629  
-        }
630  
-    }
631  
-}
632  
-
633 500
 static void
634 501
 register_fencing_topology(xmlXPathObjectPtr xpathObj, gboolean force)
635 502
 {
@@ -712,95 +579,104 @@ fencing_topology_init(xmlNode * msg)
712 579
     }
713 580
 }
714 581
 
715  
-static void
716  
-cib_stonith_devices_init(xmlNode * msg)
717  
-{
718  
-    xmlXPathObjectPtr xpathObj = NULL;
719  
-    const char *xpath = "//" XML_CIB_TAG_RESOURCE;
720  
-
721  
-    crm_trace("Pushing in stonith devices");
  582
+#define rsc_name(x) x->clone_name?x->clone_name:x->id
722 583
 
723  
-    /* Grab everything */
724  
-    xpathObj = xpath_search(msg, xpath);
  584
+static void cib_device_update(resource_t *rsc)
  585
+{
  586
+    node_t *node = NULL;
  587
+    const char *value = NULL;
  588
+    const char *rclass = NULL;
  589
+
  590
+    if(rsc->children) {
  591
+        GListPtr gIter = NULL;
  592
+        for (gIter = rsc->children; gIter != NULL; gIter = gIter->next) {
  593
+            cib_device_update(gIter->data);
  594
+        }
  595
+        return;
  596
+    }
725 597
 
726  
-    if (xpathObj) {
727  
-        register_cib_devices(xpathObj, TRUE);
728  
-        xmlXPathFreeObject(xpathObj);
  598
+    if(g_hash_table_lookup(device_list, rsc_name(rsc))) {
  599
+        stonith_device_remove(rsc_name(rsc), TRUE);
729 600
     }
730  
-}
731 601
 
732  
-static void update_cib_device_recursive(xmlNode *device)
733  
-{
734  
-    const char *kind = NULL;
  602
+    rclass = crm_element_value(rsc->xml, XML_AGENT_ATTR_CLASS);
  603
+    if(safe_str_neq(rclass, "stonith")) {
  604
+        return;
  605
+    }
735 606
 
736  
-    if(device) {
737  
-        kind = (const char *)device->name;
  607
+    value = g_hash_table_lookup(rsc->meta, XML_RSC_ATTR_TARGET_ROLE);
  608
+    if(value && strcmp(RSC_STOPPED, value) == 0) {
  609
+        crm_info("Device %s has been disabled", rsc->id);
  610
+        return;
738 611
     }
739 612
 
740  
-    if(kind == NULL) {
  613
+    node = g_hash_table_lookup(rsc->allowed_nodes, stonith_our_uname);
  614
+    if(node == NULL) {
  615
+        crm_info("Device %s has been disabled on %s: unknown", rsc->id, stonith_our_uname);
  616
+        return;
  617
+
  618
+    } else if(node->weight <= 0) {
  619
+        crm_info("Device %s has been disabled on %s: score=%d", rsc->id, stonith_our_uname, node->weight);
741 620
         return;
742 621
 
743  
-    } else if(strcmp(XML_CIB_TAG_RESOURCE, kind) == 0) {
744  
-        update_cib_device(device, TRUE);
  622
+    } else {
  623
+        xmlNode *data;
  624
+        GHashTableIter gIter;
  625
+        stonith_key_value_t *params = NULL;
  626
+
  627
+        const char *name = NULL;
  628
+        const char *agent = crm_element_value(rsc->xml, XML_EXPR_ATTR_TYPE);
  629
+        const char *provider = crm_element_value(rsc->xml, XML_AGENT_ATTR_PROVIDER);
  630
+
  631
+        crm_info("Device %s is allowed on %s: score=%d", rsc->id, stonith_our_uname, node->weight);
745 632
 
746  
-    } else if(strcmp(XML_CIB_TAG_GROUP, kind) == 0
747  
-              || strcmp(XML_CIB_TAG_INCARNATION, kind) == 0
748  
-              || strcmp(XML_CIB_TAG_MASTER, kind) == 0) {
749  
-        xmlNode *xIter = NULL;
750  
-        for(xIter = device->children; xIter; xIter = xIter->next) {
751  
-            update_cib_device_recursive(xIter);
  633
+        g_hash_table_iter_init(&gIter, rsc->parameters);
  634
+        while (g_hash_table_iter_next(&gIter, (gpointer *) & name, (gpointer *) & value)) {
  635
+            if (!name || !value) {
  636
+                continue;
  637
+            }
  638
+            params = stonith_key_value_add(params, name, value);
752 639
         }
753 640
 
754  
-    } else {
755  
-        crm_err("Unknown resource kind: %s", kind);
  641
+        data = create_device_registration_xml(rsc_name(rsc), provider, agent, params);
  642
+        stonith_device_register(data, NULL, TRUE);
756 643
     }
757 644
 }
758 645
 
  646
+extern xmlNode *do_calculations(pe_working_set_t * data_set, xmlNode * xml_input, crm_time_t * now);
759 647
 
760 648
 static void
761  
-update_cib_stonith_devices(const char *event, xmlNode * msg)
  649
+cib_devices_update(void)
762 650
 {
763  
-    xmlXPathObjectPtr xpath_obj = NULL;
764  
-    const char *kinds[] =
765  
-        {
766  
-            XML_CIB_TAG_RESOURCE,
767  
-            XML_CIB_TAG_INCARNATION,
768  
-            XML_CIB_TAG_GROUP,
769  
-            XML_CIB_TAG_MASTER
770  
-        };
771  
-    int max_kinds = DIMOF(kinds);
772  
-
773  
-    /* process new constraints */
774  
-    xpath_obj = xpath_search(msg, "//" F_CIB_UPDATE_RESULT "//" XML_CONS_TAG_RSC_LOCATION);
775  
-    if (xpath_obj) {
776  
-        int max = 0, lpc = 0;
777  
-
778  
-        if (xpath_obj && xpath_obj->nodesetval) {
779  
-            max = xpath_obj->nodesetval->nodeNr;
780  
-        }
  651
+    GListPtr gIter = NULL;
  652
+    pe_working_set_t data_set;
781 653
 
782  
-        for (lpc = 0; lpc < max; lpc++) {
783  
-            int kind = 0;
784  
-            const char *rsc_id = NULL;
785  
-            char *device_path = NULL;
786  
-            xmlNode *device = NULL;
787  
-            xmlNode *match = getXpathResult(xpath_obj, lpc);
  654
+    set_working_set_defaults(&data_set);
  655
+    data_set.input = local_cib;
  656
+    data_set.now = crm_time_new(NULL);
  657
+    data_set.flags |= pe_flag_quick_location;
788 658
 
789  
-            CRM_CHECK(match != NULL, continue);
  659
+    cluster_status(&data_set);
  660
+    do_calculations(&data_set, NULL, NULL);
790 661
 
791  
-            rsc_id = crm_element_value(match, XML_ATTR_ID);
  662
+    for (gIter = data_set.resources; gIter != NULL; gIter = gIter->next) {
  663
+        cib_device_update(gIter->data);
  664
+    }
  665
+    data_set.input = NULL; /* Wasn't a copy */
  666
+    cleanup_alloc_calculations(&data_set);
  667
+}
792 668
 
793  
-            for(kind = 0; kind < max_kinds && device == NULL; kind++) {
794  
-                device_path = g_strdup_printf("//%s[@id='%s']", kinds[kind], rsc_id);
795  
-                crm_trace("Looking for %s", device_path);
796  
-                device = get_xpath_object(device_path, local_cib, LOG_DEBUG);
797  
-                free(device_path);
798  
-            }
  669
+static void
  670
+update_cib_stonith_devices(const char *event, xmlNode * msg)
  671
+{
  672
+    gboolean needs_update = FALSE;
  673
+    xmlXPathObjectPtr xpath_obj = NULL;
799 674
 
800  
-            if(device) {
801  
-                update_cib_device_recursive(device);
802  
-            }
803  
-        }
  675
+    /* process new constraints */
  676
+     xpath_obj = xpath_search(msg, "//" F_CIB_UPDATE_RESULT "//" XML_CONS_TAG_RSC_LOCATION);
  677
+    if (xpath_obj) {
  678
+        /* Safest and simplest to always recompute */
  679
+        needs_update = TRUE;
804 680
         xmlXPathFreeObject(xpath_obj);
805 681
     }
806 682
 
@@ -814,9 +690,13 @@ update_cib_stonith_devices(const char *event, xmlNode * msg)
814 690
     /* process additions */
815 691
     xpath_obj = xpath_search(msg, "//" F_CIB_UPDATE_RESULT "//" XML_TAG_DIFF_ADDED "//" XML_CIB_TAG_RESOURCE);
816 692
     if (xpath_obj) {
817  
-        register_cib_devices(xpath_obj, FALSE);
  693
+        needs_update = TRUE;
818 694
         xmlXPathFreeObject(xpath_obj);
819 695
     }
  696
+
  697
+    if(needs_update) {
  698
+        cib_devices_update();
  699
+    }
820 700
 }
821 701
 
822 702
 static void
@@ -902,7 +782,7 @@ init_cib_cache_cb(xmlNode * msg, int call_id, int rc, xmlNode * output, void *us
902 782
     local_cib = copy_xml(output);
903 783
 
904 784
     fencing_topology_init(msg);
905  
-    cib_stonith_devices_init(msg);
  785
+    cib_devices_update();
906 786
 }
907 787
 
908 788
 static void
18  include/crm/pengine/status.h
... ...
@@ -1,16 +1,16 @@
1  
-/* 
  1
+/*
2 2
  * Copyright (C) 2004 Andrew Beekhof <andrew@beekhof.net>
3  
- * 
  3
+ *
4 4
  * This program is free software; you can redistribute it and/or
5 5
  * modify it under the terms of the GNU General Public
6 6
  * License as published by the Free Software Foundation; either
7 7
  * version 2 of the License, or (at your option) any later version.
8  
- * 
  8
+ *
9 9
  * This software is distributed in the hope that it will be useful,
10 10
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 12
  * General Public License for more details.
13  
- * 
  13
+ *
14 14
  * You should have received a copy of the GNU General Public
15 15
  * License along with this library; if not, write to the Free Software
16 16
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
@@ -58,19 +58,21 @@ enum pe_find {
58 58
 #  define pe_flag_is_managed_default	0x00000004ULL
59 59
 #  define pe_flag_maintenance_mode	0x00000008ULL
60 60
 
61  
-#  define pe_flag_stonith_enabled		0x00000010ULL
  61
+#  define pe_flag_stonith_enabled	0x00000010ULL
62 62
 #  define pe_flag_have_stonith_resource	0x00000020ULL
63 63
 
64 64
 #  define pe_flag_stop_rsc_orphans	0x00000100ULL
65 65
 #  define pe_flag_stop_action_orphans	0x00000200ULL
66  
-#  define pe_flag_stop_everything		0x00000400ULL
  66
+#  define pe_flag_stop_everything	0x00000400ULL
67 67
 
68 68
 #  define pe_flag_start_failure_fatal	0x00001000ULL
69 69
 #  define pe_flag_remove_after_stop	0x00002000ULL
70 70
 
71  
-#  define pe_flag_startup_probes		0x00010000ULL
  71
+#  define pe_flag_startup_probes	0x00010000ULL
72 72
 #  define pe_flag_have_status		0x00020000ULL
73  
-#  define pe_flag_have_remote_nodes		0x00040000ULL
  73
+#  define pe_flag_have_remote_nodes	0x00040000ULL
  74
+
  75
+#  define pe_flag_quick_location  	0x00100000ULL
74 76
 
75 77
 typedef struct pe_working_set_s {
76 78
     xmlNode *input;
24  lib/pengine/status.c
... ...
@@ -1,16 +1,16 @@
1  
-/* 
  1
+/*
2 2
  * Copyright (C) 2004 Andrew Beekhof <andrew@beekhof.net>
3  
- * 
  3
+ *
4 4
  * This library is free software; you can redistribute it and/or
5 5
  * modify it under the terms of the GNU Lesser General Public
6 6
  * License as published by the Free Software Foundation; either
7 7
  * version 2.1 of the License, or (at your option) any later version.
8  
- * 
  8
+ *
9 9
  * This library is distributed in the hope that it will be useful,
10 10
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 12
  * Lesser General Public License for more details.
13  
- * 
  13
+ *
14 14
  * You should have received a copy of the GNU Lesser General Public
15 15
  * License along with this library; if not, write to the Free Software
16 16
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
@@ -73,7 +73,9 @@ cluster_status(pe_working_set_t * data_set)
73 73
         data_set->now = crm_time_new(NULL);
74 74
     }
75 75
 
76  
-    if (data_set->input != NULL && crm_element_value(data_set->input, XML_ATTR_DC_UUID) != NULL) {
  76
+    if (data_set->dc_uuid == NULL
  77
+        && data_set->input != NULL
  78
+        && crm_element_value(data_set->input, XML_ATTR_DC_UUID) != NULL) {
77 79
         /* this should always be present */
78 80
         data_set->dc_uuid = crm_element_value_copy(data_set->input, XML_ATTR_DC_UUID);
79 81
     }
@@ -95,9 +97,16 @@ cluster_status(pe_working_set_t * data_set)
95 97
 
96 98
     unpack_nodes(cib_nodes, data_set);
97 99
     unpack_domains(cib_domains, data_set);
98  
-    unpack_remote_nodes(cib_resources, data_set);
  100
+
  101
+    if(is_not_set(data_set->flags, pe_flag_quick_location)) {
  102
+        unpack_remote_nodes(cib_resources, data_set);
  103
+    }
  104
+
99 105
     unpack_resources(cib_resources, data_set);
100  
-    unpack_status(cib_status, data_set);
  106
+
  107
+    if(is_not_set(data_set->flags, pe_flag_quick_location)) {
  108
+        unpack_status(cib_status, data_set);
  109
+    }
101 110
 
102 111
     set_bit(data_set->flags, pe_flag_have_status);
103 112
     return TRUE;
@@ -225,6 +234,7 @@ set_working_set_defaults(pe_working_set_t * data_set)
225 234
     pe_dataset = data_set;
226 235
     memset(data_set, 0, sizeof(pe_working_set_t));
227 236
 
  237
+    data_set->dc_uuid = NULL;
228 238
     data_set->order_id = 1;
229 239
     data_set->action_id = 1;
230 240
     data_set->no_quorum_policy = no_quorum_freeze;
26  pengine/pengine.c
@@ -210,29 +210,37 @@ do_calculations(pe_working_set_t * data_set, xmlNode * xml_input, crm_time_t * n
210 210
         set_working_set_defaults(data_set);
211 211
         data_set->input = xml_input;
212 212
         data_set->now = now;
213  
-        if (data_set->now == NULL) {
214  
-            data_set->now = crm_time_new(NULL);
215  
-        }
  213
+
216 214
     } else {
217 215
         crm_trace("Already have status - reusing");
218 216
     }
219 217
 
  218
+    if (data_set->now == NULL) {
  219
+        data_set->now = crm_time_new(NULL);
  220
+    }
  221
+
220 222
     crm_trace("Calculate cluster status");
221 223
     stage0(data_set);
222 224
 
223  
-    gIter = data_set->resources;
224  
-    for (; gIter != NULL; gIter = gIter->next) {
225  
-        resource_t *rsc = (resource_t *) gIter->data;
  225
+    if(is_not_set(data_set->flags, pe_flag_quick_location)) {
  226
+        gIter = data_set->resources;
  227
+        for (; gIter != NULL; gIter = gIter->next) {
  228
+            resource_t *rsc = (resource_t *) gIter->data;
226 229
 
227  
-        if (is_set(rsc->flags, pe_rsc_orphan) && rsc->role == RSC_ROLE_STOPPED) {
228  
-            continue;
  230
+            if (is_set(rsc->flags, pe_rsc_orphan) && rsc->role == RSC_ROLE_STOPPED) {
  231
+                continue;
  232
+            }
  233
+            rsc->fns->print(rsc, NULL, pe_print_log, &rsc_log_level);
229 234
         }
230  
-        rsc->fns->print(rsc, NULL, pe_print_log, &rsc_log_level);
231 235
     }
232 236
 
233 237
     crm_trace("Applying placement constraints");
234 238
     stage2(data_set);
235 239
 
  240
+    if(is_set(data_set->flags, pe_flag_quick_location)){
  241
+        return NULL;
  242
+    }
  243
+
236 244
     crm_trace("Create internal constraints");
237 245
     stage3(data_set);
238 246
 

0 notes on commit 3cb9533

Please sign in to comment.
Something went wrong with that request. Please try again.