Browse Source

added full implementation and demo module

Toby Chui 6 năm trước cách đây
mục cha
commit
94fefdb3ab
36 tập tin đã thay đổi với 377 bổ sung743 xóa
  1. 1 0
      EXPERIMENTAL/SystemAOB/ArOZDFS/README.txt
  2. 1 0
      EXPERIMENTAL/SystemAOB/ArOZDFS/arozdfs_service.config
  3. 1 0
      EXPERIMENTAL/SystemAOB/ArOZDFS/clusterSetting.config
  4. 1 0
      EXPERIMENTAL/SystemAOB/ArOZDFS/description.txt
  5. 9 0
      EXPERIMENTAL/SystemAOB/ArOZDFS/embedded.php
  6. BIN
      EXPERIMENTAL/SystemAOB/ArOZDFS/img/function_icon.png
  7. BIN
      EXPERIMENTAL/SystemAOB/ArOZDFS/img/small_icon.png
  8. 257 0
      EXPERIMENTAL/SystemAOB/ArOZDFS/index.php
  9. 2 0
      EXPERIMENTAL/SystemAOB/ArOZDFS/remoteDisks.config
  10. 1 0
      EXPERIMENTAL/SystemAOB/README.txt
  11. 9 0
      EXPERIMENTAL/SystemAOB/functions/arozdfs/.htaccess
  12. BIN
      EXPERIMENTAL/SystemAOB/functions/arozdfs/arozdfs.exe
  13. 0 0
      EXPERIMENTAL/SystemAOB/functions/arozdfs/autoConfig.php
  14. 0 0
      EXPERIMENTAL/SystemAOB/functions/arozdfs/checkToken.php
  15. 0 0
      EXPERIMENTAL/SystemAOB/functions/arozdfs/clusterSetting.config
  16. 0 0
      EXPERIMENTAL/SystemAOB/functions/arozdfs/config/arozdfs.config
  17. 0 0
      EXPERIMENTAL/SystemAOB/functions/arozdfs/delChunk.php
  18. 26 0
      EXPERIMENTAL/SystemAOB/functions/arozdfs/mergeFileChunks.php
  19. 2 0
      EXPERIMENTAL/SystemAOB/functions/arozdfs/remoteDisks.config
  20. 0 0
      EXPERIMENTAL/SystemAOB/functions/arozdfs/request.php
  21. 19 0
      EXPERIMENTAL/SystemAOB/functions/arozdfs/requestFromCluster.php
  22. 0 0
      EXPERIMENTAL/SystemAOB/functions/arozdfs/settingModifyHandler.php
  23. 20 0
      EXPERIMENTAL/SystemAOB/functions/arozdfs/slice.php
  24. 0 0
      EXPERIMENTAL/SystemAOB/functions/arozdfs/storageDirectory.config
  25. 0 0
      EXPERIMENTAL/SystemAOB/functions/arozdfs/templates/boolean.html
  26. 0 0
      EXPERIMENTAL/SystemAOB/functions/arozdfs/templates/html.html
  27. 0 0
      EXPERIMENTAL/SystemAOB/functions/arozdfs/templates/integer.html
  28. 0 0
      EXPERIMENTAL/SystemAOB/functions/arozdfs/templates/text.html
  29. 0 0
      EXPERIMENTAL/SystemAOB/functions/arozdfs/upload.php
  30. 18 0
      EXPERIMENTAL/SystemAOB/functions/arozdfs/uploadToCluster.php
  31. BIN
      arozdfs.exe
  32. 10 11
      main.go
  33. BIN
      put this in SystemAOB functions/arozdfs/chunks/mv/68284d2c-cd3b-4f63-9431-a96f0767d8ce_0
  34. BIN
      put this in SystemAOB functions/arozdfs/chunks/mv/68284d2c-cd3b-4f63-9431-a96f0767d8ce_1
  35. 0 730
      put this in SystemAOB functions/arozdfs/main.go
  36. 0 2
      put this in SystemAOB functions/arozdfs/remoteDisks.config

+ 1 - 0
EXPERIMENTAL/SystemAOB/ArOZDFS/README.txt

@@ -0,0 +1 @@
+This is a demo module for arozdfs for experimental purposes.

+ 1 - 0
EXPERIMENTAL/SystemAOB/ArOZDFS/arozdfs_service.config

@@ -0,0 +1 @@
+../SystemAOB/functions/arozdfs/

+ 1 - 0
EXPERIMENTAL/SystemAOB/ArOZDFS/clusterSetting.config

@@ -0,0 +1 @@
+{"prefix":"private/AOB","port":"8080"}

+ 1 - 0
EXPERIMENTAL/SystemAOB/ArOZDFS/description.txt

@@ -0,0 +1 @@
+This is a demo module designed to show the function of arozdfs subsystem

+ 9 - 0
EXPERIMENTAL/SystemAOB/ArOZDFS/embedded.php

@@ -0,0 +1,9 @@
+<?php
+ if(isset($_GET['filepath'])){
+     echo $_GET['filepath'] . '<br>';
+     echo "file_exists: " . file_exists($_GET['filepath']) . '<br>';
+ }
+ if (isset($_GET['filename'])){
+     echo $_GET['filename'] . '<br>';
+ }
+?>

BIN
EXPERIMENTAL/SystemAOB/ArOZDFS/img/function_icon.png


BIN
EXPERIMENTAL/SystemAOB/ArOZDFS/img/small_icon.png


+ 257 - 0
EXPERIMENTAL/SystemAOB/ArOZDFS/index.php

