summaryrefslogtreecommitdiffstats
path: root/libs
diff options
context:
space:
mode:
authorShwetha-H-Panduranga <shwetha@gluster.com>2011-12-12 11:29:47 +0530
committerShwetha-H-Panduranga <shwetha@gluster.com>2011-12-12 11:29:47 +0530
commit689f862f24f949361603a808250ae3f7ec9f40f6 (patch)
tree37894a4807f9fcf1edab4ad846e57d8ba339cf13 /libs
parentd7524954807ed63ed05762a945e7e6956c929eda (diff)
Changes to logger class, Using the logger class in the framework, adding new global values, Changes made to argument parser, testruninfo
Diffstat (limited to 'libs')
-rwxr-xr-xlibs/connect/ssh.py32
-rw-r--r--libs/globals/atfglobals.py53
-rwxr-xr-xlibs/globals/testenv.py22
-rw-r--r--libs/globals/testruninfo.py74
-rw-r--r--libs/parser/parser.py52
-rw-r--r--libs/utils/atfutils.py11
-rw-r--r--libs/utils/clientutils.py52
-rw-r--r--libs/utils/glusterutils.py210
-rw-r--r--libs/utils/hostutils.py74
-rw-r--r--libs/utils/managerutils.py11
-rw-r--r--libs/utils/serverutils.py7
11 files changed, 311 insertions, 287 deletions
diff --git a/libs/connect/ssh.py b/libs/connect/ssh.py
index a9952bb..a419c31 100755
--- a/libs/connect/ssh.py
+++ b/libs/connect/ssh.py
@@ -3,16 +3,15 @@
remote server using SSH Protocol.
"""
import paramiko
-import pdb
import time
+from atfglobals import GlobalObj
class SshConnection():
- def __init__(self):
- self._connection = None
+ def __init__(self):
self._connection = paramiko.SSHClient()
- def connect(self, host, user=None, password=None):
+ def connect(self, host, user, password):
"""
Objective:
SSH to Server "host" as User "user"
@@ -26,30 +25,24 @@ class SshConnection():
Success: 0
Failure: 1
"""
+ logger = GlobalObj.getLoggerObj()
self._connection.set_missing_host_key_policy(paramiko.AutoAddPolicy())
- if user == None:
- user = "root"
-
- if password == None:
- password = "syst3m"
-
try:
self._connection.connect(host, username=user, password=password)
except paramiko.BadHostKeyException as result:
- print(
- "BadHostKeyException: Unable to Connect to Server: '" + host +
- "' as User: '" + user + "'")
+ logger.error("BadHostKeyException: Unable to Connect to Server: '" + host +
+ "' as User: '" + user + "'")
return 1
except paramiko.AuthenticationException:
- print("AuthenticationException: Unable to Authenticate "
- + user + "@" + host)
+ logger.error("AuthenticationException: Unable to Authenticate " +
+ user + "@" + host)
return 1
except paramiko.SSHException:
- print("SSHException: Unknown server " + host)
+ logger.error("SSHException: Unknown server " + host)
return 1
return 0
@@ -74,6 +67,7 @@ class SshConnection():
Success: 0
Failure: 1
"""
+ logger = GlobalObj.getLoggerObj()
output = {}
output["exitstatus"] = None
output["stdoutdata"] = None
@@ -93,8 +87,8 @@ class SshConnection():
if commandInput:
stdin.write(commandInput)
else:
- print "This command requirs Command Input \
- after executing comamnd for command completion"
+ logger.error("This command requirs Command Input \
+ after executing comamnd for command completion")
stdin.write("\n")
return output
@@ -107,7 +101,7 @@ class SshConnection():
output["stderrdata"] = stderr.readlines()
except paramiko.SSHException:
- print("Unable to Execute Command: " + command)
+ logger.error("Unable to Execute Command: " + command)
return output
diff --git a/libs/globals/atfglobals.py b/libs/globals/atfglobals.py
index ff1faad..f1e6946 100644
--- a/libs/globals/atfglobals.py
+++ b/libs/globals/atfglobals.py
@@ -16,28 +16,43 @@ import testenv
import manager
class AtfGlobals:
-
-
def __init__(self):
self._testruninfo = None
- self._logger = logger.Log()
+ self._logger = None
self._env = None
- self._connectionsmanager = manager.ConnectionsManager()
-
- def getTestrunInfoObj(self):
- """Returns TestrunInfo Object
+ self._connectionsmanager = None
+ self.logname = "ATFLOG"
+ self.atfdir = None
+ self.testruninfo_file = None
+ self.summarylog_file = "summarylog.out"
+ self.summarylog_level = 'INFO'
+ self.detaillog_file = "detaillog.out"
+ self.detaillog_level = 'DEBUG'
+ self.stdoutlog_dolog = 'yes'
+ self.stdoutlog_level = 'INFO'
+ self.testunits_maindir = "TestUnits"
+ self.testunit_mainmodule = "testunit"
+ self.testenv_file = "testenv.cfg"
+ self.testcaseslist_file = "testcaseslist"
+ self.glusterd_dir = "/etc/glusterd/*"
+ self.glusterd_log_paths = ["/var/log/glusterfs/*.log",
+ "/var/log/glusterfs/bricks/*"]
+
+
+ def initLoggerObj(self):
+ """Instantiation of Logger Object
"""
- return self._testruninfo
-
+ self._logger = logger.Log(self.logname)
+
def getLoggerObj(self):
"""Returns Logger Object
"""
return self._logger
- def getTestenvObj(self):
- """Returns Current TestEnvironment Object.
+ def initConnectionsManagerObj(self):
+ """Instantiation of ConnectionsManager Object
"""
- return self._env
+ self._connectionsmanager = manager.ConnectionsManager()
def getConnectionsManagerObj(self):
"""Returns ConnectionsManager Object
@@ -48,21 +63,21 @@ class AtfGlobals:
"""Instantiation of TestrunInfo Object
"""
self._testruninfo = testruninfo.TestRunInfo()
-
- def initLoggerObj(self):
- """Instantiation of Logger Object
+
+ def getTestrunInfoObj(self):
+ """Returns TestrunInfo Object
"""
- self._logger = logger.Log()
+ return self._testruninfo
def initTestenvObj(self):
"""Instantiation of Testenv Object
"""
self._env = testenv.TestEnv()
- def initConnectionsManagerObj(self):
- """Instantiation of ConnectionsManager Object
+ def getTestenvObj(self):
+ """Returns Current TestEnvironment Object.
"""
- self._connectionsmanager = manager.ConnectionsManager()
+ return self._env
GlobalObj = AtfGlobals()
__all__ = ['GlobalObj']
diff --git a/libs/globals/testenv.py b/libs/globals/testenv.py
index 9aa8ec8..0720c2c 100755
--- a/libs/globals/testenv.py
+++ b/libs/globals/testenv.py
@@ -23,7 +23,7 @@ class TestEnv():
self._active_volume = None
self._exportdir_tuple = namedtuple('ExportDir',
- ['dir', 'fstype', 'device'])
+ ['dir', 'fstype', 'device', 'options'])
self._server_tuple = namedtuple('Server',
['hostname', 'user', 'password',
@@ -50,14 +50,19 @@ class TestEnv():
def addExportdir(self, key, dir_, **arguments):
"""
"""
- fstype = device = None
+ fstype = None
+ device = None
+ options = None
if (arguments.has_key('fstype') and arguments['fstype']):
fstype = arguments['fstype']
if (arguments.has_key('device') and arguments['device']):
device = arguments['device']
-
- exportdir_obj = self._exportdir_tuple(dir_, fstype, device)
+
+ if (arguments.has_key('options') and arguments['options']):
+ options = arguments['options']
+
+ exportdir_obj = self._exportdir_tuple(dir_, fstype, device, options)
self._exportdirs[key] = exportdir_obj
def getExportdir(self, exportdirkey):
@@ -167,7 +172,7 @@ class TestEnv():
path_value = brick_obj.path
if re.match("^\/", path_value):
- path = path_value
+ newpath = path_value
else:
exportdir_obj = self.getExportdir(path_value)
if exportdir_obj:
@@ -204,11 +209,14 @@ class TestEnv():
brick_keys.extend(self._bricks.keys())
return brick_keys
- def addBricksToVolume(self, volumekey="ActiveVolume", *bricks):
+ def addBricksToVolume(self, *bricks, **arguments):
"""
"""
volume_obj = None
- if volumekey == "ActiveVolume":
+
+ if arguments.has_key("volumekey"):
+ volumekey = arguments[volumekey]
+ else:
volumekey = self._active_volume
if not (volumekey and self._volumes.has_key(volumekey)):
diff --git a/libs/globals/testruninfo.py b/libs/globals/testruninfo.py
index 9b012e8..76137f1 100644
--- a/libs/globals/testruninfo.py
+++ b/libs/globals/testruninfo.py
@@ -10,10 +10,6 @@ class TestRunInfo():
self._testunits = []
self._keywords = ''
self._glusterversion = ''
- self._atfdir = ''
- self._summaryloginfo = {}
- self._detailloginfo = {}
- self._stdoutloginfo = {}
def addGlusterVersion(self, version):
"""
@@ -24,77 +20,7 @@ class TestRunInfo():
"""
"""
return self._glusterversion
-
- def addSummaryLogInfo(self, filename, loglevel):
- """
- """
- if not filename:
- filename = "SummaryLog.out"
-
- if not loglevel:
- loglevel = "info"
-
- self._summaryloginfo['filename'] = filename
- self._summaryloginfo['loglevel'] = loglevel
-
- def getSummaryLogInfo(self):
- """
- """
- return self._summaryloginfo
-
- def addDetailLogInfo(self, filename, loglevel):
- """
- """
- if not filename:
- filename = "DetailLog.out"
-
- if not loglevel:
- loglevel = "info"
-
- self._detailloginfo['filename'] = filename
- self._detailloginfo['loglevel'] = loglevel
-
- def getDetailLogInfo(self):
- """
- """
- return self._detailloginfo
- def addStdoutLogInfo(self, do_log, loglevel):
- """
- """
- true_pattern = re.compile('True|Yes', re.IGNORECASE)
- false_pattern = re.compile('False|No', re.IGNORECASE)
-
- if not loglevel:
- loglevel = "info"
-
- if true_pattern.match(do_log):
- do_log = True
-
- elif false_pattern.match(do_log):
- do_log = False
-
- else:
- do_log = True
-
- self._stdoutloginfo['do_log'] = do_log
- self._stdoutloginfo['loglevel'] = loglevel
-
- def getStdoutLogInfo(self):
- """
- """
- return self._stdoutloginfo
-
- def addAtfDir(self, atfdir):
- """
- """
- self._atfdir = atfdir
-
- def getAtfDir(self):
- """
- """
- return self._atfdir
-
def addTestUnits(self, testunit):
"""
Description:
diff --git a/libs/parser/parser.py b/libs/parser/parser.py
index ee3a2d1..70619c9 100644
--- a/libs/parser/parser.py
+++ b/libs/parser/parser.py
@@ -24,11 +24,13 @@ def verify_necessary_options(cp, section, necessary_options):
Success: True (if all necessary_options are found in 'section')
Failure: False ( if any of the necessaty_options not found in 'section')
"""
+ logger = GlobalObj.getLoggerObj()
all_options_found = True
items = dict(cp.items(section))
for option in necessary_options:
if not (items.has_key(option) and items[option]):
- print "' %s ' Should be defined in Section: %s" % (option, section)
+ logger.error("' %s ' Should be defined in Section: %s" %
+ (option, section))
all_options_found = False
return all_options_found
@@ -40,14 +42,13 @@ def parse_testrun_info_file(filename):
GlobalObj.initTestrunInfoObj()
testruninfo_obj = GlobalObj.getTestrunInfoObj()
cp = ConfigParser.SafeConfigParser()
- necessary_sections = ["keywords", "testunits", "atfdir",
- "summarylog","detaillog", "stdoutlog",
- "glusterversion"]
+ necessary_sections = ["keywords", "testunits", "glusterversion"]
matched_sections = []
unmatched_sections = []
+ logger = GlobalObj.getLoggerObj()
if not cp.read(filename):
- print "Error reading file ' %s '.File Not found " % filename
+ logger.error("Error reading file ' %s '.File Not found " % filename)
return 1
else:
available_sections = cp.sections()
@@ -63,8 +64,8 @@ def parse_testrun_info_file(filename):
if not found_all_sections:
for section in unmatched_sections:
- print "Section %s Not Found" % section
- print "Please define the above sections in TestRunInfo File"
+ logger.error("Section %s Not Found" % section)
+ logger.error("Please define the above sections in TestRunInfo File")
return 1
else:
@@ -81,37 +82,12 @@ def parse_testrun_info_file(filename):
if testunit:
testruninfo_obj.addTestUnits(testunit)
- elif re.match("atfdir", section, re.IGNORECASE):
- Map = dict(cp.items(section))
- atfdir = Map['dir']
- if not atfdir:
- print "dir option not defined in ATFDir. " + \
- "The 'dir'option should be defined"
- return 1
- else:
- testruninfo_obj.addAtfDir(atfdir)
-
- elif re.match("summarylog", section, re.IGNORECASE):
- Map = dict(cp.items(section))
- testruninfo_obj.addSummaryLogInfo(Map['filename'],
- Map['loglevel'])
-
- elif re.match("detaillog", section, re.IGNORECASE):
- Map = dict(cp.items(section))
- testruninfo_obj.addDetailLogInfo(Map['filename'],
- Map['loglevel'])
-
- elif re.match("stdoutlog", section, re.IGNORECASE):
- Map = dict(cp.items(section))
- testruninfo_obj.addStdoutLogInfo(Map['do_log'],
- Map['loglevel'])
-
elif re.match("glusterversion", section, re.IGNORECASE):
Map = dict(cp.items(section))
glusterversion = Map['version']
if not glusterversion:
- print "version option not defined in GlusterVersion. " + \
- "The 'version' option should be defined"
+ logger.error("version option not defined in GlusterVersion. " + \
+ "The 'version' option should be defined")
return 1
else:
testruninfo_obj.addGlusterVersion(glusterversion)
@@ -124,8 +100,10 @@ def parse_testcaseslist_file(filename):
"""
return_status = 1
testcaseslist = []
+ logger = GlobalObj.getLoggerObj()
+
if not os.path.exists(filename):
- print "%s file not found." % filename
+ logger.error("%s file not found." % filename)
return return_status
testruninfo_obj = GlobalObj.getTestrunInfoObj()
@@ -190,8 +168,10 @@ def parse_testenv_configfile(filename):
"mount" : "addMount",
"defaults" : "addDefaults"}
section_pattern = re.compile('(export|server|brick|volume|client|mountdevice|mount)*')
+ logger = GlobalObj.getLoggerObj()
+
if not cp.read(filename):
- print "Error reading file ' %s '.File Not found " % filename
+ logger.error("Error reading file ' %s '.File Not found " % filename)
return 1
else:
defaults = dict(cp.defaults())
diff --git a/libs/utils/atfutils.py b/libs/utils/atfutils.py
index 980c286..9b91ae2 100644
--- a/libs/utils/atfutils.py
+++ b/libs/utils/atfutils.py
@@ -30,23 +30,26 @@ def assert_failure(**arguments):
def print_stdout(stdoutdata):
"""
"""
+ logger = GlobalObj.getLoggerObj()
if not stdoutdata == None:
for data in stdoutdata:
- print data
+ logger.debug(data)
def print_stderr(stderrdata):
+ logger = GlobalObj.getLoggerObj()
if not stderrdata == None:
for data in stderrdata:
- print data
+ logger.debug(data)
def set_active_volume(volumekey):
"""
"""
+ logger = GlobalObj.getLoggerObj()
env = GlobalObj.getTestenvObj()
return_status = env.setActiveVolume(volumekey)
if return_status:
- print "Unable to set Active Volume. '%s' Not defined in TestEnvironment"\
- % volumekey
+ logger.error("Unable to set Active Volume. \
+ '%s' Not defined in TestEnvironment" % volumekey )
return return_status
diff --git a/libs/utils/clientutils.py b/libs/utils/clientutils.py
index ad5d593..33f036e 100644
--- a/libs/utils/clientutils.py
+++ b/libs/utils/clientutils.py
@@ -12,6 +12,7 @@ Supported Wrappers :-
import atfutils
import hostutils
from atfglobals import GlobalObj
+import pdb
def umount(mountkey):
"""unmounts a mountpoint
@@ -24,23 +25,26 @@ def umount(mountkey):
Success : 0
Failure : 1`
"""
- base_command = "umount "
+ logger = GlobalObj.getLoggerObj()
+ base_command = "umount"
env = GlobalObj.getTestenvObj()
cm = GlobalObj.getConnectionsManagerObj()
mount_obj = env.getMount(mountkey)
if not mount_obj:
- print "InValid Mount. %s not defined in TestEnvironment" % mountkey
+ logger.error("InValid Mount. '%s' not defined in TestEnvironment"
+ % mountkey)
return 1
clientkey = mount_obj.client
client_connection = cm.getConnection(clientkey)
if not client_connection:
- print "SSH connection to host '%s' has not been established" % clientkey
+ logger.error("SSH connection to host '%s' has not been established"
+ % clientkey)
return 1
- command = base_command + mount_obj.dir
- print "%s : %s" % (clientkey, command)
+ command = ' '.join([base_command, mount_obj.dir])
+ logger.debug('%s: Executing Command: %s' % (clientkey, command))
output = client_connection.executecommand(command)
return_status = atfutils.assert_success(**output)
atfutils.print_stdout(output['stdoutdata'])
@@ -51,7 +55,7 @@ def umount(mountkey):
return_status = 0
else:
- print "Unable to umount %s" % mountkey
+ logger.error("Unable to umount %s" % mountkey)
return return_status
@@ -91,41 +95,44 @@ def mount(mountkey):
Success : 0
Failure : 1`
"""
-
- base_command = command = "mount "
+ logger = GlobalObj.getLoggerObj()
+ base_command = "mount"
env = GlobalObj.getTestenvObj()
cm = GlobalObj.getConnectionsManagerObj()
+ command = [base_command]
+ options = []
mount_obj = env.getMount(mountkey)
if not mount_obj:
- print "InValid Mount. %s not defined in TestEnvironment" % mountkey
+ logger.error("InValid Mount. %s not defined in TestEnvironment"
+ % mountkey)
return 1
clientkey = mount_obj.client
client_connection = cm.getConnection(clientkey)
if not client_connection:
- print "SSH connection to host '%s' has not been established" % clientkey
+ logger.error("SSH connection to host '%s' has not been established"
+ % clientkey)
return 1
+ return_status = hostutils.mkdir(clientkey, mount_obj.dir)
+ if return_status:
+ return return_status
+
mountdevice_obj = mount_obj.device
device = mountdevice_obj.hostname + ":/" + mountdevice_obj.volumename
- options = ["-t", mount_obj.type]
+ options.extend(["-t", mount_obj.type])
if mount_obj.logfile:
options.extend(["-o", ("log-file="+mount_obj.logfile),
"log-level=INFO"])
-
if mount_obj.options:
options.extend([mount_obj.option])
-
options.extend([device, mount_obj.dir])
- for index, option in enumerate(options):
- command = command + option + " "
+
+ command.extend(options)
+ command = ' '.join(command)
- return_status = hostutils.mkdir(clientkey, mount_obj.dir)
- if return_status:
- return return_status
-
- print "%s : %s" % (clientkey, command)
+ logger.debug('%s: Executing Command: %s' % (clientkey, command))
output = client_connection.executecommand(command)
return_status = atfutils.assert_success(**output)
atfutils.print_stdout(output['stdoutdata'])
@@ -156,12 +163,15 @@ def mountall():
def execute_on_mount(mountkey, command, commandInput=None):
"""
"""
+ logger = GlobalObj.getLoggerObj()
env = GlobalObj.getTestenvObj()
mount_obj = env.getMount(mountkey)
if not mount_obj:
- print "InValid Mount. %s not defined in TestEnvironment" % mountkey
+ logger.error("InValid Mount. %s not defined in TestEnvironment"
+ % mountkey)
return 1
+
clientkey = mount_obj.client
mountdir = mount_obj.dir
command = "cd " + mountdir + " ;" + command
diff --git a/libs/utils/glusterutils.py b/libs/utils/glusterutils.py
index 0c15af1..7ab41d0 100644
--- a/libs/utils/glusterutils.py
+++ b/libs/utils/glusterutils.py
@@ -27,17 +27,18 @@ import atfutils
import hostutils
from atfglobals import GlobalObj
-
def glusterd_start(serverkey, force=False):
"""
"""
+ logger = GlobalObj.getLoggerObj()
env = GlobalObj.getTestenvObj()
cm = GlobalObj.getConnectionsManagerObj()
commands_to_execute = ["which glusterd", "ps -e | grep glusterd"]
gluster_version = env.getServer(serverkey).glusterversion
host_connection = cm.getConnection(serverkey)
if not host_connection:
- print "SSH connection to host '%s' has not been established" % serverkey
+ logger.error("SSH connection to host '%s' has not been established"
+ % serverkey)
return 1
""" Check if gluster is already running. If already Running and force=True,
@@ -55,7 +56,7 @@ def glusterd_start(serverkey, force=False):
command = commands_to_execute.pop()
output = host_connection.executecommand(command)
if output["exitstatus"]:
- print "Unable to start glusterd"
+ logger.error("Unable to start glusterd")
return_status = atfutils.assert_success(**output)
return return_status
else:
@@ -63,7 +64,7 @@ def glusterd_start(serverkey, force=False):
gluster_path = None
gluster_path = output["stdoutdata"][0].strip("\n")
else:
- print "Unable to find gluster path"
+ logger.error("Unable to find gluster path")
return_status = atfutils.assert_success(**output)
return return_status
@@ -72,17 +73,18 @@ def glusterd_start(serverkey, force=False):
output = host_connection.executecommand(command)
if not output["stdoutdata"] == None:
if re.search(gluster_version, str(output["stdoutdata"])):
- print "%s : %s" % (serverkey, gluster_path)
+ logger.debug('%s: Executing Command: %s'
+ %(serverkey, gluster_path))
output = host_connection.executecommand(gluster_path)
return_status = atfutils.assert_success(**output)
atfutils.print_stdout(output['stdoutdata'])
atfutils.print_stderr(output['stderrdata'])
return return_status
else:
- print "Unable to start glusterd"
+ logger.error("Unable to start glusterd")
return 1
else:
- print "Unable to start glusterd"
+ logger.error("Unable to start glusterd")
return 1
def glusterd_start_allservers(force=False):
@@ -100,12 +102,14 @@ def glusterd_start_allservers(force=False):
def glusterd_stop(serverkey):
"""
"""
+ logger = GlobalObj.getLoggerObj()
base_command = "kill -KILL "
env = GlobalObj.getTestenvObj()
cm = GlobalObj.getConnectionsManagerObj()
host_connection = cm.getConnection(serverkey)
if not host_connection:
- print "SSH connection to host '%s' has not been established" % serverkey
+ logger.error("SSH connection to host '%s' has not been established"
+ % serverkey)
return 1
gluster_pid_list = []
@@ -121,7 +125,7 @@ def glusterd_stop(serverkey):
for pid in gluster_pid_list:
command = base_command + pid
- print "%s : %s" % (serverkey, command)
+ logger.debug('%s: Executing Command: %s' % (serverkey, command))
output = host_connection.executecommand(command)
return_status = atfutils.assert_success(**output)
atfutils.print_stdout(output['stdoutdata'])
@@ -156,21 +160,26 @@ def glusterd_restart(serverkey):
def glusterd_remove_dir(serverkey):
"""
"""
- command = "rm -rf /etc/glusterd/*"
+ logger = GlobalObj.getLoggerObj()
+ base_command = "rm -rf"
env = GlobalObj.getTestenvObj()
cm = GlobalObj.getConnectionsManagerObj()
+ glusterd_dir = GlobalObj.glusterd_dir
server_obj = env.getServer(serverkey)
if not server_obj:
- print "Invalid Host. %s not defined in TestEnvironment" % serverkey
+ logger.error("Invalid Host. %s not defined in TestEnvironment"
+ % serverkey)
return 1
server_connection = cm.getConnection(serverkey)
if not server_connection:
- print "SSH connection to host '%s' has not been established" % serverkey
+ logger.error("SSH connection to host '%s' has not been established"
+ % serverkey)
return 1
-
- print "%s : %s" % (serverkey, command)
+
+ command = ' '.join([base_command, glusterd_dir])
+ logger.debug('%s: Executing Command: %s' % (serverkey, command))
output = server_connection.executecommand(command)
return_status = atfutils.assert_success(**output)
atfutils.print_stdout(output['stdoutdata'])
@@ -191,8 +200,9 @@ def glusterd_remove_dir_allservers():
def glusterd_remove_logs(serverkey):
"""
"""
- base_command = "rm -rf "
- log_paths = ["/var/log/glusterfs/*.log", "/var/log/glusterfs/bricks/*"]
+ logger = GlobalObj.getLoggerObj()
+ base_command = "rm -rf"
+ log_paths = GlobalObj.glusterd_log_paths
absolute_path_list = []
prefix_path = ''
env = GlobalObj.getTestenvObj()
@@ -200,12 +210,14 @@ def glusterd_remove_logs(serverkey):
server_obj = env.getServer(serverkey)
if not server_obj:
- print "Invalid Host. %s not defined in TestEnvironment" % serverkey
+ logger.error("Invalid Host. %s not defined in TestEnvironment"
+ % serverkey)
return 1
server_connection = cm.getConnection(serverkey)
if not server_connection:
- print "SSH connection to host '%s' has not been established" % serverkey
+ logger.error("SSH connection to host '%s' has not been established"
+ % serverkey)
return 1
if server_obj.installpath:
@@ -215,8 +227,8 @@ def glusterd_remove_logs(serverkey):
absolute_path_list.append(prefix_path + path)
for path in absolute_path_list:
- command = base_command + path
- print "%s : %s" % (serverkey, command)
+ command = ' '.join([base_command, path])
+ logger.debug('%s: Executing Command: %s' % (serverkey, command))
output = server_connection.executecommand(command)
return_status = atfutils.assert_success(**output)
atfutils.print_stdout(output['stdoutdata'])
@@ -237,21 +249,24 @@ def glusterd_remove_logs_allservers():
def volume_delete(serverkey):
"""
"""
+ logger = GlobalObj.getLoggerObj()
base_command = "gluster volume delete "
env = GlobalObj.getTestenvObj()
cm = GlobalObj.getConnectionsManagerObj()
active_volume = env.getActiveVolume()
if not active_volume:
- print "Invalid Volume.ActiveVolume not defined for the TestEnvironment"
+ logger.error("Invalid Volume.ActiveVolume not defined" +
+ "for the TestEnvironment")
return 1
volumename = active_volume.volumename
command = base_command + volumename
host_connection = cm.getConnection(serverkey)
if not host_connection:
- print "SSH connection to host '%s' has not been established" % serverkey
+ logger.error("SSH connection to host '%s' has not been established"
+ % serverkey)
return 1
- print "%s : %s" % (serverkey, command)
+ logger.debug('%s: Executing Command: %s' % (serverkey, command))
output = host_connection.executecommand(command, commandInput="y\n")
return_status = atfutils.assert_success(**output)
atfutils.print_stdout(output['stdoutdata'])
@@ -261,30 +276,30 @@ def volume_delete(serverkey):
def volume_create(serverkey):
"""
"""
+ logger = GlobalObj.getLoggerObj()
base_command = "gluster volume create "
env = GlobalObj.getTestenvObj()
cm = GlobalObj.getConnectionsManagerObj()
active_volume = env.getActiveVolume()
if not active_volume:
- print "ActiveVolume not defined for the TestEnvironment"
+ logger.error("ActiveVolume not defined for the TestEnvironment")
return 1
-
- command = base_command + \
- active_volume.volumename + " " + \
- active_volume.volumetype + " " + \
- active_volume.count + " " + \
- "transport " + active_volume.transporttype + " "
+
+ command = ' '.join([base_command, active_volume.volumename,
+ active_volume.volumetype, active_volume.count,
+ "transport", active_volume.transporttype])
for brick_obj in active_volume.bricks:
brick_value = brick_obj.hostname + ":" + brick_obj.path
- command = command + brick_value + " "
+ command = ' '.join([command, brick_value])
host_connection = cm.getConnection(serverkey)
if not host_connection:
- print "SSH connection to host '%s' has not been established" % serverkey
+ logger.error("SSH connection to host '%s' has not been established"
+ % serverkey)
return 1
- print "%s : %s" % (serverkey, command)
+ logger.debug('%s: Executing Command: %s' % (serverkey, command))
output = host_connection.executecommand(command, commandInput="y\n")
return_status = atfutils.assert_success(**output)
if return_status:
@@ -297,12 +312,13 @@ def volume_create(serverkey):
def volume_start(serverkey, force=False):
"""
"""
+ logger = GlobalObj.getLoggerObj()
base_command = "gluster volume start "
env = GlobalObj.getTestenvObj()
cm = GlobalObj.getConnectionsManagerObj()
active_volume = env.getActiveVolume()
if not active_volume:
- print "ActiveVolume not defined for the TestEnvironment"
+ logger.error("ActiveVolume not defined for the TestEnvironment")
return 1
volumename = active_volume.volumename
command = base_command + volumename
@@ -311,10 +327,11 @@ def volume_start(serverkey, force=False):
host_connection = cm.getConnection(serverkey)
if not host_connection:
- print "SSH connection to host '%s' has not been established" % serverkey
+ logger.error("SSH connection to host '%s' has not been established"
+ % serverkey)
return 1
- print "%s : %s" % (serverkey, command)
+ logger.debug('%s: Executing Command: %s' % (serverkey, command))
output = host_connection.executecommand(command, commandInput="y\n")
return_status = atfutils.assert_success(**output)
if return_status:
@@ -327,12 +344,13 @@ def volume_start(serverkey, force=False):
def volume_stop(serverkey, force=False):
"""
"""
+ logger = GlobalObj.getLoggerObj()
base_command = "gluster volume stop "
env = GlobalObj.getTestenvObj()
cm = GlobalObj.getConnectionsManagerObj()
active_volume = env.getActiveVolume()
if not active_volume:
- print "ActiveVolume not defined for the TestEnvironment"
+ logger.error("ActiveVolume not defined for the TestEnvironment")
return 1
volumename = active_volume.volumename
command = base_command + volumename
@@ -341,10 +359,11 @@ def volume_stop(serverkey, force=False):
host_connection = cm.getConnection(serverkey)
if not host_connection:
- print "SSH connection to host '%s' has not been established" % serverkey
+ logger.error("SSH connection to host '%s' has not been established"
+ % serverkey)
return 1
- print "%s : %s" % (serverkey, command)
+ logger.debug('%s: Executing Command: %s' % (serverkey, command))
output = host_connection.executecommand(command, commandInput="y\n")
return_status = atfutils.assert_success(**output)
atfutils.print_stdout(output['stdoutdata'])
@@ -354,29 +373,35 @@ def volume_stop(serverkey, force=False):
def volume_addbrick(serverkey, *bricks):
"""
"""
- base_command = "gluster volume add-brick "
+ logger = GlobalObj.getLoggerObj()
+ base_command = "gluster volume add-brick"
env = GlobalObj.getTestenvObj()
cm = GlobalObj.getConnectionsManagerObj()
active_volume = env.getActiveVolume()
+ command = [base_command]
+
if not active_volume:
- print "ActiveVolume not defined for the TestEnvironment"
+ logger.error("ActiveVolume not defined for the TestEnvironment")
return 1
- volumename = active_volume.volumenameGlobalObj.getConnectionsManagerObj()
- command = base_command + volumename + " "
+ volumename = active_volume.volumename
+
+ command.extend([volumename])
for brick in bricks:
brick_obj = env.getBrick(brick)
if not brick_obj:
- print "Invalid Brick. Brick Not defined in TestEnvironment"
+ logger.error("Invalid Brick. Brick Not defined in TestEnvironment")
return 1
brick_value = brick_obj.hostname + ":" + brick_obj.path
- command = command + brick_value
-
+ command.extend([brick_value])
+
+ command = ' '.join(command)
host_connection = cm.getConnection(serverkey)
if not host_connection:
- print "SSH connection to host '%s' has not been established" % serverkey
+ logger.error("SSH connection to host '%s' has not been established"
+ % serverkey)
return 1
- print "%s : %s" % (serverkey, command)
+ logger.debug('%s: Executing Command: %s' % (serverkey, command))
output = host_connection.executecommand(command, commandInput="y\n")
return_status = atfutils.assert_success(**output)
if not return_status:
@@ -389,25 +414,33 @@ def volume_addbrick(serverkey, *bricks):
def volume_replacebrick(serverkey, replacebrick_key, tobrick_key):
"""
"""
+ logger = GlobalObj.getLoggerObj()
base_command = "gluster volume replace-brick "
env = GlobalObj.getTestenvObj()
cm = GlobalObj.getConnectionsManagerObj()
+ command = [base_command]
+
active_volume = env.getActiveVolume()
if not active_volume:
- print "ActiveVolume not defined for the TestEnvironment"
+ logger.error("ActiveVolume not defined for the TestEnvironment")
return 1
volumename = active_volume.volumename
- command = base_command + volumename + " "
replace_brick = env.getbrick(replacebrick_key)
to_brick = env.getbrick(tobrick_key)
- command = command + replace_brick + " " + to_brick
-
+
+ if not (to_brick and replace_brick):
+ logger.error("Invalid Brick. Brick Not defined in TestEnvironment")
+ return 1
+
+ command.extend([volumename, replace_brick, to_brick])
+ command = ' '.join(command)
host_connection = cm.getConnection(serverkey)
if not host_connection:
- print "SSH connection to host '%s' has not been established" % serverkey
+ logger.error("SSH connection to host '%s' has not been established"
+ % serverkey)
return 1
- print "%s : %s" % (serverkey, command)
+ logger.debug('%s: Executing Command: %s' % (serverkey, command))
output = host_connection.executecommand(command, commandInput="y\n")
return_status = atfutils.assert_success(**output)
if not return_status:
@@ -420,21 +453,28 @@ def volume_replacebrick(serverkey, replacebrick_key, tobrick_key):
def volume_set(serverkey, key, value):
"""
"""
- base_command = "gluster volume set "
+ logger = GlobalObj.getLoggerObj()
+ base_command = "gluster volume set"
env = GlobalObj.getTestenvObj()
cm = GlobalObj.getConnectionsManagerObj()
+ command = [base_command]
+
active_volume = env.getActiveVolume()
if not active_volume:
- print "ActiveVolume not defined for the TestEnvironment"
+ logger.error("ActiveVolume not defined for the TestEnvironment")
return 1
volumename = active_volume.volumename
- command = base_command + volumename + " " + key + " " + value
+
+ command.extend([volumename, key, value])
+ command = ' '.join(command)
+
host_connection = cm.getConnection(serverkey)
if not host_connection:
- print "SSH connection to host '%s' has not been established" % serverkey
+ logger.error("SSH connection to host '%s' has not been established"
+ % serverkey)
return 1
- print "%s : %s" % (serverkey, command)
+ logger.debug('%s: Executing Command: %s' % (serverkey, command))
output = host_connection.executecommand(command, commandInput="y\n")
return_status = atfutils.assert_success(**output)
atfutils.print_stdout(output['stdoutdata'])
@@ -444,21 +484,23 @@ def volume_set(serverkey, key, value):
def volume_reset(serverkey):
"""
"""
+ logger = GlobalObj.getLoggerObj()
base_command = "gluster volume reset "
env = GlobalObj.getTestenvObj()
cm = GlobalObj.getConnectionsManagerObj()
active_volume = env.getActiveVolume()
if not active_volume:
- print "ActiveVolume not defined for the TestEnvironment"
+ logger.error("ActiveVolume not defined for the TestEnvironment")
return 1
volumename = active_volume.volumename
command = base_command + volumename
host_connection = cm.getConnection(serverkey)
if not host_connection:
- print "SSH connection to host '%s' has not been established" % serverkey
+ logger.error("SSH connection to host '%s' has not been established"
+ % serverkey)
return 1
- print "%s : %s" % (serverkey, command)
+ logger.debug('%s: Executing Command: %s' % (serverkey, command))
output = host_connection.executecommand(command, commandInput="y\n")
return_status = atfutils.assert_success(**output)
atfutils.print_stdout(output['stdoutdata'])
@@ -468,8 +510,9 @@ def volume_reset(serverkey):
def peer_probe(fromserverkey):
"""
"""
+ logger = GlobalObj.getLoggerObj()
base_command = "gluster peer probe "
- command = base_command
+ command = [base_command]
all_servers = {}
env = GlobalObj.getTestenvObj()
cm = GlobalObj.getConnectionsManagerObj()
@@ -481,14 +524,16 @@ def peer_probe(fromserverkey):
continue
else:
server_obj = all_servers[key]
- command = command + server_obj.hostname + " "
-
+ command.extend([server_obj.hostname])
+
+ command = ' '.join(command)
host_connection = cm.getConnection(fromserverkey)
if not host_connection:
- print "SSH connection to host '%s' has not been established" % serverkey
+ logger.error("SSH connection to host '%s' has not been established"
+ % serverkey)
return 1
- print "%s : %s" % (fromserverkey, command)
+ logger.debug('%s: Executing Command: %s' % (fromserverkey, command))
output = host_connection.executecommand(command)
return_status = atfutils.assert_success(**output)
atfutils.print_stdout(output['stdoutdata'])
@@ -498,6 +543,7 @@ def peer_probe(fromserverkey):
def create_brick(brickkey):
"""
"""
+ logger = GlobalObj.getLoggerObj()
return_status = 1
env = GlobalObj.getTestenvObj()
brick_obj = env.getRawBrick(brickkey)
@@ -513,20 +559,20 @@ def create_brick(brickkey):
if re.match("^\/", exportdir):
dirpath = exportdir
- command = base_command + dirpath
else:
export_obj = env.getExportdir(exportdir)
dirpath = export_obj.dir
device = export_obj.device
fstype = export_obj.fstype
+ options = export_obj.options
- print "%s : %s" % (serverkey, 'create_brick')
+ logger.debug('%s: Executing Command: %s'% (serverkey, 'create_brick'))
if device:
if umount_device(serverkey, device):
return return_status
if hostutils.mkfs(serverkey, device, fstype):
return return_status
- if mount_exportdir(serverkey, device, fstype, dirpath):
+ if mount_exportdir(serverkey, device, fstype, options, dirpath):
return return_status
return 0
@@ -541,19 +587,21 @@ def create_brick(brickkey):
def umount_device(serverkey, device):
"""
"""
+ logger = GlobalObj.getLoggerObj()
base_command = "umount "
cm = GlobalObj.getConnectionsManagerObj()
server_connection = cm.getConnection(serverkey)
if not server_connection:
- print "SSH connection to host '%s' has not been established" % serverkey
+ logger.error("SSH connection to host '%s' has not been established"
+ % serverkey)
return 1
mountpoints = hostutils.find_mountpoints(serverkey, device)
for mountpoint in mountpoints:
command = base_command + mountpoint
- print "%s : %s" % (serverkey, command)
+ logger.debug('%s: Executing Command: %s' % (serverkey, command))
output = server_connection.executecommand(command)
return_status = atfutils.assert_success(**output)
atfutils.print_stdout(output['stdoutdata'])
@@ -568,23 +616,31 @@ def umount_device(serverkey, device):
return 0
-def mount_exportdir(serverkey, device, fstype, dirpath):
+def mount_exportdir(serverkey, device, fstype, options, dirpath):
"""
"""
+ logger = GlobalObj.getLoggerObj()
base_command = "mount "
cm = GlobalObj.getConnectionsManagerObj()
+ command = [base_command]
server_connection = cm.getConnection(serverkey)
if not server_connection:
- print "SSH connection to host '%s' has not been established" % serverkey
+ logger.error("SSH connection to host '%s' has not been established"
+ % serverkey)
return 1
if fstype is None:
fstype = "xfs"
+ command.extend(["-t", fstype])
+
+ if options:
+ command.extend([options])
+
+ command.extend([device, dirpath])
+ command = ' '.join(command)
- command = base_command + "-t " + fstype + " " + device + " " + dirpath
-
- print "%s : %s" % (serverkey, command)
+ logger.debug('%s: Executing Command: %s' % (serverkey, command))
output = server_connection.executecommand(command)
return_status = atfutils.assert_success(**output)
atfutils.print_stdout(output['stdoutdata'])
diff --git a/libs/utils/hostutils.py b/libs/utils/hostutils.py
index 68bb1bf..9992bb6 100644
--- a/libs/utils/hostutils.py
+++ b/libs/utils/hostutils.py
@@ -12,18 +12,23 @@ Supported Wrappers:
import re
import atfutils
from atfglobals import GlobalObj
+import pdb
+
+system_dirs = re.compile('(/bin|/boot|/dev|/etc|/lib|/mnt|/net|/opt|/root|/sbin|/usr|/var|/sys)\/?$')
def cd(hostkey, dirpath):
"""
"""
- base_command = "cd "
+ logger = GlobalObj.getLoggerObj()
+ base_command = "cd"
cm = GlobalObj.getConnectionsManagerObj()
host_connection = cm.getConnection(hostkey)
if not host_connection:
- print "SSH Connection Not established to host '%s' " % hostkey
+ logger.error("SSH Connection Not established to host '%s' " % hostkey)
return 1
- command = base_command + dirpath
- print "%s : %s" % (hostkey, command)
+
+ command = ' '.join([base_command, dirpath])
+ logger.debug('%s: Executing Command: %s' % (hostkey, command))
output = host_connection.executecommand(command)
return_status = atfutils.assert_success(**output)
atfutils.print_stdout(output['stdoutdata'])
@@ -33,20 +38,22 @@ def cd(hostkey, dirpath):
def rmdir(hostkey, dirpath):
"""
"""
- base_command = "rm -rf "
+ logger = GlobalObj.getLoggerObj()
+ base_command = "rm -rf"
cm = GlobalObj.getConnectionsManagerObj()
- system_dirs = re.compile('(/bin|/boot|/dev|/etc|/lib|/mnt|/net|/opt|/root|/sbin|/usr|/var|/sys)\/?$')
if system_dirs.match(dirpath):
- print "System Directiories cannot be deleted"
+ logger.error("System Directiories cannot be deleted")
return 1
else:
host_connection = cm.getConnection(hostkey)
if not host_connection:
- print "SSH Connection Not established to host '%s' " % hostkey
+ logger.error("SSH Connection Not established to host '%s' "
+ % hostkey)
return 1
- command = base_command + dirpath
- print "%s : %s" % (hostkey, command)
+
+ command = ' '.join([base_command, dirpath])
+ logger.debug('%s: Executing Command: %s' % (hostkey, command))
output = host_connection.executecommand(command)
return_status = atfutils.assert_success(**output)
atfutils.print_stdout(output['stdoutdata'])
@@ -56,20 +63,23 @@ def rmdir(hostkey, dirpath):
def mkdir(hostkey, dirpath):
"""
"""
- base_command = "mkdir -p "
+ logger = GlobalObj.getLoggerObj()
+ base_command = "mkdir -p"
cm = GlobalObj.getConnectionsManagerObj()
- system_dirs = re.compile('(/bin|/boot|/dev|/etc|/lib|/mnt|/net|/opt|/root|/sbin|/usr|/var|/sys)\/?$')
+
if system_dirs.match(dirpath):
- print "System Directiories cannot be created"
+ logger.error("System Directiories cannot be created")
return 1
else:
host_connection = cm.getConnection(hostkey)
if not host_connection:
- print "SSH Connection Not established to host '%s' " % hostkey
+ logger.error("SSH Connection Not established to host '%s' "
+ % hostkey)
return 1
- command = base_command + dirpath
- print "%s : %s" % (hostkey, command)
+
+ command = ' '.join([base_command, dirpath])
+ logger.debug('%s: Executing Command: %s' % (hostkey, command))
output = host_connection.executecommand(command)
return_status = atfutils.assert_success(**output)
atfutils.print_stdout(output['stdoutdata'])
@@ -79,18 +89,25 @@ def mkdir(hostkey, dirpath):
def mkfs(hostkey, device, fstype=None):
"""
"""
- base_command = "mkfs "
+ logger = GlobalObj.getLoggerObj()
+ base_command = "mkfs"
cm = GlobalObj.getConnectionsManagerObj()
host_connection = cm.getConnection(hostkey)
+ command = [base_command]
+ options = []
+
if not host_connection:
- print "SSH Connection Not established to host '%s' " % hostkey
+ logger.error("SSH Connection Not established to host '%s' " % hostkey)
return 1
if fstype is None:
fstype = "xfs"
-
- command = base_command + " -t " + fstype + " -f " + device
- print "%s : %s" % (hostkey, command)
+
+ options.extend(["-t", fstype, "-f", device])
+
+ command.extend(options)
+ command = ' '.join(command)
+ logger.debug('%s: Executing Command: %s' % (hostkey, command))
output = host_connection.executecommand(command)
return_status = atfutils.assert_success(**output)
atfutils.print_stdout(output['stdoutdata'])
@@ -100,17 +117,19 @@ def mkfs(hostkey, device, fstype=None):
def find_mountpoints(hostkey, device):
"""
"""
+ logger = GlobalObj.getLoggerObj()
base_command = "mount | grep "
cm = GlobalObj.getConnectionsManagerObj()
host_connection = cm.getConnection(hostkey)
if not host_connection:
- print "SSH connection to host '%s' has not been established" % hostkey
+ logger.error("SSH connection to host '%s' has not been established"
+ % hostkey)
return 1
mountpoints = []
command = base_command + device
- print "%s : %s" % (hostkey, command)
+ logger.debug('%s: Executing Command: %s' % (hostkey, command))
output = host_connection.executecommand(command)
if not output["exitstatus"]:
for data in output["stdoutdata"]:
@@ -121,14 +140,16 @@ def find_mountpoints(hostkey, device):
def execute_command(hostkey, command, commandInput=None):
"""
"""
+ logger = GlobalObj.getLoggerObj()
cm = GlobalObj.getConnectionsManagerObj()
host_connection = cm.getConnection(hostkey)
if not host_connection:
- print "SSH Connection Not established to host '%s' " % hostkey
+ logger.error("SSH Connection Not established to host '%s' "
+ % hostkey)
return 1
new_command = _substitute_value_for_variables(hostkey, command)
- print "%s : %s" % (hostkey, command)
+ logger.debug('%s: Executing Command: %s' % (hostkey, command))
output = host_connection.executecommand(new_command, commandInput)
return_status = atfutils.assert_success(**output)
atfutils.print_stdout(output['stdoutdata'])
@@ -139,6 +160,7 @@ def execute_command(hostkey, command, commandInput=None):
def _substitute_value_for_variables(hostkey, command):
"""
"""
+ logger = GlobalObj.getLoggerObj()
pattern_for_variables = re.compile("<[a-z]+\d*>")
pattern_for_hosts = re.compile('(server|client|master)*')
variables_to_replace = []
@@ -166,7 +188,7 @@ def _substitute_value_for_variables(hostkey, command):
host = function(hostkey)
if not host:
- print "No Host to execute the command\n"
+ logger.error("No Host to execute the command\n")
return 1
for variable in variables:
diff --git a/libs/utils/managerutils.py b/libs/utils/managerutils.py
index ca38b3f..6f72e99 100644
--- a/libs/utils/managerutils.py
+++ b/libs/utils/managerutils.py
@@ -13,13 +13,19 @@ from atfglobals import GlobalObj
def ssh_connect(hostkey):
"""
"""
+ logger = GlobalObj.getLoggerObj()
env = GlobalObj.getTestenvObj()
cm = GlobalObj.getConnectionsManagerObj()
+ if cm is None:
+ logger.error("Init ConnectionsManager")
+ return 1
+
host_connection = cm.getConnection(hostkey)
if not host_connection:
host_obj = env.getHost(hostkey)
if not host_obj:
- print "Invalid Host. %s is not defined in TestEnvironment" % hostkey
+ logger.error("Invalid Host. %s is not defined in TestEnvironment"
+ % hostkey)
return 1
else:
host_connection = ssh.SshConnection()
@@ -33,13 +39,14 @@ def ssh_connect(hostkey):
cm.addClient(hostkey, host_connection)
return 0
else:
- print "Connection to %s already exist" % hostkey
+ logger.debug("Connection to %s already exist" % hostkey)
return 0
def ssh_connect_allhosts():
"""
"""
+ GlobalObj.initConnectionsManagerObj()
env = GlobalObj.getTestenvObj()
cm = GlobalObj.getConnectionsManagerObj()
hosts_keys = env.getHostsKeys()
diff --git a/libs/utils/serverutils.py b/libs/utils/serverutils.py
index 618ee23..78e48b8 100644
--- a/libs/utils/serverutils.py
+++ b/libs/utils/serverutils.py
@@ -7,17 +7,20 @@ from atfglobals import GlobalObj
def execute_on_brick(brickkey, command, commandInput=None):
"""
"""
+ logger = GlobalObj.getLoggerObj()
env = GlobalObj.getTestenvObj()
raw_brick_obj = env.getRawBrick(brickkey)
if not raw_brick_obj:
- print "InValid Brick. %s not defined in TestEnvironment" % brickkey
+ logger.error("InValid Brick. %s not defined in TestEnvironment"
+ % brickkey)
return 1
serverkey = re.split("\.", raw_brick_obj.hostname, maxsplit=1)[0]
brick_obj = env.getBrick(brickkey)
if not brick_obj:
- print "InValid Brick. %s not defined in TestEnvironment" % brickkey
+ logger.error("InValid Brick. %s not defined in TestEnvironment"
+ % brickkey)
return 1
exportdirpath = brick_obj.path