Browse Community
Help
Log In
Responses(5)
Solutions(0)
Yan_Faubert
117 Posts
0
April 25th, 2014 06:00
Just to add for completeness how I compile and run this program:
root@yfvm-deb1:~/jcifs/jcifs-krb5-1.3.17# cat setcp export CLASSPATH=~/jcifs/jcifs-krb5-1.3.17/jcifs-krb5-1.3.17.jar:. root@yfvm-deb1:~/jcifs/jcifs-krb5-1.3.17# . setcp root@yfvm-deb1:~/jcifs/jcifs-krb5-1.3.17# root@yfvm-deb1:~/jcifs/jcifs-krb5-1.3.17# javac NetworkShareFileCopy.java root@yfvm-deb1:~/jcifs/jcifs-krb5-1.3.17# java NetworkShareFileCopy User: faubert:xxxxxxx Path: smb://static.vm7027.yfisi.local/ifs_data_oplock/testFile.txt Successful: true
root@yfvm-deb1:~/jcifs/jcifs-krb5-1.3.17# cat setcp
export CLASSPATH=~/jcifs/jcifs-krb5-1.3.17/jcifs-krb5-1.3.17.jar:.
root@yfvm-deb1:~/jcifs/jcifs-krb5-1.3.17# . setcp
root@yfvm-deb1:~/jcifs/jcifs-krb5-1.3.17#
root@yfvm-deb1:~/jcifs/jcifs-krb5-1.3.17# javac NetworkShareFileCopy.java
root@yfvm-deb1:~/jcifs/jcifs-krb5-1.3.17# java NetworkShareFileCopy
User: faubert:xxxxxxx
Path: smb://static.vm7027.yfisi.local/ifs_data_oplock/testFile.txt
Successful: true
And I did validate the file actually got created on the cluster!
yfvm-7027-2# pwd /ifs/data/oplock yfvm-7027-2# ls -latr testFile.txt -rwx------ + 1 faubert YFISI\clusteruse 29 Apr 25 09:34 testFile.txt yfvm-7027-2#
yfvm-7027-2# pwd
/ifs/data/oplock
yfvm-7027-2# ls -latr testFile.txt
-rwx------ + 1 faubert YFISI\clusteruse 29 Apr 25 09:34 testFile.txt
yfvm-7027-2#
bubstep816
12 Posts
I will test these out and let you know.
peglarr
99 Posts
Thanks Yan - nicely done.
Interesting comparison on the # of lines of code needed for this technique versus doing a RESTful PUT of a given file.
I did a test with basic jcifs program and was able to create a file over SMB to a cluster that is joined to AD.
My environment:
OneFS (7.0.2.7):
Isilon OneFS yfvm-7027-2 v7.0.2.7 Isilon OneFS v7.0.2.7 B_7_0_2_263(RELEASE): 0x700025000700107:Thu Feb 27 12:40:26 PST 2014 root@fastbuild-05.west.isilon.com:/build/mnt/obj.RELEASE/build/mnt/src/sys/IQ.amd64.release amd64
Linux:
Debian Wheezy
Linux yfvm-deb1 3.2.0-4-amd64 #1 SMP Debian 3.2.41-2 x86_64 GNU/Linux
Java:
java version "1.7.0_55"
Java(TM) SE Runtime Environment (build 1.7.0_55-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.55-b03, mixed mode)
Sample code I used with jcifs-krb5-1.3.17.jar:
root@yfvm-deb1:~/jcifs/jcifs-krb5-1.3.17# cat NetworkShareFileCopy.java import jcifs.smb.NtlmPasswordAuthentication; import jcifs.smb.SmbFile; import jcifs.smb.SmbFileOutputStream; public class NetworkShareFileCopy { static final String DOMAIN = "YFISI"; static final String USER_NAME = "my_domain_id"; static final String PASSWORD = "my_domain_pass"; //e.g. Assuming your network folder is: \\my.myserver.net\ifs_data_oplock\ static final String NETWORK_FOLDER = "smb://static.vm7027.yfisi.local/ifs_data_oplock/"; public static void main(String args[]) { String fileContent = "This is a test file some data"; new NetworkShareFileCopy().copyFiles(fileContent, "testFile.txt"); } public boolean copyFiles(String fileContent, String fileName) { boolean successful = false; try{ String user = USER_NAME + ":" + PASSWORD; System.out.println("User: " + user); NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication(DOMAIN, USER_NAME, PASSWORD); String path = NETWORK_FOLDER + fileName; System.out.println("Path: " +path); SmbFile sFile = new SmbFile(path, auth); SmbFileOutputStream sfos = new SmbFileOutputStream(sFile); sfos.write(fileContent.getBytes()); successful = true; System.out.println("Successful: " + successful); } catch (Exception e) { successful = false; e.printStackTrace(); } return successful; } }
root@yfvm-deb1:~/jcifs/jcifs-krb5-1.3.17# cat NetworkShareFileCopy.java
import jcifs.smb.NtlmPasswordAuthentication;
import jcifs.smb.SmbFile;
import jcifs.smb.SmbFileOutputStream;
public class NetworkShareFileCopy {
static final String DOMAIN = "YFISI";
static final String USER_NAME = "my_domain_id";
static final String PASSWORD = "my_domain_pass";
//e.g. Assuming your network folder is: \\my.myserver.net\ifs_data_oplock\
static final String NETWORK_FOLDER = "smb://static.vm7027.yfisi.local/ifs_data_oplock/";
public static void main(String args[]) {
String fileContent = "This is a test file some data";
new NetworkShareFileCopy().copyFiles(fileContent, "testFile.txt");
}
public boolean copyFiles(String fileContent, String fileName) {
boolean successful = false;
try{
String user = USER_NAME + ":" + PASSWORD;
System.out.println("User: " + user);
NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication(DOMAIN, USER_NAME, PASSWORD);
String path = NETWORK_FOLDER + fileName;
System.out.println("Path: " +path);
SmbFile sFile = new SmbFile(path, auth);
SmbFileOutputStream sfos = new SmbFileOutputStream(sFile);
sfos.write(fileContent.getBytes());
successful = true;
System.out.println("Successful: " + successful);
} catch (Exception e) {
successful = false;
e.printStackTrace();
return successful;
April 25th, 2014 07:00
This is my 'python' equivalent of what the previous sample is doing but using the RAN API.
yfaubert@yfvm-deb1:~/ran$ cat create_file.py import requests ran_url = "https://yfvm-7027.yfisi.local:8080/namespace/ifs-data-ran" filename = file_to_send = "file_to_send.dd" authinfo = ('papiuser', 'papi_password') if __name__ == "__main__": fullpath = ran_url + "/" + file_to_send param = {"overwrite": True} headers = {'content-type': 'binary/octet-stream', 'x-isi-ifs-target-type': 'object', 'x-isi-ifs-access-control': '0644'} with open(filename) as file: create_reply = requests.put(fullpath, data=file, verify=False, headers=headers, params=param, auth=authinfo) print "Create reply: " + str(create_reply.text)
yfaubert@yfvm-deb1:~/ran$ cat create_file.py
import requests
ran_url = "https://yfvm-7027.yfisi.local:8080/namespace/ifs-data-ran"
filename = file_to_send = "file_to_send.dd"
authinfo = ('papiuser', 'papi_password')
if __name__ == "__main__":
fullpath = ran_url + "/" + file_to_send
param = {"overwrite": True}
headers = {'content-type': 'binary/octet-stream', 'x-isi-ifs-target-type': 'object', 'x-isi-ifs-access-control': '0644'}
with open(filename) as file:
create_reply = requests.put(fullpath, data=file, verify=False, headers=headers, params=param, auth=authinfo)
print "Create reply: " + str(create_reply.text)
Dell Support Resources
View All
Top
Yan_Faubert
117 Posts
0
April 25th, 2014 06:00
Just to add for completeness how I compile and run this program:
And I did validate the file actually got created on the cluster!
bubstep816
12 Posts
0
April 25th, 2014 06:00
I will test these out and let you know.
peglarr
99 Posts
0
April 25th, 2014 06:00
Thanks Yan - nicely done.
Interesting comparison on the # of lines of code needed for this technique versus doing a RESTful PUT of a given file.
Yan_Faubert
117 Posts
0
April 25th, 2014 06:00
I did a test with basic jcifs program and was able to create a file over SMB to a cluster that is joined to AD.
My environment:
OneFS (7.0.2.7):
Isilon OneFS yfvm-7027-2 v7.0.2.7 Isilon OneFS v7.0.2.7 B_7_0_2_263(RELEASE): 0x700025000700107:Thu Feb 27 12:40:26 PST 2014 root@fastbuild-05.west.isilon.com:/build/mnt/obj.RELEASE/build/mnt/src/sys/IQ.amd64.release amd64
Linux:
Debian Wheezy
Linux yfvm-deb1 3.2.0-4-amd64 #1 SMP Debian 3.2.41-2 x86_64 GNU/Linux
Java:
java version "1.7.0_55"
Java(TM) SE Runtime Environment (build 1.7.0_55-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.55-b03, mixed mode)
Sample code I used with jcifs-krb5-1.3.17.jar:
Yan_Faubert
117 Posts
0
April 25th, 2014 07:00
This is my 'python' equivalent of what the previous sample is doing but using the RAN API.