@Override public String getEventDescription() { return "Updating guest OS: " + getId(); }
@Override public String getEventDescription() { return "Removing Guest OS: " + getId(); }
@Override public String getEventDescription() { return "adding a new guest OS type Id: " + getEntityId(); }
@Override public Pair<List<? extends GuestOSHypervisor>, Integer> listGuestOSMappingByCriteria(final ListGuestOsMappingCmd cmd) { final Filter searchFilter = new Filter(GuestOSHypervisorVO.class, "hypervisorType", true, cmd.getStartIndex(), cmd.getPageSizeVal()); final Long id = cmd.getId(); final Long osTypeId = cmd.getOsTypeId(); final String hypervisor = cmd.getHypervisor(); final String hypervisorVersion = cmd.getHypervisorVersion(); //throw exception if hypervisor name is not passed, but version is if (hypervisorVersion != null && (hypervisor == null || hypervisor.isEmpty())) { throw new InvalidParameterValueException("Hypervisor version parameter cannot be used without specifying a hypervisor : XenServer, KVM or VMware"); } final SearchCriteria<GuestOSHypervisorVO> sc = _guestOSHypervisorDao.createSearchCriteria(); if (id != null) { sc.addAnd("id", SearchCriteria.Op.EQ, id); } if (osTypeId != null) { sc.addAnd("guestOsId", SearchCriteria.Op.EQ, osTypeId); } if (hypervisor != null) { sc.addAnd("hypervisorType", SearchCriteria.Op.EQ, hypervisor); } if (hypervisorVersion != null) { sc.addAnd("hypervisorVersion", SearchCriteria.Op.EQ, hypervisorVersion); } final Pair<List<GuestOSHypervisorVO>, Integer> result = _guestOSHypervisorDao.searchAndCount(sc, searchFilter); return new Pair<List<? extends GuestOSHypervisor>, Integer>(result.first(), result.second()); }
@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(); 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(key), false);
@Override public void execute() { GuestOSHypervisor guestOsMapping = _mgr.getAddedGuestOsMapping(getEntityId()); if (guestOsMapping != null) { GuestOsMappingResponse response = _responseGenerator.createGuestOSMappingResponse(guestOsMapping); response.setResponseName(getCommandName()); setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add guest OS mapping"); } }
@Override public void execute() { CallContext.current().setEventDetails("Guest OS Id: " + getEntityId()); GuestOS guestOs = _mgr.getAddedGuestOs(getEntityId()); if (guestOs != null) { GuestOSResponse response = _responseGenerator.createGuestOSResponse(guestOs); response.setResponseName(getCommandName()); setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add new guest OS type"); } }
@Override @DB @ActionEvent(eventType = EventTypes.EVENT_GUEST_OS_MAPPING_UPDATE, eventDescription = "updating guest OS mapping", async = true) public GuestOSHypervisor updateGuestOsMapping(final UpdateGuestOsMappingCmd cmd) { final Long id = cmd.getId(); final String osNameForHypervisor = cmd.getOsNameForHypervisor(); //check if mapping exists final GuestOSHypervisor guestOsHypervisorHandle = _guestOSHypervisorDao.findById(id); if (guestOsHypervisorHandle == null) { throw new InvalidParameterValueException("Guest OS Mapping not found. Please specify a valid ID for the Guest OS Mapping"); } if (!guestOsHypervisorHandle.getIsUserDefined()) { throw new InvalidParameterValueException("Unable to modify system defined Guest OS mapping"); } final GuestOSHypervisorVO guestOsHypervisor = _guestOSHypervisorDao.createForUpdate(id); guestOsHypervisor.setGuestOsName(osNameForHypervisor); if (_guestOSHypervisorDao.update(id, guestOsHypervisor)) { return _guestOSHypervisorDao.findById(id); } else { return null; } }
@Override public String getEventDescription() { return "Removing Guest OS Mapping: " + getId(); }
@Override public String getEventDescription() { return "Updating Guest OS Mapping: " + getId(); }
@Override public void create() { GuestOSHypervisor guestOsMapping = _mgr.addGuestOsMapping(this); if (guestOsMapping != null) { setEntityId(guestOsMapping.getId()); setEntityUuid(guestOsMapping.getUuid()); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add guest OS mapping entity"); } }
@Override public void create() { GuestOS guestOs = _mgr.addGuestOs(this); if (guestOs != null) { setEntityId(guestOs.getId()); setEntityUuid(guestOs.getUuid()); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add new guest OS type entity"); } }
@Override public void execute() { GuestOSHypervisor guestOsMapping = _mgr.updateGuestOsMapping(this); if (guestOsMapping != null) { GuestOsMappingResponse response = _responseGenerator.createGuestOSMappingResponse(guestOsMapping); response.setResponseName(getCommandName()); setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update guest OS mapping"); } }
@Override public void execute() { GuestOS guestOs = _mgr.updateGuestOs(this); if (guestOs != null) { GuestOSResponse response = _responseGenerator.createGuestOSResponse(guestOs); response.setResponseName(getCommandName()); setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update guest OS type"); } }
@Override public void execute() { CallContext.current().setEventDetails("Guest OS Mapping Id: " + id); boolean result = _mgr.removeGuestOsMapping(this); if (result) { SuccessResponse response = new SuccessResponse(getCommandName()); setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to remove guest OS mapping"); } }
@Override public void execute() { CallContext.current().setEventDetails("Guest OS Id: " + id); boolean result = _mgr.removeGuestOs(this); if (result) { SuccessResponse response = new SuccessResponse(getCommandName()); setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to remove guest OS"); } }
@Override public void execute() { Pair<List<? extends GuestOSHypervisor>, Integer> result = _mgr.listGuestOSMappingByCriteria(this); ListResponse<GuestOsMappingResponse> response = new ListResponse<GuestOsMappingResponse>(); List<GuestOsMappingResponse> osMappingResponses = new ArrayList<GuestOsMappingResponse>(); for (GuestOSHypervisor guestOSHypervisor : result.first()) { GuestOsMappingResponse guestOsMappingResponse = _responseGenerator.createGuestOSMappingResponse(guestOSHypervisor); osMappingResponses.add(guestOsMappingResponse); } response.setResponses(osMappingResponses, result.second()); response.setResponseName(getCommandName()); setResponseObject(response); } }
@Override public String getEventDescription() { return "adding a new guest OS mapping Id: " + getEntityId(); }
@Override @DB @ActionEvent(eventType = EventTypes.EVENT_GUEST_OS_REMOVE, eventDescription = "removing guest OS type", async = true) public boolean removeGuestOs(final RemoveGuestOsCmd cmd) { final Long id = cmd.getId(); //check if guest OS exists final GuestOS guestOs = ApiDBUtils.findGuestOSById(id); if (guestOs == null) { throw new InvalidParameterValueException("Guest OS not found. Please specify a valid ID for the Guest OS"); } if (!guestOs.isUserDefined()) { throw new InvalidParameterValueException("Unable to remove system defined guest OS"); } return _guestOSDao.remove(id); }
@Override @DB @ActionEvent(eventType = EventTypes.EVENT_GUEST_OS_MAPPING_REMOVE, eventDescription = "removing guest OS mapping", async = true) public boolean removeGuestOsMapping(final RemoveGuestOsMappingCmd cmd) { final Long id = cmd.getId(); //check if mapping exists final GuestOSHypervisor guestOsHypervisorHandle = _guestOSHypervisorDao.findById(id); if (guestOsHypervisorHandle == null) { throw new InvalidParameterValueException("Guest OS Mapping not found. Please specify a valid ID for the Guest OS Mapping"); } if (!guestOsHypervisorHandle.getIsUserDefined()) { throw new InvalidParameterValueException("Unable to remove system defined Guest OS mapping"); } return _guestOSHypervisorDao.removeGuestOsMapping(id); }