String msg = "must specify pod Id when add host";
s_logger.debug(msg);
throw new CloudRuntimeException(msg);
}
ClusterVO cluster = _clusterDao.findById(clusterId);
if (cluster == null || (cluster.getHypervisorType() != HypervisorType.Ovm)) {
if (s_logger.isInfoEnabled())
s_logger.info("invalid cluster id or cluster is not for Ovm hypervisors");
return null;
}
String agentUsername = _params.get("agentusername");
if (agentUsername == null) {
throw new CloudRuntimeException("Agent user name must be specified");
}
String agentPassword = _params.get("agentpassword");
if (agentPassword == null) {
throw new CloudRuntimeException("Agent password must be specified");
}
try {
String hostname = url.getHost();
InetAddress ia = InetAddress.getByName(hostname);
String hostIp = ia.getHostAddress();
String guid = UUID.nameUUIDFromBytes(hostIp.getBytes()).toString();
if (checkIfExisted(guid)) {
throw new CloudRuntimeException("The host " + hostIp + " has been added before");
}
s_logger.debug("Ovm discover is going to disover host having guid " + guid);
ClusterVO clu = _clusterDao.findById(clusterId);
if (clu.getGuid() == null) {
clu.setGuid(UUID.randomUUID().toString());
_clusterDao.update(clusterId, clu);
}
com.trilead.ssh2.Connection sshConnection = new com.trilead.ssh2.Connection(hostIp, 22);
sshConnection.connect(null, 60000, 60000);