@Override public Long getInstanceId() { return getId(); }
@Override public String getEventDescription() { return "creating template: " + getTemplateName(); }
@Override public void execute() { executeWithView(ResponseView.Restricted); }
@Override public String getEventDescription() { StringBuilder descBuilder = new StringBuilder(); if (getDestinationZoneIds() != null) { for (Long destId : getDestinationZoneIds()) { descBuilder.append(", "); descBuilder.append(this._uuidMgr.getUuid(DataCenter.class, destId)); } if (descBuilder.length() > 0) { descBuilder.deleteCharAt(0); } } return "copying template: " + this._uuidMgr.getUuid(VirtualMachineTemplate.class, getId()) +((getSourceZoneId() != null) ? " from zone: " + this._uuidMgr.getUuid(DataCenter.class, getSourceZoneId()) : "") + ((descBuilder.length() > 0) ? " to zones: " + descBuilder.toString() : ""); }
@Test public void testZoneidMinusOne() throws ResourceAllocationException { // If zoneId is passed as -1, then zone ids list should be null. registerTemplateCmd = new RegisterTemplateCmd(); registerTemplateCmd.zoneId = -1L; Assert.assertNull(registerTemplateCmd.getZoneIds()); }
@Override public Long getInstanceId() { return getId(); }
@Override public Long getInstanceId() { return getId(); }
private void validateRequest() { if (getZoneId() <= 0) { throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "invalid zoneid"); } }
@Override public void execute() { ListResponse<TemplateResponse> response = _queryService.listTemplates(this); response.setResponseName(getCommandName()); setResponseObject(response); }
@Test public void testZoneidAndZoneIdListEmpty() throws ResourceAllocationException { try { copyTemplateCmd = new CopyTemplateCmd(); copyTemplateCmd.execute(); } catch (ServerApiException e) { if(e.getErrorCode() != ApiErrorCode.PARAM_ERROR) { Assert.fail("API should fail when no parameters are passed."); } } }
@Override public long getEntityOwnerId() { VirtualMachineTemplate template = _entityMgr.findById(VirtualMachineTemplate.class, getId()); if (template != null) { return template.getAccountId(); } return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked }
@Override public long getEntityOwnerId() { VirtualMachineTemplate template = _entityMgr.findById(VirtualMachineTemplate.class, getId()); if (template != null) { return template.getAccountId(); } return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked }
@Override public TemplateProfile prepare(GetUploadParamsForTemplateCmd cmd) throws ResourceAllocationException { TemplateProfile profile = super.prepare(cmd); // Check that the resource limit for secondary storage won't be exceeded _resourceLimitMgr.checkResourceLimit(_accountMgr.getAccount(cmd.getEntityOwnerId()), ResourceType.secondary_storage); return profile; }
@Test public void testZoneidPresentZoneidListAbsent() throws ResourceAllocationException { registerTemplateCmd = new RegisterTemplateCmd(); registerTemplateCmd.zoneIds = null; registerTemplateCmd.zoneId = 1L; Assert.assertEquals((Long)1L,registerTemplateCmd.getZoneIds().get(0)); } }
@Override public String getEventDescription() { return "Deleting template " + this._uuidMgr.getUuid(VirtualMachineTemplate.class, getId()); }
@Override public long getEntityOwnerId() { VirtualMachineTemplate template = _entityMgr.findById(VirtualMachineTemplate.class, getId()); if (template != null) { return template.getAccountId(); } // bad id given, parent this command to SYSTEM so ERROR events are tracked return Account.ACCOUNT_ID_SYSTEM; }
@Override public long getEntityOwnerId() { VirtualMachineTemplate template = _entityMgr.findById(VirtualMachineTemplate.class, getId()); if (template != null) { return template.getAccountId(); } // invalid id, parent this command to SYSTEM so ERROR events are tracked return Account.ACCOUNT_ID_SYSTEM; }
@Override public long getEntityOwnerId() { VirtualMachineTemplate template = _entityMgr.findById(VirtualMachineTemplate.class, getId()); if (template != null) { return template.getAccountId(); } return Account.ACCOUNT_ID_SYSTEM; }