From b339831ca53ef5f8e6ea88d10f022bb5f8f3c5fb Mon Sep 17 00:00:00 2001 From: Matt Wisch Date: Fri, 12 Aug 2016 15:51:12 -0400 Subject: [PATCH] Updated method to index hosts for Grafana Dashboard creation Updated the hosts_to_dictionary function to check to see if the last digit of the overcloud host name is a digit. If so, it uses a regex to isolate the all of the digits at the end of the hostname, and proceeds to use that as the dictionary index. This change allows for alternate overcloud host naming schemes that do not have a hyphen preceding the server number. Change-Id: Ief10b2100b5d7c55a940ab4186ce2e31c109420c Closes-Bug: #1612787 --- ansible/install/filter_plugins/browbeat_install_filters.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ansible/install/filter_plugins/browbeat_install_filters.py b/ansible/install/filter_plugins/browbeat_install_filters.py index f9a3db1f2..453f82541 100644 --- a/ansible/install/filter_plugins/browbeat_install_filters.py +++ b/ansible/install/filter_plugins/browbeat_install_filters.py @@ -9,6 +9,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. +import re def dict_remove(the_dict, item): """Remove an item from a dictionary.""" @@ -24,9 +25,8 @@ def hosts_to_dictionary(arg): dictionary = {} nonindex = 1000000 for item in arg: - if '-' in item: - idx = item.rindex('-') - dictionary[int(item[idx + 1:])] = item + if item[(len(item)-1)].isdigit(): + dictionary[int(re.sub('.*[^0-9][^0-9]*', '', item))] = item else: nonindex += 1 dictionary[nonindex] = item