Problems with hostname contextualization on Windows

Hi,

I’m getting an error on trying to rename a Windows host with context variables at VM creation time. Network related context variables are being changed without problems, but hostname not.

Looking at the logs this is the output:
**********************
Windows PowerShell transcript start
Start time: 20170919083900
Username: WORKGROUP\SYSTEM
RunAs User: WORKGROUP\SYSTEM
Machine: WIN-MDTFJMR535S (Microsoft Windows NT 6.3.9600.0)
Host Application: C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe -noExit -ExecutionPolicy Unrestricted -file C:\Program Files (x86)\OpenNebula\context.ps1
Process ID: 760
**********************
Running Script: C:\Program Files (x86)\OpenNebula\context.ps1

martes, 19 de septiembre de 2017 8:39:00

Detecting contextualization data
- Looking for CONTEXT ISO
Get-WMIObject : Critical error
At C:\Program Files (x86)\OpenNebula\context.ps1:544 char:17
+ $contextDrive = Get-WMIObject Win32_Volume | ? { $_.Label -eq "CONTEXT" }
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Get-WmiObject], Managemen
   tException
    + FullyQualifiedErrorId : GetWMIManagementException,Microsoft.PowerShell.C
   ommands.GetWmiObjectCommand

  ... Not found
- Looking for VMware tools
  ... Not found in C:\Program Files (x86)\VMware\VMware Tools\vmtoolsd.exe
  ... Not found in C:\Program Files (x86)\VMware\VMware Tools\vmtoolsd.exe
  ... Found in C:\Program Files\VMware\VMware Tools\vmtoolsd.exe
- Extend partitions
Changing Hostname to NOMBREGUAY
Get-WmiObject : Critical error
At C:\Program Files (x86)\OpenNebula\context.ps1:389 char:25
+         $ComputerInfo = Get-WmiObject -Class Win32_ComputerSystem
+                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Get-WmiObject], Managemen
   tException
    + FullyQualifiedErrorId : GetWMIManagementException,Microsoft.PowerShell.C
   ommands.GetWmiObjectCommand

You cannot call a method on a null-valued expression.
At C:\Program Files (x86)\OpenNebula\context.ps1:392 char:9
+         $ret = $ComputerInfo.rename($context_hostname)
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

... Success
... Rebooting
Restart-Computer : Failed to restart the computer WIN-SCS9P81S7NV with the
following error message: Critical error .
At C:\Program Files (x86)\OpenNebula\context.ps1:415 char:13
+             Restart-Computer -Force
+             ~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (WIN-SCS9P81S7NV:String) [Rest
   art-Computer], InvalidOperationException
    + FullyQualifiedErrorId : RestartcomputerFailed,Microsoft.PowerShell.Comma
   nds.RestartComputerCommand



**********************
Windows PowerShell transcript end
End time: 20170919083910
**********************

Those are the vOneCloud logs from the machine:
Tue Sep 19 06:38:27 2017 [Z0][VM][I]: New state is ACTIVE
Tue Sep 19 06:38:27 2017 [Z0][VM][I]: New LCM state is PROLOG
Tue Sep 19 06:38:28 2017 [Z0][VM][I]: New LCM state is BOOT
Tue Sep 19 06:38:28 2017 [Z0][VMM][I]: Generating deployment file: /var/lib/one/vms/48/deployment.0
Tue Sep 19 06:38:28 2017 [Z0][VMM][I]: Successfully execute transfer manager driver operation: tm_context.
Tue Sep 19 06:38:28 2017 [Z0][VMM][I]: Successfully execute network driver operation: pre.
Tue Sep 19 06:38:53 2017 [Z0][VMM][I]: Successfully execute virtualization driver operation: deploy.
Tue Sep 19 06:38:53 2017 [Z0][VMM][I]: Successfully execute network driver operation: post.
Tue Sep 19 06:38:53 2017 [Z0][VM][I]: New LCM state is RUNNING

Thank you!


Versions of the related components and OS (frontend, hypervisors, VMs):
vOneCloud 5.4, with Windows contextualization 5.4.0.4 (available here: Windows server context), on VMWare vCenter 6.0

Steps to reproduce:

Current results:

Expected results:

Hi @asantamarta, I have opened a bug (https://github.com/OpenNebula/addon-context-windows/issues/35) and I’ll first try to reproduce. I’ll let you know here. Thank you. Vlastimil

I have added a check if the Windows Management Instrumentation (WMI) is working properly, so it shouldn’t do partial contextualization now. If you want, you can check here one-context-5.4.0.6.msi (26 KB). Thank you.

Thank you so much, that worked like a charm!!

Just to mention, if you can be so kind to update the msi package location at the documentation (http://docs.opennebula.org/5.4/operation/vm_setup/vcenter.html) I think many people at my situation could benefit from this.

Again, thank you!

Hello @asantamarta, we have released new stable version 5.4.1 (https://github.com/OpenNebula/addon-context-windows/releases/tag/v5.4.1) and updated the docs. Thank you for your help!

Best regards,
Vlastimil Holer