protected Guid getClusterId(Action action) { if (action.getCluster().isSetId()) { return asGuid(action.getCluster().getId()); } else { return lookupClusterIdByName(action.getCluster().getName()); } }
protected Guid getClusterId(Action action) { if (action.getCluster().isSetId()) { return asGuid(action.getCluster().getId()); } else { Cluster cluster = lookupClusterByName(action.getCluster().getName()); return cluster != null ? cluster.getId() : null; } }
private Guid getTargetClusterId(Action action) { if (action.isSetCluster() && action.getCluster().isSetId()) { return asGuid(action.getCluster().getId()); } // means use the cluster of the provided host return null; }
@Override public Response approve(Action action) { if (action.isSetCluster() && (action.getCluster().isSetId() || action.getCluster().isSetName())) { update(setCluster(get(), action.getCluster())); } ApproveVdsParameters params = new ApproveVdsParameters(guid); params = (ApproveVdsParameters) getMapper (Action.class, VdsOperationActionParameters.class).map(action, params); // Set pk authentication as default params.setAuthMethod(VdsOperationActionParameters.AuthenticationMethod.PublicKey); if (action.isSetRootPassword()) { params.setAuthMethod(VdsOperationActionParameters.AuthenticationMethod.Password); params.setRootPassword(action.getRootPassword()); } else if (action.isSetSsh() && action.getSsh().isSetAuthenticationMethod()) { if (action.getSsh().getAuthenticationMethod() == SshAuthenticationMethod.PASSWORD) { params.setAuthMethod(VdsOperationActionParameters.AuthenticationMethod.Password); if (action.getSsh().isSetUser() && action.getSsh().getUser().isSetPassword()) { params.setPassword(action.getSsh().getUser().getPassword()); } } } // by default activate the host after approval boolean activate = ParametersHelper.getBooleanParameter(httpHeaders, uriInfo, BackendHostsResource.ACTIVATE, true, true); params.setActivateHost(activate); return doAction(ActionType.ApproveVds, params, action); }
@Test public void testImportNotFound() { Action action = new Action(); action.setStorageDomain(new StorageDomain()); action.getStorageDomain().setId(GUIDS[2].toString()); action.setCluster(new org.ovirt.engine.api.model.Cluster()); action.getCluster().setId(GUIDS[1].toString()); setUpGetEntityExpectations(StorageDomainType.ImportExport, STORAGE_DOMAIN_ID, true); verifyNotFoundException(assertThrows(WebApplicationException.class, () -> resource.doImport(action))); }
@Test public void testImportNotFound() { Action action = new Action(); action.setStorageDomain(new StorageDomain()); action.getStorageDomain().setId(GUIDS[2].toString()); action.setCluster(new org.ovirt.engine.api.model.Cluster()); action.getCluster().setId(GUIDS[1].toString()); setUpGetEntityExpectations(StorageDomainType.ImportExport, GUIDS[2], true); setUpGetDataCenterByStorageDomainExpectations(STORAGE_DOMAIN_ID); verifyNotFoundException(assertThrows(WebApplicationException.class, () -> resource.doImport(action))); }
to.setCluster(adaptOut(from.getCluster()));