-
Notifications
You must be signed in to change notification settings - Fork 1.3k
kvm: get ip address of Windows vms via virsh domifaddr #12651
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 4.22
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -52,6 +52,12 @@ public class LibvirtGetVmIpAddressCommandWrapperTest { | |||||
| " net4 2e:9b:60:dc:49:30 N/A N/A\n" + // | ||||||
| " lxc5b7327203b6f 92:b2:77:0b:a9:20 N/A N/A\n"; | ||||||
|
|
||||||
| private static String VIRSH_DOMIF_OUTPUT_WINDOWS = " Name MAC address Protocol Address\n" + // | ||||||
| "-------------------------------------------------------------------------------\n" + // | ||||||
| " Ethernet Instance 0 02:0c:02:f9:00:80 ipv4 192.168.0.10/24\n" + // | ||||||
| " Loopback Pseudo-Interface 1 ipv6 ::1/128\n" + // | ||||||
| " - - ipv4 127.0.0.1/8\n"; | ||||||
|
|
||||||
| @Before | ||||||
| public void setUp() { | ||||||
| MockitoAnnotations.openMocks(this); | ||||||
|
|
@@ -118,7 +124,34 @@ public void testExecuteWithWindowsVm() { | |||||
| when(getVmIpAddressCommand.getVmNetworkCidr()).thenReturn("192.168.0.0/24"); | ||||||
| when(getVmIpAddressCommand.getMacAddress()).thenReturn("02:0c:02:f9:00:80"); | ||||||
| when(getVmIpAddressCommand.isWindows()).thenReturn(true); | ||||||
| when(Script.executePipedCommands(anyList(), anyLong())).thenReturn(new Pair<>(0, "192.168.0.10")); | ||||||
| when(Script.executePipedCommands(anyList(), anyLong())).thenReturn(new Pair<>(0, VIRSH_DOMIF_OUTPUT_WINDOWS)); | ||||||
|
|
||||||
| Answer answer = commandWrapper.execute(getVmIpAddressCommand, libvirtComputingResource); | ||||||
|
|
||||||
| assertTrue(answer.getResult()); | ||||||
| assertEquals("192.168.0.10", answer.getDetails()); | ||||||
| } finally { | ||||||
| if (scriptMock != null) | ||||||
| scriptMock.close(); | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
|
|
||||||
| @Test | ||||||
| public void testExecuteWithWindowsVm2() { | ||||||
|
||||||
| public void testExecuteWithWindowsVm2() { | |
| public void testExecuteWithWindowsVmFallbackToRegistry() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test data for line 58 appears to be missing the MAC address column. Based on the virsh domifaddr output format, each line should have 4 columns: Name, MAC address, Protocol, and Address. Line 58 "Loopback Pseudo-Interface 1" only has 3 columns (Name, Protocol, Address), which will cause the parsing logic to incorrectly treat "1" (part of the interface name) as the MAC address when using parts[parts.length - 3]. This should either include a MAC address or use "-" as a placeholder to maintain the expected column structure, similar to line 59.