#! /usr/bin/python # -*- coding: utf-8 -*- import sys, platform from com.ericsson.xn.xtool.BashSession import BashPexpect if __name__ == "__main__": if not platform.system() == "Linux": print "The server is not Linux Server. This script is supposed to be executed on Linux Server only." else: bashExpect = BashPexpect("bash-\d.\d[#|$] ") bashExpect.start() idle_time = 30 if len(sys.argv) > 1: try: idle_time = int(sys.argv[1]) except Exception as e: pass idle_time = 5 if idle_time < 5 else idle_time idle_time = 60 if idle_time > 60 else idle_time bashExpect.grantRemoteRootAndExtentSessionTime(idle_time) """ else: bashExpect.grantXOAMtoRemoteRoot() bashExpect.close() """
return False elif(not os.path.isdir(input[1])): print "The path: '" + str(input[1]) + "' that you specified doesn't exist." return False else: size = str(input[2]).strip() amount = int(size[:-1]) unit = size[-1:].upper() if("G" != unit and "M" != unit): print "The size of the file can only be in M or G, like 10M, 5G." return False else: statvfs = os.statvfs(os.path.normpath(input[1])) bFree = statvfs.f_frsize * statvfs.f_bavail alloSize = amount * 1024 * 1024 * 1024 if("G" == unit) else amount * 1024 * 1024 if(alloSize / bFree > 0.95): print "The file that you will allocate will occupy more than 95 percents of the given path, this is not allowed." return False else: return True if __name__ == '__main__': if(not CommonFunction.cmd_executable("/usr/bin/fallocate")): print "Cannot find the command 'fallocate' in this operation system." elif(not platform.system() == "Linux"): print "The server is not Linux Server. This script is supposed to be executed on Linux Server only." elif(inputValidation(sys.argv)): bash = BashPexpect("bash-\d.\d[$|#] ") bash.start() bash.allocateFileInTargetPath(sys.argv) bash.close()