@@ -0,0 +1,257 @@
+<?php
+include_once '../auth.php';
+?>
+<html>
+<head>
+    <link rel="stylesheet" href="../script/tocas/tocas.css">
+	<script src="../script/tocas/tocas.js"></script>
+	<script src="../script/jquery.min.js"></script>
+	<script src="../script/ao_module.js"></script>
+</head>
+<body>
+	<div class="ts container">
+	<br>
+	<div class="ts segment">
+		<div class="ts header">
+			<i class="file icon"></i>
+			<div class="content">
+				arozdfs Demo Module
+				<div class="sub header">Reference code for how to use the arozdfs sybsystem</div>
+			</div>
+		</div>
+	</div>
+	<?php 
+	//Check if arozdfs services exists.
+	if (!file_exists("../SystemAOB/functions/arozdfs/")){
+		die("ERROR. Arozdfs service not found or permission denied.");
+	}
+	$dfsroot = "../SystemAOB/functions/arozdfs/";
+	$settings = json_decode(file_get_contents($dfsroot . "clusterSetting.config"),true);
+	$uploadTargets = explode("\n",trim(file_get_contents($dfsroot . "remoteDisks.config")));
+	$storeDir = file_get_contents($dfsroot . "storageDirectory.config");
+	$parentDir = dirname(__FILE__);
+	?>
+	<div class="ts primary segment">
+	<p>There are five main functions in using arozdfs. Select the following functions one by one and try out the process.</p>
+		<div class="ts breadcrumb">
+			<a class="section">Upload</a>
+			<i class="right chevron icon divider"></i>
+			<a class="section">Slice</a>
+			<i class="right chevron icon divider"></i>
+			<a class="section">Download</a>
+			<i class="right chevron icon divider"></i>
+			<a class="section">Open</a>
+			<i class="right chevron icon divider"></i>
+			<a class="section">Remove</a>
+		</div>
+	</div>
+	<div class="ts segment">
+		<p>1. Upload the file that you want to send into the arozdfs. Click <a href="">here</a> after the upload is finished.</p>
+		<?php $moduleName =  basename($parentDir); ?>
+		<iframe width="100%" height="260px" src="../Upload%20Manager/upload_interface_min.php?target=SystemAOB\functions\arozdfs&filetype="> </iframe>
+	</div>
+	<div class="ts segment">
+		<p>2. Select the file you want slice and click on it. The page will refresh automatically when slicing processes ended.</p>
+		<div class="ts ordered list">
+			<?php
+				$uploadedFiles = glob($dfsroot . "uploads/*");
+				foreach ($uploadedFiles as $file){
+					if (is_file($file)){
+						echo '<a class="item hexfoldername" rawname="' . basename($file) . '" onClick="sliceThis(this);">' . basename($file) .'</a>';
+					}
+				}
+				?>
+		</div>
+        <div class="ts horizontal form">
+            <div class="field">
+                <label>Chunk Size (MB)</label>
+                <input id="chunksize" type="number" value="32">
+            </div>
+        </div>
+	</div>
+	<div class="ts segment">
+		<p>3. Upload the chunks to the listed clusters. If nothing is displayed below, please redo step 2 until the file chunks are shown below.<br>Upload pending chunk: </p>
+		<div class="ts ordered list">
+			<?php
+			    $valid = false;
+				if (isset($_GET['uuid'])){
+				    $valid = true;
+					$chunks = glob($dfsroot . "chunks/" . $_GET['uuid'] . "/" . $_GET['uuid'] . "*");
+					foreach ($chunks as $chunk){
+						if (is_file($chunk)){
+							echo '<a class="item">' . basename($chunk) . '</a>';
+						}
+					}
+			
+				}
+				
+			?>
+		</div>
+		<div class="ts horizontal form">
+            <div class="field">
+                <label>Storage Filename</label>
+                <input type="text" value="<?php 
+                    if (isset($_GET['filename'])){
+                        echo strip_tags($_GET['filename']);
+                    }
+                ?>">
+            </div>
+        </div>
+        <?php
+            //Echo the upload button if uuid and filename is given
+            if ($valid){
+                echo '<button class="ts primary button" filename="' . strip_tags($_GET['filename']) . '" uuid="' . $_GET['uuid'] . '" onClick="startUpload(this);">Upload</button>';
+            }
+        ?>
+	</div>
+	<div class="ts segment">
+        <p>4. Download and Merge: These are the files uploaded to the arozdfs clusters. Click any of the filename below to download.</p>
+        <div class="ts ordered list">
+            <?php
+                $fileIndexs = glob($dfsroot . "index/*.index");
+                foreach ($fileIndexs as $index){
+                    echo '<a class="item hexfoldername" rawname="' . basename($index,".index") . '" onclick="downloadFile(this);" >' . basename($index,".index") . '</a>';
+                }
+            ?>
+        </div>
+	</div>
+    <div class="ts segment">
+        <p>5. Preview exported files. Click any file in the list below to view its content.</p>
+        <div class="ts ordered list">
+            <?php
+                $mergedFiles = glob($dfsroot . "tmp/outfiles/*");
+                foreach ($mergedFiles as $file){
+                    if (is_file($file)){
+                         echo '<a class="item hexfoldername" filename="' . $file. '" onclick="openFile(this);" >' . basename($file) . '</a>';
+                    }
+                   
+                }
+            ?>
+        </div>
+    </div>
+	<div class="ts primary segment">
+		<p>Here is the file index tree that is currently stored inside the distrubuted file system.</p>
+		<div class="ts ordered list">
+		<?php
+		
+		function getDirContents($path) {
+			$rii = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path));
+
+			$files = array(); 
+			foreach ($rii as $file)
+				if (!$file->isDir())
+					$files[] = $file->getPathname();
+
+			return $files;
+		}
+		
+		
+		foreach (getDirContents($dfsroot . trim("index/")) as $index){
+			echo '<div class="item">' . str_replace("\\","/",str_replace($dfsroot,"arozdfs//",$index)) . '</div>'; //Fix the problem on Window host which display a mix of / and \
+		}
+		?>
+		</div>
+		<p>Here is a list of chunks stored on this host.</p>
+		<div class="ts ordered list">
+			<?php
+			$realStorePath = $storeDir;
+			if (file_exists($dfsroot . trim($storeDir))){
+				$realStorePath = $dfsroot . trim($storeDir);
+			}
+			foreach (getDirContents($realStorePath) as $index){
+				echo '<div class="item">' . str_replace("\\","/",str_replace($dfsroot,"arozdfs//",$index)) . '</div>'; 
+			}
+			?>
+		</div>
+	</div>
+	<div class="ts primary segment">
+		<p>The followings are "arozdfs root", "cluster setting", "upload target UUID" and "local storage directory" information.<br>
+			These can be modified using NotepadA before the upload process start.</p>
+			<?php
+			var_dump([$dfsroot,$settings,$uploadTargets,$storeDir]);
+			?>
+	</div>
+
+	<div id="msgbox" class="ts active bottom right snackbar" style="display:none;">
+		<div id="message" class="content">
+			This is a message box.
+		</div>
+	</div>
+
+	</div>
+<script>
+var arozdfsModule = "../ArOZDFS/"; //Current module path from ArOZ Online Root
+
+$(document).ready(function(){
+	//Translate all the hex foldername to human readable filename if found
+	$(".hexfoldername").each(function(){
+		var decodedName = ao_module_codec.decodeUmFilename($(this).text()); //Decode the umfile naming method.
+		$(this).text(decodedName); //Upload the hex filename to its original filename
+	});
+});
+
+function baseName(str){
+   var tmp = str.split("/");
+   return tmp.pop();
+}
+
+function openFile(object){
+    var filename = $(object).attr("filename");
+    var displayname = ao_module_codec.decodeUmFilename(baseName(filename));
+    if (ao_module_virtualDesktop){
+        ao_module_openFile(filename.replace("../",""),displayname);
+    }else{
+        window.open("../SystemAOB/functions/file_system/index.php?controlLv=2&mode=file&dir=" + filename.replace("../","") + "&filename=" + displayname);
+    }
+}
+
+function downloadFile(object){
+    var vdir = $(object).attr("rawname");
+    msgbox("Download started. This might take a while.");
+	$.get("../SystemAOB/functions/arozdfs/requestFromCluster.php?vdir=" + vdir.trim(),function(data){
+        console.log(data);
+        mergeFileChunks(data.trim(),vdir);
+	});
+}
+
+function mergeFileChunks(chunkid, outfilename){
+    msgbox("Merging process started.");
+	$.get("../SystemAOB/functions/arozdfs/mergeFileChunks.php?chunkid=" + chunkid + "&outfile=" + outfilename ,function(data){
+        console.log(data);
+        if (data.includes("DONE")){
+            window.location.reload();
+        }
+	});
+}
+
+
+function startUpload(object){
+	var uuid = $(object).attr("uuid");
+	var vdir = $(object).attr("filename");
+	msgbox("Upload started. This might take a while.");
+	$.get("../SystemAOB/functions/arozdfs/uploadToCluster.php?uuid=" + uuid.trim() + "&filename=" + vdir.trim(),function(data){
+	    console.log(data);
+	    if (data.includes("[OK] All chunks uploaded")){
+	        window.location.reload();
+	    }
+	});
+}
+
+function sliceThis(object){
+	var filename = $(object).attr("rawname"); //Get the original name from the DOM attibute
+	$.get("../SystemAOB/functions/arozdfs/slice.php?filename=" + filename + "&chunksize=" + $("#chunksize").val(),function(data){
+		//After slicing, an UUID should return. The sliced file chunks are now lying inside arozdfs/chunks/{uuid}/{uuid}_* 
+		console.log(data);
+		window.location.href = "index.php?uuid=" + data + "&filename=" + filename;
+	});
+}
+
+
+function msgbox(msg){
+//Just a utility function to show that something is working
+	$("#message").text(msg);
+	$("#msgbox").fadeIn().delay(5000).fadeOut();
+}
+</script>
+</body>
+</html>

