Windows contextualization problem

I’m trying to context a template with Windows 2008R2.

My template is in the way:

CONTEXT=[
DNS_HOSTNAME="$NAME",
ETH0_DNS=“212.128.130.11 212.128.130.10”,
ETH0_IP="$NIC[IP, NETWORK=“Housing”]",
ETH0_SEARCH_DOMAIN=“usal.es”,
HOST="$NAME",
NETWORK=“YES”,
SET_HOSTNAME="$NAME",
USERNAME=“Administrador”
]
CPU="2"
DESCRIPTION="Windows 2008 R2"
GRAPHICS=[KEYMAP=“es”,LISTEN=“0.0.0.0”,TYPE=“vnc”]
HYPERVISOR="vcenter"
LOGO="images/logos/windows8.png"
MEMORY="2048"
NIC=[MODEL=“virtualvmxnet3”,NETWORK=“Housing”,NETWORK_UNAME=“oneadmin”]
PUBLIC_CLOUD=[TYPE=“vcenter”,VM_TEMPLATE=“4239099c-beac-b987-1895-eea0b50525e5”]
SCHED_REQUIREMENTS="NAME=“housing”"
SUNSTONE_CAPACITY_SELECT="YES"
SUNSTONE_NETWORK_SELECT="NO"
VCPU=“2”

And my problem is that the Windows doesnot configure the context.

I’ve the 2 files in c:\ and asigned the VBS to the starts scripts.

But when deploy a new VM, it doesnot configure correctly.

Could you help me? Is the correct form ETH0_ for the device?

Thanks.

Try use this context scripts: https://gist.github.com/RaveNoX/59f20b11d7c3ea13fed1
It works fine in my infrastructure.

Remember that startup scripts run with delay after windows starts.
So wait some time after startup.

1 Like

Thanks.

I’ve trying with your scripts, but I’ve no success.

I’ve got a template of Windows, without sysprep, and I clone that and:
install vmware tools
add the scripts (yours, of course)
shutdown the VM
remove the network interface
restart the VM
execute sysprep and shutdown
clone to template import from ONE

Perhaps the problem is in the template?

When I assign the IP, I use:
CONTEXT=[ ETH0_IP="$NIC[IP, NETWORK=“Housing”]" ]

Is this correct?

Thanks.

Did you verify that the context script runs at all?

When I created a Windows machine, I found out that this line in the VBS does not work (I think it’s a bug). The line has to be If IsEmpty(driveLetter) Then

The code in GitHub (If NOT Len(driveLetter) Then) evaluates to True even if a CD-ROM-Drive is found (because if Len is positive, NOT Len is negative, but recognized as True). This assigns C as driveLetter. Under Windows, C isn’t very common for a CD-ROM-Drive, so this is likely to fail.

@wilma_hermann: this worked for me, thanks!

At Github, they have two years old merge request which (apart from other things) fixes exactly this issue. I see the last commit is ~28 days ago, but the issues without a reply are much older. Is Github the proper place to report bugs against addon-context-windows?

@OpenNebula @jmelis we’ve wasted a good part of the day on this issue as well…

I noticed that the 4.12 documentation mentions contextualization files on a CD, but the 5.0 docs say the windows contextualization files should be on C:
(where they are doomed to be “cleaned up” by a user some day)

The problem is in the disk lookup part of startup.vbs - as mentioned in the github comment of @Yenya - the code always results in just looking at C: for context files. https://github.com/OpenNebula/addon-context-windows/pull/8/commits/54aed7ad13711d66b78c7201cf5f8d5ff2d141bc
With the changed proposed by Yenya, it also looks at D:\CONTEXT (the cdrom) for those files, so contextualization works properly, with context files on a CD, not on local filesystem C:

quote from Github (thanks @Yenya):

wrong: If NOT Len(driveLetter) Then
correct: If IsEmpty(driveLetter) Then

If this is fixed in the addon, people can use windows context. files in 5.0 on CD again.

cheers!

I wonder whether the contextualization package for Windows is maintained, and if so, what is the proper way of suggesting fixes. I have several merge requests at github for more than month without any reaction from the package authors.

Sorry for the delay with this. I’m now working on merging pull requests.

Now most of the pull requests are merged and initial testing seems to be OK. Thanks for the patches.

1 Like

@jfontan Thanks !

Try install Windows with Contextualization. Not work for me. I put 2 files to C: and add startup script to GP. After restart Network card get IP 169.254.94.240…

I try new installation of Windows. Same trouble! :frowning:

It may be caused by the ExecutionPolicy. Can you try executing this command in PowerShell and rebooting the machine?

> Set-ExecutionPolicy Unrestricted

Also, can you check that a file called C:\.opennebula-context exists? If that’s the case and the IP is not being configured delete it and reboot again.

