mirror of https://github.com/apache/cloudstack.git
pass guest OS name instead of guest ID when start system VM
This commit is contained in:
parent
675106d3e5
commit
bca96b1079
|
|
@ -33,14 +33,16 @@ public class StartConsoleProxyCommand extends AbstractStartCommand {
|
|||
private String urlPort;
|
||||
private String mgmt_host;
|
||||
private int mgmt_port;
|
||||
private boolean sslEnabled;
|
||||
private boolean sslEnabled;
|
||||
private String guestOSDescription;
|
||||
|
||||
protected StartConsoleProxyCommand() {
|
||||
}
|
||||
|
||||
public StartConsoleProxyCommand(int networkRateMbps, int networkRateMulticastMbps, int proxyCmdPort,
|
||||
ConsoleProxyVO proxy, String vmName, String storageHost,
|
||||
List<VolumeVO> vols, String vncPort, String urlPort, String mgmtHost, int mgmtPort, boolean sslEnabled) {
|
||||
List<VolumeVO> vols, String vncPort, String urlPort, String mgmtHost, int mgmtPort,
|
||||
boolean sslEnabled, String guestOSDescription) {
|
||||
super(vmName, storageHost, vols);
|
||||
this.networkRateMbps = networkRateMbps;
|
||||
this.networkRateMulticastMbps = networkRateMulticastMbps;
|
||||
|
|
@ -50,7 +52,8 @@ public class StartConsoleProxyCommand extends AbstractStartCommand {
|
|||
this.urlPort = urlPort;
|
||||
this.mgmt_host = mgmtHost;
|
||||
this.mgmt_port = mgmtPort;
|
||||
this.sslEnabled = sslEnabled;
|
||||
this.sslEnabled = sslEnabled;
|
||||
this.guestOSDescription = guestOSDescription;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -66,6 +69,10 @@ public class StartConsoleProxyCommand extends AbstractStartCommand {
|
|||
return networkRateMbps;
|
||||
}
|
||||
|
||||
public String getGuestOSDescription() {
|
||||
return guestOSDescription;
|
||||
}
|
||||
|
||||
public int getNetworkRateMulticastMbps() {
|
||||
return networkRateMulticastMbps;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ public class StartRouterCommand extends AbstractStartCommand {
|
|||
DomainRouterVO router;
|
||||
int networkRateMbps;
|
||||
int networkRateMulticastMbps;
|
||||
private String guestOSDescription;
|
||||
|
||||
protected StartRouterCommand() {
|
||||
super();
|
||||
|
|
@ -41,11 +42,13 @@ public class StartRouterCommand extends AbstractStartCommand {
|
|||
}
|
||||
|
||||
public StartRouterCommand(DomainRouterVO router, int networkRateMbps, int networkRateMulticastMbps,
|
||||
String routerName, String[] storageIps, List<VolumeVO> vols, boolean mirroredVols) {
|
||||
String routerName, String[] storageIps, List<VolumeVO> vols, boolean mirroredVols,
|
||||
String guestOSDescription ) {
|
||||
super(routerName, storageIps, vols, mirroredVols);
|
||||
this.router = router;
|
||||
this.networkRateMbps = networkRateMbps;
|
||||
this.networkRateMulticastMbps = networkRateMulticastMbps;
|
||||
this.guestOSDescription = guestOSDescription;
|
||||
}
|
||||
|
||||
public DomainRouter getRouter() {
|
||||
|
|
@ -56,6 +59,10 @@ public class StartRouterCommand extends AbstractStartCommand {
|
|||
return networkRateMbps;
|
||||
}
|
||||
|
||||
public String getGuestOSDescription() {
|
||||
return guestOSDescription;
|
||||
}
|
||||
|
||||
public int getNetworkRateMulticastMbps() {
|
||||
return networkRateMulticastMbps;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,14 +33,15 @@ public class StartSecStorageVmCommand extends AbstractStartCommand {
|
|||
private int proxyCmdPort;
|
||||
private String mgmt_host;
|
||||
private int mgmt_port;
|
||||
private boolean sslCopy;
|
||||
private boolean sslCopy;
|
||||
private String guestOSDescription;
|
||||
|
||||
protected StartSecStorageVmCommand() {
|
||||
}
|
||||
|
||||
public StartSecStorageVmCommand(int networkRateMbps, int networkRateMulticastMbps, int proxyCmdPort,
|
||||
SecondaryStorageVmVO secStorageVm, String vmName, String storageHost,
|
||||
List<VolumeVO> vols, String mgmtHost, int mgmtPort, boolean sslCopy) {
|
||||
List<VolumeVO> vols, String mgmtHost, int mgmtPort, boolean sslCopy, String guestOSDescription) {
|
||||
super(vmName, storageHost, vols);
|
||||
this.networkRateMbps = networkRateMbps;
|
||||
this.networkRateMulticastMbps = networkRateMulticastMbps;
|
||||
|
|
@ -49,7 +50,8 @@ public class StartSecStorageVmCommand extends AbstractStartCommand {
|
|||
|
||||
this.mgmt_host = mgmtHost;
|
||||
this.mgmt_port = mgmtPort;
|
||||
this.sslCopy = sslCopy;
|
||||
this.sslCopy = sslCopy;
|
||||
this.guestOSDescription = guestOSDescription;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -65,6 +67,10 @@ public class StartSecStorageVmCommand extends AbstractStartCommand {
|
|||
return networkRateMbps;
|
||||
}
|
||||
|
||||
public String getGuestOSDescription() {
|
||||
return guestOSDescription;
|
||||
}
|
||||
|
||||
public int getNetworkRateMulticastMbps() {
|
||||
return networkRateMulticastMbps;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1118,7 +1118,7 @@ public abstract class CitrixResourceBase implements StoragePoolResource, ServerR
|
|||
bootArgs += " pod=" + _pod;
|
||||
bootArgs += " localgw=" + _localGateway;
|
||||
String result = startSystemVM(vmName, storage.getVlanId(), network, cmd.getVolumes(), bootArgs, storage.getGuestMacAddress(), storage.getGuestIpAddress(), storage
|
||||
.getPrivateMacAddress(), storage.getPublicMacAddress(), cmd.getProxyCmdPort(), storage.getRamSize(), storage.getGuestOSId(), cmd.getNetworkRateMbps());
|
||||
.getPrivateMacAddress(), storage.getPublicMacAddress(), cmd.getProxyCmdPort(), storage.getRamSize(), cmd.getGuestOSDescription(), cmd.getNetworkRateMbps());
|
||||
if (result == null) {
|
||||
return new StartSecStorageVmAnswer(cmd);
|
||||
}
|
||||
|
|
@ -3103,7 +3103,7 @@ public abstract class CitrixResourceBase implements StoragePoolResource, ServerR
|
|||
String bootArgs = cmd.getBootArgs();
|
||||
|
||||
String result = startSystemVM(vmName, router.getVlanId(), network, cmd.getVolumes(), bootArgs, router.getGuestMacAddress(), router.getPrivateIpAddress(), router
|
||||
.getPrivateMacAddress(), router.getPublicMacAddress(), 3922, router.getRamSize(), router.getGuestOSId(), cmd.getNetworkRateMbps());
|
||||
.getPrivateMacAddress(), router.getPublicMacAddress(), 3922, router.getRamSize(), cmd.getGuestOSDescription(), cmd.getNetworkRateMbps());
|
||||
if (result == null) {
|
||||
networkUsage(router.getPrivateIpAddress(), "create", null);
|
||||
return new StartRouterAnswer(cmd);
|
||||
|
|
@ -3118,7 +3118,7 @@ public abstract class CitrixResourceBase implements StoragePoolResource, ServerR
|
|||
}
|
||||
|
||||
protected String startSystemVM(String vmName, String vlanId, Network nw0, List<VolumeVO> vols, String bootArgs, String guestMacAddr, String privateIp, String privateMacAddr,
|
||||
String publicMacAddr, int cmdPort, long ramSize, long guestOsId, int networkRateMbps) {
|
||||
String publicMacAddr, int cmdPort, long ramSize, String getGuestOSDescription, int networkRateMbps) {
|
||||
|
||||
setupLinkLocalNetwork();
|
||||
VM vm = null;
|
||||
|
|
@ -3136,9 +3136,9 @@ public abstract class CitrixResourceBase implements StoragePoolResource, ServerR
|
|||
|
||||
Ternary<SR, VDI, VolumeVO> mount = mounts.get(0);
|
||||
|
||||
Set<VM> templates = VM.getByNameLabel(conn, CitrixHelper.getGuestOsType(guestOsId));
|
||||
Set<VM> templates = VM.getByNameLabel(conn, getGuestOsType(getGuestOSDescription));
|
||||
if (templates.size() == 0) {
|
||||
String msg = " can not find systemvm template " + CitrixHelper.getGuestOsType(guestOsId) ;
|
||||
String msg = " can not find systemvm template " + getGuestOsType(getGuestOSDescription) ;
|
||||
s_logger.warn(msg);
|
||||
return msg;
|
||||
|
||||
|
|
@ -3293,7 +3293,7 @@ public abstract class CitrixResourceBase implements StoragePoolResource, ServerR
|
|||
bootArgs += " localgw=" + _localGateway;
|
||||
|
||||
String result = startSystemVM(vmName, proxy.getVlanId(), network, cmd.getVolumes(), bootArgs, proxy.getGuestMacAddress(), proxy.getGuestIpAddress(), proxy
|
||||
.getPrivateMacAddress(), proxy.getPublicMacAddress(), cmd.getProxyCmdPort(), proxy.getRamSize(), proxy.getGuestOSId(), cmd.getNetworkRateMbps());
|
||||
.getPrivateMacAddress(), proxy.getPublicMacAddress(), cmd.getProxyCmdPort(), proxy.getRamSize(), cmd.getGuestOSDescription(), cmd.getNetworkRateMbps());
|
||||
if (result == null) {
|
||||
return new StartConsoleProxyAnswer(cmd);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -107,12 +107,14 @@ import com.cloud.offerings.NetworkOfferingVO;
|
|||
import com.cloud.offerings.dao.NetworkOfferingDao;
|
||||
import com.cloud.service.ServiceOfferingVO;
|
||||
import com.cloud.service.dao.ServiceOfferingDao;
|
||||
import com.cloud.storage.GuestOSVO;
|
||||
import com.cloud.storage.StorageManager;
|
||||
import com.cloud.storage.StoragePoolVO;
|
||||
import com.cloud.storage.VMTemplateHostVO;
|
||||
import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
|
||||
import com.cloud.storage.VMTemplateVO;
|
||||
import com.cloud.storage.VolumeVO;
|
||||
import com.cloud.storage.dao.GuestOSDao;
|
||||
import com.cloud.storage.dao.VMTemplateDao;
|
||||
import com.cloud.storage.dao.VMTemplateHostDao;
|
||||
import com.cloud.storage.dao.VolumeDao;
|
||||
|
|
@ -218,24 +220,16 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, VirtualMach
|
|||
@Inject
|
||||
private AccountDao _accountDao;
|
||||
|
||||
@Inject
|
||||
private VMTemplateHostDao _vmTemplateHostDao;
|
||||
|
||||
@Inject
|
||||
private AgentManager _agentMgr;
|
||||
@Inject
|
||||
private StorageManager _storageMgr;
|
||||
@Inject
|
||||
private HighAvailabilityManager _haMgr;
|
||||
@Inject private VMTemplateHostDao _vmTemplateHostDao;
|
||||
@Inject private AgentManager _agentMgr;
|
||||
@Inject private StorageManager _storageMgr;
|
||||
@Inject private HighAvailabilityManager _haMgr;
|
||||
@Inject NetworkManager _networkMgr;
|
||||
|
||||
@Inject AccountManager _accountMgr;
|
||||
@Inject
|
||||
private EventDao _eventDao;
|
||||
@Inject
|
||||
ServiceOfferingDao _offeringDao;
|
||||
@Inject
|
||||
NetworkOfferingDao _networkOfferingDao;
|
||||
@Inject private EventDao _eventDao;
|
||||
@Inject GuestOSDao _guestOSDao = null;
|
||||
@Inject ServiceOfferingDao _offeringDao;
|
||||
@Inject NetworkOfferingDao _networkOfferingDao;
|
||||
private IpAddrAllocator _IpAllocator;
|
||||
|
||||
private ConsoleProxyListener _listener;
|
||||
|
|
@ -651,13 +645,24 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, VirtualMach
|
|||
throw new CloudRuntimeException(msg);
|
||||
}
|
||||
|
||||
// Determine the VM's OS description
|
||||
String guestOSDescription;
|
||||
GuestOSVO guestOS = _guestOSDao.findById(proxy.getGuestOSId());
|
||||
if (guestOS == null) {
|
||||
String msg = "Could not find guest OS description for OSId "
|
||||
+ proxy.getGuestOSId() + " for vm: " + proxy.getName();
|
||||
s_logger.debug(msg);
|
||||
throw new CloudRuntimeException(msg);
|
||||
} else {
|
||||
guestOSDescription = guestOS.getName();
|
||||
}
|
||||
// _storageMgr.share(proxy, vols, null, true);
|
||||
|
||||
// carry the console proxy port info over so that we don't
|
||||
// need to configure agent on this
|
||||
StartConsoleProxyCommand cmdStart = new StartConsoleProxyCommand(_networkRate, _multicastRate,
|
||||
_proxyCmdPort, proxy, proxy.getName(), "", vols, Integer.toString(_consoleProxyPort),
|
||||
Integer.toString(_consoleProxyUrlPort), _mgmt_host, _mgmt_port, _sslEnabled);
|
||||
Integer.toString(_consoleProxyUrlPort), _mgmt_host, _mgmt_port, _sslEnabled, guestOSDescription);
|
||||
if (s_logger.isDebugEnabled())
|
||||
s_logger.debug("Sending start command for console proxy " + proxy.getName() + " to " + routingHost.getName());
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -120,11 +120,13 @@ import com.cloud.resource.Resource;
|
|||
import com.cloud.resource.Resource.ReservationStrategy;
|
||||
import com.cloud.service.ServiceOfferingVO;
|
||||
import com.cloud.service.dao.ServiceOfferingDao;
|
||||
import com.cloud.storage.GuestOSVO;
|
||||
import com.cloud.storage.StorageManager;
|
||||
import com.cloud.storage.StoragePoolVO;
|
||||
import com.cloud.storage.VMTemplateVO;
|
||||
import com.cloud.storage.VolumeVO;
|
||||
import com.cloud.storage.dao.DiskTemplateDao;
|
||||
import com.cloud.storage.dao.GuestOSDao;
|
||||
import com.cloud.storage.dao.StoragePoolDao;
|
||||
import com.cloud.storage.dao.VMTemplateDao;
|
||||
import com.cloud.storage.dao.VMTemplateHostDao;
|
||||
|
|
@ -212,6 +214,7 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager
|
|||
@Inject NetworkOfferingDao _networkOfferingDao = null;
|
||||
@Inject NetworkConfigurationDao _networkProfileDao = null;
|
||||
@Inject NicDao _nicDao;
|
||||
@Inject GuestOSDao _guestOSDao = null;
|
||||
|
||||
@Inject(adapter=NetworkGuru.class)
|
||||
Adapters<NetworkGuru> _networkGurus;
|
||||
|
|
@ -984,8 +987,21 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager
|
|||
|
||||
try {
|
||||
String[] storageIps = new String[2];
|
||||
|
||||
// Determine the VM's OS description
|
||||
String guestOSDescription;
|
||||
GuestOSVO guestOS = _guestOSDao.findById(router.getGuestOSId());
|
||||
if (guestOS == null) {
|
||||
String msg = "Could not find guest OS description for OSId "
|
||||
+ router.getGuestOSId() + " for vm: " + router.getName();
|
||||
s_logger.debug(msg);
|
||||
throw new CloudRuntimeException(msg);
|
||||
} else {
|
||||
guestOSDescription = guestOS.getName();
|
||||
}
|
||||
|
||||
final StartRouterCommand cmdStartRouter = new StartRouterCommand(router, _networkRate,
|
||||
_multicastRate, name, storageIps, vols, mirroredVols);
|
||||
_multicastRate, name, storageIps, vols, mirroredVols, guestOSDescription);
|
||||
answer = _agentMgr.send(routingHost.getId(), cmdStartRouter);
|
||||
if (answer != null && answer.getResult()) {
|
||||
if (answer instanceof StartRouterAnswer){
|
||||
|
|
|
|||
|
|
@ -89,12 +89,14 @@ import com.cloud.network.dao.IPAddressDao;
|
|||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.service.ServiceOfferingVO;
|
||||
import com.cloud.service.dao.ServiceOfferingDao;
|
||||
import com.cloud.storage.GuestOSVO;
|
||||
import com.cloud.storage.StorageManager;
|
||||
import com.cloud.storage.StoragePoolVO;
|
||||
import com.cloud.storage.VMTemplateHostVO;
|
||||
import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
|
||||
import com.cloud.storage.VMTemplateVO;
|
||||
import com.cloud.storage.VolumeVO;
|
||||
import com.cloud.storage.dao.GuestOSDao;
|
||||
import com.cloud.storage.dao.StoragePoolDao;
|
||||
import com.cloud.storage.dao.StoragePoolHostDao;
|
||||
import com.cloud.storage.dao.VMTemplateDao;
|
||||
|
|
@ -205,6 +207,7 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
|
|||
@Inject private EventDao _eventDao;
|
||||
@Inject private ServiceOfferingDao _offeringDao;
|
||||
@Inject private AccountManager _accountMgr;
|
||||
@Inject GuestOSDao _guestOSDao = null;
|
||||
|
||||
private IpAddrAllocator _IpAllocator;
|
||||
|
||||
|
|
@ -373,11 +376,23 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
|
|||
}
|
||||
VolumeVO vol = vols.get(0);
|
||||
|
||||
// Determine the VM's OS description
|
||||
String guestOSDescription;
|
||||
GuestOSVO guestOS = _guestOSDao.findById(secStorageVm.getGuestOSId());
|
||||
if (guestOS == null) {
|
||||
String msg = "Could not find guest OS description for OSId "
|
||||
+ secStorageVm.getGuestOSId() + " for vm: " + secStorageVm.getName();
|
||||
s_logger.debug(msg);
|
||||
throw new CloudRuntimeException(msg);
|
||||
} else {
|
||||
guestOSDescription = guestOS.getName();
|
||||
}
|
||||
|
||||
// carry the secondary storage vm port info over so that we don't
|
||||
// need to configure agent on this
|
||||
StartSecStorageVmCommand cmdStart = new StartSecStorageVmCommand(_networkRate,
|
||||
_multicastRate, _secStorageVmCmdPort, secStorageVm,
|
||||
secStorageVm.getName(), "", vols, _mgmt_host, _mgmt_port, _useSSlCopy);
|
||||
secStorageVm.getName(), "", vols, _mgmt_host, _mgmt_port, _useSSlCopy, guestOSDescription);
|
||||
|
||||
if (s_logger.isDebugEnabled())
|
||||
s_logger.debug("Sending start command for secondary storage vm "
|
||||
|
|
|
|||
|
|
@ -678,14 +678,12 @@ public class UserVmManagerImpl implements UserVmManager {
|
|||
String guestOSDescription;
|
||||
GuestOSVO guestOS = _guestOSDao.findById(vm.getGuestOSId());
|
||||
if (guestOS == null) {
|
||||
String description = "Could not find guest OS description for vm: " + vm.getName();
|
||||
s_logger.debug(description);
|
||||
event.setDescription(description);
|
||||
event.setLevel(EventVO.LEVEL_ERROR);
|
||||
_eventDao.persist(event);
|
||||
return null;
|
||||
String msg = "Could not find guest OS description for OSId "
|
||||
+ vm.getGuestOSId() + " for vm: " + vm.getName();
|
||||
s_logger.debug(msg);
|
||||
throw new CloudRuntimeException(msg);
|
||||
} else {
|
||||
guestOSDescription = guestOS.getName();
|
||||
guestOSDescription = guestOS.getName();
|
||||
}
|
||||
|
||||
HashSet<Host> avoid = new HashSet<Host>();
|
||||
|
|
|
|||
Loading…
Reference in New Issue