VMware {code} Community
richard_judd
Contributor
Contributor

Using the Web Service to update or create Svga.vramSize

Anyone know how to programatically add "Svga.vramSize = xxxxxxxxxx" to the machines .vmw configuration file.

Currently this only seems possible by directly editing the .vmx file while logged directly in the ESX server..

Even adding it via the "Edit Settings" menu in Virtual Center does not work.

Tags (2)
Reply
0 Kudos
14 Replies
lamw
Community Manager
Community Manager

Take a look this script: , this operation may or may not persist while the VM is online. You'll need to test it out, but this allows you to add key/value pairs into the .vmx file

=========================================================================

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at:

VMware Code Central - Scripts/Sample code for Developers and Administrators

VMware Developer Comuunity

Twitter: @lamw

If you find this information useful, please award points for "correct" or "helpful".

Reply
0 Kudos
richard_judd
Contributor
Contributor

Hi.

I think this is going to have the same result... as I can add any key-pair into the vmx file except for "Svga.vramSize=15360000".. This must be known/expected behaviour as any other key pair (even just rubbish) will work every time..

??

Reply
0 Kudos
lamw
Community Manager
Community Manager

I'm not sure what the maximum value can be set to, you'll need to do research on that but the question was just updating the .vmx with a pair/value key, which is what the script does.

These threads may help:

=========================================================================

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at:

VMware Code Central - Scripts/Sample code for Developers and Administrators

VMware Developer Comuunity

Twitter: @lamw

If you find this information useful, please award points for "correct" or "helpful".

Reply
0 Kudos
richard_judd
Contributor
Contributor

Are you saying that you can programatically add the key/pair for "Svga.vramSize/15360000" (15360000 is 15mb)

I have tried and this does not work... i recieve no errors either..

Reply
0 Kudos
lamw
Community Manager
Community Manager

So it looks like this specific key will not add via API, I would not be surprised if this was deprecated in vSphere or in any other subsequent release. The other thing I've found that might be helpful is this VMware KB: http://kb.vmware.com/kb/1003 the value must be evenly divisible by 65536. In any case, when you manually edit the .vmx file, this is not governed or regulated by the API's as it's not aware of the modification and per the KB, it looks like the instructions are to manually update the .vmx. You can still script this, but you would need to enable unsupported SSH console if you're using ESXi and you just need to do this while the VM is powered off.

=========================================================================

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at:

VMware Code Central - Scripts/Sample code for Developers and Administrators

VMware Developer Comuunity

Twitter: @lamw

If you find this information useful, please award points for "correct" or "helpful".

richard_judd
Contributor
Contributor

I dont think the API supports it at all..... even when trying to add the key pair through the GUI (edit settings/options/general/configuration parameters) it doesn`t work,.. the VC accepts the change and displays the completed status as you would expect, but when you check the setting it isn`t there. Programatically I`ve used vmware.vim.dll version 2.0 and 4.0, neither work.

Using ssh and directly editing the .vmx file is of course possible, but as the rest of the provisioning, auditing etc.. is done the API (over 4,000 machines done so far) I may let this one slip and create a script that can be run in ahousekeeping mode after the fact (by default all the vms have 15360000 set), or get VMware to include it in the API ...

thanks for your input earlier though ..

Reply
0 Kudos
lamw
Community Manager
Community Manager

I'm not sure if you're running vSphere, but I just found that this is supported but it looks like VMware has updated their UI to update the svga ram size. Take a look at the screenshot where it specifies the video ram, I'm sure this is in the API to reconfigure.

=========================================================================

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at:

VMware Code Central - Scripts/Sample code for Developers and Administrators

VMware Developer Comuunity

Twitter: @lamw

If you find this information useful, please award points for "correct" or "helpful".

Reply
0 Kudos
lamw
Community Manager
Community Manager

Yep, looks like there is a method in the API: and you'll just use ReconfigVM_Task()

Also note, this actually does add svga.vramSize to the .vmx file

=========================================================================

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at:

VMware Code Central - Scripts/Sample code for Developers and Administrators

VMware Developer Comuunity

Twitter: @lamw

If you find this information useful, please award points for "correct" or "helpful".

Reply
0 Kudos
richard_judd
Contributor
Contributor

So any reason why this code below would not work (i've tried on vSphere and ESX 3.5)

note: It is only the the vramSize key/pair taht doesnot work ... the rest is good..

Dim numDisplaysKey As String = "Svga.numDisplays" Dim numDisplaysValue As String = "4" Dim maxHeightKey As String = "Svga.maxHeight" Dim maxHeightValue As String = "1024" Dim maxWidthKey As String = "Svga.maxWidth" Dim maxWidthValue As String = "5120" Dim vramSizeKey As String = "Svga.vramSize" Dim vramSizeValue As String = "20971520"

Dim info As VMware.Vim.VirtualMachineConfigSpec info = New VMware.Vim.VirtualMachineConfigSpec With info .NumCPUs = cpp .MemoryMB = mep

If displyConfig IsNot Nothing Then .ExtraConfig = New VMware.Vim.OptionValue(2) {} .ExtraConfig(0) = New VMware.Vim.OptionValue() .ExtraConfig(0).Key = numDisplaysKey .ExtraConfig(0).Value = numDisplaysValue .ExtraConfig(1) = New VMware.Vim.OptionValue() .ExtraConfig(1).Key = maxWidthKey .ExtraConfig(1).Value = maxWidthValue .ExtraConfig(2) = New VMware.Vim.OptionValue() .ExtraConfig(2).Key = vramSizeKey .ExtraConfig(2).Value = vramSizeValue End If End With vm.ReconfigVM_Task(info)

Reply
0 Kudos
lamw
Community Manager
Community Manager

Don't know ... again this may have been deprecated between 3.5u4 and 4.0. I just know that you can directly update the vram for svga by using the steps listed from my 2 previous comments. You're more than welcome to open a support ticket with VMware if you have SDK support, but you may just get 'we don't support' this anymore OR deprecated functionality.

=========================================================================

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at:

VMware Code Central - Scripts/Sample code for Developers and Administrators

VMware Developer Comuunity

Twitter: @lamw

If you find this information useful, please award points for "correct" or "helpful".

richard_judd
Contributor
Contributor

Thanks for that William .. Smiley Happy

Using the ifo you gave me and a little reverse engineering I have sucessfully written the code that does everything I want.

Dim info As VMware.Vim.VirtualMachineConfigSpec

info = New VMware.Vim.VirtualMachineConfigSpec

With info

.NumCPUs = cpp

.MemoryMB = mep

If Me.cbx_GBM_BBP_NumDisplays.SelectedIndex <> -1 Then

If displyConfig IsNot Nothing Then

.ExtraConfig = New VMware.Vim.OptionValue(1) {}

.ExtraConfig(0) = New VMware.Vim.OptionValue()

.ExtraConfig(0).Key = maxWidthKey

.ExtraConfig(0).Value = maxWidthValue

.ExtraConfig(1) = New VMware.Vim.OptionValue()

.ExtraConfig(1).Key = maxHeightKey

.ExtraConfig(1).Value = maxHeightValue

.ExtraConfig(2) = New VMware.Vim.OptionValue()

.ExtraConfig(2).Key = numDisplaysKey

.ExtraConfig(2).Value = numDisplaysValue

Call ConfigureVirtualVideoRAMsize(vramSizeValue, vm)

End If

End If

End With

vm.ReconfigVM_Task(info) : info = Nothing

Public Sub ConfigureVirtualVideoRAMsize(ByVal vramInKB As Integer, ByVal vm As VirtualMachine)

Dim videoCard As VirtualMachineVideoCard = Nothing

' Get all the virtual devices of a VirtualMachine

Dim vDevices As VirtualDevice() = vm.Config.Hardware.Device

' Find the video card from available virtual devices

For x As Integer = 0 To vDevices.Length - 1

If TypeOf vDevices(x) Is VMware.Vim.VirtualMachineVideoCard Then

videoCard = DirectCast(vDevices(x), VirtualMachineVideoCard)

Exit For

End If

Next

If videoCard IsNot Nothing Then

' Set the new videoRamSize

videoCard.VideoRamSizeInKB = vramInKB

' Create the configuration spec to be passed in ReconfigVM method

Dim deviceSpec As New VirtualDeviceConfigSpec()

deviceSpec.Operation = VirtualDeviceConfigSpecOperation.edit

deviceSpec.Device = videoCard

Dim confSpec As New VirtualMachineConfigSpec()

confSpec.DeviceChange = New VirtualDeviceConfigSpec()

vm.ReconfigVM(confSpec)

End If

End Sub

Reply
0 Kudos
lamw
Community Manager
Community Manager

Very cool! Glad got it working, if you don't mind you should think about putting this up as a piece of sample code in VMware Code Central

=========================================================================

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at:

VMware Code Central - Scripts/Sample code for Developers and Administrators

VMware Developer Comuunity

Twitter: @lamw

If you find this information useful, please award points for "correct" or "helpful".

Reply
0 Kudos
richard_judd
Contributor
Contributor

more people need to upload more C# or VB.net samples,. it has been a pain to reverse the perl or powershell snippets ...

Reply
0 Kudos
richard_judd
Contributor
Contributor

Uploaded two code examples that i'm currently using:

Switching between Network Interfaces

Configuring VirtualVideoCard

Reply
0 Kudos