Loading file_catalog/init.sql +46 −50 Original line number Diff line number Diff line Loading @@ -37,10 +37,10 @@ CREATE TABLE Node ( name VARCHAR NOT NULL, type NodeType NOT NULL, format VARCHAR default NULL, /* format serve per distinguere unstuctured (format=NULL) da structured che hanno un formato noto */ -- format serve per distinguere unstuctured (format=NULL) da structured che hanno un formato noto asyncTrans BOOLEAN NOT NULL, /* asyncTransf serve per indicare se il nodo e` ospitato da un cold storage e deve essere necessariamente trasferito con un trasferimento asincrono */ -- asyncTransf serve per indicare se il nodo e` ospitato da un cold storage e deve essere necessariamente -- trasferito con un trasferimento asincrono busyState BOOLEAN NOT NULL, ownerID VARCHAR NOT NULL, creatorID VARCHAR NOT NULL, Loading @@ -56,15 +56,11 @@ Dovrebbe stare sul servizio che fa il trasferimento (es. redis) */ contentMD5 TEXT default NULL, createdOn TIMESTAMP default CURRENT_TIMESTAMP, lastModified TIMESTAMP NOT NULL, /* link TEXT default NULL, */ -- link TEXT default NULL, acceptViews TEXT[] default NULL, provideViews TEXT[] default NULL, /* storageID VARCHAR, serve per mappare il nome del servizio di storage da interrogare per accedere al contenuto di questo nodo */ -- serve per mappare il nome del servizio di storage da interrogare per accedere al contenuto di questo nodo -- storageID VARCHAR, protocols TEXT[] default NULL, PRIMARY KEY (nodeID) ); Loading @@ -81,8 +77,7 @@ CREATE TABLE NodeProperty ( ); CREATE TABLE DeletedNode ( CREATE TABLE DeletedNode ( nodeID BIGSERIAL NOT NULL, name VARCHAR NOT NULL, ownerID VARCHAR NOT NULL, Loading @@ -90,8 +85,9 @@ CREATE TABLE DeletedNode PRIMARY KEY (nodeID) ); /* Initialize root node for vospace */ insert into Node (name, type, asyncTrans, busyState, ownerID, creatorID, groupRead, groupWrite, isPublic, lastModified) values ('YOUR_ROOT_NODE', 'container', '1', 'N', '9127391732918723981732198273275643832902', '9127391732918723981732198273275643832902', '{"YOUR_ADMIN_GROUP"}', '{"YOUR_ADMIN_GROUP"}', '1', CURRENT_TIMESTAMP); No newline at end of file INSERT INTO Node (name, type, asyncTrans, busyState, ownerID, creatorID, groupRead, groupWrite, isPublic, lastModified) VALUES ('YOUR_ROOT_NODE', 'container', '1', 'N', '9127391732918723981732198273275643832902', '9127391732918723981732198273275643832902', '{"YOUR_ADMIN_GROUP"}', '{"YOUR_ADMIN_GROUP"}', '1', CURRENT_TIMESTAMP); tests/test_ssh.py 0 → 100644 +14 −0 Original line number Diff line number Diff line import paramiko client = paramiko.SSHClient() client.load_system_host_keys() client.connect("localhost", 2022, "root", "ibm") stdin, stdout, stderr = client.exec_command("eeadm task list --json") exitCode = stdout.channel.recv_exit_status() print(exitCode) output = stdout.readlines() print(output[0].rstrip('\n')) client.close() transfer_service/checksum.py +8 −13 Original line number Diff line number Diff line Loading @@ -31,8 +31,3 @@ class Checksum(object): filePath = os.path.abspath(folder) + '/' + file md5file.write(self.md5sum(filePath) + " ./" + file + '\n') md5file.close() script, folderName = sys.argv md5calc = Checksum() md5calc.recursive(folderName) transfer_service/store_preprocessor.py 0 → 100644 +74 −0 Original line number Diff line number Diff line # TODO: # - permissions setup on folder # - inteface with the file catalog (insert) # - data cleanup # import os import shutil import sys from datetime import datetime as dt from checksum import Checksum class StorePreprocessor(object): def __init__(self): self.md5calc = Checksum() def scan(self): dirList = [] fileList = [] elementList = os.listdir(self.path) for el in elementList: elPath = self.path + '/' + el if os.path.isdir(elPath): dirList.append(el) elif os.path.isfile(elPath): fileList.append(el) else: sys.exit("FATAL: invalid file/dir.") return [ dirList, fileList ] def prepare(self, username): self.username = username self.path = "/home/" + username + "/store" def start(self): [ dirs, files ] = self.scan() timestamp = dt.now().strftime("%Y_%m_%d-%H_%M_%S") if files and dirs: destPath = self.path + '/' + timestamp try: os.mkdir(destPath) except OSError as error: sys.exit(f"FATAL: {error}") for file in files: srcPath = self.path + '/' + file shutil.move(srcPath, destPath) for dir in dirs: srcPath = self.path + '/' + dir shutil.move(srcPath, destPath) self.md5calc.recursive(destPath) elif files and not dirs: destPath = self.path + '/' + timestamp try: os.mkdir(destPath) except OSError as error: sys.exit(f"FATAL: {error}") for file in files: srcPath = self.path + '/' + file shutil.move(srcPath, destPath) self.md5calc.recursive(destPath) elif not files and dirs: for dir in dirs: destPath = self.path + '/' + dir self.md5calc.recursive(destPath) else: sys.exit("The 'store' directory is empty.") sp = StorePreprocessor() sp.prepare("cristiano") sp.start() Loading
file_catalog/init.sql +46 −50 Original line number Diff line number Diff line Loading @@ -37,10 +37,10 @@ CREATE TABLE Node ( name VARCHAR NOT NULL, type NodeType NOT NULL, format VARCHAR default NULL, /* format serve per distinguere unstuctured (format=NULL) da structured che hanno un formato noto */ -- format serve per distinguere unstuctured (format=NULL) da structured che hanno un formato noto asyncTrans BOOLEAN NOT NULL, /* asyncTransf serve per indicare se il nodo e` ospitato da un cold storage e deve essere necessariamente trasferito con un trasferimento asincrono */ -- asyncTransf serve per indicare se il nodo e` ospitato da un cold storage e deve essere necessariamente -- trasferito con un trasferimento asincrono busyState BOOLEAN NOT NULL, ownerID VARCHAR NOT NULL, creatorID VARCHAR NOT NULL, Loading @@ -56,15 +56,11 @@ Dovrebbe stare sul servizio che fa il trasferimento (es. redis) */ contentMD5 TEXT default NULL, createdOn TIMESTAMP default CURRENT_TIMESTAMP, lastModified TIMESTAMP NOT NULL, /* link TEXT default NULL, */ -- link TEXT default NULL, acceptViews TEXT[] default NULL, provideViews TEXT[] default NULL, /* storageID VARCHAR, serve per mappare il nome del servizio di storage da interrogare per accedere al contenuto di questo nodo */ -- serve per mappare il nome del servizio di storage da interrogare per accedere al contenuto di questo nodo -- storageID VARCHAR, protocols TEXT[] default NULL, PRIMARY KEY (nodeID) ); Loading @@ -81,8 +77,7 @@ CREATE TABLE NodeProperty ( ); CREATE TABLE DeletedNode ( CREATE TABLE DeletedNode ( nodeID BIGSERIAL NOT NULL, name VARCHAR NOT NULL, ownerID VARCHAR NOT NULL, Loading @@ -90,8 +85,9 @@ CREATE TABLE DeletedNode PRIMARY KEY (nodeID) ); /* Initialize root node for vospace */ insert into Node (name, type, asyncTrans, busyState, ownerID, creatorID, groupRead, groupWrite, isPublic, lastModified) values ('YOUR_ROOT_NODE', 'container', '1', 'N', '9127391732918723981732198273275643832902', '9127391732918723981732198273275643832902', '{"YOUR_ADMIN_GROUP"}', '{"YOUR_ADMIN_GROUP"}', '1', CURRENT_TIMESTAMP); No newline at end of file INSERT INTO Node (name, type, asyncTrans, busyState, ownerID, creatorID, groupRead, groupWrite, isPublic, lastModified) VALUES ('YOUR_ROOT_NODE', 'container', '1', 'N', '9127391732918723981732198273275643832902', '9127391732918723981732198273275643832902', '{"YOUR_ADMIN_GROUP"}', '{"YOUR_ADMIN_GROUP"}', '1', CURRENT_TIMESTAMP);
tests/test_ssh.py 0 → 100644 +14 −0 Original line number Diff line number Diff line import paramiko client = paramiko.SSHClient() client.load_system_host_keys() client.connect("localhost", 2022, "root", "ibm") stdin, stdout, stderr = client.exec_command("eeadm task list --json") exitCode = stdout.channel.recv_exit_status() print(exitCode) output = stdout.readlines() print(output[0].rstrip('\n')) client.close()
transfer_service/checksum.py +8 −13 Original line number Diff line number Diff line Loading @@ -31,8 +31,3 @@ class Checksum(object): filePath = os.path.abspath(folder) + '/' + file md5file.write(self.md5sum(filePath) + " ./" + file + '\n') md5file.close() script, folderName = sys.argv md5calc = Checksum() md5calc.recursive(folderName)
transfer_service/store_preprocessor.py 0 → 100644 +74 −0 Original line number Diff line number Diff line # TODO: # - permissions setup on folder # - inteface with the file catalog (insert) # - data cleanup # import os import shutil import sys from datetime import datetime as dt from checksum import Checksum class StorePreprocessor(object): def __init__(self): self.md5calc = Checksum() def scan(self): dirList = [] fileList = [] elementList = os.listdir(self.path) for el in elementList: elPath = self.path + '/' + el if os.path.isdir(elPath): dirList.append(el) elif os.path.isfile(elPath): fileList.append(el) else: sys.exit("FATAL: invalid file/dir.") return [ dirList, fileList ] def prepare(self, username): self.username = username self.path = "/home/" + username + "/store" def start(self): [ dirs, files ] = self.scan() timestamp = dt.now().strftime("%Y_%m_%d-%H_%M_%S") if files and dirs: destPath = self.path + '/' + timestamp try: os.mkdir(destPath) except OSError as error: sys.exit(f"FATAL: {error}") for file in files: srcPath = self.path + '/' + file shutil.move(srcPath, destPath) for dir in dirs: srcPath = self.path + '/' + dir shutil.move(srcPath, destPath) self.md5calc.recursive(destPath) elif files and not dirs: destPath = self.path + '/' + timestamp try: os.mkdir(destPath) except OSError as error: sys.exit(f"FATAL: {error}") for file in files: srcPath = self.path + '/' + file shutil.move(srcPath, destPath) self.md5calc.recursive(destPath) elif not files and dirs: for dir in dirs: destPath = self.path + '/' + dir self.md5calc.recursive(destPath) else: sys.exit("The 'store' directory is empty.") sp = StorePreprocessor() sp.prepare("cristiano") sp.start()