private boolean preparePxeInAdvancedZone( VirtualMachineProfile profile, NicProfile nic, Network network, DeployDestination dest, ReservationContext context) throws Exception { DomainRouterVO vr = getVirtualRouter(network); List<NicVO> nics = _nicDao.listByVmId(vr.getId()); NicVO mgmtNic = null; for (NicVO nicvo : nics) { if (ControlNetworkGuru.class.getSimpleName().equals(nicvo.getReserver())) { mgmtNic = nicvo; break; } } if (mgmtNic == null) { throw new CloudRuntimeException( String.format("cannot find management nic on virtual router[id:%s]", vr.getId())); } String internalServerIp = _configDao.getValue(Config.BaremetalInternalStorageServer.key()); if (internalServerIp == null) { throw new CloudRuntimeException( String.format( "please specify 'baremetal.internal.storage.server.ip', which is the http server/nfs server storing kickstart files and ISO files, in global setting")); } List<String> tuple = parseKickstartUrl(profile); String cmd = String.format( "/usr/bin/prepare_pxe.sh %s %s %s %s %s %s", tuple.get(1), tuple.get(2), profile.getTemplate().getUuid(), String.format("01-%s", nic.getMacAddress().replaceAll(":", "-")).toLowerCase(), tuple.get(0), nic.getMacAddress().toLowerCase()); s_logger.debug( String.format( "prepare pxe on virtual router[ip:%s], cmd: %s", mgmtNic.getIp4Address(), cmd)); Pair<Boolean, String> ret = SshHelper.sshExecute( mgmtNic.getIp4Address(), 3922, "root", getSystemVMKeyFile(), null, cmd); if (!ret.first()) { throw new CloudRuntimeException( String.format( "failed preparing PXE in virtual router[id:%s], because %s", vr.getId(), ret.second())); } // String internalServerIp = "10.223.110.231"; cmd = String.format( "/usr/bin/baremetal_snat.sh %s %s %s", mgmtNic.getIp4Address(), internalServerIp, mgmtNic.getGateway()); s_logger.debug( String.format( "prepare SNAT on virtual router[ip:%s], cmd: %s", mgmtNic.getIp4Address(), cmd)); ret = SshHelper.sshExecute( mgmtNic.getIp4Address(), 3922, "root", getSystemVMKeyFile(), null, cmd); if (!ret.first()) { throw new CloudRuntimeException( String.format( "failed preparing PXE in virtual router[id:%s], because %s", vr.getId(), ret.second())); } return true; }