From 013df8d531e489938736d6f975bca913088400c7 Mon Sep 17 00:00:00 2001 From: Cristiano Urban Date: Wed, 3 Mar 2021 15:40:53 +0100 Subject: [PATCH] Added 'getSize()' method. Signed-off-by: Cristiano Urban --- transfer_service/tape_client.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/transfer_service/tape_client.py b/transfer_service/tape_client.py index c2826cb..048289b 100644 --- a/transfer_service/tape_client.py +++ b/transfer_service/tape_client.py @@ -73,6 +73,19 @@ class TapeClient(object): def disconnect(self): self.client.close() + def getSize(self, fsMountPoint): + cmd = "df " + fsMountPoint + " | tail -n +2" + #out = subprocess.run(cmd, shell = True, capture_output = True) + stdin, stdout, stderr = self.client.exec_command(cmd) + #res = stdout.stdout.decode('UTF-8').rstrip('\n') + res = stdout.readlines()[0] + res = ' '.join(res.split()).split(' ') + #print(res) + total = res[1] + used = res[2] + available = res[3] + return ( total, used, available) + # Test #tc = TapeClient("192.168.56.101", 22, "root", "ibm") @@ -80,6 +93,8 @@ class TapeClient(object): #tc.copy("/home/curban/store/mydir", "/home/mydir") #tc.copy("/home/curban/store/foo2.txt", "/home/mydir/foo2.txt") #tl = tc.getTaskList() +#fsSize = tc.getSize("/ia2_tape_stb_01") +#print(fsSize) #tc.disconnect() #for i in tl: # print(i.id) -- GitLab