Skip to content
Snippets Groups Projects
Commit 160adb4c authored by Luijsterburg, Joris's avatar Luijsterburg, Joris
Browse files

Added first POC of s3specific free space rule

parent e4dac71c
No related branches found
No related tags found
No related merge requests found
#!/bin/bash
# modresc Name [name, type, host, path, status, comment, info, free_space, context, rebalance] Value
# (modify Resource)
#iadmin modresc s3resc1 freespace 100MB
name=$1
value=$2
iadmin modresc $name freespace $value
#!/bin/bash
#remember to set the .s3cfg when excuting this, the irods user needs it as well!
bucketname=$1
totalbucketsize=$2
s3result=$(s3cmd du s3:/$bucketname)
returnvalue=$?
s3resultarray=($s3result)
s3duinb=${s3resultarray[0]}
s3duinkb=`expr $s3duinb / 1024 `
s3totalfree=`expr $totalbucketsize - $s3duinkb`
echo $s3totalfree
exit $returnvalue
upds3freespace{
#first test if this is an s3resource or not, and get the bucketname at the same time
foreach(*resource in SELECT RESC_TYPE_NAME,RESC_VAULT_PATH where RESC_NAME = "*resc"){
*resourcetype=*resource.RESC_TYPE_NAME
*bucket=*resource.RESC_VAULT_PATH
if(*resourcetype!="s3"){
writeLine("stdout","This is not an s3 resource, the rule doesn't work with a non s3-resource")
failmsg(-1,"This is not an s3 resource, the rule doesn't work with a non s3-resource")
}
}
#get bucket free space in variable
writeLine("stdout","fetching disk usage of irods bucket with maximum of 10MB");
msiExecCmd("s3diskusagefromresc","*bucket 10240", "null", "null", "null", *OUTPUT);
#TODO: check if output is correct, the resource could be ill configured
#msiGetStderrInExecCmdOut(*OUTPUT,*ErrorOut);
#writeLine("stdout","Error message is *ErrorOut");
#printing messages
msiGetStdoutInExecCmdOut(*OUTPUT,*Out);
writeLine("stdout","Output message is *Out");
#TODO: update freespace with icommand iadmin
}
INPUT *resc="s3resc2"
OUTPUT ruleExecOut
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment