• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java SCPClient类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.trilead.ssh2.SCPClient的典型用法代码示例。如果您正苦于以下问题:Java SCPClient类的具体用法?Java SCPClient怎么用?Java SCPClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



SCPClient类属于com.trilead.ssh2包,在下文中一共展示了SCPClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: copySlaveJarUsingSCP

import com.trilead.ssh2.SCPClient; //导入依赖的package包/类
/**
 * Method copies the slave jar to the remote system using scp.
 *
 * @param listener         The listener.
 * @param workingDirectory The directory into which the slave jar will be copied.
 * @throws IOException          If something goes wrong.
 * @throws InterruptedException If something goes wrong.
 */
private void copySlaveJarUsingSCP(TaskListener listener, String workingDirectory) throws IOException, InterruptedException {
    SCPClient scp = new SCPClient(connection);
    try {
        // check if the working directory exists
        if (connection.exec("test -d " + workingDirectory, listener.getLogger()) != 0) {
            listener.getLogger().println("Remote filesystem doesn't exist");
            // working directory doesn't exist, lets make it.
            if (connection.exec("mkdir -p " + workingDirectory, listener.getLogger()) != 0) {
                listener.getLogger().println("Failed to create " + workingDirectory);
            }
        }

        // delete the slave jar as we do with SFTP
        connection.exec("rm " + workingDirectory + "/slave.jar", new NullStream());

        // SCP it to the slave. hudson.Util.ByteArrayOutputStream2 doesn't work for this. It pads the byte array.
        listener.getLogger().println("Copying slave jar");
        scp.put(new Slave.JnlpJar("slave.jar").readFully(), "slave.jar", workingDirectory, "0644");
    } catch (IOException e) {
        throw new IOException2("Error copying slave jar", e);
    }
}
 
开发者ID:thescouser89,项目名称:ovirt-slaves-plugin,代码行数:31,代码来源:OVirtSshLauncher.java


示例2: scopy

import com.trilead.ssh2.SCPClient; //导入依赖的package包/类
/**
 * Copy the local file named zipFile to remote host and the the target
 * location is targetPath.
 * 
 * @param zipFile
 *            local zipFile
 * @param targetPath
 *            target location in the remote host
 * @throws RemoteException
 *             When this remote operation fails for any non-local reason.
 * @throws IOException
 *             When connect remote host by ssh2
 * */
public boolean scopy(Connection conn, File zipFile, String targetPath)
		throws IOException, RemoteException {
	String zipFileName = zipFile.toString();
	targetPath = pathStrConvert(targetPath);

	try
	{
		SCPClient scpc = conn.createSCPClient();
		mkdirTargetPath(targetPath);
		scpc.put(zipFileName, targetPath);
	
	}catch(IllegalStateException e)
	{
		throw new RemoteException(e.getMessage());
	}
	//System.out.println(zipFileName+"   "+targetPath);
	//mkdir targetPath
	
	if (isExistedFile(targetPath, zipFile.getName()) == false)
		throw new RemoteException("File scp failed");

	return true;
}
 
开发者ID:MToLinux,项目名称:Nginxlib,代码行数:37,代码来源:RecController.java


示例3: GetRemoteConf

import com.trilead.ssh2.SCPClient; //导入依赖的package包/类
/**
 * Get the nginx.conf file which nginx.conf fullpath is parameter remoteFile.
 * @throws IOException 
 * */
private void GetRemoteConf(String remoteFile) throws RemoteException
{
       if(null == localConfPath || "" == localConfPath){
       	throw new RemoteException("local localConfPath is not correct.please set SetConfpathWithName()");
       }
	
	/* Now connect */
	try {
		oldConfDatestamp = getFileModifyTime();
		
		SCPClient scpc=conn.createSCPClient();
		scpc.get(remoteFile, localConfPath);
		/*no Close the connection */

	} catch (IOException e) {
		throw new RemoteException(e.getMessage());
	}
}
 
开发者ID:MToLinux,项目名称:Nginxlib,代码行数:23,代码来源:RecRemoteOperator.java


示例4: WriteRemoteConf

import com.trilead.ssh2.SCPClient; //导入依赖的package包/类
/**
 * Write the Remote nginx.conf file which is select.
 * @throws RemoteException 
 * */
private void WriteRemoteConf() throws RemoteException{
       if(null == localConfPath || "" == localConfPath){
       	throw new RemoteException("local localConfPath is not correct.please set SetConfpathWithName()");
       }
       
	try {
		if(!CanCommitFile()){
        	throw new RemoteException("the remote Nginx.conf has modified before.Please check remote Nginx.conf timestamp");
		}
		SCPClient scpc=conn.createSCPClient();
		
		String localFile = GetlocalConfFullName();
		String remoteConfDirectory = remoteConf.substring(0,
				remoteConf.lastIndexOf("/"));
		scpc.put(localFile, remoteConfDirectory);
		
		//update local datetimestamp
		oldConfDatestamp = getFileModifyTime();
	} catch (IOException e) {
		throw new RemoteException(e.getMessage());
	}
}
 
开发者ID:MToLinux,项目名称:Nginxlib,代码行数:27,代码来源:RecRemoteOperator.java


示例5: sendFileToHostTest

import com.trilead.ssh2.SCPClient; //导入依赖的package包/类
@Test
@PrepareForTest(SshUtils.class)
public void sendFileToHostTest() throws Exception {
    File localfilePath = Mockito.mock(File.class);
    SCPClient scp = configureSendFileToHostTest(localfilePath);

    spy.sendFileToHost(localfilePath, "remoteFileName", "remotePath", "address");

    verifySendFileToHostTest(localfilePath, scp, 1, 1);
}
 
开发者ID:Autonomiccs,项目名称:autonomiccs-platform,代码行数:11,代码来源:SshUtilsTest.java


示例6: sendFileToHostTestCatchIOException

import com.trilead.ssh2.SCPClient; //导入依赖的package包/类
@Test
@PrepareForTest(SshUtils.class)
public void sendFileToHostTestCatchIOException() throws Exception {
    File localfilePath = Mockito.mock(File.class);
    SCPClient scp = configureSendFileToHostTest(localfilePath);
    Mockito.doThrow(IOException.class).when(spy).authenticateSshSessionWithPublicKey(Mockito.eq(sshConnectionWithHost));

    spy.sendFileToHost(localfilePath, "remoteFileName", "remotePath", "address");

    verifySendFileToHostTest(localfilePath, scp, 0, 0);
}
 
开发者ID:Autonomiccs,项目名称:autonomiccs-platform,代码行数:12,代码来源:SshUtilsTest.java


示例7: configureSendFileToHostTest

import com.trilead.ssh2.SCPClient; //导入依赖的package包/类
private SCPClient configureSendFileToHostTest(File localfilePath) throws Exception {
    Mockito.doReturn("string").when(localfilePath).getAbsolutePath();
    Mockito.doReturn(sshConnectionWithHost).when(spy).getSshConnectionWithHost(Mockito.anyString());
    Mockito.doReturn(sshSession).when(spy).authenticateSshSessionWithPublicKey(Mockito.eq(sshConnectionWithHost));

    SCPClient scp = Mockito.mock(SCPClient.class);
    Mockito.doNothing().when(scp).put(Mockito.anyString(), Mockito.eq("remoteFileName"), Mockito.eq("remotePath"), Mockito.eq("0755"));

    PowerMockito.mock(SCPClient.class);
    PowerMockito.whenNew(SCPClient.class).withArguments(Mockito.eq(sshConnectionWithHost)).thenReturn(scp);

    return scp;
}
 
开发者ID:Autonomiccs,项目名称:autonomiccs-platform,代码行数:14,代码来源:SshUtilsTest.java


示例8: verifySendFileToHostTest

