use of com.cloud.storage.GuestOSVO in project cloudstack by apache.
the class TemplateManagerImpl method prepareIsoForVmProfile.
@Override
public void prepareIsoForVmProfile(VirtualMachineProfile profile) {
UserVmVO vm = _userVmDao.findById(profile.getId());
if (vm.getIsoId() != null) {
TemplateInfo template = prepareIso(vm.getIsoId(), vm.getDataCenterId());
if (template == null) {
s_logger.error("Failed to prepare ISO on secondary or cache storage");
throw new CloudRuntimeException("Failed to prepare ISO on secondary or cache storage");
}
if (template.isBootable()) {
profile.setBootLoaderType(BootloaderType.CD);
}
GuestOSVO guestOS = _guestOSDao.findById(template.getGuestOSId());
String displayName = null;
if (guestOS != null) {
displayName = guestOS.getDisplayName();
}
TemplateObjectTO iso = (TemplateObjectTO) template.getTO();
iso.setGuestOsType(displayName);
DiskTO disk = new DiskTO(iso, 3L, null, Volume.Type.ISO);
profile.addDisk(disk);
} else {
TemplateObjectTO iso = new TemplateObjectTO();
iso.setFormat(ImageFormat.ISO);
DiskTO disk = new DiskTO(iso, 3L, null, Volume.Type.ISO);
profile.addDisk(disk);
}
}
use of com.cloud.storage.GuestOSVO in project cloudstack by apache.
the class Ovm3HypervisorGuru method implement.
@Override
public VirtualMachineTO implement(VirtualMachineProfile vm) {
VirtualMachineTO to = toVirtualMachineTO(vm);
to.setBootloader(vm.getBootLoaderType());
GuestOSVO guestOS = guestOsDao.findById(vm.getVirtualMachine().getGuestOSId());
to.setOs(guestOS.getDisplayName());
return to;
}
use of com.cloud.storage.GuestOSVO in project cloudstack by apache.
the class OvmGuru method implement.
@Override
public VirtualMachineTO implement(VirtualMachineProfile vm) {
VirtualMachineTO to = toVirtualMachineTO(vm);
to.setBootloader(vm.getBootLoaderType());
// Determine the VM's OS description
GuestOSVO guestOS = _guestOsDao.findById(vm.getVirtualMachine().getGuestOSId());
to.setOs(guestOS.getDisplayName());
return to;
}
use of com.cloud.storage.GuestOSVO in project cloudstack by apache.
the class ManagementServerImpl method updateGuestOs.
@Override
@DB
@ActionEvent(eventType = EventTypes.EVENT_GUEST_OS_UPDATE, eventDescription = "updating guest OS type", async = true)
public GuestOS updateGuestOs(final UpdateGuestOsCmd cmd) {
final Long id = cmd.getId();
final String displayName = cmd.getOsDisplayName();
//check if guest OS exists
final GuestOS guestOsHandle = ApiDBUtils.findGuestOSById(id);
if (guestOsHandle == null) {
throw new InvalidParameterValueException("Guest OS not found. Please specify a valid ID for the Guest OS");
}
if (!guestOsHandle.getIsUserDefined()) {
throw new InvalidParameterValueException("Unable to modify system defined guest OS");
}
if (cmd.getDetails() != null && !cmd.getDetails().isEmpty()) {
Map<String, String> detailsMap = cmd.getDetails();
for (Object key : detailsMap.keySet()) {
_guestOsDetailsDao.addDetail(id, (String) key, detailsMap.get((String) key), false);
}
}
//Check if update is needed
if (displayName.equals(guestOsHandle.getDisplayName())) {
return guestOsHandle;
}
//Check if another Guest OS by same name exists
final GuestOS duplicate = ApiDBUtils.findGuestOSByDisplayName(displayName);
if (duplicate != null) {
throw new InvalidParameterValueException("The specified Guest OS name : " + displayName + " already exists. Please specify a unique guest OS name");
}
final GuestOSVO guestOs = _guestOSDao.createForUpdate(id);
guestOs.setDisplayName(displayName);
if (_guestOSDao.update(id, guestOs)) {
return _guestOSDao.findById(id);
} else {
return null;
}
}
use of com.cloud.storage.GuestOSVO in project cloudstack by apache.
the class ManagementServerImpl method listGuestOSByCriteria.
@Override
public Pair<List<? extends GuestOS>, Integer> listGuestOSByCriteria(final ListGuestOsCmd cmd) {
final Filter searchFilter = new Filter(GuestOSVO.class, "displayName", true, cmd.getStartIndex(), cmd.getPageSizeVal());
final Long id = cmd.getId();
final Long osCategoryId = cmd.getOsCategoryId();
final String description = cmd.getDescription();
final String keyword = cmd.getKeyword();
final SearchCriteria<GuestOSVO> sc = _guestOSDao.createSearchCriteria();
if (id != null) {
sc.addAnd("id", SearchCriteria.Op.EQ, id);
}
if (osCategoryId != null) {
sc.addAnd("categoryId", SearchCriteria.Op.EQ, osCategoryId);
}
if (description != null) {
sc.addAnd("displayName", SearchCriteria.Op.LIKE, "%" + description + "%");
}
if (keyword != null) {
sc.addAnd("displayName", SearchCriteria.Op.LIKE, "%" + keyword + "%");
}
final Pair<List<GuestOSVO>, Integer> result = _guestOSDao.searchAndCount(sc, searchFilter);
return new Pair<List<? extends GuestOS>, Integer>(result.first(), result.second());
}
Aggregations