Windows server context

I’ve followed the doc to make a VM template for Windows Server 2016. Is the order really correct? It says:

  1. Start a VM with OS
    2-3. Download and install the one-context-5.4.0.msi and run sysprep
  2. Install VMtools…

Shouldn’t the sysprep be runned at the last step with generalize and shutdown? Otherwise the VM is not generalized after step 4.

Also I’m wondering if the sysprep would be run with a unattend file so that regional settings and the initial admin password is set, even if that can be set to something else through the context part/attribute?

1 Like

This is the error I get if I start a new VM.
Update: If I run the script manually in PS it says “No Context CDROM found”

You are right, sysprep must be executed after VMware tools are installed. We will change the documentation accordingly.

You can add an unattend.xml file to automatically configure windows. For password this can be done using contextualization. You can find the list of options here:

There may be two problems there:

  • VMware tools are not installed
  • The VM does not have contextualization enabled

Check in the VM template, Context tab, that the checkbox “Add Network contextualization” is enabled

Thanks. The VM template has VM tools installed and OK. I’ve removed the NIC from the VM prior to converting it to a template (saw that in some forum thread). This is how the template looks like in OpenNebula. Hope that is correct?
I’ve also added an unattend file to the sysprep command to hide eula and set input localization and such.

Any other suggestions on what could cause this?

No. It’s the first time I see that problem. Maybe someone with more Windows scripting expertise can jump in.

Ok, but as far as you can see I’ve done what’s necessary to get it going? Is it some security setting in the OS that needs to be modified maybe?

Where is the context attributes put on the VM? Does it attach an cdrom image? I can, in some cases, get it to run OK when i manually start context.ps1. And if that runs OK there’s a file created in the c: root with the attributes I’ve entered.
I can’t figure out when it works and not though. But it always fail during automatic start (which is done from the opennebula service I think?)

On KVM, it’s taken from the ISO image named CONTEXT. On VMware, vmtools and channel between the hypervisor are used. Can you please try to start the service manually on booted system (so we know if it’s related to the boot process, e.g. a dependency issue, or problem with the service itself)

net stop onecontext
net start onecontext

and check the c:\.opennebula-context.out, if the failure is still there.

Unfortunately, I’m not able to reproduce the problem on clean W2k16.

This is the log when stop/start of service.

One thing I noticed though. If I check the log after normal boot it looks like this:

Also I can’t delete the logfile because PS is still running (I’ve let it run for an extended time but it never stops).

But when I run the context.ps1 script manually it runs OK

So it looks like it doesn’t work only during the boot process. I guess the WMI isn’t started yet, so I would try to add a service dependency on WMI. If you want, you can try one-context- to check if it behaves. The changes against GitHub - OpenNebula/addon-context-windows: Windows VM Contextualization are following:

diff --git a/package.wxs b/package.wxs
index f9f13c0..4858d26 100644
--- a/package.wxs
+++ b/package.wxs
@@ -56,7 +56,10 @@
               Arguments="-s onecontext"
-              ErrorControl="normal" />
+              ErrorControl="normal">
+              <ServiceDependency Id="winmgmt" />
+            </ServiceInstall>
             <ServiceControl Id="ocControl" Name="onecontext"

Thank you.

Unfortunally the same problem exist. I’ve also tested it on a Win2012R2 template but the same problem occurs. Again, if I run it manually in a PS shell it works as expected. Is there a “flag” that tells the service that it’s already runned once ?

I saw something interesting right now actually. I looked at the params of the context service and the path is:
C:\Windows\SysWOW64\WindowsPowerShell\V1.0\powershell.exe " and the file context.ps1. If i run this in a cmd prompt it says “No context CDROM found”. If I run the ps1 file in PS shell it works.

We test the W2012r2 and it’s fine for us as well. Unfortunately, I still can’t reproduce the problem. The best would be if you can provide the image so I can look on it. If it’s possible, I’ll send you the Dropbox file request in private message.

Currently, the PS script is started with -noExit, so after contextualization is done, the whole service leaves in fake running state.

Two points:

  1. The fact that you see WMI critical error and then another run without critical error is pretty normal on the very first run after sysprep. I can reproduce that as well, it doesn’t make any problem. Simply, the failing run is done during the Windows preparation phase.

  2. But, you complain about no contextualization is done on run as a service. I found out that both environment variables in ${env:ProgramFiles} and ${env:ProgramFiles(x86)} used to detect the location of vmtoolsd.exe return same path C:\Program Files (x86). That means, during the run as a service, VMware tools aren’t found in C:\Program Files\VMware\VMware Tools\vmtoolsd.exe. And that’s the problem. Also ${env:ProgramW6432} needs to be checked.

I’ll prepare a fix tomorrow and provide MSI so you can validate a fix.

Thank you!

  1. Reason why the .out file couldn’t be deleted is missing Stop-Transcript before exit. This is a bug, will be fixed.

Ok, sounds great. Thanks! Looking forward to try it out :slight_smile:

This package should fix the problem with the service one-context- (26 KB). I had some problem with upgrading the package, had to first uninstall the old one.

Great, it works now! Thanks for input/fix.

My problem is:
I did what you mentioned:(on Windows Server 2008R2)

net stop onecontext
net start onecontext

and there is no such file c:\.opennebula-context.out in my vm. I checked the status of opennebula context service. it says it is on.

So any suggestions?