import com.trilead.ssh2.SCPClient; //导入依赖的package包/类
private void verifySendFileToHostTest(File localfilePath, SCPClient scp, int timesGetAbsolutePath, int timesPut) throws IOException {
    Mockito.verify(spy).authenticateSshSessionWithPublicKey(Mockito.eq(sshConnectionWithHost));
    Mockito.verify(localfilePath, Mockito.times(timesGetAbsolutePath)).getAbsolutePath();
    Mockito.verify(scp, Mockito.times(timesPut)).put(Mockito.anyString(), Mockito.eq("remoteFileName"), Mockito.eq("remotePath"), Mockito.eq("0755"));
    Mockito.verify(sshConnectionWithHost).close();
}
 
开发者ID:Autonomiccs,项目名称:autonomiccs-platform,代码行数:7,代码来源:SshUtilsTest.java


示例9: configure

import com.trilead.ssh2.SCPClient; //导入依赖的package包/类
@Override
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
    super.configure(name, params);
    _tftpDir = (String)params.get(BaremetalPxeService.PXE_PARAM_TFTP_DIR);
    if (_tftpDir == null) {
        throw new ConfigurationException("No tftp directory specified");
    }

    com.trilead.ssh2.Connection sshConnection = new com.trilead.ssh2.Connection(_ip, 22);

    s_logger.debug(String.format("Trying to connect to kickstart PXE server(IP=%1$s, username=%2$s, password=%3$s", _ip, _username, "******"));
    try {
        sshConnection.connect(null, 60000, 60000);
        if (!sshConnection.authenticateWithPassword(_username, _password)) {
            s_logger.debug("SSH Failed to authenticate");
            throw new ConfigurationException(String.format("Cannot connect to kickstart PXE server(IP=%1$s, username=%2$s, password=%3$s", _ip, _username, "******"));
        }

        String cmd = String.format("[ -f /%1$s/pxelinux.0 ]", _tftpDir);
        if (!SSHCmdHelper.sshExecuteCmd(sshConnection, cmd)) {
            throw new ConfigurationException("Miss files in TFTP directory at " + _tftpDir + " check if pxelinux.0 are here");
        }

        SCPClient scp = new SCPClient(sshConnection);
        String prepareScript = "scripts/network/ping/prepare_kickstart_bootfile.py";
        String prepareScriptPath = Script.findScript("", prepareScript);
        if (prepareScriptPath == null) {
            throw new ConfigurationException("Can not find prepare_kickstart_bootfile.py at " + prepareScript);
        }
        scp.put(prepareScriptPath, "/usr/bin/", "0755");

        String cpScript = "scripts/network/ping/prepare_kickstart_kernel_initrd.py";
        String cpScriptPath = Script.findScript("", cpScript);
        if (cpScriptPath == null) {
            throw new ConfigurationException("Can not find prepare_kickstart_kernel_initrd.py at " + cpScript);
        }
        scp.put(cpScriptPath, "/usr/bin/", "0755");

        String userDataScript = "scripts/network/ping/baremetal_user_data.py";
        String userDataScriptPath = Script.findScript("", userDataScript);
        if (userDataScriptPath == null) {
            throw new ConfigurationException("Can not find baremetal_user_data.py at " + userDataScript);
        }
        scp.put(userDataScriptPath, "/usr/bin/", "0755");

        return true;
    } catch (Exception e) {
        throw new CloudRuntimeException(e);
    } finally {
        if (sshConnection != null) {
            sshConnection.close();
        }
    }
}
 
开发者ID:apache,项目名称:cloudstack,代码行数:55,代码来源:BaremetalKickStartPxeResource.java


示例10: configure

import com.trilead.ssh2.SCPClient; //导入依赖的package包/类
@Override
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
    super.configure(name, params);
    _storageServer = (String)params.get(BaremetalPxeService.PXE_PARAM_PING_STORAGE_SERVER_IP);
    _pingDir = (String)params.get(BaremetalPxeService.PXE_PARAM_PING_ROOT_DIR);
    _tftpDir = (String)params.get(BaremetalPxeService.PXE_PARAM_TFTP_DIR);
    _cifsUserName = (String)params.get(BaremetalPxeService.PXE_PARAM_PING_STORAGE_SERVER_USERNAME);
    _cifsPassword = (String)params.get(BaremetalPxeService.PXE_PARAM_PING_STORAGE_SERVER_PASSWORD);

    if (_podId == null) {
        throw new ConfigurationException("No Pod specified");
    }

    if (_storageServer == null) {
        throw new ConfigurationException("No stroage server specified");
    }

    if (_tftpDir == null) {
        throw new ConfigurationException("No tftp directory specified");
    }

    if (_pingDir == null) {
        throw new ConfigurationException("No PING directory specified");
    }

    if (_cifsUserName == null || _cifsUserName.equalsIgnoreCase("")) {
        _cifsUserName = "xxx";
    }

    if (_cifsPassword == null || _cifsPassword.equalsIgnoreCase("")) {
        _cifsPassword = "xxx";
    }

    String pingDirs[] = _pingDir.split("/");
    if (pingDirs.length != 2) {
        throw new ConfigurationException("PING dir should have format like myshare/direcotry, eg: windows/64bit");
    }
    _share = pingDirs[0];
    _dir = pingDirs[1];

    com.trilead.ssh2.Connection sshConnection = new com.trilead.ssh2.Connection(_ip, 22);

    s_logger.debug(String.format("Trying to connect to PING PXE server(IP=%1$s, username=%2$s, password=%3$s", _ip, _username, "******"));
    try {
        sshConnection.connect(null, 60000, 60000);
        if (!sshConnection.authenticateWithPassword(_username, _password)) {
            s_logger.debug("SSH Failed to authenticate");
            throw new ConfigurationException(String.format("Cannot connect to PING PXE server(IP=%1$s, username=%2$s, password=%3$s", _ip, _username, "******"));
        }

        String cmd = String.format("[ -f /%1$s/pxelinux.0 ] && [ -f /%2$s/kernel ] && [ -f /%3$s/initrd.gz ] ", _tftpDir, _tftpDir, _tftpDir);
        if (!SSHCmdHelper.sshExecuteCmd(sshConnection, cmd)) {
            throw new ConfigurationException("Miss files in TFTP directory at " + _tftpDir + " check if pxelinux.0, kernel initrd.gz are here");
        }

        SCPClient scp = new SCPClient(sshConnection);
        String prepareScript = "scripts/network/ping/prepare_tftp_bootfile.py";
        String prepareScriptPath = Script.findScript("", prepareScript);
        if (prepareScriptPath == null) {
            throw new ConfigurationException("Can not find prepare_tftp_bootfile.py at " + prepareScriptPath);
        }
        scp.put(prepareScriptPath, "/usr/bin/", "0755");

        String userDataScript = "scripts/network/ping/baremetal_user_data.py";
        String userDataScriptPath = Script.findScript("", userDataScript);
        if (userDataScriptPath == null) {
            throw new ConfigurationException("Can not find baremetal_user_data.py at " + userDataScriptPath);
        }
        scp.put(userDataScriptPath, "/usr/bin/", "0755");

        return true;
    } catch (Exception e) {
        throw new ConfigurationException(e.getMessage());
    } finally {
        if (sshConnection != null) {
            sshConnection.close();
        }
    }
}
 
开发者ID:apache,项目名称:cloudstack,代码行数:80,代码来源:BaremetalPingPxeResource.java


示例11: configure

import com.trilead.ssh2.SCPClient; //导入依赖的package包/类
@Override
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
    com.trilead.ssh2.Connection sshConnection = null;
    try {
        super.configure(name, params);
        s_logger.debug(String.format("Trying to connect to DHCP server(IP=%1$s, username=%2$s, password=%3$s)", _ip, _username, "******"));
        sshConnection = SSHCmdHelper.acquireAuthorizedConnection(_ip, _username, _password);
        if (sshConnection == null) {
            throw new ConfigurationException(String.format("Cannot connect to DHCP server(IP=%1$s, username=%2$s, password=%3$s", _ip, _username, "******"));
        }

        if (!SSHCmdHelper.sshExecuteCmd(sshConnection, "[ -f '/usr/sbin/dhcpd' ]")) {
            throw new ConfigurationException("Cannot find dhcpd.conf /etc/dhcpd.conf at  on " + _ip);
        }

        SCPClient scp = new SCPClient(sshConnection);

        String editHosts = "scripts/network/exdhcp/dhcpd_edithosts.py";
        String editHostsPath = Script.findScript("", editHosts);
        if (editHostsPath == null) {
            throw new ConfigurationException("Can not find script dnsmasq_edithosts.sh at " + editHosts);
        }
        scp.put(editHostsPath, "/usr/bin/", "0755");

        String prepareDhcpdScript = "scripts/network/exdhcp/prepare_dhcpd.sh";
        String prepareDhcpdScriptPath = Script.findScript("", prepareDhcpdScript);
        if (prepareDhcpdScriptPath == null) {
            throw new ConfigurationException("Can not find prepare_dhcpd.sh at " + prepareDhcpdScriptPath);
        }
        scp.put(prepareDhcpdScriptPath, "/usr/bin/", "0755");

        //TODO: tooooooooooooooo ugly here!!!
        String[] ips = _ip.split("\\.");
        ips[3] = "0";
        StringBuffer buf = new StringBuffer();
        int i;
        for (i = 0; i < ips.length - 1; i++) {
            buf.append(ips[i]).append(".");
        }
        buf.append(ips[i]);
        String subnet = buf.toString();
        String cmd = String.format("sh /usr/bin/prepare_dhcpd.sh %1$s", subnet);
        if (!SSHCmdHelper.sshExecuteCmd(sshConnection, cmd)) {
            throw new ConfigurationException("prepare Dhcpd at " + _ip + " failed, command:" + cmd);
        }

        s_logger.debug("Dhcpd resource configure successfully");
        return true;
    } catch (Exception e) {
        s_logger.debug("Dhcpd resource configure failed", e);
        throw new ConfigurationException(e.getMessage());
    } finally {
        SSHCmdHelper.releaseSshConnection(sshConnection);
    }
}
 
开发者ID:apache,项目名称:cloudstack,代码行数:56,代码来源:BaremetalDhcpdResource.java


示例12: configure

import com.trilead.ssh2.SCPClient; //导入依赖的package包/类
@Override
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
    com.trilead.ssh2.Connection sshConnection = null;
    try {
        super.configure(name, params);
        s_logger.debug(String.format("Trying to connect to DHCP server(IP=%1$s, username=%2$s, password=%3$s)", _ip, _username, _password));
        sshConnection = SSHCmdHelper.acquireAuthorizedConnection(_ip, _username, _password);
        if (sshConnection == null) {
            throw new ConfigurationException(String.format("Cannot connect to DHCP server(IP=%1$s, username=%2$s, password=%3$s", _ip, _username, _password));
        }

        if (!SSHCmdHelper.sshExecuteCmd(sshConnection, "[ -f '/usr/sbin/dnsmasq' ]")) {
            throw new ConfigurationException("Cannot find dnsmasq at /usr/sbin/dnsmasq on " + _ip);
        }

        SCPClient scp = new SCPClient(sshConnection);

        String editHosts = "scripts/network/exdhcp/dnsmasq_edithosts.sh";
        String editHostsPath = Script.findScript("", editHosts);
        if (editHostsPath == null) {
            throw new ConfigurationException("Can not find script dnsmasq_edithosts.sh at " + editHosts);
        }
        scp.put(editHostsPath, "/usr/bin/", "0755");

        String prepareDnsmasq = "scripts/network/exdhcp/prepare_dnsmasq.sh";
        String prepareDnsmasqPath = Script.findScript("", prepareDnsmasq);
        if (prepareDnsmasqPath == null) {
            throw new ConfigurationException("Can not find script prepare_dnsmasq.sh at " + prepareDnsmasq);
        }
        scp.put(prepareDnsmasqPath, "/usr/bin/", "0755");

        /*
        String prepareCmd = String.format("sh /usr/bin/prepare_dnsmasq.sh %1$s %2$s %3$s", _gateway, _dns, _ip);
        if (!SSHCmdHelper.sshExecuteCmd(sshConnection, prepareCmd)) {
            throw new ConfigurationException("prepare dnsmasq at " + _ip + " failed");
        }
        */

        s_logger.debug("Dnsmasq resource configure successfully");
        return true;
    } catch (Exception e) {
        s_logger.debug("Dnsmasq resorce configure failed", e);
        throw new ConfigurationException(e.getMessage());
    } finally {
        SSHCmdHelper.releaseSshConnection(sshConnection);
    }
}
 
