From 84c80c8d0f36416311fa6bf64e643d13c37e32ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Tue, 22 Jan 2013 15:07:57 +0100 Subject: [PATCH] Feature #1554: Make requirements and rank expressions able to search in /HOST/CLUSTER_TEMPLATE --- src/xml/expr_arith.y | 7 +++++++ src/xml/expr_bool.y | 24 ++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/src/xml/expr_arith.y b/src/xml/expr_arith.y index b5eb4c0be5..ebd59a4fd5 100644 --- a/src/xml/expr_arith.y +++ b/src/xml/expr_arith.y @@ -105,11 +105,13 @@ expr: STRING { float val = 0.0; ostringstream xpath_t; ostringstream xpath_s; + ostringstream xpath_c; vector results; xpath_t << "/HOST/TEMPLATE/" << $1; xpath_s << "/HOST/HOST_SHARE/" << $1; + xpath_c << "/HOST/CLUSTER_TEMPLATE/" << $1; results = (*oxml)[xpath_t.str().c_str()]; @@ -118,6 +120,11 @@ expr: STRING { float val = 0.0; results = (*oxml)[xpath_s.str().c_str()]; } + if (results.size() == 0) + { + results = (*oxml)[xpath_c.str().c_str()]; + } + if (results.size() != 0) { istringstream iss(results[0]); diff --git a/src/xml/expr_bool.y b/src/xml/expr_bool.y index 504948b757..46133eea65 100644 --- a/src/xml/expr_bool.y +++ b/src/xml/expr_bool.y @@ -214,6 +214,14 @@ void get_xml_attribute(ObjectXML * oxml, const char* attr, int& val) xpath_h << "/HOST/" << attr; results = (*oxml)[xpath_h.str().c_str()]; + + if (results.size() == 0) + { + xpath_h.str(""); + + xpath_h << "/HOST/CLUSTER_TEMPLATE/" << attr; + results = (*oxml)[xpath_h.str().c_str()]; + } } } @@ -248,6 +256,14 @@ void get_xml_attribute(ObjectXML * oxml, const char* attr, float& val) xpath_h << "/HOST/" << attr; results = (*oxml)[xpath_h.str().c_str()]; + + if (results.size() == 0) + { + xpath_h.str(""); + + xpath_h << "/HOST/CLUSTER_TEMPLATE/" << attr; + results = (*oxml)[xpath_h.str().c_str()]; + } } } @@ -282,6 +298,14 @@ void get_xml_attribute(ObjectXML * oxml, const char* attr, string& val) xpath_h << "/HOST/" << attr; results = (*oxml)[xpath_h.str().c_str()]; + + if (results.size() == 0) + { + xpath_h.str(""); + + xpath_h << "/HOST/CLUSTER_TEMPLATE/" << attr; + results = (*oxml)[xpath_h.str().c_str()]; + } } }