+ 2 - 0
EXPERIMENTAL/SystemAOB/ArOZDFS/remoteDisks.config

@@ -0,0 +1,2 @@
+59bd2f20-dfdd-4dc3-b221-1a070baa6156
+fc25f57e-00a7-44da-becd-fa6356b3445a

+ 1 - 0
EXPERIMENTAL/SystemAOB/README.txt

@@ -0,0 +1 @@
+This are the experimental version of the arozdfs implementation. This is only used for golang section debuging and testing. The arozdfs php side will be rewritten after the golang section has finished. DO NOT USE THIS IN PRODUCTION ENVIRONMENT.

+ 9 - 0
EXPERIMENTAL/SystemAOB/functions/arozdfs/.htaccess

@@ -0,0 +1,9 @@
+# Prevent viewing of .htaccess file
+<Files .htaccess>
+order allow,deny
+deny from all
+</Files>
+
+# Prevent directory listings
+Options All -Indexes
+

BIN
put this in SystemAOB functions/arozdfs/arozdfs.exe → EXPERIMENTAL/SystemAOB/functions/arozdfs/arozdfs.exe


+ 0 - 0
put this in SystemAOB functions/arozdfs/autoConfig.php → EXPERIMENTAL/SystemAOB/functions/arozdfs/autoConfig.php


+ 0 - 0
put this in SystemAOB functions/arozdfs/checkToken.php → EXPERIMENTAL/SystemAOB/functions/arozdfs/checkToken.php


+ 0 - 0
put this in SystemAOB functions/arozdfs/clusterSetting.config → EXPERIMENTAL/SystemAOB/functions/arozdfs/clusterSetting.config


+ 0 - 0
put this in SystemAOB functions/arozdfs/config/arozdfs.config → EXPERIMENTAL/SystemAOB/functions/arozdfs/config/arozdfs.config


+ 0 - 0
put this in SystemAOB functions/arozdfs/delChunk.php → EXPERIMENTAL/SystemAOB/functions/arozdfs/delChunk.php


+ 26 - 0
EXPERIMENTAL/SystemAOB/functions/arozdfs/mergeFileChunks.php

@@ -0,0 +1,26 @@
+<?php
+include_once("../../../auth.php");
+if (isset($_GET['chunkid']) && $_GET['chunkid'] != "" && isset($_GET['outfile']) && $_GET['outfile'] != ""){
+	if (!file_exists("tmp/outfiles/")){
+		mkdir("tmp/outfiles/",0777,true);
+	}
+	$outfolder = "tmp/outfiles/";
+	$outfile = $outfolder . strip_tags($_GET['outfile']);
+	$storepath = "tmp/" . $_GET['chunkid'] . "/";
+	//This is a bit tricky. We use timestamp as the folder to store each uuids. So, to get the file uuid, we need to get the first file (aka {uuid}_0 ) for the file uuid.
+	$fc = glob($storepath . "*_0");
+	$fc = basename($fc[0]);
+	$fuuid = explode("_",$fc)[0];
+	//Call arozdfs for command
+	//This command build the file from chunks and place the outfile in tmp/outfiles/ with the given filename from variable "outfile"
+	$output = shell_exec('arozdfs.exe open -storepath "' . $storepath . '" -uuid "' . $fuuid . '" -outfile "' . $outfolder . $_GET['outfile'] . '" -c'); //Remove -c if you do not want the file chunks to be removed after building the file.
+	
+	$files = glob($storepath . "*_*");
+	if (count($files) == 0){
+		rmdir($storepath);
+	}
+	echo "DONE";
+}else{
+	die("ERROR. Undefined chunkid or outfile.");
+}
+?>

+ 2 - 0
EXPERIMENTAL/SystemAOB/functions/arozdfs/remoteDisks.config

@@ -0,0 +1,2 @@
+59bd2f20-dfdd-4dc3-b221-1a070baa6156
+fc25f57e-00a7-44da-becd-fa6356b3445a

+ 0 - 0
put this in SystemAOB functions/arozdfs/request.php → EXPERIMENTAL/SystemAOB/functions/arozdfs/request.php


+ 19 - 0
EXPERIMENTAL/SystemAOB/functions/arozdfs/requestFromCluster.php

@@ -0,0 +1,19 @@
+<?php
+include_once("../../../auth.php");
+if (isset($_GET['vdir']) && $_GET['vdir'] != ""){
+	$vdir = $_GET['vdir'];
+	$storePath = time();
+	if (file_exists("index/" . $vdir . ".index")){
+	    if (!file_exists("tmp/" . $storePath)){
+    		mkdir("tmp/" . $storePath, 0777, true);
+    	}
+		$output = shell_exec('arozdfs.exe download -vdir "' . $vdir . '" -storepath "' . "tmp/" . $storePath . '"'); //Change this line to other binary if you are not running on Window Host
+		echo $storePath;
+	}else{
+		die("ERROR. Targeting file not exists.");
+	}
+	
+}else{
+	die("ERROR. Undefined vdir for downloading.");
+}
+?>

