Match HOST_ID using tab character too

In the case of puppetmaster.o.o, we are actually returning 3 results,
because of the following:

  # php -q /usr/share/cacti/cli/add_graphs.php --list-hosts | grep "puppetmaster"
  5	ci-puppetmaster.openstack.org	9	ci-puppetmaster.openstack.org
  85	old-puppetmaster.openstack.org	9	old-puppetmaster.openstack.org
  86	puppetmaster.openstack.org	9	puppetmaster.openstack.org

this is ofcource wrong and breaking cacti.  Now match with leading
tab, so we only return a single host.

Change-Id: Ie4a692f4afbc31f82844a326d38e69d2e1aea549
Signed-off-by: Paul Belanger <pabelanger@redhat.com>
This commit is contained in:
Paul Belanger 2017-10-16 14:05:43 -04:00
parent 902a10734a
commit 430fff4515
No known key found for this signature in database
GPG Key ID: 611A80832067AF38

View File

@ -10,8 +10,7 @@ HOST_TEMPLATE_ID=`php -q /usr/share/cacti/cli/add_device.php \
php -q add_device.php --description="$HOST_NAME" --ip="$HOST_NAME" \ php -q add_device.php --description="$HOST_NAME" --ip="$HOST_NAME" \
--template=$HOST_TEMPLATE_ID --version=2 --community="public" --template=$HOST_TEMPLATE_ID --version=2 --community="public"
HOST_ID=`php -q add_graphs.php --list-hosts |grep $HOST_NAME|cut -f 1` HOST_ID=`php -q add_graphs.php --list-hosts |grep -P "\t$HOST_NAME"|cut -f 1`
if [[ $HOST_NAME =~ vanilla\.ic\.openstack\.org ]]; then if [[ $HOST_NAME =~ vanilla\.ic\.openstack\.org ]]; then
TREE_NAME='Infra Cloud Vanilla' TREE_NAME='Infra Cloud Vanilla'