protected ActionParametersBase getRemoveVmInterfaceParams(VmNetworkInterface vnic) { return new RemoveVmInterfaceParameters(vnic.getVmId(), vnic.getId()); }
public static void addReportedDevices(BackendResource resource, Nic model, VmNetworkInterface entity) { List<ReportedDevice> devices = getDevices(resource, entity.getVmId(), entity.getMacAddress()); if (!devices.isEmpty()) { ReportedDevices reportedDevices = new ReportedDevices(); reportedDevices.getReportedDevices().addAll(devices); model.setReportedDevices(reportedDevices); } }
private VmNetworkInterface setUpEntityExpectations( VmNetworkInterface entity, VmNetworkStatistics statistics, int index, String networkName) { when(entity.getId()).thenReturn(GUIDS[index]); when(entity.getVmId()).thenReturn(VM_ID); when(entity.getNetworkName()).thenReturn(networkName); when(entity.getName()).thenReturn(NAMES[index]); when(entity.getMacAddress()).thenReturn(ADDRESSES[2]); when(entity.getType()).thenReturn(0); when(entity.getSpeed()).thenReturn(50); return setUpStatisticalEntityExpectations(entity, statistics); }
static VmNetworkInterface setUpEntityExpectations( VmNetworkInterface entity, VmNetworkStatistics statistics, int index, String networkName) { when(entity.getId()).thenReturn(GUIDS[index]); when(entity.getVmId()).thenReturn(INSTANCE_TYPE_ID); when(entity.getNetworkName()).thenReturn(networkName); when(entity.getName()).thenReturn(NAMES[index]); when(entity.getMacAddress()).thenReturn(ADDRESSES[2]); when(entity.getType()).thenReturn(0); when(entity.getSpeed()).thenReturn(50); return setUpStatisticalEntityExpectations(entity, statistics); }
static VmNetworkInterface setUpEntityExpectations( VmNetworkInterface entity, VmNetworkStatistics statistics, int index, String networkName) { when(entity.getId()).thenReturn(GUIDS[index]); when(entity.getVmId()).thenReturn(VM_ID); when(entity.getNetworkName()).thenReturn(networkName); when(entity.getName()).thenReturn(NAMES[index]); when(entity.getMacAddress()).thenReturn(ADDRESSES[2]); when(entity.getType()).thenReturn(0); when(entity.getSpeed()).thenReturn(50); return setUpStatisticalEntityExpectations(entity, statistics); }
static VmNetworkInterface setUpEntityExpectations( VmNetworkInterface entity, VmNetworkStatistics statistics, int index, String networkName) { when(entity.getId()).thenReturn(GUIDS[index]); when(entity.getVmId()).thenReturn(VM_ID); when(entity.getNetworkName()).thenReturn(networkName); when(entity.getName()).thenReturn(NAMES[index]); when(entity.getMacAddress()).thenReturn(ADDRESSES[2]); when(entity.getType()).thenReturn(0); when(entity.getSpeed()).thenReturn(50); return setUpStatisticalEntityExpectations(entity, statistics); }
/** * Ensures that a collection of interfaces related the specified VM are returned. */ @Test public void testGetAllInterfacesForVm() { List<VmNetworkInterface> result = dao.getAllForVm(VM_ID); assertNotNull(result); assertFalse(result.isEmpty()); for (VmNetworkInterface iface : result) { assertEquals(VM_ID, iface.getVmId()); } }
/** * Ensures that the VMs for a privileged user are returned */ @Test public void testGetAllInterfacesForVmFilteredWithPermissions() { List<VmNetworkInterface> result = dao.getAllForVm(VM_ID, PRIVILEGED_USER_ID, true); assertNotNull(result); assertFalse(result.isEmpty()); for (VmNetworkInterface iface : result) { assertEquals(VM_ID, iface.getVmId()); } }
/** * Ensures that the VMs for an unprivileged user are returned if no filtering is requested */ @Test public void testGetAllInterfacesForVmFilteredWithoutPermissionsAndWithoutFiltering() { List<VmNetworkInterface> result = dao.getAllForVm(VM_ID, UNPRIVILEGED_USER_ID, false); assertNotNull(result); assertFalse(result.isEmpty()); for (VmNetworkInterface iface : result) { assertEquals(VM_ID, iface.getVmId()); } }
public VmNetworkInterface(VmNetworkInterface iface) { setId(iface.getId()); setMacAddress(iface.getMacAddress()); setName(iface.getName()); setNetworkName(iface.getNetworkName()); setLinked(iface.isLinked()); setSpeed(iface.getSpeed()); setType(iface.getType()); setVmId(iface.getVmId()); setVmName(iface.getVmName()); setVmTemplateId(iface.getVmTemplateId()); setStatistics(new VmNetworkStatistics(iface.getStatistics())); }
@Mapping(from = VmNetworkInterface.class, to = Nic.class) public static Nic map(VmNetworkInterface entity, Nic template) { Nic model = template != null ? template : new Nic(); if (entity.getVmId() != null) { model.setVm(new Vm()); model.getVm().setId(entity.getVmId().toString()); } if (entity.getId() != null) { model.setId(entity.getId().toString()); } if (entity.getName() != null) { model.setName(entity.getName()); } if (entity.getMacAddress() != null) { model.setMac(new Mac()); model.getMac().setAddress(entity.getMacAddress()); } model.setLinked(entity.isLinked()); model.setInterface(map(entity.getType())); model.setPlugged(entity.isPlugged()); if (entity.getVnicProfileId() != null) { model.setVnicProfile(new VnicProfile()); model.getVnicProfile().setId(entity.getVnicProfileId().toString()); } return model; }
@Override public String toString() { return ToStringBuilder.forInstance(this) .append("id", getId()) .append("name", getName()) .append("networkName", getNetworkName()) .append("vnicProfileName", getVnicProfileName()) .append("vnicProfileId", getVnicProfileId()) .append("speed", getSpeed()) .append("type", getType()) .append("macAddress", getMacAddress()) .append("active", isPlugged()) .append("linked", isLinked()) .append("portMirroring", isPortMirroring()) .append("vmId", getVmId()) .append("vmName", getVmName()) .append("vmTemplateId", getVmTemplateId()) .append("QoSName", getQosName()) .append("remoteNetworkName", getRemoteNetworkName()) .build(); }