Fix XML root element references;Deleted comments
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
8340b97a4d
commit
969e3b385b
@ -63,7 +63,6 @@ ForEach ($Disk in $OVFConfig.DynamicDisks) {
|
||||
}
|
||||
|
||||
$XMLDisk = $XML.CreateElement('Disk', $XML.DocumentElement.xmlns)
|
||||
# $XMLDiskAttrUnits = $XML.CreateAttribute('capacityAllocationUnits', $XML.DocumentElement.ovf)
|
||||
Switch ($Disk.UnitSize) {
|
||||
'KB' {
|
||||
$Powers = 10
|
||||
@ -85,27 +84,11 @@ ForEach ($Disk in $OVFConfig.DynamicDisks) {
|
||||
Continue
|
||||
}
|
||||
}
|
||||
# $XMLDiskAttrUnits.Value = "byte * 2^$($Powers)"
|
||||
[void]$XMLExtraConfig.SetAttribute('capacityAllocationUnits', $NS.LookupNamespace('ovf'), "byte * 2^$($Powers)")
|
||||
# $XMLDiskAttrFormat = $XML.CreateAttribute('format', $XML.DocumentElement.ovf)
|
||||
# $XMLDiskAttrFormat.Value = 'http://www.vmware.com/interfaces/specifications/vmdk.html#streamOptimized'
|
||||
[void]$XMLExtraConfig.SetAttribute('format', $NS.LookupNamespace('ovf'), 'http://www.vmware.com/interfaces/specifications/vmdk.html#streamOptimized')
|
||||
# $XMLDiskId = $XML.CreateAttribute('diskId', $XML.DocumentElement.ovf)
|
||||
# $XMLDiskId.Value = "vmdisk$($DiskId)"
|
||||
[void]$XMLExtraConfig.SetAttribute('diskId', $NS.LookupNamespace('ovf'), "vmdisk$($DiskId)")
|
||||
# $XMLDiskAttrCapacity = $XML.CreateAttribute('capacity', $XML.DocumentElement.ovf)
|
||||
# $XMLDiskAttrCapacity.Value = '${{vmconfig.disksize.{0}}}' -f $DiskId
|
||||
[void]$XMLExtraConfig.SetAttribute('capacity', $NS.LookupNamespace('ovf'), '${{vmconfig.disksize.{0}}}' -f $DiskId)
|
||||
# $XMLDiskAttrPopulated = $XML.CreateAttribute('populatedSize', $XML.DocumentElement.ovf)
|
||||
# $XMLDiskAttrPopulated.Value = 0
|
||||
[void]$XMLExtraConfig.SetAttribute('populatedSize', $NS.LookupNamespace('ovf'), 0)
|
||||
|
||||
# [void]$XMLDisk.Attributes.Append($XMLDiskAttrUnits)
|
||||
# [void]$XMLDisk.Attributes.Append($XMLDiskAttrFormat)
|
||||
# [void]$XMLDisk.Attributes.Append($XMLDiskId)
|
||||
# [void]$XMLDisk.Attributes.Append($XMLDiskAttrCapacity)
|
||||
# [void]$XMLDisk.Attributes.Append($XMLDiskAttrPopulated)
|
||||
|
||||
[void]$XMLDisk.SetAttribute('capacityAllocationUnits', $NS.LookupNamespace('ovf'), "byte * 2^$($Powers)")
|
||||
[void]$XMLDisk.SetAttribute('format', $NS.LookupNamespace('ovf'), 'http://www.vmware.com/interfaces/specifications/vmdk.html#streamOptimized')
|
||||
[void]$XMLDisk.SetAttribute('diskId', $NS.LookupNamespace('ovf'), "vmdisk$($DiskId)")
|
||||
[void]$XMLDisk.SetAttribute('capacity', $NS.LookupNamespace('ovf'), '${{vmconfig.disksize.{0}}}' -f $DiskId)
|
||||
[void]$XMLDisk.SetAttribute('populatedSize', $NS.LookupNamespace('ovf'), 0)
|
||||
[void]$XML.SelectSingleNode('//ns:DiskSection', $NS).AppendChild($XMLDisk)
|
||||
|
||||
# Add new resourceType nodes
|
||||
@ -120,7 +103,7 @@ ForEach ($Disk in $OVFConfig.DynamicDisks) {
|
||||
$InstanceID++
|
||||
}
|
||||
$XMLDiskItem.SelectSingleNode('rasd:InstanceID', $NS).InnerText = $InstanceID
|
||||
$XML.SelectSingleNode('//ns:VirtualHardwareSection', $NS).AppendChild($XMLDiskItem)
|
||||
[void]$XML.SelectSingleNode('//ns:VirtualHardwareSection', $NS).AppendChild($XMLDiskItem)
|
||||
|
||||
$OVFConfig.PropertyCategories[0].ProductProperties += @{
|
||||
Key = "vmconfig.disksize.$($DiskId)"
|
||||
@ -148,17 +131,13 @@ If ($OVFConfig.DeploymentConfigurations.Count -gt 0) {
|
||||
ForEach ($Configuration in $OVFConfig.DeploymentConfigurations) {
|
||||
$XMLConfig = $XML.CreateElement('Configuration', $XML.DocumentElement.xmlns)
|
||||
|
||||
# $XMLConfigAttrId = $XML.CreateAttribute('id', $XML.DocumentElement.ovf)
|
||||
# $XMLConfigAttrId.Value = $Configuration.Id
|
||||
[void]$XMLExtraConfig.SetAttribute('id', $NS.LookupNamespace('ovf'), $Configuration.Id)
|
||||
[void]$XMLConfig.SetAttribute('id', $NS.LookupNamespace('ovf'), $Configuration.Id)
|
||||
|
||||
$XMLConfigLabel = $XML.CreateElement('Label', $XML.DocumentElement.xmlns)
|
||||
$XMLConfigLabel.InnerText = $Configuration.Label
|
||||
|
||||
$XMLConfigDescription = $XML.CreateElement('Description', $XML.DocumentElement.xmlns)
|
||||
$XMLConfigDescription.InnerText = $Configuration.Description
|
||||
|
||||
# [void]$XMLConfig.Attributes.Append($XMLConfigAttrId)
|
||||
[void]$XMLConfig.AppendChild($XMLConfigLabel)
|
||||
[void]$XMLConfig.AppendChild($XMLConfigDescription)
|
||||
|
||||
@ -173,7 +152,7 @@ If ($OVFConfig.DeploymentConfigurations.Count -gt 0) {
|
||||
$XMLMemoryTemplate = $XML.SelectSingleNode("//ns:VirtualHardwareSection/ns:Item/rasd:ResourceType[.='4']", $NS).ParentNode.CloneNode($True)
|
||||
# Delete default resourceType nodes
|
||||
ForEach ($Node in $XML.SelectNodes("//ns:VirtualHardwareSection/ns:Item/rasd:ResourceType[.='3' or .='4']", $NS).ParentNode) {
|
||||
$Node.ParentNode.RemoveChild($Node)
|
||||
[void]$Node.ParentNode.RemoveChild($Node)
|
||||
}
|
||||
# Add updated resourceType nodes
|
||||
ForEach ($Configuration in $OVFConfig.DeploymentConfigurations) {
|
||||
@ -187,32 +166,20 @@ If ($OVFConfig.DeploymentConfigurations.Count -gt 0) {
|
||||
$XMLMemory.SelectSingleNode('rasd:ElementName', $NS).InnerText = '{0}MB of memory' -f $Configuration.Size.Memory
|
||||
$XMLMemory.SelectSingleNode('rasd:VirtualQuantity', $NS).InnerText = $Configuration.Size.Memory
|
||||
|
||||
$XML.SelectSingleNode('//ns:VirtualHardwareSection', $NS).AppendChild($XMLCPU)
|
||||
$XML.SelectSingleNode('//ns:VirtualHardwareSection', $NS).AppendChild($XMLMemory)
|
||||
[void]$XML.SelectSingleNode('//ns:VirtualHardwareSection', $NS).AppendChild($XMLCPU)
|
||||
[void]$XML.SelectSingleNode('//ns:VirtualHardwareSection', $NS).AppendChild($XMLMemory)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# $XMLAttrTransport = $XML.CreateAttribute('transport', $XML.DocumentElement.ovf)
|
||||
# $XMLAttrTransport.Value = 'com.vmware.guestInfo'
|
||||
# [void]$XML.SelectSingleNode('//ns:VirtualHardwareSection', $NS).Attributes.Append($XMLAttrTransport)
|
||||
[void]$XML.SelectSingleNode('//ns:VirtualHardwareSection', $NS).SetAttribute('transport', $NS.LookupNamespace('ovf'), 'com.vmware.guestInfo')
|
||||
ForEach ($ExtraConfig in $OVFConfig.AdvancedOptions) {
|
||||
$XMLExtraConfig = $XML.CreateElement('vmw:ExtraConfig', $XML.DocumentElement.vmw)
|
||||
|
||||
# $XMLExtraConfigAttrRequired = $XML.CreateAttribute('required', $XML.DocumentElement.ovf)
|
||||
# $XMLExtraConfigAttrRequired.Value = "$([boolean]$ExtraConfig.Required)".ToLower()
|
||||
# $XMLExtraConfigAttrKey = $XML.CreateAttribute('key', $XML.DocumentElement.vmw)
|
||||
# $XMLExtraConfigAttrKey.Value = $ExtraConfig.Key
|
||||
# $XMLExtraConfigAttrValue = $XML.CreateAttribute('value', $XML.DocumentElement.vmw)
|
||||
# $XMLExtraConfigAttrValue.Value = $ExtraConfig.Value
|
||||
|
||||
# [void]$XMLExtraConfig.Attributes.Append($XMLExtraConfigAttrRequired)
|
||||
[void]$XMLExtraConfig.SetAttribute('required', $NS.LookupNamespace('ovf'), "$([boolean]$ExtraConfig.Required)".ToLower())
|
||||
# [void]$XMLExtraConfig.Attributes.Append($XMLExtraConfigAttrKey)
|
||||
[void]$XMLExtraConfig.SetAttribute('key', $NS.LookupNamespace('vmw'), $ExtraConfig.Key)
|
||||
# [void]$XMLExtraConfig.Attributes.Append($XMLExtraConfigAttrValue)
|
||||
[void]$XMLExtraConfig.SetAttribute('value', $NS.LookupNamespace('vmw'), $ExtraConfig.Value)
|
||||
|
||||
[void]$XML.SelectSingleNode('//ns:VirtualHardwareSection', $NS).AppendChild($XMLExtraConfig)
|
||||
}
|
||||
Write-Host "Added $($OVFConfig.AdvancedOptions.Count) 'vmw:ExtraConfig' nodes"
|
||||
@ -244,18 +211,13 @@ ForEach ($Category in $OVFConfig.PropertyCategories) {
|
||||
ForEach ($Property in $Category.ProductProperties) {
|
||||
$XMLProperty = $XML.CreateElement('Property', $XML.DocumentElement.xmlns)
|
||||
|
||||
# $XMLPropertyAttrKey = $XML.CreateAttribute('key', $XML.DocumentElement.ovf)
|
||||
# $XMLPropertyAttrKey.Value = $Property.Key
|
||||
$XMLProperty.SetAttribute('key', $NS.LookupNamespace('ovf'), $Property.Key)
|
||||
# $XMLPropertyAttrType = $XML.CreateAttribute('type', $XML.DocumentElement.ovf)
|
||||
Switch -regex ($Property.Type) {
|
||||
'^boolean' {
|
||||
# $XMLPropertyAttrType.Value = 'boolean'
|
||||
$XMLProperty.SetAttribute('type', $NS.LookupNamespace('ovf'), 'boolean')
|
||||
[void]$XMLProperty.SetAttribute('type', $NS.LookupNamespace('ovf'), 'boolean')
|
||||
}
|
||||
'^int' {
|
||||
# $XMLPropertyAttrType.Value = 'uint16'
|
||||
$XMLProperty.SetAttribute('type', $NS.LookupNamespace('ovf'), 'uint16')
|
||||
[void]$XMLProperty.SetAttribute('type', $NS.LookupNamespace('ovf'), 'uint16')
|
||||
$Qualifiers = @()
|
||||
If ($Property.Type -match '^int\((\d*)\.\.(\d*)\)') {
|
||||
If ($Matches[1]) {
|
||||
@ -264,28 +226,16 @@ ForEach ($Category in $OVFConfig.PropertyCategories) {
|
||||
If ($Matches[2]) {
|
||||
$Qualifiers += "MaxValue($($Matches[2]))"
|
||||
}
|
||||
# $XMLPropertyAttrQualifiers = $XML.CreateAttribute('qualifiers', $XML.DocumentElement.ovf)
|
||||
# $XMLPropertyAttrQualifiers.Value = $Qualifiers -join ' '
|
||||
# [void]$XMLProperty.Attributes.Append($XMLPropertyAttrQualifiers)
|
||||
$XMLProperty.SetAttribute('qualifiers', $NS.LookupNamespace('ovf'), $Qualifiers -join ' ')
|
||||
[void]$XMLProperty.SetAttribute('qualifiers', $NS.LookupNamespace('ovf'), $Qualifiers -join ' ')
|
||||
}
|
||||
}
|
||||
'^ip' {
|
||||
# $XMLPropertyAttrType.Value = 'string'
|
||||
$XMLProperty.SetAttribute('type', $NS.LookupNamespace('ovf'), 'string')
|
||||
# $XMLPropertyAttrQualifiers = $XML.CreateAttribute('qualifiers', $XML.DocumentElement.vmw)
|
||||
# $XMLPropertyAttrQualifiers.Value = 'Ip'
|
||||
# [void]$XMLProperty.Attributes.Append($XMLPropertyAttrQualifiers)
|
||||
$XMLProperty.SetAttribute('qualifiers', $NS.LookupNamespace('vmw'), 'Ip')
|
||||
[void]$XMLProperty.SetAttribute('type', $NS.LookupNamespace('ovf'), 'string')
|
||||
[void]$XMLProperty.SetAttribute('qualifiers', $NS.LookupNamespace('vmw'), 'Ip')
|
||||
}
|
||||
'^password' {
|
||||
# $XMLPropertyAttrType.Value = 'string'
|
||||
$XMLProperty.SetAttribute('type', $NS.LookupNamespace('ovf'), 'string')
|
||||
# $XMLPropertyAttrPassword = $XML.CreateAttribute('password', $XML.DocumentElement.ovf)
|
||||
# $XMLPropertyAttrPassword.Value = 'true'
|
||||
# [void]$XMLProperty.Attributes.Append($XMLPropertyAttrPassword)
|
||||
$XMLProperty.SetAttribute('password', $NS.LookupNamespace('ovf'), 'true')
|
||||
|
||||
[void]$XMLProperty.SetAttribute('type', $NS.LookupNamespace('ovf'), 'string')
|
||||
[void]$XMLProperty.SetAttribute('password', $NS.LookupNamespace('ovf'), 'true')
|
||||
$Qualifiers = @()
|
||||
If ($Property.Type -match '^password\((\d*)\.\.(\d*)\)') {
|
||||
If ($Matches[1]) {
|
||||
@ -294,15 +244,11 @@ ForEach ($Category in $OVFConfig.PropertyCategories) {
|
||||
If ($Matches[2]) {
|
||||
$Qualifiers += "MaxLen($($Matches[2]))"
|
||||
}
|
||||
# $XMLPropertyAttrQualifiers = $XML.CreateAttribute('qualifiers', $XML.DocumentElement.ovf)
|
||||
# $XMLPropertyAttrQualifiers.Value = $Qualifiers -join ' '
|
||||
# [void]$XMLProperty.Attributes.Append($XMLPropertyAttrQualifiers)
|
||||
$XMLProperty.SetAttribute('qualifiers', $NS.LookupNamespace('ovf'), $Qualifiers -join ' ')
|
||||
[void]$XMLProperty.SetAttribute('qualifiers', $NS.LookupNamespace('ovf'), $Qualifiers -join ' ')
|
||||
}
|
||||
}
|
||||
'^string' {
|
||||
# $XMLPropertyAttrType.Value = 'string'
|
||||
$XMLProperty.SetAttribute('type', $NS.LookupNamespace('ovf'), 'string')
|
||||
[void]$XMLProperty.SetAttribute('type', $NS.LookupNamespace('ovf'), 'string')
|
||||
$Qualifiers = @()
|
||||
If ($Property.Type -match '^string\((\d*)\.\.(\d*)\)') {
|
||||
If ($Matches[1]) {
|
||||
@ -311,33 +257,19 @@ ForEach ($Category in $OVFConfig.PropertyCategories) {
|
||||
If ($Matches[2]) {
|
||||
$Qualifiers += "MaxLen($($Matches[2]))"
|
||||
}
|
||||
# $XMLPropertyAttrQualifiers = $XML.CreateAttribute('qualifiers', $XML.DocumentElement.ovf)
|
||||
# $XMLPropertyAttrQualifiers.Value = $Qualifiers -join ' '
|
||||
# [void]$XMLProperty.Attributes.Append($XMLPropertyAttrQualifiers)
|
||||
$XMLProperty.SetAttribute('qualifiers', $NS.LookupNamespace('ovf'), $Qualifiers -join ' ')
|
||||
[void]$XMLProperty.SetAttribute('qualifiers', $NS.LookupNamespace('ovf'), $Qualifiers -join ' ')
|
||||
} ElseIf ($Property.Type -match '^string\[(.*)\]') {
|
||||
# $XMLPropertyAttrQualifiers = $XML.CreateAttribute('qualifiers', $XML.DocumentElement.ovf)
|
||||
# $XMLPropertyAttrQualifiers.Value = "ValueMap{$($Matches[1] -replace '","', '", "')}"
|
||||
# [void]$XMLProperty.Attributes.Append($XMLPropertyAttrQualifiers)
|
||||
$XMLProperty.SetAttribute('qualifiers', $NS.LookupNamespace('ovf'), "ValueMap{$($Matches[1] -replace '","', '", "')}")
|
||||
[void]$XMLProperty.SetAttribute('qualifiers', $NS.LookupNamespace('ovf'), "ValueMap{$($Matches[1] -replace '","', '", "')}")
|
||||
}
|
||||
}
|
||||
}
|
||||
# $XMLPropertyAttrUserConfigurable = $XML.CreateAttribute('userConfigurable', $XML.DocumentElement.ovf)
|
||||
# $XMLPropertyAttrUserConfigurable.Value = "$([boolean]$Property.UserConfigurable)".ToLower()
|
||||
$XMLProperty.SetAttribute('userConfigurable', $NS.LookupNamespace('ovf'), "$([boolean]$Property.UserConfigurable)".ToLower())
|
||||
# $XMLPropertyAttrValue = $XML.CreateAttribute('value', $XML.DocumentElement.ovf)
|
||||
[void]$XMLProperty.SetAttribute('userConfigurable', $NS.LookupNamespace('ovf'), "$([boolean]$Property.UserConfigurable)".ToLower())
|
||||
|
||||
If ($Property.Type -eq 'boolean') {
|
||||
# $XMLPropertyAttrValue.Value = "$([boolean]$Property.DefaultValue)".ToLower()
|
||||
$XMLProperty.SetAttribute('value', $NS.LookupNamespace('ovf'), "$([boolean]$Property.DefaultValue)".ToLower())
|
||||
[void]$XMLProperty.SetAttribute('value', $NS.LookupNamespace('ovf'), "$([boolean]$Property.DefaultValue)".ToLower())
|
||||
} Else {
|
||||
# $XMLPropertyAttrValue.Value = $Property.DefaultValue
|
||||
$XMLProperty.SetAttribute('value', $NS.LookupNamespace('ovf'), $Property.DefaultValue)
|
||||
[void]$XMLProperty.SetAttribute('value', $NS.LookupNamespace('ovf'), $Property.DefaultValue)
|
||||
}
|
||||
# [void]$XMLProperty.Attributes.Append($XMLPropertyAttrKey)
|
||||
# [void]$XMLProperty.Attributes.Append($XMLPropertyAttrType)
|
||||
# [void]$XMLProperty.Attributes.Append($XMLPropertyAttrUserConfigurable)
|
||||
# [void]$XMLProperty.Attributes.Append($XMLPropertyAttrValue)
|
||||
|
||||
If ($Property.Label) {
|
||||
$XMLPropertyLabel = $XML.CreateElement('Label', $XML.DocumentElement.xmlns)
|
||||
@ -351,35 +283,19 @@ ForEach ($Category in $OVFConfig.PropertyCategories) {
|
||||
}
|
||||
|
||||
If (($Property.Configurations.Count -eq 1) -and ($Property.Configurations -eq '*')) {
|
||||
# $XMLPropertyAttrConfiguration = $XML.CreateAttribute('configuration', $XML.DocumentElement.ovf)
|
||||
# $XMLPropertyAttrConfiguration.Value = $OVFConfig.DeploymentConfigurations.Id -join ' '
|
||||
# [void]$XMLProperty.Attributes.Append($XMLPropertyAttrConfiguration)
|
||||
$XMLProperty.SetAttribute('configuration', $NS.LookupNamespace('ovf'), $OVFConfig.DeploymentConfigurations.Id -join ' ')
|
||||
[void]$XMLProperty.SetAttribute('configuration', $NS.LookupNamespace('ovf'), $OVFConfig.DeploymentConfigurations.Id -join ' ')
|
||||
} ElseIf ($Property.Configurations.Count -gt 0) {
|
||||
# $XMLPropertyAttrConfiguration = $XML.CreateAttribute('configuration', $XML.DocumentElement.ovf)
|
||||
# $XMLPropertyAttrConfiguration.Value = $Property.Configurations -join ' '
|
||||
# [void]$XMLProperty.Attributes.Append($XMLPropertyAttrConfiguration)
|
||||
$XMLProperty.SetAttribute('configuration', $NS.LookupNamespace('ovf'), $Property.Configurations -join ' ')
|
||||
[void]$XMLProperty.SetAttribute('configuration', $NS.LookupNamespace('ovf'), $Property.Configurations -join ' ')
|
||||
}
|
||||
|
||||
If ($Property.Value.Count -eq 1) {
|
||||
# $XMLPropertyAttrValue = $XML.CreateAttribute('value', $XML.DocumentElement.ovf)
|
||||
# $XMLPropertyAttrValue.Value = $Property.Value
|
||||
# [void]$XMLProperty.Attributes.Append($XMLPropertyAttrValue)
|
||||
$XMLProperty.SetAttribute('value', $NS.LookupNamespace('ovf'), $Property.Value)
|
||||
[void]$XMLProperty.SetAttribute('value', $NS.LookupNamespace('ovf'), $Property.Value)
|
||||
} ElseIf ($Property.Value.Count -gt 1) {
|
||||
ForEach ($Value in $Property.Value) {
|
||||
$XMLValue = $XML.CreateElement('Value', $XML.DocumentElement.xmlns)
|
||||
|
||||
# $XMLValueAttrValue = $XML.CreateAttribute('value', $XML.DocumentElement.ovf)
|
||||
# $XMLValueAttrValue.Value = $Value
|
||||
$XMLProperty.SetAttribute('value', $NS.LookupNamespace('ovf'), $Value)
|
||||
# $XMLValueAttrConfiguration = $XML.CreateAttribute('configuration', $XML.DocumentElement.ovf)
|
||||
# $XMLValueAttrConfiguration.Value = $Value
|
||||
$XMLProperty.SetAttribute('configuration', $NS.LookupNamespace('ovf'), $Value)
|
||||
|
||||
# [void]$XMLValue.Attributes.Append($XMLValueAttrValue)
|
||||
# [void]$XMLValue.Attributes.Append($XMLValueAttrConfiguration)
|
||||
[void]$XMLValue.SetAttribute('value', $NS.LookupNamespace('ovf'), $Value)
|
||||
[void]$XMLValue.SetAttribute('configuration', $NS.LookupNamespace('ovf'), $Value)
|
||||
|
||||
[void]$XMLProperty.AppendChild($XMLValue)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user