开发者ID:apache,项目名称:cloudstack,代码行数:48,代码来源:BaremetalDnsmasqResource.java


示例13: setupServer

import com.trilead.ssh2.SCPClient; //导入依赖的package包/类
protected void setupServer() throws IOException {
    com.trilead.ssh2.Connection sshConnection = new com.trilead.ssh2.Connection(_ip, 22);
    sshConnection.connect(null, 60000, 60000);
    if (!sshConnection.authenticateWithPassword(_username, _password)) {
        throw new CloudRuntimeException("Unable to authenticate");
    }
    SCPClient scp = new SCPClient(sshConnection);

    String configScriptName = "scripts/vm/hypervisor/ovm/configureOvm.sh";
    String configScriptPath = Script.findScript("", configScriptName);
    if (configScriptPath == null) {
        throw new CloudRuntimeException("Unable to find " + configScriptName);
    }
    scp.put(configScriptPath, "/usr/bin/", "0755");

    if (!SSHCmdHelper.sshExecuteCmd(sshConnection, "sh /usr/bin/configureOvm.sh preSetup")) {
        throw new CloudRuntimeException("Execute configureOvm.sh preSetup failed on " + _ip);
    }

    File tmp = new File(configScriptPath);
    File scriptDir = new File(tmp.getParent());
    File[] scripts = scriptDir.listFiles();
    for (int i = 0; i < scripts.length; i++) {
        File script = scripts[i];
        if (script.getName().equals("configureOvm.sh")) {
            continue;
        }

        if (s_logger.isDebugEnabled()) {
            s_logger.debug("Copying " + script.getPath() + " to " + s_ovsAgentPath + " on " + _ip + " with permission 0644");
        }
        scp.put(script.getPath(), s_ovsAgentPath, "0644");
    }

    sshConnection = SSHCmdHelper.acquireAuthorizedConnection(_ip, _username, _password);
    if (sshConnection == null) {
        throw new CloudRuntimeException(String.format("Cannot connect to ovm host(IP=%1$s, username=%2$s, password=%3$s", _ip, _username, _password));
    }

    if (!SSHCmdHelper.sshExecuteCmd(sshConnection, "sh /usr/bin/configureOvm.sh postSetup")) {
        throw new CloudRuntimeException("Execute configureOvm.sh postSetup failed on " + _ip);
    }

}
 
开发者ID:apache,项目名称:cloudstack,代码行数:45,代码来源:OvmResourceBase.java


示例14: setupServer

import com.trilead.ssh2.SCPClient; //导入依赖的package包/类
/**
 * setupServer:
 * Add the cloudstack plugin and setup the agent.
 * Add the ssh keys to the host.
 *
 * @param c
 * @throws IOException
 */
