View Source

Use the {{createVolumeWithDirectory}} API to create a volume that includes a directory if it does not exist.
{code}
########====CDP Server Configuration Start====########
#set CDP server host name
$HOST="10.230.131.25";
#set CDP server to access API
$PORT="9443";
#set CDP user
$USER="admin";
#set CDP user password
$PASS="admin";
########====CDP Server Configuration End====########

#arguments
$VOLNAME="APItest5";
$VOLDESC="APItestDesc";
$VOLPATH="/root/APIVol5";
$VOLQUOTATYPE="NONE";
$HARDQUOTA="";
$SOFTQUOTA="";
$CREATEDIR="createDirectoryIfItDoesNotExist";

if ($VOLNAME!="")
{
$volumeObj->name = $VOLNAME;
}

if ($VOLDESC!="")
{
$volumeObj->description = $VOLDESC;
}

if ($VOLPATH!="")
{
$volumeObj->path = $VOLPATH;
}

if ($QUOTATYPE!="")
{
$volumeObj->quotaType = $VOLQUOTATYPE;
}

if ($HARDQUOTA!="")
{
$volumeObj->hardQuota = $HARDQUOTA;
}

if ($SOFTQUOTA!="")
{
$volumeObj->softQuota = $SOFTQUOTA;
}
if ($CREATEDIR!="")
{
$volumeObj->createDirectoryIfItDoesNotExist = $CREATEDIR;
}
#Create a volume that includes a directory if it does not exist.
try{
$client = new soapclient("https://$HOST:$PORT/Volume?wsdl",
array('login'=>"$USER",
'password'=>"$PASS",
'trace'=>1
)
);


$client->createVolumeWithDirectory(array('volume'=>$volumeObj));

echo "Successfully created Volume: $VOLNAME\n";

exit(0);

}

catch (SoapFault $exception)
{
echo $exception;
exit(1);
}
{code}