@Override public int hashCode() { return Objects.hash(getId(), getName(), getBondOptions(), getSlaves()); }
public static CreateOrUpdateBond fromBond(Bond bond) { CreateOrUpdateBond createOrUpdateBond = new CreateOrUpdateBond(); createOrUpdateBond.setId(bond.getId()); createOrUpdateBond.setName(bond.getName()); createOrUpdateBond.setSlaves(new HashSet<>(bond.getSlaves())); createOrUpdateBond.setBondOptions(bond.getBondOptions()); return createOrUpdateBond; }
private Bond getOriginalBond(final Map<Guid, VdsNetworkInterface> nicsById, CreateOrUpdateBond createOrUpdateBond) { if (createOrUpdateBond.getId() != null) { assert nicsById.containsKey( createOrUpdateBond.getId()) : "createOrUpdateBond's id is not part of the nicsById map"; //$NON-NLS-1$ } Bond originalBond = createOrUpdateBond.getId() != null ? (Bond) nicsById.get(createOrUpdateBond.getId()) : createOrUpdateBond.toBond(); return originalBond; }
public void addBondToParameters(CreateOrUpdateBond bond) { if (bond.getId() != null) { throw new IllegalArgumentException("When adding a bond to the parameters its id should be null"); //$NON-NLS-1$ } CreateOrUpdateBond originalBondWithTheSameName = originalBondsByName.get(bond.getName()); if (originalBondWithTheSameName != null) { bond.setId(originalBondWithTheSameName.getId()); removedBonds.remove(originalBondWithTheSameName.getId()); } bonds.add(bond); }
private CreateOrUpdateBond createBond(Guid id, String bondName, List<VdsNetworkInterface> slaves) { CreateOrUpdateBond result = new CreateOrUpdateBond(); result.setId(id); result.setName(bondName); for (VdsNetworkInterface slave : slaves) { result.getSlaves().add(slave.getName()); } return result; }
public boolean equalToBond(Bond bond) { return Objects.equals(getId(), bond.getId()) && Objects.equals(getName(), bond.getName()) && Objects.equals(getBondOptions(), bond.getBondOptions()) && bondsHasSameSlaves(bond); }
CreateOrUpdateBond bond = new CreateOrUpdateBond(); bond.setName(bondPopup.getBond().getSelectedItem()); setBondOptions(bond, bondPopup); attachNetworks(bond.getName(), networks); attachLabels(bond.getName(), labels);
private void assertBond(CreateOrUpdateBond bond, Guid bondId, List<VdsNetworkInterface> slaves) { assertThat("id mismatch", bond.getId(), is(bondId)); //$NON-NLS-1$ for (VdsNetworkInterface slave : slaves) { assertThat("missing slave", bond.getSlaves().contains(slave.getName()), is(true)); //$NON-NLS-1$ } assertThat("invalid slaves count", bond.getSlaves().size(), is(slaves.size())); //$NON-NLS-1$ }
private void addBondToParamsAndModel(Bond bond, BondNetworkInterfaceModel bondModel, List<LogicalNetworkModel> networks) { CreateOrUpdateBond createOrUpdateBond = CreateOrUpdateBond.fromBond(bond); dataFromHostSetupNetworksModel.getBonds().add(createOrUpdateBond); when(bondModel.getOriginalIface()).thenReturn(bond); when(bondModel.getCreateOrUpdateBond()).thenReturn(createOrUpdateBond); when(bondModel.getItems()).thenReturn(networks); } }
private Map<String, List<VdsNetworkInterface>> getBondNameToSlaves() { final Map<String, VdsNetworkInterface> nicMap = Entities.entitiesByName(allExistingNics); Map<String, List<VdsNetworkInterface>> bondToSlaves = new HashMap<>(); for (CreateOrUpdateBond createOrUpdateBond : hostSetupNetworksParametersData.getBonds()) { String bondName = createOrUpdateBond.getName(); assert !bondToSlaves.containsKey(bondName) : "the same bond shouldn't exist twice in the parameters"; //$NON-NLS-1$ bondToSlaves.put(bondName, new ArrayList<VdsNetworkInterface>()); Set<String> slavesNames = createOrUpdateBond.getSlaves(); for (String slaveName : slavesNames) { bondToSlaves.get(bondName).add(nicMap.get(slaveName)); } } return bondToSlaves; }
private boolean bondsHasSameSlaves(Bond existingNic) { Collection<String> slavesOfBondFromRequest = replaceNullWithEmptyList(getSlaves()); Collection<String> slavesOfExistingBond = replaceNullWithEmptyList(existingNic.getSlaves()); //bonds can be in any order, and I don't want to change this order during this check. return slavesOfBondFromRequest.size() == slavesOfExistingBond.size() && slavesOfBondFromRequest.containsAll(slavesOfExistingBond); }
setTitle(ConstantsManager.getInstance() .getMessages() .editBondInterfaceTitle(bond.getName())); List<String> bondName = Arrays.asList(bond.getName()); getBond().setItems(bondName); getBond().setSelectedItem(bond.getName()); String bondOptions = bond.getBondOptions(); List<Map.Entry<String, EntityModel<String>>> items = (List<Map.Entry<String, EntityModel<String>>>) getBondingOptions().getItems(); boolean found = false;
private Set<String> getAllSlaveNames() { Set<String> slaveNames = new HashSet<>(); for (CreateOrUpdateBond bond : hostSetupNetworksParametersData.getBonds()) { slaveNames.addAll(bond.getSlaves()); } return slaveNames; }
@Override public String getName() { return createOrUpdateBond.getName(); }
public String getBondOptions() { return getCreateOrUpdateBond().getBondOptions(); }
private void setBondOptions(CreateOrUpdateBond bond, SetupNetworksBondModel bondDialogModel) { Map.Entry<String, EntityModel<String>> BondPair = bondDialogModel.getBondingOptions().getSelectedItem(); String key = BondPair.getKey(); bond.setBondOptions("custom".equals(key) ? BondPair.getValue().getEntity() : key); //$NON-NLS-1$ }
private void initCreateOrUpdateBondParameters() { NetworkCommonUtils.fillBondSlaves(allExistingNics); for (VdsNetworkInterface nic : allExistingNics) { if (nic.isBond()) { getHostSetupNetworksParametersData().getBonds() .add(CreateOrUpdateBond.fromBond((Bond) nic)); } } hostSetupNetworksParametersData.setOriginalBondsByName(Entities.entitiesByName(hostSetupNetworksParametersData.getBonds())); }
parameters.getRemovedBonds().add(mapBonds(bonds, bond).getId());