Introduce sized deployment options
	
		
			
	
		
	
	
		
	
		
			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:
		| @@ -34,11 +34,11 @@ foreach ($ovfProperty in $ovfProperties) { | |||||||
| } | } | ||||||
|  |  | ||||||
| # Check for mandatory values | # Check for mandatory values | ||||||
| Switch ($ovfPropertyValues['deployment.type']) { | Switch -regex ($ovfPropertyValues['deployment.type']) { | ||||||
|     'domainmember' { |     '^domainmember' { | ||||||
|         $MandatoryProperties, $MissingProperties = @('guestinfo.hostname', 'guestinfo.ipaddress', 'guestinfo.prefixlength', 'guestinfo.gateway', 'addsconfig.domainname', 'addsconfig.username', 'addsconfig.password'), @() |         $MandatoryProperties, $MissingProperties = @('guestinfo.hostname', 'guestinfo.ipaddress', 'guestinfo.prefixlength', 'guestinfo.gateway', 'addsconfig.domainname', 'addsconfig.username', 'addsconfig.password'), @() | ||||||
|     } |     } | ||||||
|     'standalone' { |     '^standalone' { | ||||||
|         $MandatoryProperties, $MissingProperties = @('guestinfo.hostname', 'guestinfo.ipaddress', 'guestinfo.prefixlength', 'guestinfo.gateway', 'guestinfo.administratorpw', 'guestinfo.ntpserver'), @()         |         $MandatoryProperties, $MissingProperties = @('guestinfo.hostname', 'guestinfo.ipaddress', 'guestinfo.prefixlength', 'guestinfo.gateway', 'guestinfo.administratorpw', 'guestinfo.ntpserver'), @()         | ||||||
|     } |     } | ||||||
|     default { |     default { | ||||||
| @@ -152,8 +152,8 @@ If ((Get-WmiObject -Class 'Win32_NetworkAdapterConfiguration').IPAddress -NotCon | |||||||
|     $ErrorActionPreference, $OldErrorActionPreference = $OldErrorActionPreference, $NULL |     $ErrorActionPreference, $OldErrorActionPreference = $OldErrorActionPreference, $NULL | ||||||
| } | } | ||||||
|  |  | ||||||
| Switch ($ovfPropertyValues['deployment.type']) { | Switch -regex ($ovfPropertyValues['deployment.type']) { | ||||||
|     'domainmember' { |     '^domainmember' { | ||||||
|         # Join Active Directory domain as member |         # Join Active Directory domain as member | ||||||
|         If (!(Get-WmiObject -Class Win32_ComputerSystem).PartOfDomain) { |         If (!(Get-WmiObject -Class Win32_ComputerSystem).PartOfDomain) { | ||||||
|             $AddComputerSplat = @{ |             $AddComputerSplat = @{ | ||||||
| @@ -174,7 +174,7 @@ Switch ($ovfPropertyValues['deployment.type']) { | |||||||
|             # Exit |             # Exit | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|     'standalone' { |     '^standalone' { | ||||||
|         # Change password of built-in Administrator |         # Change password of built-in Administrator | ||||||
|         $BuiltinAdministrator = (Get-LocalUser | Where-Object {$_.SID -match '-500'}) |         $BuiltinAdministrator = (Get-LocalUser | Where-Object {$_.SID -match '-500'}) | ||||||
|         $ConvertToSecureStringSplat = @{ |         $ConvertToSecureStringSplat = @{ | ||||||
|   | |||||||
| @@ -176,6 +176,31 @@ If ($OVFConfig.DeploymentConfigurations.Count -gt 0) { | |||||||
|     } |     } | ||||||
|     [void]$XML.SelectSingleNode('//ns:Envelope', $NS).InsertAfter($XMLSection, $XML.SelectSingleNode('//ns:NetworkSection', $NS)) |     [void]$XML.SelectSingleNode('//ns:Envelope', $NS).InsertAfter($XMLSection, $XML.SelectSingleNode('//ns:NetworkSection', $NS)) | ||||||
|     Write-Host "Inserted 'DeploymentOptionSection' with $($Configuration.Count) nodes" |     Write-Host "Inserted 'DeploymentOptionSection' with $($Configuration.Count) nodes" | ||||||
|  |  | ||||||
|  |     If ($OVFConfig.DeploymentConfigurations.Count -eq $OVFConfig.DeploymentConfigurations.Size.Count) { | ||||||
|  |         # Create copies of default resourceType nodes | ||||||
|  |         $XMLCPUTemplate = $XML.SelectSingleNode("//ns:VirtualHardwareSection/ns:Item/rasd:ResourceType[.='3']", $NS).ParentNode.CloneNode($True) | ||||||
|  |         $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) | ||||||
|  |         } | ||||||
|  |         # Add updated resourceType nodes | ||||||
|  |         ForEach ($Configuration in $OVFConfig.DeploymentConfigurations) { | ||||||
|  |             $XMLCPU = $XMLCPUTemplate.CloneNode($True) | ||||||
|  |             [void]$XMLCPU.SetAttribute('ovf:configuration', $Configuration.Id) | ||||||
|  |             $XMLCPU.SelectSingleNode('rasd:ElementName', $NS).InnerText = '{0} virtual CPU(s)' -f $Configuration.Size.CPU | ||||||
|  |             $XMLCPU.SelectSingleNode('rasd:VirtualQuantity', $NS).InnerText = $Configuration.Size.CPU | ||||||
|  |  | ||||||
|  |             $XMLMemory = $XMLMemoryTemplate.CloneNode($True) | ||||||
|  |             [void]$XMLMemory.SetAttribute('ovf:configuration', $Configuration.Id) | ||||||
|  |             $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) | ||||||
|  |         } | ||||||
|  |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| $XMLAttrTransport = $XML.CreateAttribute('transport', $XML.DocumentElement.ovf) | $XMLAttrTransport = $XML.CreateAttribute('transport', $XML.DocumentElement.ovf) | ||||||
|   | |||||||
| @@ -1,10 +1,28 @@ | |||||||
| DeploymentConfigurations: | DeploymentConfigurations: | ||||||
| - Id: domainmember | - Id: domainmember-medium | ||||||
|   Label: Domain member |   Label: Domain member | ||||||
|   Description: Windows Server joined to an Active Directory domain |   Description: Windows Server joined to an Active Directory domain | ||||||
| - Id: standalone |   Size: | ||||||
|  |     CPU: 2 | ||||||
|  |     Memory: 4096 | ||||||
|  | - Id: domainmember-large | ||||||
|  |   Label: Domain member | ||||||
|  |   Description: Windows Server joined to an Active Directory domain [LARGE] | ||||||
|  |   Size: | ||||||
|  |     CPU: 4 | ||||||
|  |     Memory: 8192 | ||||||
|  | - Id: standalone-medium | ||||||
|   Label: Stand-alone |   Label: Stand-alone | ||||||
|   Description: Stand-alone Windows Server |   Description: Stand-alone Windows Server | ||||||
|  |   Size: | ||||||
|  |     CPU: 2 | ||||||
|  |     Memory: 4096 | ||||||
|  | - Id: standalone-large | ||||||
|  |   Label: Stand-alone | ||||||
|  |   Description: Stand-alone Windows Server [LARGE] | ||||||
|  |   Size: | ||||||
|  |     CPU: 4 | ||||||
|  |     Memory: 8192 | ||||||
| Disks: | Disks: | ||||||
|   Referenced: |   Referenced: | ||||||
|   - Id: vmdisk1 |   - Id: vmdisk1 | ||||||
| @@ -27,8 +45,10 @@ PropertyCategories: | |||||||
|   - Key: deployment.type |   - Key: deployment.type | ||||||
|     Type: string |     Type: string | ||||||
|     Value: |     Value: | ||||||
|     - domainmember |     - domainmember-medium | ||||||
|     - standalone |     - domainmember-large | ||||||
|  |     - standalone-medium | ||||||
|  |     - standalone-large | ||||||
|     UserConfigurable: false |     UserConfigurable: false | ||||||
| - Name: 1) Operating System | - Name: 1) Operating System | ||||||
|   ProductProperties: |   ProductProperties: | ||||||
| @@ -45,7 +65,8 @@ PropertyCategories: | |||||||
|     Description: Must meet password complexity rules |     Description: Must meet password complexity rules | ||||||
|     DefaultValue: password |     DefaultValue: password | ||||||
|     Configurations: |     Configurations: | ||||||
|     - standalone |     - standalone-medium | ||||||
|  |     - standalone-large | ||||||
|     UserConfigurable: true |     UserConfigurable: true | ||||||
|   - Key: guestinfo.ntpserver |   - Key: guestinfo.ntpserver | ||||||
|     Type: string(1..) |     Type: string(1..) | ||||||
| @@ -53,7 +74,8 @@ PropertyCategories: | |||||||
|     Description: A comma-separated list of timeservers |     Description: A comma-separated list of timeservers | ||||||
|     DefaultValue: 0.pool.ntp.org,1.pool.ntp.org,2.pool.ntp.org |     DefaultValue: 0.pool.ntp.org,1.pool.ntp.org,2.pool.ntp.org | ||||||
|     Configurations: |     Configurations: | ||||||
|     - standalone |     - standalone-medium | ||||||
|  |     - standalone-large | ||||||
|     UserConfigurable: true |     UserConfigurable: true | ||||||
| - Name: 2) Networking | - Name: 2) Networking | ||||||
|   ProductProperties: |   ProductProperties: | ||||||
| @@ -93,7 +115,8 @@ PropertyCategories: | |||||||
|     Description: Must be able to be resolved through provided DNS server |     Description: Must be able to be resolved through provided DNS server | ||||||
|     DefaultValue: example.org |     DefaultValue: example.org | ||||||
|     Configurations: |     Configurations: | ||||||
|     - domainmember |     - domainmember-medium | ||||||
|  |     - domainmember-large | ||||||
|     UserConfigurable: true |     UserConfigurable: true | ||||||
|   - Key: addsconfig.username |   - Key: addsconfig.username | ||||||
|     Type: string(1..) |     Type: string(1..) | ||||||
| @@ -101,7 +124,8 @@ PropertyCategories: | |||||||
|     Description: '' |     Description: '' | ||||||
|     DefaultValue: username |     DefaultValue: username | ||||||
|     Configurations: |     Configurations: | ||||||
|     - domainmember |     - domainmember-medium | ||||||
|  |     - domainmember-large | ||||||
|     UserConfigurable: true |     UserConfigurable: true | ||||||
|   - Key: addsconfig.password |   - Key: addsconfig.password | ||||||
|     Type: password(1..) |     Type: password(1..) | ||||||
| @@ -109,7 +133,8 @@ PropertyCategories: | |||||||
|     Description: '' |     Description: '' | ||||||
|     DefaultValue: password |     DefaultValue: password | ||||||
|     Configurations: |     Configurations: | ||||||
|     - domainmember |     - domainmember-medium | ||||||
|  |     - domainmember-large | ||||||
|     UserConfigurable: true |     UserConfigurable: true | ||||||
| AdvancedOptions: | AdvancedOptions: | ||||||
| - Key: appliance.name | - Key: appliance.name | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user