+ 0 - 0
put this in SystemAOB functions/arozdfs/settingModifyHandler.php → EXPERIMENTAL/SystemAOB/functions/arozdfs/settingModifyHandler.php


+ 20 - 0
EXPERIMENTAL/SystemAOB/functions/arozdfs/slice.php

@@ -0,0 +1,20 @@
+<?php
+include_once("../../../auth.php");
+if (isset($_GET['filename']) && $_GET['filename'] != ""){
+	$fileToBeSliced = $_GET['filename'];
+	if (isset($_GET['chunksize']) && $_GET['chunksize'] != ""){
+		$sliceSetting = " -slice " . $_GET['chunksize'];
+	}else{
+		$sliceSetting = "";
+	}
+	if (file_exists("uploads/" . $fileToBeSliced) && strpos(realpath("uploads/" . $fileToBeSliced),realpath("uploads/")) !== false){
+		$output = shell_exec("arozdfs.exe slice -infile uploads/" . $fileToBeSliced . $sliceSetting); //Change this line to other binary if you are not running on Window Host
+		echo $output;
+	}else{
+		die("ERROR. Targeting file not exists.");
+	}
+	
+}else{
+	die("ERROR. Undefined filename for slicing.");
+}
+?>

+ 0 - 0
put this in SystemAOB functions/arozdfs/storageDirectory.config → EXPERIMENTAL/SystemAOB/functions/arozdfs/storageDirectory.config


+ 0 - 0
put this in SystemAOB functions/arozdfs/templates/boolean.html → EXPERIMENTAL/SystemAOB/functions/arozdfs/templates/boolean.html


+ 0 - 0
put this in SystemAOB functions/arozdfs/templates/html.html → EXPERIMENTAL/SystemAOB/functions/arozdfs/templates/html.html


+ 0 - 0
put this in SystemAOB functions/arozdfs/templates/integer.html → EXPERIMENTAL/SystemAOB/functions/arozdfs/templates/integer.html


+ 0 - 0
put this in SystemAOB functions/arozdfs/templates/text.html → EXPERIMENTAL/SystemAOB/functions/arozdfs/templates/text.html


+ 0 - 0
put this in SystemAOB functions/arozdfs/upload.php → EXPERIMENTAL/SystemAOB/functions/arozdfs/upload.php


+ 18 - 0
EXPERIMENTAL/SystemAOB/functions/arozdfs/uploadToCluster.php

@@ -0,0 +1,18 @@
+<?php
+include_once("../../../auth.php");
+if (isset($_GET['uuid']) && $_GET['uuid'] != "" && isset($_GET['filename']) && $_GET['filename'] != ""){
+	$fileUUID = $_GET['uuid'];
+	$filename = strip_tags($_GET['filename']);
+	$chunks = glob("chunks/" . $fileUUID . "/" . $fileUUID . "_*");
+	if (count($chunks) > 0){
+		//The number of chunks is more than 0. Save to proceed
+		$output = shell_exec('arozdfs.exe upload -storepath "' . $fileUUID . '" -uuid "' . $fileUUID . '" -vdir ' . $filename); //Change this line to other binary if you are not running on Window Host
+		echo $output;
+	}else{
+		die("ERROR. Targeting file not exists.");
+	}
+	
+}else{
+	die("ERROR. Undefined filename or uuid.");
+}
+?>

BIN
arozdfs.exe


+ 10 - 11
main.go

@@ -298,6 +298,7 @@ func DownloadFile(filepath string, url string) bool {
 		return false
 	}
 	defer out.Close()
+
 	// Write the body to file
 	_, err = io.Copy(out, resp.Body)
 	return true
