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

Method invocation failed because the interface does not contain a method named 'GetType' #708

Closed
trlthiago opened this issue Dec 4, 2024 · 1 comment · Fixed by #710
Closed

Comments

@trlthiago
Copy link

SUMMARY

Hi, I am getting this error:

"Unhandled exception while executing module: Method invocation failed because [Microsoft.VirtualManager.Remoting.IVirtualManagerService] does not contain a method named 'GetType'."

I am executing a powershell script to create a VM on VMM.

  - name: Create VM via VMM
    ansible.windows.win_powershell:
      script: "{{ lookup('ansible.builtin.template', 'create-vm.ps1') }}"
    register: create_result

The script execute some cmdlets from virtualmachinemanager module and i think the following one rises the error

New-SCVirtualMachine -Name $vmName -VMConfiguration $virtualMachineConfiguration -Cloud $cloud -JobGroup $jobGroupId -StartAction "TurnOnVMIfRunningWhenVSStopped" -StopAction "SaveVM" -StartVM

ISSUE TYPE
  • Bug Report
ANSIBLE VERSION
ansible [core 2.16.3]
  config file = None
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3/dist-packages/ansible
  ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.12.3 (main, Sep 11 2024, 14:17:37) [GCC 13.2.0] (/usr/bin/python3)
  jinja version = 3.1.2
  libyaml = True
COLLECTION VERSION
community.general                        8.3.0
ansible.windows                             2.2.0
community.windows                      2.1.0
CONFIGURATION
$ansible-config dump --only-changed
CONFIG_FILE() = None
OS / ENVIRONMENT

$lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 24.04.1 LTS
Release: 24.04
Codename: noble
$uname -a
Linux 6.8.0-1015-azure

ACTUAL RESULTS
The full traceback is:
Method invocation failed because [Microsoft.VirtualManager.Remoting.IVirtualManagerService] does not contain a method named 'GetType'.
At line:383 char:39
+ ... rop.Name] = Convert-OutputObject -InputObject $prop.Value -Depth $chi ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Convert-OutputObject], RuntimeException
    + FullyQualifiedErrorId : MethodNotFound,Convert-OutputObject

ScriptStackTrace:
at Convert-OutputObject<Process>, <No file>: line 351
at Convert-OutputObject<Process>, <No file>: line 383
at Convert-OutputObject<Process>, <No file>: line 361
at <ScriptBlock>, <No file>: line 805

System.Management.Automation.RuntimeException: Method invocation failed because [Microsoft.VirtualManager.Remoting.IVirtualManagerService] does not contain a method named 'GetType'.
   at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)
   at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)
   at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
   at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
   at System.Management.Automation.Interpreter.Interpreter.Run(InterpretedFrame frame)
   at System.Management.Automation.Interpreter.LightLambda.RunVoid1[T0](T0 arg0)
   at System.Management.Automation.PSScriptCmdlet.RunClause(Action`1 clause, Object dollarUnderbar, Object inputToProcess)
   at System.Management.Automation.PSScriptCmdlet.DoProcessRecord()
   at System.Management.Automation.CommandProcessor.ProcessRecord()
fatal: [172.16.17.14]: FAILED! => {
    "changed": false,
    "msg": "Unhandled exception while executing module: Method invocation failed because [Microsoft.VirtualManager.Remoting.IVirtualManagerService] does not contain a method named 'GetType'."
}

@jborean93
Copy link
Collaborator

I don't have an environment setup to test the output object returned by New-SCVirtualMachine but I've hopefully fixed the issue by checking if GetType exists as a method on each object through #710. I don't fully know how an object doesn't have the GetType() method but hopefully that PR fixes this problem. It would be great if you could test it out to verify it solves your problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants