UNSOLVED

canadian_tracke

updated

9 years ago

0

3035

August 11th, 2017 06:00

PHP script to create a directory and symlink

Good day!

I am trying to write a php script to create a directory then make a symlink to that directory.  So far, I cannot even get the directory created.  The authentication has even been simplified to rule that out.

Here is what I have. This script is trying to create the folder 'NewFolder'.    Any hints?

~snip~

$ch = curl_init();

$auth=base64_encode("username:password");

curl_setopt($ch, CURLOPT_URL, "https://media-vault:8080/namespace/ifs/home/username/NewFolder");

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");

curl_setopt($ch, CURLOPT_USERPWD, "username" . ":" . "password");

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);

curl_setopt($ch, CURLOPT_VERBOSE, 1);

curl_setopt($ch, CURLOPT_PUT, true);

$headers = array();

$headers[] = "X-Isi-Ifs-Target-Type: container";

curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$result = curl_exec($ch);

if (curl_errno($ch)) {

    echo "\nError:" . curl_error($ch) ."\n\n";

}

curl_close ($ch);

  • Peter_Sero

    6 Operator

    •

    1169 Posts

    2196

    1

    Posted August 11th, 2017 09:00

    What error message do you get?

    Does the user have the ISI_PRIV_NS_IFS_ACCESS privilege for the namespace API,

    via a custom role?

    -- Peter

  • 2196

    0

    Posted August 11th, 2017 10:00

    Hello Peter!

    That user can run this from a shell on a remote machine. It creates the directory fine:

    curl --insecure --user username:password -H "x-isi-ifs-target-type: container" -v "https://media-vault:8080/namespace/ifs/home/username/NewFolder" -X PUT

  • 2196

    0

    Posted August 11th, 2017 11:00

    For debugging, you can try a similar curl comand from the command line:

    curl -X PUT -k --user 'username:password' --header 'x-isi-ifs-target-type:container' https://media-vault:8080/namespace/ifs/anewfolder

    Also, you might consider appending a ?recursive=true flag to your url if the /ifs/home/username folder doesn't exist yet.

  • AdamFox

    254 Posts

    2196

    2

    Posted August 11th, 2017 11:00

    FYI:

    The RAN API does not support creating a symlink today.  You will need to have your SE file a feature request for that.  But creating a directory does work, as long as you have the RBAC permissions for Namespace access and you have permission to create a directory at that point in the filesystem.

  • 2196

    1

    Posted August 11th, 2017 13:00

    Make sure that the node you're authenticating to is the same node that you're issuing subsequent commands on.  If you're using a SmartConnect zone, you will get authentication errors.

  • 2196

    0

    Posted August 15th, 2017 05:00

    Thank you all for the responses!

    All very helpful!

    Even with all the permissions correct and hitting the direct IP address of the isilon-node, my script still does not create a directory.   Using the same credentials and IP address, I can create the directory with curl but not with PHP.  Any hints or examples?

  • eespin

    21 Posts

    2196

    0

    Posted September 13th, 2017 16:00

    what's your CURL error? Can you tail your /etc/httpd/logs/error_log and past it here?