Added additional linux clients

* Create Directory
* Is directory present
* Fixed Pep8
* Fixed string concatenation
* Changed algorithm of verifying directory existance
* args used for better readability
* removed prints
Change-Id: Ib57fb37e087a4281e37e8e7a9f4f6b7caa592898
This commit is contained in:
ivo5307
2013-08-21 13:55:47 -05:00
parent 684f3fcb92
commit 74f476d06e

View File

@@ -411,3 +411,28 @@ class LinuxClient(BasePersistentLinuxClient):
value = meta_item[1].strip('" ')
meta[key] = value
return meta
def create_directory(self, path):
'''
@summary: Creates Directory
@param path: Directory path
@type path: string
'''
command = "{0} {1}".format("mkdir -p", path)
output = self.ssh_client.exec_command(command)
return output
def is_directory_present(self, directory_path):
'''
@summary: Check if directory is present
@param path: Path for the directory
@type path: string
'''
cmd_str = "{0} {1} {2} {3} {4}"
args = ["[ -d",
directory_path,
"] && echo 'Directory found' || echo 'Directory",
directory_path, "not found'"]
command = cmd_str.format(*args)
output = self.ssh_client.exec_command(command)
return output.rstrip('\n') == 'Directory found'