@@ -334,7 +335,7 @@ func startSlicingProc() {
 	if storepath != "" && infile != "" {
 		//fmt.Println(storepath + " " + infile + " " + strconv.Itoa(slice) + " " + fileUUID)
 		splitFileChunks(infile, "chunks/"+storepath, fileUUID, slice)
-		//fmt.Println(fileUUID)
+		fmt.Println(fileUUID)
 	} else {
 		fmt.Println("ERROR. Undefined storepath or infile.")
 	}
@@ -362,7 +363,7 @@ func splitFileChunks(rawfile string, outputdir string, outfilename string, chunk
 	// calculate total number of parts the file will be chunked into
 
 	totalPartsNum := uint64(math.Ceil(float64(fileSize) / float64(fileChunk)))
-	fmt.Printf("[Info] Splitting to %d pieces.\n", totalPartsNum)
+	//fmt.Printf("[Info] Splitting to %d pieces.\n", totalPartsNum)
 	for i := uint64(0); i < totalPartsNum; i++ {
 		partSize := int(math.Min(fileChunk, float64(fileSize-int64(i*uint64(fileChunk)))))
 		partBuffer := make([]byte, partSize)
@@ -375,7 +376,7 @@ func splitFileChunks(rawfile string, outputdir string, outfilename string, chunk
 		}
 		// write/save buffer to disk
 		ioutil.WriteFile(fileName, partBuffer, os.ModeAppend)
-		fmt.Println("[Export] ", fileName)
+		//fmt.Println("[Export] ", fileName)
 	}
 	return true
 }
@@ -490,7 +491,7 @@ func startUploadProc() {
 		clusteruuids := file_get_contents(push)
 		if trim(clusteruuids) == "" {
 			fmt.Println("ERROR. remoteDisks not found or it is empty! ")
-			os.Exit(0)
+			return
 		}
 		clusteruuids = trim(strings.Trim(clusteruuids, "\n"))
 		uuiddata = explode("\n", clusteruuids)
@@ -505,13 +506,13 @@ func startUploadProc() {
 		}
 	} else {
 		fmt.Println("ERROR. remoteDisks not found or it is empty! ")
-		os.Exit(0)
+		return
 	}
 
 	//Handshake with clusters, create auth token if needed
 	if !createToken(ipList) {
 		fmt.Println("ERROR. Problem occured while trying to create token for one of the cluster's host. Upload process terminated.")
-		os.Exit(0)
+		return
 	}
 
 	//Ready to push. Create index file.
@@ -536,15 +537,14 @@ func startUploadProc() {
 	}
 
 	//Write the upload results to index file
+	f, _ := os.OpenFile("index/"+vdir+string(".index"), os.O_APPEND|os.O_WRONLY, 0600)
 	for j := 0; j < len(uploadFinishIndicators); j++ {
-		f, _ := os.OpenFile("index/"+vdir+string(".index"), os.O_APPEND|os.O_WRONLY, 0600)
-		defer f.Close()
 		f.WriteString(str_replace(".done", "", basename(uploadFinishIndicators[j])))
 		f.WriteString(",")
 		f.WriteString(file_get_contents(uploadFinishIndicators[j]))
 		f.WriteString("\n")
 	}
-
+	f.Close()
 	//Clear up all indicators
 	for k := 0; k < len(uploadFinishIndicators); k++ {
 		os.Remove(uploadFinishIndicators[k])
@@ -578,7 +578,6 @@ func resolveUUID(uuid string) string {
 
 func SendPostRequest(url string, filename string, fieldname string, resultName string, targetUUID string) []byte {
 	file, err := os.Open(filename)
-
 	if err != nil {
 		panic(err)
 	}
@@ -616,7 +615,7 @@ func SendPostRequest(url string, filename string, fieldname string, resultName s
 		panic(err)
 	}
 
-	//Upload suceed. Create a .done file to indicate this file is done uploading
+	//Upload succeed. Create a .done file to indicate this file is done uploading
 	file_put_contents(resultName, string(targetUUID))
 	fmt.Println("[OK] " + str_replace(".done", "", basename(resultName)) + " uploaded.")
 	return content

BIN
put this in SystemAOB functions/arozdfs/chunks/mv/68284d2c-cd3b-4f63-9431-a96f0767d8ce_0


BIN
put this in SystemAOB functions/arozdfs/chunks/mv/68284d2c-cd3b-4f63-9431-a96f0767d8ce_1


+ 0 - 730
put this in SystemAOB functions/arozdfs/main.go

@@ -1,730 +0,0 @@
-package main
-
-import (
-	"bytes"
-	"encoding/json"
-	"fmt"
-	"io"
-	"io/ioutil"
-	"math"
-	"mime/multipart"
-	"net/http"
-	"os"
-	"path"
-	"path/filepath"
-	"strconv"
-	"strings"
-	"time"
-
-	"github.com/FossoresLP/go-uuid-v4"
-)
-
-func check(e error) {
-	if e != nil {
-		panic(e)
-	}
-}
-
-//ArOZ PHP-Golang Bridge
-//The following sections remap the PHP functions to golang for the ease of development
-func file_exists(filepath string) bool {
-	if _, err := os.Stat(filepath); !os.IsNotExist(err) {
-		return true
-	}
-	return false
-}
-
-func mkdir(filepath string) {
-	os.MkdirAll(filepath, os.ModePerm)
-}
-
-func file_put_contents(file string, data string) bool {
-	f, err := os.Create(file)
-	check(err)
-	_, err = f.WriteString(data)
-	defer f.Close()
-	if err != nil {
-		return false
-	}
-	return true
-}
-
-func file_get_contents(file string) string {
-	b, err := ioutil.ReadFile(file)
-	check(err)
-	return string(b)
-}
-
-func strtolower(word string) string {
-	return strings.ToLower(word)
-}
-
-func strtoupper(word string) string {
-	return strings.ToUpper(word)
-}
-
-func trim(word string) string {
-	return strings.Trim(word, " ")
-}
-
-func strlen(word string) int {
-	return len(word)
-}
-
-func count(array []string) int {
-	return len(array)
-}
-
-func explode(key string, word string) []string {
-	return strings.Split(word, key)
-}
-
-func implode(key string, array []string) string {
-	return strings.Join(array[:], key)
-}
-
-func str_replace(target string, result string, word string) string {
-	return strings.Replace(word, target, result, -1)
-}
-
-func in_array(a string, list []string) bool {
-	for _, b := range list {
-		if b == a {
-			return true
-		}
-	}
-	return false
-}
-
-func strpos(word string, target string) int {
-	return strings.Index(word, target)
-}
-
-func dirname(filepath string) string {
-	return path.Dir(filepath)
-}
-
-func basename(fullpath string) string {
-	return filepath.Base(fullpath)
-}
-
-//End of mapping functions
-//Utilities functions
-func genUUIDv4() string {
-	uuid, err := uuid.NewString()
-	check(err)
-	return uuid
-}
-
-func padZeros(thisInt string, maxval int) string {
-	targetLength := len(strconv.Itoa(maxval))
-	result := thisInt
-	if len(thisInt) < targetLength {
-		padzeros := targetLength - len(thisInt)
-		for i := 0; i < padzeros; i++ {
-			result = "0" + result
-		}
-	}
-	return result
-
-}
-
-type clusterConfig struct {
-	Prefix string `json:"prefix"`
-	Port   string `json:"port"`
-}
-
-//End of utilities functions
-//System constants
-const clusterServices = "../cluster/"
-const delChunkScript = "SystemAOB/functions/arozdfs/delChunk.php?chunkuuid="
-const requestScript = "SystemAOB/functions/arozdfs/request.php?chunkuuid="
-const uploadScript = "SystemAOB/functions/arozdfs/upload.php"
-const clusterSetting = "clusterSetting.config"
-
-var config clusterConfig
-
-func init() {
-	//Check if the required directory exists. If not, create it.
-	if !file_exists("chunks/") {
-		mkdir("chunks/")
-	}
-	if !file_exists("uploads/") {
-		mkdir("uploads/")
-	}
-	if !file_exists("index/") {
-		mkdir("index/")
-	}
-	if !file_exists("tmp/") {
-		mkdir("tmp/")
-	}
-	if !file_exists("remoteDisks.config") {
-		file_put_contents("remoteDisks.config", "")
-	}
-
-	//Load config from clusterSetting.config
-	jsonFile, _ := os.Open(clusterSetting)
-	byteValue, _ := ioutil.ReadAll(jsonFile)
-	json.Unmarshal(byteValue, &config)
-}
-
-func main() {
-	//arozdfs implementation in Golang
-	//Refer to the help section for the usable commands and parameters
-
-	if len(os.Args) == 1 {
-		fmt.Println("ERROR. Undefined function group or operations. Type 'arozdfs help' for usage instructions. ")
-		return
-	}
-
-	//For each argument, start the processing
-	switch functgroup := os.Args[1]; functgroup {
-	case "help":
-		showHelp()
-	case "slice":
-		startSlicingProc()
-	case "upload":
-		startUploadProc()
-	case "download":
-		startDownloadProc()
-	case "open":
-		openChunkedFile()
-	case "remove":
-		removeFile()
-	case "debug":
-		fmt.Println(config.Port + "/" + config.Prefix) //Debug function. Change this line for unit testing
-	default:
-		showNotFound()
-	}
-
-	/*
-		//Examples for using the Go-PHP bridge functions
-		file_put_contents("Hello World.txt", "This is the content of the file.")
-		fmt.Println(file_get_contents("Hello World.txt"))
-
-		array := explode(",", "Apple,Orange,Pizza")
-		fmt.Println(array)
-		newstring := implode(",", array)
-		fmt.Println(newstring)
-		fmt.Println(in_array("Pizza", array))
-		fmt.Println(strpos(newstring, "Pizza"))
-		fmt.Println(strtoupper("hello world"))
-		fmt.Println(str_replace("Pizza", "Ramen", newstring))
-	*/
-}
-
-func startDownloadProc() {
-	vdir := ""
-	storepath := "tmp/"
-	for i, arg := range os.Args {
-		if strpos(arg, "-") == 0 {
-			//This is a parameter defining keyword
-			if arg == "-vdir" {
-				vdir = os.Args[i+1]
-			} else if arg == "-storepath" {
-				storepath = os.Args[i+1]
-				//Check if the storepath is end with /. if not, append it into the pathname
-				if storepath[len(storepath)-1:] != "/" {
-					storepath = storepath + "/"
-				}
-			}
-		}
-	}
-	if vdir != "" {
-		//Go ahead the download process and get the content of the file
-		fc := strings.Trim(str_replace("\r\n", "\n", file_get_contents("index/"+vdir+".index")), "\n")
-		datachunks := explode("\n", fc)
-		var filelist []string
-		var locations []string
-
-		for i := 0; i < len(datachunks); i++ {
-			tmp := explode(",", datachunks[i])
-			filechunk := tmp[0]
-			locationUUID := tmp[1]
-			filelist = append(filelist, filechunk)
-			thisip := resolveUUID(locationUUID)
-			clusterConfig := ":" + string(config.Port) + "/" + string(config.Prefix) + "/"
-			fullip := "http://" + thisip + clusterConfig
-			locations = append(locations, fullip)
-		}
-		//fmt.Println(filelist)
-		//fmt.Println(locations)
-
-		//Start the request process
-		for j := 0; j < len(filelist); j++ {
-			//Multithreading download for each fileitem
-			filename := filelist[j]
-			targetURL := locations[j] + requestScript + string(filename)
-			go downloadFileChunkWithOutput(storepath+filename, targetURL, filename)
-		}
-
-		fileUUID := explode("_", filelist[0])[0] //Getting the first part of a file with uuid, e.g. {uuid}_0 --> get only the {uuid} part
-		//Wait for the go routine to finish
-		downloadFinishIndicators, _ := filepath.Glob(storepath + fileUUID + "_*.done")
-		for len(downloadFinishIndicators) < len(filelist) {
-			time.Sleep(time.Duration(500) * time.Millisecond)
-			downloadFinishIndicators, _ = filepath.Glob(storepath + fileUUID + "_*.done")
-		}
-		//Clear up all indicators
-		for k := 0; k < len(downloadFinishIndicators); k++ {
-			os.Remove(downloadFinishIndicators[k])
-		}
-		fmt.Println("[OK] All chunks downloaded")
-	} else {
-		fmt.Println("ERROR. vdir cannot be empty")
-		os.Exit(0)
-	}
-}
-
-func downloadFileChunkWithOutput(filepath string, url string, filename string) {
-	if DownloadFile(filepath, url) {
-		fmt.Println("[OK] " + filename)
-		file_put_contents(filepath+".done", "")
-	}
-}
-
-func DownloadFile(filepath string, url string) bool {
-
-	// Get the data
-	resp, err := http.Get(url)
-	if err != nil {
-		return false
-	}
-	defer resp.Body.Close()
-
-	// Create the file
-	out, err := os.Create(filepath)
-	if err != nil {
-		return false
-	}
-	defer out.Close()
-	// Write the body to file
-	_, err = io.Copy(out, resp.Body)
-	return true
-
-}
-
-func startSlicingProc() {
-	infile := ""
-	slice := 64 //Default 64MB per file chunk
-	fileUUID := genUUIDv4()
-	storepath := fileUUID + "/"
-	for i, arg := range os.Args {
-		if strpos(arg, "-") == 0 {
-			//This is a parameter defining keyword
-			if arg == "-infile" {
-				infile = os.Args[i+1]
-			} else if arg == "-storepath" {
-				storepath = os.Args[i+1]
-				//Check if the storepath is end with /. if not, append it into the pathname
-				if storepath[len(storepath)-1:] != "/" {
-					storepath = storepath + "/"
-				}
-			} else if arg == "-slice" {
-				sliceSize, err := strconv.Atoi(os.Args[i+1])
-				check(err)
-				slice = sliceSize
-			}
-		}
-	}
-	if slice <= 0 {
-		fmt.Println("ERROR. slice size cannot be smaller or equal to 0")
-		os.Exit(0)
-	}
-	if storepath != "" && infile != "" {
-		//fmt.Println(storepath + " " + infile + " " + strconv.Itoa(slice) + " " + fileUUID)
-		splitFileChunks(infile, "chunks/"+storepath, fileUUID, slice)
-		//fmt.Println(fileUUID)
-	} else {
-		fmt.Println("ERROR. Undefined storepath or infile.")
-	}
-
-}
-
-func splitFileChunks(rawfile string, outputdir string, outfilename string, chunksize int) bool {
-	if !file_exists(outputdir) {
-		mkdir(outputdir)
-	}
-	fileToBeChunked := rawfile
-	file, err := os.Open(fileToBeChunked)
-
-	if err != nil {
-		return false
-	}
-
-	defer file.Close()
-
-	fileInfo, _ := file.Stat()
-
-	var fileSize int64 = fileInfo.Size()
-	var fileChunk = float64(chunksize * 1024 * 1024) // chunksize in MB
-
-	// calculate total number of parts the file will be chunked into
-
-	totalPartsNum := uint64(math.Ceil(float64(fileSize) / float64(fileChunk)))
-	fmt.Printf("[Info] Splitting to %d pieces.\n", totalPartsNum)
-	for i := uint64(0); i < totalPartsNum; i++ {
-		partSize := int(math.Min(fileChunk, float64(fileSize-int64(i*uint64(fileChunk)))))
-		partBuffer := make([]byte, partSize)
-		file.Read(partBuffer)
-		// write to disk
-		fileName := outputdir + outfilename + "_" + padZeros(strconv.FormatUint(i, 10), int(totalPartsNum))
-		_, err := os.Create(fileName)
-		if err != nil {
-			return false
-		}
-		// write/save buffer to disk
-		ioutil.WriteFile(fileName, partBuffer, os.ModeAppend)
-		fmt.Println("[Export] ", fileName)
-	}
-	return true
-}
-
-func openChunkedFile() {
-	storepath := "tmp/"
-	uuid := ""
-	outfile := ""
-	removeAfterMerge := 0
-	for i, arg := range os.Args {
-		if strpos(arg, "-") == 0 {
-			//This is a parameter defining keyword
-			if arg == "-uuid" {
-				uuid = os.Args[i+1]
-			} else if arg == "-storepath" {
-				storepath = os.Args[i+1]
-				//Check if the storepath is end with /. if not, append it into the pathname
-				if storepath[len(storepath)-1:] != "/" {
-					storepath = storepath + "/"
-				}
-			} else if arg == "-outfile" {
-				outfile = os.Args[i+1]
-			} else if arg == "-c" {
-				//Remove the file chunks after the merging process
-				removeAfterMerge = 1
-			}
-		}
-	}
-	if storepath != "" && uuid != "" && outfile != "" {
-		//fmt.Println(storepath + " " + uuid + " " + outfile)
-		if joinFileChunks(storepath+uuid, outfile) {
-			//Do checksum here
-
-			//Remove all files if -c is used
-			if removeAfterMerge == 1 {
-				matches, _ := filepath.Glob(storepath + uuid + "_*")
-				for j := 0; j < len(matches); j++ {
-					os.Remove(matches[j])
-				}
-			}
-		} else {
-			fmt.Println("ERROR. Unable to merge file chunks.")
-		}
-	} else {
-		fmt.Println("ERROR. Undefined storepath, outfile or uuid.")
-	}
-}
-
-func joinFileChunks(fileuuid string, outfilename string) bool {
-	matches, _ := filepath.Glob(fileuuid + "_*")
-	if len(matches) == 0 {
-		fmt.Println("ERROR. No filechunk file for this uuid.")
-		return false
-	}
-	outfile, err := os.Create(outfilename)
-	if err != nil {
-		return false
-	}
-	//For each file chunk, merge them into the output file
-	for j := 0; j < len(matches); j++ {
-		b, _ := ioutil.ReadFile(matches[j])
-		outfile.Write(b)
-	}
-	return true
-}
-
-func startUploadProc() {
-	push := "remoteDisks.config"
-	storepath := "chunks/"
-	uuid := ""
-	vdir := ""
-	for i, arg := range os.Args {
-		if strpos(arg, "-") == 0 {
-			//This is a parameter defining keyword
-			if arg == "-uuid" {
-				uuid = os.Args[i+1]
-			} else if arg == "-storepath" {
-				storepath = os.Args[i+1]
-				//Check if the storepath is end with /. if not, append it into the pathname
-				if storepath[len(storepath)-1:] != "/" {
-					storepath = "chunks/" + storepath + "/"
-				}
-			} else if arg == "-vdir" {
-				vdir = os.Args[i+1]
-			} else if arg == "-push" {
-				//Remove the file chunks after the merging process
-				push = os.Args[i+1]
-			}
-		}
-	}
-	//Check if the input data are valid
-	if uuid == "" || vdir == "" {
-		fmt.Println("ERROR. Undefined uuid or vdir.")
-		os.Exit(0)
-	}
-	if !file_exists(clusterSetting) {
-		fmt.Println("ERROR. clusterSetting configuration not found")
-		os.Exit(0)
-	}
-	if file_exists("index/" + vdir + string(".index")) {
-		fmt.Println("ERROR. Given file already exists in vdir. Please use remove before uploading a new file on the same vdir location.")
-		os.Exit(0)
-	}
-
-	//Starting the uuid to ip conversion process
-
-	var ipList []string
-	var uuiddata []string
-	var uploadUUIDList []string
-	//Read cluster uuid list from remoteDisks.config
-	if file_exists(push) {
-		clusteruuids := file_get_contents(push)
-		if trim(clusteruuids) == "" {
-			fmt.Println("ERROR. remoteDisks not found or it is empty! ")
-			os.Exit(0)
-		}
-		clusteruuids = trim(strings.Trim(clusteruuids, "\n"))
-		uuiddata = explode("\n", clusteruuids)
-		//Generate iplist and ready for posting file chunks
-		for i := 0; i < len(uuiddata); i++ {
-			thisuuid := uuiddata[i%len(uuiddata)]
-			uploadUUIDList = append(uploadUUIDList, thisuuid)
-			thisip := resolveUUID(thisuuid)
-			clusterConfig := ":" + string(config.Port) + "/" + string(config.Prefix) + "/"
-			fullip := "http://" + thisip + clusterConfig
-			ipList = append(ipList, fullip)
-		}
-	} else {
-		fmt.Println("ERROR. remoteDisks not found or it is empty! ")
-		os.Exit(0)
-	}
-
-	//Handshake with clusters, create auth token if needed
-	if !createToken(ipList) {
-		fmt.Println("ERROR. Problem occured while trying to create token for one of the cluster's host. Upload process terminated.")
-		os.Exit(0)
-	}
-
-	//Ready to push. Create index file.
-	file_put_contents("index/"+vdir+string(".index"), "")
-	fileList, _ := filepath.Glob(storepath + uuid + "_*")
-	//Make a directory for storing the result of the upload
-	if !file_exists(storepath + ".upload/") {
-		mkdir(storepath + ".upload/")
-	}
-	for i := 0; i < len(fileList); i++ {
-		uploadIP := (ipList[i%len(ipList)])
-		uploadUUID := (uploadUUIDList[i%len(ipList)])
-		go SendPostRequest(uploadIP+uploadScript, fileList[i], "file", storepath+".upload/"+basename(fileList[i])+".done", uploadUUID)
-	}
-	//Retry for error chunks. Not implemented yet
-
-	//Wait for all upload process to end
-	uploadFinishIndicators, _ := filepath.Glob(storepath + ".upload/" + uuid + "_*.done")
-	for len(uploadFinishIndicators) < len(fileList) {
-		time.Sleep(time.Duration(500) * time.Millisecond)
-		uploadFinishIndicators, _ = filepath.Glob(storepath + ".upload/" + uuid + "_*.done")
-	}
-
-	//Write the upload results to index file
-	for j := 0; j < len(uploadFinishIndicators); j++ {
-		f, _ := os.OpenFile("index/"+vdir+string(".index"), os.O_APPEND|os.O_WRONLY, 0600)
-		defer f.Close()
-		f.WriteString(str_replace(".done", "", basename(uploadFinishIndicators[j])))
-		f.WriteString(",")
-		f.WriteString(file_get_contents(uploadFinishIndicators[j]))
-		f.WriteString("\n")
-	}
-
-	//Clear up all indicators
-	for k := 0; k < len(uploadFinishIndicators); k++ {
-		os.Remove(uploadFinishIndicators[k])
-	}
-	os.Remove(storepath + ".upload/")
-
-	fmt.Println("[OK] All chunks uploaded.")
-}
-
-func createToken(ipList []string) bool {
-	//Not implemented
-	return true
-}
-
-func resolveUUID(uuid string) string {
-	tmp := []byte(uuid)
-	uuid = string(bytes.Trim(tmp, "\xef\xbb\xbf"))
-	uuid = strings.Trim(strings.Trim(uuid, "\n"), "\r")
-	if file_exists(clusterServices + "mappers/") {
-		if file_exists(clusterServices + "/mappers/" + uuid + ".inf") {
-			return file_get_contents(clusterServices + "/mappers/" + uuid + ".inf")
-		} else {
-			fmt.Println("ERROR. UUID not found. Please perform a scan first before using arozdfs functions")
-		}
-	} else {
-		fmt.Println("ERROR. Unable to resolve UUID to IP: cluster services not found. Continuing with UUID as IP address.")
-
-	}
-	return uuid
-}
-
-func SendPostRequest(url string, filename string, fieldname string, resultName string, targetUUID string) []byte {
-	file, err := os.Open(filename)
-
-	if err != nil {
-		panic(err)
-	}
-	defer file.Close()
-
-	body := &bytes.Buffer{}
-	writer := multipart.NewWriter(body)
-	part, err := writer.CreateFormFile(fieldname, filepath.Base(file.Name()))
-
-	if err != nil {
-		panic(err)
-	}
-
-	io.Copy(part, file)
-	writer.Close()
-	request, err := http.NewRequest("POST", url, body)
-
-	if err != nil {
-		panic(err)
-	}
-
-	request.Header.Add("Content-Type", writer.FormDataContentType())
-	client := &http.Client{}
-
-	response, err := client.Do(request)
-
-	if err != nil {
-		panic(err)
-	}
-	defer response.Body.Close()
-
-	content, err := ioutil.ReadAll(response.Body)
-
-	if err != nil {
-		panic(err)
-	}
-
-	//Upload suceed. Create a .done file to indicate this file is done uploading
-	file_put_contents(resultName, string(targetUUID))
-	return content
-}
-
-func removeFile() {
-	fileindex := ""
-	if len(os.Args) == 3 {
-		fileindex = os.Args[2]
-	}
-	if fileindex == "" {
-		fmt.Println("ERROR. undefined file index. Usage: arozdfs file.ext (Root as ./index)")
-		os.Exit(0)
-	}
-
-	indexFileRealpath := "index/" + fileindex + ".index"
-	if !file_exists(indexFileRealpath) {
-		fmt.Println("ERROR. fileindex not found in " + indexFileRealpath)
-		os.Exit(0)
-	}
-
-	//Everything checked and go ahead to load the list into variables
-	var filelist []string
-	var targetUUIDs []string
-	fc := strings.Trim(str_replace("\r\n", "\n", file_get_contents(indexFileRealpath)), "\n")
-	datachunks := explode("\n", fc)
-	for i := 0; i < len(datachunks); i++ {
-		thisChunk := datachunks[i]
-		thisChunk = strings.Trim(strings.Trim(thisChunk, "\n"), "\r")
-		chunkdata := explode(",", thisChunk)
-		filelist = append(filelist, chunkdata[0])
-		targetUUIDs = append(targetUUIDs, "http://"+resolveUUID(chunkdata[1])+":"+config.Port+"/"+config.Prefix+"/")
-	}
-
-	//fmt.Println(filelist)
-	//fmt.Println(targetUUIDs)
-
-	//Remove the chunks on each endpoints
-	failed := len(filelist)
-	var failedChunk []string
-	for j := 0; j < len(filelist); j++ {
-		targetEndpoint := targetUUIDs[j] + delChunkScript + filelist[j]
-		resp, err := http.Get(targetEndpoint)
-		if err != nil {
-			// handle error
-			fmt.Println("ERROR. Unable to connect to endpoint: " + targetEndpoint + ". Continue with the rest of the endpoints.")
-		}
-		body, _ := ioutil.ReadAll(resp.Body)
-		fmt.Println("[REPLY] " + string(body) + " for " + filelist[j])
-		if trim(string(body)) == "DONE" {
-			failed--
-		} else {
-			failedChunk = append(failedChunk, filelist[j])
-		}
-		resp.Body.Close()
-	}
-	if failed == 0 {
-		fmt.Println("[OK] All file chunks has been removed from the clusters")
-		os.Remove(indexFileRealpath)
-	} else {
-		fmt.Println("[WARNING] Unable to remove at least one chunks from cluster. Index file is not removed.")
-		fmt.Println(failedChunk)
-	}
-
-}
-
-func showHelp() {
-	fmt.Println(`[arozdfs - Distributed File Storage Management Tool for ArOZ Online Cloud System]
-	This is a command line tool build for the ArOZ Online distributed cloud platform file chunking and redundant data storage. 
-	Please refer to the ArOZ Online Documentaion for more information.
-	`)
-	fmt.Println(`Supported commands:
-	help --> show all the help information
-
-	[Uploading to arozdfs commands]
-	slice
-	-infile <filename> --> declare the input file
-	-slice <filesize> --> declare the slicing filesize
-	-storepath <pathname> (Optional) --> Relative path for storing the sliced chunk files, default ./{file-uuid}
-
-	upload
-	-storepath <pathname> --> The location where the file chunks are stored, root start at ./chunks, not recommend for leaving this empty
-	-uuid <file uuid> --> uuid of the file to be uploaded
-	-vdir <file.index> --> where the file.index should be stored. (Use for file / folder navigation)
-	-push <remoteDisks.config> (Optional) --> push to a list of clusters and sync file index to other clusters, default ./remoteDisks.config
-
-	[Download from arozdfs commands]
-	download
-	-vdir <file.index> --> file.index location
-	-storepath <tmp directory> (Optional) --> define a special directory for caching the downloaded data chunks, default ./tmp
-
-	open
-	-uuid <file uuid> --> the uuid which the file is stored
-	-outfile <filename> --> filepath for the exported and merged file
-	-storepath <tmp directory> (Optional)--> the file chunks tmp folder, default ./tmp
-	-c (Optional) --> remove all stored file chunks after merging the file chunks.
-
-	[File Operations]
-	remove <file.index> --> remove all chunks related to this file index
-	rename <file.index> <newfile.index> --> rename all records related to this file
-	move <filepath/file.index> <newpath/file.index> --> move the file to a new path in index directory
-
-
-	[System checking commands]
-	checkfile <file.index> --> check if a file contains all chunks which has at least two copies of each chunks
-	rebuild --> Check all files on the system and fix all chunks which has corrupted
-	migrate <remoteDisks.config> --> Move all chunks from this host to other servers in the list.`)
-}
-
-func showNotFound() {
-	fmt.Println("ERROR. Command not found: " + os.Args[1])
-}

+ 0 - 2
put this in SystemAOB functions/arozdfs/remoteDisks.config

@@ -1,2 +0,0 @@
-9f269d38-07c4-460e-b477-26066e59f1c9
-aa2acf42-d0b9-4441-8351-7fa84a5dc26d