use of org.ovirt.engine.core.common.businessentities.network.NetworkAttachment in project ovirt-engine by oVirt.
the class HostSetupNetworksCommand method getRemovedNetworks.
private Set<String> getRemovedNetworks() {
if (removedNetworks == null) {
List<NetworkAttachment> removedNetworkAttachments = Entities.filterEntitiesByRequiredIds(getParameters().getRemovedNetworkAttachments(), existingAttachments);
removedNetworks = new HashSet<>(removedNetworkAttachments.size());
Map<Guid, NetworkAttachment> networkIdToAttachment = new MapNetworkAttachments(getParameters().getNetworkAttachments()).byNetworkId();
for (NetworkAttachment removedAttachment : removedNetworkAttachments) {
if (!networkIdToAttachment.containsKey(removedAttachment.getNetworkId())) {
removedNetworks.add(existingNetworkRelatedToAttachment(removedAttachment).getVdsmName());
}
}
}
return removedNetworks;
}
use of org.ovirt.engine.core.common.businessentities.network.NetworkAttachment in project ovirt-engine by oVirt.
the class GetNetworkAttachmentsByHostIdQuery method executeQueryCommand.
@Override
protected void executeQueryCommand() {
Guid hostId = getParameters().getId();
List<NetworkAttachment> networkAttachments = networkAttachmentDao.getAllForHost(hostId);
List<VdsNetworkInterface> allInterfacesForHost = interfaceDao.getAllInterfacesForVds(hostId);
VDS vds = hostDao.get(hostId);
Guid clusterId = vds.getClusterId();
BusinessEntityMap<Network> networkMap = new BusinessEntityMap<>(networkDao.getAllForCluster(clusterId));
reportedConfigurationsFiller.fillReportedConfigurations(allInterfacesForHost, networkMap, networkAttachments, vds.getDynamicData().getReportedDnsResolverConfiguration(), clusterId);
completeNicNames(networkAttachments, allInterfacesForHost);
completeNetworkNames(networkAttachments, networkMap);
getQueryReturnValue().setReturnValue(networkAttachments);
}
use of org.ovirt.engine.core.common.businessentities.network.NetworkAttachment in project ovirt-engine by oVirt.
the class AddNetworkAttachmentCommand method resolveCreatedAttachmentId.
private Guid resolveCreatedAttachmentId(final Guid requiredNetworkId, Guid configuredNicId) {
VdsNetworkInterface configuredNic = interfaceDao.get(configuredNicId);
List<NetworkAttachment> attachmentsOnNic = networkAttachmentDao.getAllForNic(configuredNic.getId());
NetworkAttachment createNetworkAttachment = attachmentsOnNic.stream().filter(networkAttachment -> networkAttachment.getNetworkId().equals(requiredNetworkId)).findFirst().orElse(null);
if (createNetworkAttachment == null) {
throw new IllegalStateException();
}
return createNetworkAttachment.getId();
}
use of org.ovirt.engine.core.common.businessentities.network.NetworkAttachment in project ovirt-engine by oVirt.
the class AddNetworkAttachmentCommand method executeCommand.
@Override
protected void executeCommand() {
HostSetupNetworksParameters params = new HostSetupNetworksParameters(getParameters().getVdsId());
NetworkAttachment networkAttachment = getParameters().getNetworkAttachment();
params.getNetworkAttachments().add(networkAttachment);
// storing ids, so we're sure, that they were not mistakenly altered in HostSetupNetworks command.
Guid networkId = networkAttachment.getNetworkId();
Guid nicId = networkAttachment.getNicId();
ActionReturnValue returnValue = runInternalAction(ActionType.HostSetupNetworks, params);
if (returnValue.getSucceeded()) {
Guid createdAttachmentId = resolveCreatedAttachmentId(networkId, nicId);
getReturnValue().setActionReturnValue(createdAttachmentId);
} else {
propagateFailure(returnValue);
}
setSucceeded(returnValue.getSucceeded());
}
use of org.ovirt.engine.core.common.businessentities.network.NetworkAttachment in project ovirt-engine by oVirt.
the class AddNetworkAttachmentCommand method validate.
@Override
protected boolean validate() {
NicNameNicIdCompleter completer = new NicNameNicIdCompleter(getHostInterfaces());
completer.completeNetworkAttachment(getParameters().getNetworkAttachment());
this.networkIdNameCompleter.completeNetworkAttachment(getParameters().getNetworkAttachment(), getStoragePoolId());
NetworkAttachment networkAttachment = getParameters().getNetworkAttachment();
if (networkAttachment == null) {
return failValidation(EngineMessage.NETWORK_ATTACHMENT_NOT_SPECIFIED);
}
if (networkAttachment.getId() != null) {
return failValidation(EngineMessage.NETWORK_ATTACHMENT_CANNOT_BE_CREATED_WITH_SPECIFIC_ID, ReplacementUtils.createSetVariableString("NETWORK_ATTACHMENT_CANNOT_BE_CREATED_WITH_SPECIFIC_ID_ENTITY", networkAttachment.getId()));
}
return true;
}
Aggregations