Subversion Repositories SmartDukaan

Rev

Rev 6885 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
6848 kshitij.so 1
package in.shop2020.serving.services;
2
 
3
import java.util.Arrays;
4
import java.util.List;
5
 
6
import org.apache.tools.ant.Project;
7
import org.apache.tools.ant.taskdefs.optional.ssh.Scp;
8
 
9
import in.shop2020.config.ConfigException;
10
import in.shop2020.thrift.clients.config.ConfigClient;
11
import org.apache.log4j.Logger;
12
 
13
 
14
public class ScpService {
15
 
16
	private static Logger log = Logger.getLogger(Class.class);
17
	public List<String> ips;
18
	public String keyFile;
19
 
20
    public void scpFile( String remoteFilePath, String localFilePath ) throws ConfigException {
21
 
22
        	List<String> ips = Arrays.asList((ConfigClient.getClient().get("ips_for_banner_uploading")).split(" "));
23
        	if ( !(ips.get(0).equalsIgnoreCase("NA"))){
24
        		keyFile= ConfigClient.getClient().get("secret_key_file");
25
	        	for(int i=0;i<ips.size();i+=1){
26
	                Scp scp = new Scp();
27
	                scp.setFile(localFilePath);
28
	                log.info("Banner Uploading paths Local Path: "+localFilePath+"Remote Path :"+remoteFilePath);
29
	                scp.setKeyfile(keyFile);
30
	                scp.setRemoteTodir("root: @"+ips.get(i)+":"+remoteFilePath);
31
	                scp.setProject(new Project());
32
	                scp.setTrust(true);
33
	                scp.execute();
34
	        	}
35
        	}
36
    		/*Scp scp = new Scp();
37
            scp.setFile(localFilePath);
38
            log.info(localFilePath);
39
            log.info(remoteFilePath);
40
            scp.setKeyfile("/usr/share/tomcat6/id_rsa");
41
            scp.setRemoteTodir("root: @shop2020.in:"+remoteFilePath);
42
            scp.setProject(new Project());
43
            scp.setTrust(true);
44
            scp.execute();*/
45
 
46
 
47
		} 
48
 
49
    public static void main(String[] args) throws ConfigException {
50
    	ScpService scp = new ScpService();
51
        scp.scpFile("/root/banner1.jpg", "/home/phani/Desktop/banner1.jpg");
52
    }
53
 
54
}