In my last post you saw how I was able to do a directory listing on an Isilon cluster using the Isilon REST API. In this posting I am providing an example of how you can create a directory on the Isilon cluster using the Isilon REST API.
The simple script below shows how I can create the directory schmaus8 (as an example) under the /ifs/data path on the cluster:
use REST::Client; use JSON; use Data::Dumper; use MIME::Base64; use IO::Socket::SSL qw( SSL_VERIFY_NONE ); $ENV{PERL_LWP_SSL_VERIFY_HOSTNAME}=0; my $username = 'admin'; my $password = 'password$'; my $headers = {Accept => 'application/json', Authorization => 'Basic ' . encode_base64($username . ':' . $password), 'x-isi-ifs-target-type' => 'container'}; my $client = REST::Client->new(); $client->getUseragent()->ssl_opts( SSL_verify_mode => 0 ); $client->setHost('https://10.88.82.106:8080'); $client->PUT('/namespace/ifs/data/schmaus8','schmaus8',$headers); print $client->responseContent(). "\n"; ; exit;
The output if successful from the script above will be nothing:
C:\TEMP>perl isi-file-create.pl C:\TEMP>
This script could be altered to provide input for the path you need to have created. You could also join the previous script I provided to first check and see if the directory exists before you try to create it.