send ssh key to kvm host, even if it's developer env

This commit is contained in:
Edison Su 2012-05-16 14:40:14 -07:00
parent 5320828387
commit a10a07c09e
3 changed files with 25 additions and 8 deletions

View File

@ -305,10 +305,12 @@ public class LibvirtVMDef {
return devicesBuilder.toString();
}
@SuppressWarnings("unchecked")
public List<DiskDef> getDisks() {
return (List<DiskDef>) devices.get(DiskDef.class.toString());
}
@SuppressWarnings("unchecked")
public List<InterfaceDef> getInterfaces() {
return (List<InterfaceDef>) devices.get(InterfaceDef.class
.toString());

View File

@ -76,9 +76,8 @@ public class SshKeysDistriMonitor implements Listener {
((StartupRoutingCommand) cmd).getHypervisorType() == HypervisorType.XenServer) {
/*TODO: Get the private/public keys here*/
Map<String, String> configs = _configDao.getConfiguration("management-server", new HashMap<String, Object>());
String pubKey = configs.get("ssh.publickey");
String prvKey = configs.get("ssh.privatekey");
String pubKey = _configDao.getValue("ssh.publickey");
String prvKey = _configDao.getValue("ssh.privatekey");
try {
ModifySshKeysCommand cmds = new ModifySshKeysCommand(pubKey, prvKey);

View File

@ -577,14 +577,24 @@ public class ConfigurationServerImpl implements ConfigurationServer {
// Grab the SSH key pair and insert it into the database, if it is not present
String userid = System.getProperty("user.name");
if (!userid.startsWith("cloud")) {
Boolean devel = Boolean.valueOf(_configDao.getValue("developer"));
if (!userid.startsWith("cloud") && !devel) {
return;
}
String already = _configDao.getValue("ssh.privatekey");
String homeDir = Script.runSimpleBashScript("echo ~cloud");
if (homeDir == null) {
throw new CloudRuntimeException("Cannot get home directory for account: cloud");
String homeDir = null;
if (devel) {
homeDir = Script.runSimpleBashScript("echo ~");
if (homeDir == null) {
throw new CloudRuntimeException("Cannot get home directory for account: cloud");
}
} else {
homeDir = Script.runSimpleBashScript("echo ~cloud");
if (homeDir == null) {
throw new CloudRuntimeException("Cannot get home directory for account: cloud");
}
}
if (s_logger.isInfoEnabled()) {
s_logger.info("Processing updateKeyPairs");
}
@ -660,7 +670,13 @@ public class ConfigurationServerImpl implements ConfigurationServer {
}
}
s_logger.info("Going to update systemvm iso with generated keypairs if needed");
injectSshKeysIntoSystemVmIsoPatch(pubkeyfile.getAbsolutePath(), privkeyfile.getAbsolutePath());
try {
injectSshKeysIntoSystemVmIsoPatch(pubkeyfile.getAbsolutePath(), privkeyfile.getAbsolutePath());
} catch (CloudRuntimeException e) {
if (!devel) {
throw new CloudRuntimeException(e.getMessage());
}
}
}
private void writeKeyToDisk(String key, String keyPath) {