Skip to content
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

VMNetworkAdapter: Multiple DNS IP adresses does not work (parameter type need to be changed) #190

Closed
benjFR69 opened this issue Sep 7, 2021 · 1 comment · Fixed by #205
Labels
bug The issue is a bug. good first issue The issue should be easier to fix and can be taken up by a beginner to learn to contribute on GitHub

Comments

@benjFR69
Copy link

benjFR69 commented Sep 7, 2021

Hello, thanks for this code as it is very uncommon to have something functional for hyperv...

Details of the scenario you tried and the problem that is occurring

When you try to provide a table in the networkingsetting object it does not work as parameter of function is String and not Tab String (MSFT_xVMNetworkAdapter.psm1#L648 )

Verbose logs showing the problem

"module_version": "3.17.0.0",
"msg": "Failed to invoke DSC Set method: Incorrect function. ",
"reboot_required": false,
"verbose_set": [
"Perform operation 'Invoke CimMethod' with following parameters, ''methodName' = ResourceSet,'className' = MSFT_DSCLocalConfigurationManager,'namespaceName' = root/Microsoft/Windows/DesiredStateConfiguration'.",
"An LCM method call arrived from computer HOST with user sid S-1-5-21-203002872-2615672331-1556995904-17199.",
"[LY-C3-HOST3]: LCM: [ Start Set ] [[xVMNetworkAdapter]DirectResourceAccess]",
"[LY-C3-HOST3]: [[xVMNetworkAdapter]DirectResourceAccess] Getting VM Network Adapter information.",
"[LY-C3-HOST3]: [[xVMNetworkAdapter]DirectResourceAccess] Adding VM Network Adapter.",
"[LY-C3-HOST3]: LCM: [ End Set ] [[xVMNetworkAdapter]DirectResourceAccess] in 1.7500 seconds.",
"Operation 'Invoke CimMethod' complete.",
"Time taken for configuration job to complete is 1.906 seconds"

Suggested solution to the issue

Change parameter type to "String[]"

The DSC configuration that is used to reproduce the issue (as detailed as possible)

"item": {
"NetworkSetting": {
"DefaultGateway": "172.99.0.1",
"DnsServer": "@("172.99.3.22", "172.993.2")",
"IpAddress": "172.99.3.16",
"Subnet": "255.255.0.0"
},
"name": "default",
"switchname": "test",
"vlanid": "15"
},

We also tried multiple setting :
"DnsServer": ["172.99.3.22", "172.99.3.2"],
"DnsServer": ("172.99.3.22", "172.99.3.2"),
"DnsServer": "172.99.3.22, 172.99.3.2",


#### The operating system the target node is running
Not related to operating system

#### Version and build of PowerShell the target node is running
<!--
    To help with this information, please run this command:
    $PSVersionTable
-->
[HOST]: PS> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.14393.3866
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.14393.3866
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

#### Version of the DSC module that was used
ansible.windows.win_dsc 
This plugin is part of the ansible.windows collection (version 1.7.2).

Thanks for your help and fix !
@johlju
Copy link
Member

johlju commented Jun 12, 2022

This row get the object to set:

$networkSettings = $vmNetAdapter.GetRelated('Msvm_GuestNetworkAdapterConfiguration') | Select-Object -First 1

and here we set the DNS Server value:

$networkSettings.DNSServers = $DNSServer

The problem is that the schema is not an array:

because the property we set expects an array:

https://docs.microsoft.com/en-us/windows/win32/hyperv_v2/msvm-guestnetworkadapterconfiguration#properties

Happy to review a PR that changes the schema to an array and enforces that array.

@johlju johlju added bug The issue is a bug. help wanted The issue is up for grabs for anyone in the community. good first issue The issue should be easier to fix and can be taken up by a beginner to learn to contribute on GitHub labels Jun 12, 2022
@johlju johlju changed the title Multiple DNS IP adresses does not work (parameter type need to be changed) VMNetworkAdapter: Multiple DNS IP adresses does not work (parameter type need to be changed) Jun 12, 2022
@johlju johlju removed the help wanted The issue is up for grabs for anyone in the community. label Jul 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug The issue is a bug. good first issue The issue should be easier to fix and can be taken up by a beginner to learn to contribute on GitHub
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants