use of com.cloud.storage.VMTemplateVO in project cloudstack by apache.
the class ResourceManagerImpl method getDefaultHypervisor.
@Override
public HypervisorType getDefaultHypervisor(final long zoneId) {
HypervisorType defaultHyper = HypervisorType.None;
if (_defaultSystemVMHypervisor != HypervisorType.None) {
defaultHyper = _defaultSystemVMHypervisor;
}
final DataCenterVO dc = _dcDao.findById(zoneId);
if (dc == null) {
return HypervisorType.None;
}
_dcDao.loadDetails(dc);
final String defaultHypervisorInZone = dc.getDetail("defaultSystemVMHypervisorType");
if (defaultHypervisorInZone != null) {
defaultHyper = HypervisorType.getType(defaultHypervisorInZone);
}
final List<VMTemplateVO> systemTemplates = _templateDao.listAllSystemVMTemplates();
boolean isValid = false;
for (final VMTemplateVO template : systemTemplates) {
if (template.getHypervisorType() == defaultHyper) {
isValid = true;
break;
}
}
if (isValid) {
final List<ClusterVO> clusters = _clusterDao.listByDcHyType(zoneId, defaultHyper.toString());
if (clusters.size() <= 0) {
isValid = false;
}
}
if (isValid) {
return defaultHyper;
} else {
return HypervisorType.None;
}
}
use of com.cloud.storage.VMTemplateVO in project cloudstack by apache.
the class BasicNetworkVisitor method visit.
@Override
public boolean visit(final SshKeyToRouterRules sshkey) throws ResourceUnavailableException {
final VirtualRouter router = sshkey.getRouter();
final VirtualMachineProfile profile = sshkey.getProfile();
final String sshKeystr = sshkey.getSshPublicKey();
final UserVmVO userVM = sshkey.getUserVM();
final Commands commands = new Commands(Command.OnError.Stop);
final NicVO nicVo = sshkey.getNicVo();
final VMTemplateVO template = sshkey.getTemplate();
if (template != null && template.getEnablePassword()) {
_commandSetupHelper.createPasswordCommand(router, profile, nicVo, commands);
}
_commandSetupHelper.createVmDataCommand(router, userVM, nicVo, sshKeystr, commands);
return _networkGeneralHelper.sendCommandsToRouter(router, commands);
}
use of com.cloud.storage.VMTemplateVO in project cloudstack by apache.
the class VmwareServerDiscoverer method createVmwareToolsIso.
private void createVmwareToolsIso() {
String isoName = "vmware-tools.iso";
VMTemplateVO tmplt = _tmpltDao.findByTemplateName(isoName);
Long id;
if (tmplt == null) {
id = _tmpltDao.getNextInSequence(Long.class, "id");
VMTemplateVO template = VMTemplateVO.createPreHostIso(id, isoName, isoName, ImageFormat.ISO, true, true, TemplateType.PERHOST, null, null, true, 64, Account.ACCOUNT_ID_SYSTEM, null, "VMware Tools Installer ISO", false, 1, false, HypervisorType.VMware);
_tmpltDao.persist(template);
} else {
id = tmplt.getId();
tmplt.setTemplateType(TemplateType.PERHOST);
tmplt.setUrl(null);
_tmpltDao.update(id, tmplt);
}
}
use of com.cloud.storage.VMTemplateVO in project cloudstack by apache.
the class ApiResponseHelper method createSystemVmResponse.
@Override
public SystemVmResponse createSystemVmResponse(VirtualMachine vm) {
SystemVmResponse vmResponse = new SystemVmResponse();
if (vm.getType() == Type.SecondaryStorageVm || vm.getType() == Type.ConsoleProxy || vm.getType() == Type.DomainRouter) {
// SystemVm vm = (SystemVm) systemVM;
vmResponse.setId(vm.getUuid());
// vmResponse.setObjectId(vm.getId());
vmResponse.setSystemVmType(vm.getType().toString().toLowerCase());
vmResponse.setName(vm.getHostName());
if (vm.getPodIdToDeployIn() != null) {
HostPodVO pod = ApiDBUtils.findPodById(vm.getPodIdToDeployIn());
if (pod != null) {
vmResponse.setPodId(pod.getUuid());
}
}
VMTemplateVO template = ApiDBUtils.findTemplateById(vm.getTemplateId());
if (template != null) {
vmResponse.setTemplateId(template.getUuid());
}
vmResponse.setCreated(vm.getCreated());
if (vm.getHostId() != null) {
Host host = ApiDBUtils.findHostById(vm.getHostId());
if (host != null) {
vmResponse.setHostId(host.getUuid());
vmResponse.setHostName(host.getName());
vmResponse.setHypervisor(host.getHypervisorType().toString());
}
}
if (vm.getState() != null) {
vmResponse.setState(vm.getState().toString());
}
// for console proxies, add the active sessions
if (vm.getType() == Type.ConsoleProxy) {
ConsoleProxyVO proxy = ApiDBUtils.findConsoleProxy(vm.getId());
// proxy can be already destroyed
if (proxy != null) {
vmResponse.setActiveViewerSessions(proxy.getActiveSession());
}
}
DataCenter zone = ApiDBUtils.findZoneById(vm.getDataCenterId());
if (zone != null) {
vmResponse.setZoneId(zone.getUuid());
vmResponse.setZoneName(zone.getName());
vmResponse.setDns1(zone.getDns1());
vmResponse.setDns2(zone.getDns2());
}
List<NicProfile> nicProfiles = ApiDBUtils.getNics(vm);
for (NicProfile singleNicProfile : nicProfiles) {
Network network = ApiDBUtils.findNetworkById(singleNicProfile.getNetworkId());
if (network != null) {
if (network.getTrafficType() == TrafficType.Management) {
vmResponse.setPrivateIp(singleNicProfile.getIPv4Address());
vmResponse.setPrivateMacAddress(singleNicProfile.getMacAddress());
vmResponse.setPrivateNetmask(singleNicProfile.getIPv4Netmask());
} else if (network.getTrafficType() == TrafficType.Control) {
vmResponse.setLinkLocalIp(singleNicProfile.getIPv4Address());
vmResponse.setLinkLocalMacAddress(singleNicProfile.getMacAddress());
vmResponse.setLinkLocalNetmask(singleNicProfile.getIPv4Netmask());
} else if (network.getTrafficType() == TrafficType.Public) {
vmResponse.setPublicIp(singleNicProfile.getIPv4Address());
vmResponse.setPublicMacAddress(singleNicProfile.getMacAddress());
vmResponse.setPublicNetmask(singleNicProfile.getIPv4Netmask());
vmResponse.setGateway(singleNicProfile.getIPv4Gateway());
} else if (network.getTrafficType() == TrafficType.Guest) {
/*
* In basic zone, public ip has TrafficType.Guest in case EIP service is not enabled.
* When EIP service is enabled in the basic zone, system VM by default get the public
* IP allocated for EIP. So return the guest/public IP accordingly.
* */
NetworkOffering networkOffering = ApiDBUtils.findNetworkOfferingById(network.getNetworkOfferingId());
if (networkOffering.getElasticIp()) {
IpAddress ip = ApiDBUtils.findIpByAssociatedVmId(vm.getId());
if (ip != null) {
Vlan vlan = ApiDBUtils.findVlanById(ip.getVlanId());
vmResponse.setPublicIp(ip.getAddress().addr());
vmResponse.setPublicNetmask(vlan.getVlanNetmask());
vmResponse.setGateway(vlan.getVlanGateway());
}
} else {
vmResponse.setPublicIp(singleNicProfile.getIPv4Address());
vmResponse.setPublicMacAddress(singleNicProfile.getMacAddress());
vmResponse.setPublicNetmask(singleNicProfile.getIPv4Netmask());
vmResponse.setGateway(singleNicProfile.getIPv4Gateway());
}
}
}
}
}
vmResponse.setObjectName("systemvm");
return vmResponse;
}
use of com.cloud.storage.VMTemplateVO in project cloudstack by apache.
the class ApiResponseHelper method createExtractResponse.
@Override
public ExtractResponse createExtractResponse(Long uploadId, Long id, Long zoneId, Long accountId, String mode, String url) {
ExtractResponse response = new ExtractResponse();
response.setObjectName("template");
VMTemplateVO template = ApiDBUtils.findTemplateById(id);
response.setId(template.getUuid());
response.setName(template.getName());
if (zoneId != null) {
DataCenter zone = ApiDBUtils.findZoneById(zoneId);
response.setZoneId(zone.getUuid());
response.setZoneName(zone.getName());
}
response.setMode(mode);
if (uploadId == null) {
// region-wide image store
response.setUrl(url);
response.setState(Upload.Status.DOWNLOAD_URL_CREATED.toString());
} else {
UploadVO uploadInfo = ApiDBUtils.findUploadById(uploadId);
response.setUploadId(uploadInfo.getUuid());
response.setState(uploadInfo.getUploadState().toString());
response.setUrl(uploadInfo.getUploadUrl());
}
Account account = ApiDBUtils.findAccountById(accountId);
response.setAccountId(account.getUuid());
return response;
}
Aggregations