I try this steps 100 times. Script set static DNS and Gateway but dont change IP.

Script output:

PS C:\> .\context.ps1
Exception calling "Exists" with "1" argument(s): "Unknown error (0x80005000)"
At C:\context.ps1:47 char:12
+         if(!([ADSI]::Exists("WinNT://$computerName/$username"))) {
+            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : COMException

The property 'value' cannot be found on this object. Verify that the property exists and can be set.
At C:\context.ps1:60 char:5
+     $admin.UserFlags.value = $admin.UserFlags.value -bor 0x10000
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : PropertyNotFound

The following exception occurred while retrieving member "CommitChanges": "Unknown error (0x80005000)"
At C:\context.ps1:61 char:5
+     $admin.CommitChanges()
+     ~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], ExtendedTypeSystemException
    + FullyQualifiedErrorId : CatchFromBaseGetMember

Exception calling "Exists" with "1" argument(s): "Unknown error (0x80005000)"
At C:\context.ps1:71 char:28
+                         if([ADSI]::Exists("WinNT://$computerName/$username")) {
+                            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : COMException


Updated 6 rule(s).
Ok.



__GENUS          : 2
__CLASS          : __PARAMETERS
__SUPERCLASS     :
__DYNASTY        : __PARAMETERS
__RELPATH        :
__PROPERTY_COUNT : 1
__DERIVATION     : {}
__SERVER         :
__NAMESPACE      :
__PATH           :
ReturnValue      : 0
PSComputerName   :

__GENUS          : 2
__CLASS          : __PARAMETERS
__SUPERCLASS     :
__DYNASTY        : __PARAMETERS
__RELPATH        :
__PROPERTY_COUNT : 1
__DERIVATION     : {}
__SERVER         :
__NAMESPACE      :
__PATH           :
ReturnValue      : 83
PSComputerName   :

__GENUS          : 2
__CLASS          : __PARAMETERS
__SUPERCLASS     :
__DYNASTY        : __PARAMETERS
__RELPATH        :
__PROPERTY_COUNT : 1
__DERIVATION     : {}
__SERVER         :
__NAMESPACE      :
__PATH           :
ReturnValue      : 66
PSComputerName   :

__GENUS          : 2
__CLASS          : __PARAMETERS
__SUPERCLASS     :
__DYNASTY        : __PARAMETERS
__RELPATH        :
__PROPERTY_COUNT : 1
__DERIVATION     : {}
__SERVER         :
__NAMESPACE      :
__PATH           :
ReturnValue      : 0
PSComputerName   :

__GENUS          : 2
__CLASS          : __PARAMETERS
__SUPERCLASS     :
__DYNASTY        : __PARAMETERS
__RELPATH        :
__PROPERTY_COUNT : 1
__DERIVATION     : {}
__SERVER         :
__NAMESPACE      :
__PATH           :
ReturnValue      : 0
PSComputerName   :

__GENUS          : 2
__CLASS          : __PARAMETERS
__SUPERCLASS     :
__DYNASTY        : __PARAMETERS
__RELPATH        :
__PROPERTY_COUNT : 1
__DERIVATION     : {}
__SERVER         :
__NAMESPACE      :
__PATH           :
ReturnValue      : 0
PSComputerName   :

Those errors you’re seeing belong to Admin password change, unrelated to the problem we have.

You may try to only configure networking in case some other part is exiting. At the end of context.ps1 change the code to:

# Execute script
if(Test-Path $contextScriptPath) {
    $context = getContext $contextScriptPath
    # addLocalUser $context
    # renameComputer $context
    # enableRemoteDesktop
    # enablePing
    configureNetwork $context
    # runScripts $context $contextLetter
    # setContextualized
}

You can also enable tracing to check if it’s trying to configure the IP:

C:\> Set-PSDebug -Trace 1
C:\> .\context.ps1
1 Like

I think your issue is here -

__GENUS          : 2
__CLASS          : __PARAMETERS
__SUPERCLASS     :
__DYNASTY        : __PARAMETERS
__RELPATH        :
__PROPERTY_COUNT : 1
__DERIVATION     : {}
__SERVER         :
__NAMESPACE      :
__PATH           :
ReturnValue      : 66
PSComputerName   : 

Return code 66 is “Invalid subnet mask” and you don’t appear to have one set in your context that I can see. I’d recommend that the subnet mask is set in the virtual network that you are using, it should come through to the VM as ETH0_MASK for the script to read it. I would also recommend setting the default gateway if it is not set already.

1 Like

Thank you very much! In Virtual networks I set NETMASK = 24 it’s work in OpenNebula 4. I set 255.255.255.0 and all works fine!
Thanks!

Problem SOLVED