VMware Cloud Community
AdrianTT
Enthusiast
Enthusiast

BUG: vCloud Director 8.20.01 - GUI Defect - Create Organization VDC Template PAYG Memory Garanteed

Hi there,

Just wanted to report a possible defect in vCloud Director 8.20.0.1 (Build 5439762) when creating/editing an Organization VDC Template with the Pay-As-You-Go allocation model for the Memory resources guaranteed field; the default value is 20% for Pay-As-You-Go and the interface does not allow the value to be less than 20%; if it is set any lower it is set back to 20%. Values over 20% are retained however there is no way to set to less then 20% .

OrgVDCTemplate.png

Reviewing the documentation (vCloud Director Administrator's Guide - vCloud Director 8.20 p.68) there is no mention of a minimum value for this field so suspect this may be a bug as creating an Organization VDC as PAYG (when not using a template allows this to be set to 0-20%).

As a workaround the following can be executed against the vCloud Director Database which seems to be the only way I have found that allows this to be updated;

UPDATE [vCloud].[dbo].[org_prov_vdc_specification] 

SET [memory_guarantee_percentage] = 0

WHERE [id] = (

     SELECT [current_specification]

     FROM [vCloud].[dbo].[org_prov_vdc_template]

     WHERE [provider_name] = 'Test Org VDC (DC1)'

);

After this is executed the Interface does not show the correct values however any VDCs that are Instantiated from the Template get the correct settings and the API returns the correct values.

OrgVDCTemplateAPI.png

Further when attempting to update via the API (Updating the XML specification and attempting a HTTP PUT against the URI in the Link.edit property) an exception is thrown regarding a duplicate key in dbo.org_prov_vdc_template_bindings.

<Error xmlns="http://www.vmware.com/vcloud/v1.5" stackTrace="org.springframework.dao.DataIntegrityViolationException: Could not execute JDBC batch update; SQL [/* Method: VdcTemplateService.updateTemplate */ insert into org_prov_vdc_template_bindings (external_network_id, name, prov_vdc_id, org_prov_vdc_template_id, id) values (?, ?, ?, ?, ?)]; constraint [null]; nested exception is org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update

" majorErrorCode="500" message="[ 23eccef1-9feb-488e-9d16-8ce81e1f56e9 ] Could not execute JDBC batch update; SQL [/* Method: VdcTemplateService.updateTemplate */ insert into org_prov_vdc_template_bindings (external_network_id, name, prov_vdc_id, org_prov_vdc_template_id, id) values (?, ?, ?, ?, ?)]; constraint [null]; nested exception is org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update

- Could not execute JDBC batch update

- Violation of UNIQUE KEY constraint 'uq_or_pr_vd_te_b_o_p_v_t_i_n_p'. Cannot insert duplicate key in object 'dbo.org_prov_vdc_template_bindings'. The duplicate key value is (0xbc18684d77004d6994865c8005757513, 0565aa5e-4e05-37cc-0203-2f7364b9fb5a, 0x2cbb70a62bb74fa6a140dd3dc5d93e0e)." minorErrorCode="INTERNAL_SERVER_ERROR" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.vmware.com/vcloud/v1.5 http://10.9.10.40/api/v1.5/schema/master.xsd"></Error>

A quick hack to attempt to update the specification via the REST API via Powershell which throw the Exception as per below:

function Get-vCloudAPIResponse(){

<#

.SYNOPSIS

Wrapper function which returns the XML response from a vCloud Director API Call

.DESCRIPTION

Wrapper function which returns the XML response from a vCloud Director API Call

.PARAMETER URI

The URI of the vCloud API object to perform the GET request against

.PARAMETER ContentType

The Content-Type to pass to vCloud in the headers

.EXAMPLE

Get-vCloudAPIResponse -URI "https://vcd.pigeonnuggets.com/api/vApp/vm-f13ad1ca-3151-455c-aa84-935a2669da96/virtualHardwareSectio..." -ContentType "application/vnd.vmware.vcloud.rasditemslist+xml"

Returns the XML response from a HTTP GET to the API /virtualHardwareSection/disks section for object vm-f13ad1ca-3151-455c-aa84-935a2669da96 using the Session Key from the current connection and sets the content type to application/vnd.vmware.vcloud.rasditemslist+xml

.NOTES

  NAME: Get-vCloudAPIResponse

  AUTHOR: Adrian Begg

  LASTEDIT: 2017-05-24

  KEYWORDS: vmware get vcloud director

  #Requires -Version 2.0

#>

Param(

[Parameter(Mandatory=$True)] [string] $URI,

[Parameter(Mandatory=$True)] [string] $ContentType

)

if(!$global:DefaultCIServers.IsConnected){

throw "You are not currently connected to any servers. Please connect first using a Connect-CIServer cmdlet."

}

# Setup Web Request for the API call to retireve the data from vCloud

$webclient = New-Object system.net.webclient

$webclient.Headers.Add("x-vcloud-authorization",$global:DefaultCIServers.SessionSecret)

$webclient.Headers.Add("Accept","application/*+xml;version=27.0")

$webclient.Headers.Add("Content-Type", $ContentType)

$webclient.Headers.Add("Accept-Language: en")

try{

[xml]$xmlResponse = $webclient.DownloadString($URI)

} catch {

throw "An error occured attempting to make HTTP GET against $URI"

}               

$xmlResponse

}

function Publish-vCloudAPICall(){

<#

.SYNOPSIS

Wrapper function which performs a POST of XML to the vCloud Director API

.DESCRIPTION

Wrapper function which performs a POST of XML to the vCloud Director API

.PARAMETER URI

The URI of the vCloud API object to perform the POST request against

.PARAMETER ContentType

The Content-Type to pass to vCloud in the headers

.PARAMETER Data

The payload to POST to the API

.EXAMPLE

.NOTES

  NAME: Publish-vCloudAPICall

  AUTHOR: Adrian Begg

  LASTEDIT: 2017-05-24

  KEYWORDS: vmware publish vcloud director

  #Requires -Version 2.0

#>

Param(

[Parameter(Mandatory=$True)] [string] $URI,

[Parameter(Mandatory=$True)] [string] $ContentType,

[Parameter(Mandatory=$True)] [xml] $Data

)

if(!$global:DefaultCIServers.IsConnected){

throw "You are not currently connected to any servers. Please connect first using a Connect-CIServer cmdlet."

}

# Setup Web Request

$webclient = New-Object system.net.webclient

$webclient.Headers.Add("x-vcloud-authorization",$global:DefaultCIServers.SessionSecret)

$webclient.Headers.Add("Accept","application/*+xml;version=27.0")

$webclient.Headers.Add("Content-Type", $ContentType)

$webclient.Headers.Add("Accept-Language: en")

# Convert the new configuration to byte array for upload

[string] $strUploadData = $Data.OuterXml

[byte[]]$byteArray = [System.Text.Encoding]::ASCII.GetBytes($strUploadData)

# "To the cloud !"

try{

$UploadData = $webclient.UploadData($URI, "PUT", $bytearray)

} catch {

throw "An error occured attempting to make HTTP POST against $URI"

}

}

function Get-CIVdcTemplate(){

<#

.SYNOPSIS

Returns a Virtual Datacenter Template

.DESCRIPTION

Returns a Virtual Datacenter Template if no name is provided a collection of all VDC Templates is returned

.PARAMETER TemplateName

The name of the VDC Tempalte to search for

.EXAMPLE

Get-CIVdcTemplate

Returns a collection of VDC Templates

.EXAMPLE

Get-CIVdcTemplate -TemplateName "Test VDC Template"

Returns the template with the name "Test VDC Template"

.NOTES

  NAME: Get-CIVdcTemplate

  AUTHOR: Adrian Begg

  LASTEDIT: 2017-07-11

  #Requires -Version 2.0

#>

Param(

[Parameter(Mandatory=$False)] [string] $TemplateName

)

# Check if the server is connected

if(!$global:DefaultCIServers.IsConnected){

throw "You are not currently connected to any servers. Please connect first using a Connect-CIServer cmdlet."

}

# Check the version of vCloud Director is above v8.20

if(!($global:DefaultCIServers.Version -gt 8.00)){

throw "Org VDC Templates are introdcued in vCloud Director 8.00. The current connected server is version $($global:DefaultCIServers.Version)"

}

# Query the Organisation for the VDC TemplateRefereneces

$URI = $global:DefaultCIServers.ServiceUri.AbsoluteURI + "admin/extension/vdcTemplateReferences"

[xml] $XMLTemplateRef = Get-vCloudAPIResponse -URI $URI -ContentType "application/vnd.vmware.admin.vmwVdcTemplate+xml"

if(!([string]::IsNullOrEmpty($TemplateName))){

$colVDCReferences = $XMLTemplateRef.VMWVdcTemplateReferences.Reference | ?{$_.name -eq $TemplateName}

} else{

$colVDCReferences = $XMLTemplateRef.VMWVdcTemplateReferences.Reference

}

$colVDCTemplates = New-Object -TypeName System.Collections.ArrayList

foreach($objRef in $colVDCReferences){

# Retrieve the configuration for each of the VDC Templates and add to a collection

$VDCTemplateURI = $objRef.href

[xml] $VDCTemplateSpec = Get-vCloudAPIResponse -URI $VDCTemplateURI -ContentType "application/vnd.vmware.admin.vmwVdcTemplate+xml"

# Add the object to the collection

$objVDCTemplate = New-Object System.Management.Automation.PSObject

$objVDCTemplate | Add-Member Note* Name $objRef.name

$objVDCTemplate | Add-Member Note* URI $objRef.href

$objVDCTemplate | Add-Member Note* VDCTemplateXML $VDCTemplateSpec

$colVDCTemplates.Add($objVDCTemplate) > $null

}

$colVDCTemplates

}

# Manually attempt to update via the API call HTTP PUT against the URI

$objTest = Get-CIVdcTemplate "Test Org VDC (DC1)"

$objTest.VDCTemplateXML.VMWVdcTemplate.VdcTemplateSpecification.MemoryGuaranteedPercentage = "0"

Update-vCloudAPICall -URI $objTest.URI -Data $objTest.VDCTemplateXML.OuterXml -ContentType "application/vnd.vmware.admin.vmwVdcTemplate+xml"

Please consider marking this answer "correct" or "helpful" if you think your query have been answered correctly. Cheers,
0 Kudos
0 Replies