@Override public String getName() { return createOrUpdateBond.getName(); }
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; }
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 Map<String, NetworkInterfaceModel> createBondModels( Map<String, Set<LogicalNetworkModel>> nicNameToNetworkModels, Map<String, List<VdsNetworkInterface>> bondNameToSlaves, Map<String, List<NetworkLabelModel>> nicNameToLabelModels, final Map<Guid, VdsNetworkInterface> nicsById) { Map<String, NetworkInterfaceModel> bondModels = new HashMap<>(); for (CreateOrUpdateBond createOrUpdateBond : hostSetupNetworksParametersData.getBonds()) { String bondName = createOrUpdateBond.getName(); List<NetworkInterfaceModel> slavesModels = createSlaveModels(bondNameToSlaves, nicsById, bondName); Collection<LogicalNetworkModel> nicNetworks = nicNameToNetworkModels.get(bondName); Bond originalBond = getOriginalBond(nicsById, createOrUpdateBond); BondNetworkInterfaceModel bondNetworkInterfaceModel = new BondNetworkInterfaceModel(originalBond, createOrUpdateBond, nicNetworks, nicNameToLabelModels.get(createOrUpdateBond.getName()), slavesModels, this); bondModels.put(bondName, bondNetworkInterfaceModel); } return bondModels; }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (!(o instanceof CreateOrUpdateBond)) { return false; } CreateOrUpdateBond that = (CreateOrUpdateBond) o; return Objects.equals(getId(), that.getId()) && Objects.equals(getName(), that.getName()) && Objects.equals(getBondOptions(), that.getBondOptions()) && Objects.equals(getSlaves(), that.getSlaves()); }
@Override public int hashCode() { return Objects.hash(getId(), getName(), getBondOptions(), getSlaves()); }
public boolean equalToBond(Bond bond) { return Objects.equals(getId(), bond.getId()) && Objects.equals(getName(), bond.getName()) && Objects.equals(getBondOptions(), bond.getBondOptions()) && bondsHasSameSlaves(bond); }
public Bond toBond() { Bond bond = new Bond(); bond.setId(getId()); bond.setName(getName()); bond.setSlaves(new ArrayList<>(getSlaves())); bond.setBondOptions(getBondOptions()); return bond; }
protected ToStringBuilder appendAttributes(ToStringBuilder tsb) { return tsb.append("id", getId()) .append("name", getName()) .append("bondingOptions", getBondOptions()) .append("slaves", getSlaves()); }