Search in sources :

Example 21 with GuestOSVO

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);
    }
}
Also used : UserVmVO(com.cloud.vm.UserVmVO) TemplateInfo(org.apache.cloudstack.engine.subsystem.api.storage.TemplateInfo) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) GuestOSVO(com.cloud.storage.GuestOSVO) TemplateObjectTO(org.apache.cloudstack.storage.to.TemplateObjectTO) DiskTO(com.cloud.agent.api.to.DiskTO)

Example 22 with GuestOSVO

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;
}
Also used : GuestOSVO(com.cloud.storage.GuestOSVO) VirtualMachineTO(com.cloud.agent.api.to.VirtualMachineTO)

Example 23 with GuestOSVO

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;
}
Also used : GuestOSVO(com.cloud.storage.GuestOSVO) VirtualMachineTO(com.cloud.agent.api.to.VirtualMachineTO)

Example 24 with GuestOSVO

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;
    }
}
Also used : InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) GuestOS(com.cloud.storage.GuestOS) GuestOSVO(com.cloud.storage.GuestOSVO) ActionEvent(com.cloud.event.ActionEvent) DB(com.cloud.utils.db.DB)

Example 25 with GuestOSVO

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());
}
Also used : Filter(com.cloud.utils.db.Filter) ArrayList(java.util.ArrayList) ExcludeList(com.cloud.deploy.DeploymentPlanner.ExcludeList) List(java.util.List) GuestOSVO(com.cloud.storage.GuestOSVO) Pair(com.cloud.utils.Pair) SSHKeyPair(com.cloud.user.SSHKeyPair)

Aggregations

GuestOSVO (com.cloud.storage.GuestOSVO)28 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)12 VirtualMachineTO (com.cloud.agent.api.to.VirtualMachineTO)10 HostVO (com.cloud.host.HostVO)10 GuestOSHypervisorVO (com.cloud.storage.GuestOSHypervisorVO)10 VolumeObjectTO (org.apache.cloudstack.storage.to.VolumeObjectTO)9 AgentUnavailableException (com.cloud.exception.AgentUnavailableException)8 OperationTimedoutException (com.cloud.exception.OperationTimedoutException)8 UserVmVO (com.cloud.vm.UserVmVO)8 VMSnapshotTO (com.cloud.agent.api.VMSnapshotTO)7 VMSnapshotVO (com.cloud.vm.snapshot.VMSnapshotVO)6 ArrayList (java.util.ArrayList)6 CreateVMSnapshotAnswer (com.cloud.agent.api.CreateVMSnapshotAnswer)5 HypervisorType (com.cloud.hypervisor.Hypervisor.HypervisorType)5 HashMap (java.util.HashMap)5 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)4 Answer (com.cloud.agent.api.Answer)3 Command (com.cloud.agent.api.Command)3 RevertToVMSnapshotAnswer (com.cloud.agent.api.RevertToVMSnapshotAnswer)3 ActionEvent (com.cloud.event.ActionEvent)3