Loading ifs/scripts/shutdown_adafs.py +6 −1 Original line number Diff line number Diff line Loading @@ -15,6 +15,8 @@ global PRETEND global PSSH_PATH global WAITTIME CONST_PSSH_HOSTFILE_PATH = '/tmp/hostfile_pssh' def check_dependencies(): global PSSH_PATH Loading Loading @@ -49,8 +51,11 @@ def shutdown_system(daemon_path, nodelist, sigkill): print '[ERR] Daemon executable not found or not a file' exit(1) nodefile = False if os.path.exists(nodelist): # XXX Currently, we assume that the nodefile syntax is sane. if os.path.exists(nodelist): nodefile = True if not util.create_pssh_hostfile(nodelist, CONST_PSSH_HOSTFILE_PATH): exit(1) nodelist = CONST_PSSH_HOSTFILE_PATH if PSSH_PATH is '': check_dependencies() # set pssh arguments Loading ifs/scripts/startup_adafs.py +6 −1 Original line number Diff line number Diff line Loading @@ -15,6 +15,8 @@ global PRETEND global PSSH_PATH global WAITTIME CONST_PSSH_HOSTFILE_PATH = '/tmp/hostfile_pssh' def check_dependencies(): global PSSH_PATH Loading Loading @@ -51,8 +53,11 @@ def init_system(daemon_path, rootdir, mountdir, nodelist, cleanroot): print '[ERR] Daemon executable not found or not a file' exit(1) nodefile = False if os.path.exists(nodelist): # XXX Currently, we assume that the nodefile syntax is sane. if os.path.exists(nodelist): nodefile = True if not util.create_pssh_hostfile(nodelist, CONST_PSSH_HOSTFILE_PATH): exit(1) nodelist = CONST_PSSH_HOSTFILE_PATH if PSSH_PATH is '': check_dependencies() # set pssh arguments Loading ifs/scripts/util/util.py +28 −0 Original line number Diff line number Diff line Loading @@ -111,3 +111,31 @@ def check_shell_out(msg): if msg.err != '': raise OSError('Shell command failed with\n\t%s' % msg.err) return msg.output def create_pssh_hostfile(hostfile, hostfile_pssh): """Function creates a pssh compatible hostfile Args: hostfile(str): Path to source hostfile hostfile_pssh(str): Path to pssh compatible hostfile (contents will be created first) Returns: (bool): Returns true if successful """ # truncate pssh hostfile try: open(hostfile_pssh, 'w').close() # make nodefile pssh compatible with open(hostfile, 'r') as rf: for line in rf.readlines(): # skip commented lines if line.startswith('#'): continue with open(hostfile_pssh, 'a') as wf: wf.write(line.strip().split(' ')[0] + '\n') except IOError as e: print 'ERR while creating pssh compatible hostfile' print e.strerror return False return True Loading
ifs/scripts/shutdown_adafs.py +6 −1 Original line number Diff line number Diff line Loading @@ -15,6 +15,8 @@ global PRETEND global PSSH_PATH global WAITTIME CONST_PSSH_HOSTFILE_PATH = '/tmp/hostfile_pssh' def check_dependencies(): global PSSH_PATH Loading Loading @@ -49,8 +51,11 @@ def shutdown_system(daemon_path, nodelist, sigkill): print '[ERR] Daemon executable not found or not a file' exit(1) nodefile = False if os.path.exists(nodelist): # XXX Currently, we assume that the nodefile syntax is sane. if os.path.exists(nodelist): nodefile = True if not util.create_pssh_hostfile(nodelist, CONST_PSSH_HOSTFILE_PATH): exit(1) nodelist = CONST_PSSH_HOSTFILE_PATH if PSSH_PATH is '': check_dependencies() # set pssh arguments Loading
ifs/scripts/startup_adafs.py +6 −1 Original line number Diff line number Diff line Loading @@ -15,6 +15,8 @@ global PRETEND global PSSH_PATH global WAITTIME CONST_PSSH_HOSTFILE_PATH = '/tmp/hostfile_pssh' def check_dependencies(): global PSSH_PATH Loading Loading @@ -51,8 +53,11 @@ def init_system(daemon_path, rootdir, mountdir, nodelist, cleanroot): print '[ERR] Daemon executable not found or not a file' exit(1) nodefile = False if os.path.exists(nodelist): # XXX Currently, we assume that the nodefile syntax is sane. if os.path.exists(nodelist): nodefile = True if not util.create_pssh_hostfile(nodelist, CONST_PSSH_HOSTFILE_PATH): exit(1) nodelist = CONST_PSSH_HOSTFILE_PATH if PSSH_PATH is '': check_dependencies() # set pssh arguments Loading
ifs/scripts/util/util.py +28 −0 Original line number Diff line number Diff line Loading @@ -111,3 +111,31 @@ def check_shell_out(msg): if msg.err != '': raise OSError('Shell command failed with\n\t%s' % msg.err) return msg.output def create_pssh_hostfile(hostfile, hostfile_pssh): """Function creates a pssh compatible hostfile Args: hostfile(str): Path to source hostfile hostfile_pssh(str): Path to pssh compatible hostfile (contents will be created first) Returns: (bool): Returns true if successful """ # truncate pssh hostfile try: open(hostfile_pssh, 'w').close() # make nodefile pssh compatible with open(hostfile, 'r') as rf: for line in rf.readlines(): # skip commented lines if line.startswith('#'): continue with open(hostfile_pssh, 'a') as wf: wf.write(line.strip().split(' ')[0] + '\n') except IOError as e: print 'ERR while creating pssh compatible hostfile' print e.strerror return False return True