public Boolean setupServer(String key) throws IOException {
    LOGGER.debug("Setup all bits on agent: " + config.getAgentHostname());
    /* version dependent patching ? */
    try {
        com.trilead.ssh2.Connection sshConnection = SSHCmdHelper
                .acquireAuthorizedConnection(config.getAgentIp(),
                        config.getAgentSshUserName(),
                        config.getAgentSshPassword());
        if (sshConnection == null) {
            throw new ConfigurationException(String.format("Unable to "
                    + "connect to server(IP=%1$s, username=%2$s, "
                    + "password=%3$s", config.getAgentIp(),
                    config.getAgentSshUserName(),
                    config.getAgentSshPassword()));
        }
        SCPClient scp = new SCPClient(sshConnection);
        String userDataScriptDir = "scripts/vm/hypervisor/ovm3/";
        String userDataScriptPath = Script.findScript("", userDataScriptDir);
        if (userDataScriptPath == null) {
            throw new ConfigurationException("Can not find "
                    + userDataScriptDir);
        }
        String mkdir = "mkdir -p " + config.getAgentScriptsDir();
        if (!SSHCmdHelper.sshExecuteCmd(sshConnection, mkdir)) {
            throw new ConfigurationException("Failed " + mkdir + " on "
                    + config.getAgentHostname());
        }
        for (String script : config.getAgentScripts()) {
            script = userDataScriptPath + "/" + script;
            scp.put(script, config.getAgentScriptsDir(), "0755");
        }
        String prepareCmd = String.format(config.getAgentScriptsDir() + "/"
                + config.getAgentScript() + " --ssl=" + c.getUseSsl() + " "
                + "--port=" + c.getPort());
        if (!SSHCmdHelper.sshExecuteCmd(sshConnection, prepareCmd)) {
            throw new ConfigurationException("Failed to insert module on "
                    + config.getAgentHostname());
        } else {
            /* because of OVM 3.3.1 (might be 2000) */
            Thread.sleep(5000);
        }
        CloudstackPlugin cSp = new CloudstackPlugin(c);
        cSp.ovsUploadSshKey(config.getAgentSshKeyFileName(),
                FileUtils.readFileToString(getSystemVMKeyFile(key)));
        cSp.dom0CheckStorageHealthCheck(config.getAgentScriptsDir(),
                config.getAgentCheckStorageScript(),
                config.getCsHostGuid(),
                config.getAgentStorageCheckTimeout(),
                config.getAgentStorageCheckInterval());
    } catch (Exception es) {
        LOGGER.error("Unexpected exception ", es);
        String msg = "Unable to install module in agent";
        throw new CloudRuntimeException(msg);
    }
    return true;
}
 
开发者ID:apache,项目名称:cloudstack,代码行数:65,代码来源:Ovm3HypervisorSupport.java


示例15: sendFileToHost

import com.trilead.ssh2.SCPClient; //导入依赖的package包/类
/**
 * Copy a local file to a remote directory, uses mode 0600 when creating the
 * file on the remote side.
 *
 * @param localfilePath
 *            The file that will be sent to the host
 * @param remotePath
 *            Remote target directory. Use an empty string to specify the
 *            default directory.
 * @param address
 *            The Management IP address from machine that will be connected.
 * @throws IOException
 */
public void sendFileToHost(File localfilePath, String remoteFileName, String remotePath, String address) {
    Connection sshConnectionWithHost = getSshConnectionWithHost(address);
    try {
        authenticateSshSessionWithPublicKey(sshConnectionWithHost);
        SCPClient scp = new SCPClient(sshConnectionWithHost);
        scp.put(localfilePath.getAbsolutePath(), remoteFileName, remotePath, "0755");
    } catch (IOException e) {
        logger.error(String.format("Error while sending file [%s] to host [%s]", localfilePath, address), e);
    }
    sshConnectionWithHost.close();
}
 
开发者ID:Autonomiccs,项目名称:autonomiccs-platform,代码行数:25,代码来源:SshUtils.java



注:本文中的com.trilead.ssh2.SCPClient类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java CasUtil类代码示例发布时间:2022-05-23
下一篇:
Java CloseFuture类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap