From 87af1a4da7c6587564d828a9239067feb6323539 Mon Sep 17 00:00:00 2001 From: Ignatious Johnson Christopher Date: Wed, 3 Jun 2015 10:46:43 -0700 Subject: [PATCH] Minimum diskGB varialbe should not be enforced, should assume that the mimimum requirement for 256GB, if the requirement is not met, enforce setting the variable in testbed.py. Closes-Bug: 1460757 Change-Id: Id4b9580d39808ed2e30c985be4e6add7b7d0814a --- fabfile/tasks/helpers.py | 25 +++++++++++++++++++++---- fabfile/utils/analytics.py | 5 +++-- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/fabfile/tasks/helpers.py b/fabfile/tasks/helpers.py index d99696ced..aa298e708 100644 --- a/fabfile/tasks/helpers.py +++ b/fabfile/tasks/helpers.py @@ -16,6 +16,7 @@ import datetime from fabfile.tasks.esxi_defaults import apply_esxi_defaults from fabfile.utils.cluster import get_ntp_server +from fabfile.utils.analytics import get_analytics_data_dir, get_minimum_diskGB @task @parallel @@ -1136,15 +1137,31 @@ def delete_cassandra_db_files(): sudo('rm -rf %s/saved_caches' %(db_path)) +@task +@EXECUTE_TASK +@roles('database') +def check_disk_space(): + data_dir = get_analytics_data_dir() + if not exists(data_dir, use_sudo=True): + return True + disk_cmd = "df -Pk " + data_dir + " | grep % | awk '{print $2}'" + total_disk = sudo(disk_cmd) + if (int(total_disk)/(1024*1024) < int(get_minimum_diskGB())): + return False + return True + @task @roles('build') def pre_check(): - db = getattr(testbed, 'minimum_diskGB', None) - if not db: - print "\nERROR: Minimum disk space for analytics db is not set in testbed.py" + result = execute('check_disk_space') + nodes_without_minimum_space = filter(lambda node: node != None, + map(lambda (node, met): node if not met else None, result.items())) + if nodes_without_minimum_space: + print "\nERROR: Minimum disk space(256GB) for analytics db is not met in nodes: %s"\ + % nodes_without_minimum_space print "\tPlease set 'minimum_diskGB' in testbed.py and continue." print "\tSpecifiy the avalilable disk space of database node in GB" - print "\tRecommended to use a database node with 256GB disk." + print "\tHowever minimum disk space for database node is 256GB." exit(1) database_nodes = deepcopy(env.roledefs['database']) if (len(database_nodes) % 2) != 1: diff --git a/fabfile/utils/analytics.py b/fabfile/utils/analytics.py index 072e2caec..300637b0d 100644 --- a/fabfile/utils/analytics.py +++ b/fabfile/utils/analytics.py @@ -24,7 +24,8 @@ def get_database_dir(): return getattr(testbed, 'database_dir', None) def get_analytics_data_dir(): - return getattr(testbed, 'analytics_data_dir', None) + return getattr(testbed, 'analytics_data_dir', + '/var/lib/cassandra/data') def get_ssd_data_dir(): return getattr(testbed, 'ssd_data_dir', None) @@ -46,7 +47,7 @@ def get_analytics_flow_ttl(): #end get_analytics_flow_ttl def get_minimum_diskGB(): - return getattr(testbed, 'minimum_diskGB', None) + return getattr(testbed, 'minimum_diskGB', '256') #end get_analytics_flow_ttl def get_kafka_enabled():