private Guid getClusterId(Host host) { if (host.isSetCluster()) { org.ovirt.engine.api.model.Cluster cluster = host.getCluster(); if (cluster.isSetId()) { return asGuid(cluster.getId()); } if (cluster.isSetName()) { return getClusterIdByName(cluster.getName()); } } return getClusterIdByName(DEFAULT_NAME); }
@Override public Host update(Host incoming) { QueryIdResolver<Guid> hostResolver = new QueryIdResolver<>(QueryType.GetVdsByVdsId, IdQueryParameters.class); VDS entity = getEntity(hostResolver, true); BackendExternalProviderHelper.completeExternalNetworkProviderConfigurations(this, incoming.getExternalNetworkProviderConfigurations()); // if fence agents list is null set it to null in entity if(incoming.getAgents() == null) { entity.setFenceAgents(null); } if (incoming.isSetCluster() && (incoming.getCluster().isSetId() || incoming.getCluster().isSetName())) { Guid clusterId = lookupClusterId(incoming); if (!clusterId.equals(entity.getClusterId())) { performAction(ActionType.ChangeVDSCluster, new ChangeVDSClusterParameters(clusterId, guid)); // After changing the cluster with the specialized command we need to reload the entity, so that it // contains the new cluster id. If we don't do this the next command will think that we are trying // to change the cluster, and it will explicitly refuse to perform the update. entity = getEntity(hostResolver, true); } } Host host = performUpdate(incoming, entity, map(entity), hostResolver, ActionType.UpdateVds, new UpdateParametersProvider()); return host; }
entity.setName(model.getName()); if (model.isSetCluster() && model.getCluster().isSetId()) { entity.setClusterId(GuidUtils.asGuid(model.getCluster().getId()));
to.setCertificate(adaptOut(from.getCertificate())); if (from.isSetCluster()) { to.setCluster(adaptOut(from.getCluster()));