Skip to content

Commit 754a2a1

Browse files
Merge pull request #134 from Azure/master
Bring Compute Admin fixes to vNext
2 parents b0a4781 + 5a58c4f commit 754a2a1

10 files changed

Lines changed: 445 additions & 276 deletions

File tree

CanaryValidator/Canary.Tests.ps1

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,6 @@ while ($runCount -le $NumberOfIterations)
242242
$defaultSubscription = Get-AzureRmSubscription -SubscriptionName "Default Provider Subscription" -ErrorAction Stop
243243
$asCanaryQuotas = NewAzureStackDefaultQuotas -ResourceLocation $ResourceLocation -SubscriptionId $defaultSubscription.SubscriptionId -AADTenantID $TenantID -EnvironmentDomainFQDN $EnvironmentDomainFQDN -Credentials $ServiceAdminCredentials -ArmEndPoint $AdminArmEndPoint
244244
New-AzureRMPlan -Name $tenantPlanName -DisplayName $tenantPlanName -ArmLocation $ResourceLocation -ResourceGroup $subscriptionRGName -QuotaIds $asCanaryQuotas -ErrorAction Stop
245-
246245
}
247246

248247
Invoke-Usecase -Name 'CreateTenantOffer' -Description "Create a tenant offer" -UsecaseBlock `

ComputeAdmin/AzureStack.ComputeAdmin.psm1

Lines changed: 288 additions & 158 deletions
Large diffs are not rendered by default.

ComputeAdmin/README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ Instructions below are relative to the .\ComputeAdmin folder of the [AzureStack-
44
Make sure you have the following module prerequisites installed:
55

66
```powershell
7-
Install-Module -Name AzureRM -RequiredVersion 1.2.8 -Scope CurrentUser
8-
Install-Module -Name AzureStack -RequiredVersion 1.2.8 -Scope CurrentUser
7+
Install-Module -Name 'AzureRm.Bootstrapper' -Scope CurrentUser
8+
Install-AzureRmProfile -profile '2017-03-09-profile' -Force -Scope CurrentUser
9+
Install-Module -Name AzureStack -RequiredVersion 1.2.9 -Scope CurrentUser
910
```
1011
Then make sure the following modules are imported:
1112

@@ -20,7 +21,7 @@ Adding a VM Image requires that you obtain the GUID value of your Directory Tena
2021
$aadTenant = Get-AADTenantGUID -AADTenantName "<myaadtenant>.onmicrosoft.com"
2122
```
2223

23-
Otherwise, it can be retrieved directly from your Azure Stack deployment. First, add your host to the list of TrustedHosts:
24+
Otherwise, it can be retrieved directly from your Azure Stack deployment. This method can also be used for AD FS. First, add your host to the list of TrustedHosts:
2425
```powershell
2526
Set-Item wsman:\localhost\Client\TrustedHosts -Value "<Azure Stack host address>" -Concatenate
2627
```
@@ -42,6 +43,8 @@ $ISOPath = "<Path to ISO>"
4243
New-Server2016VMImage -ISOPath $ISOPath -TenantId $aadTenant
4344
```
4445

46+
This command may show a popup prompt that can be ignored without issue.
47+
4548
To ensure that the Windows Server 2016 VM Image has the latest cumulative update, provide the -IncludeLatestCU parameter.
4649

4750
Please note that to use this image for **installing additional Azure Stack services**, you will need to make use of the -Net35 parameter to install .NET Framework 3.5 into the image.
@@ -79,7 +82,7 @@ To verify that the command ran successfully, go to Marketplace in the portal, an
7982
Run the below command to remove an uploaded VM image. After removal, tenants will no longer be able to deploy virtual machines with this image.
8083

8184
```powershell
82-
Remove-VMImage -publisher "Canonical" -offer "UbuntuServer" -sku "14.04.3-LTS" -version "1.0.0" -osType Linux -tenantID <GUID AADTenant>
85+
Remove-VMImage -publisher "Canonical" -offer "UbuntuServer" -sku "14.04.3-LTS" -version "1.0.0" -tenantID <GUID AADTenant>
8386
```
8487

8588
Note: This cmdlet will remove the associated Marketplace item unless the -KeepMarketplaceItem parameter is specified.

ComputeAdmin/Tests/ComputeAdmin.Tests.ps1

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Describe $script:ModuleName {
1717
}
1818

1919
It 'Remove-VMImage should be exported' {
20-
Get-Command -Name Add-VMImage -ErrorAction SilentlyContinue |
20+
Get-Command -Name Remove-VMImage -ErrorAction SilentlyContinue |
2121
Should Not Be $null
2222
}
2323
}
@@ -57,39 +57,44 @@ InModuleScope $script:ModuleName {
5757

5858
Describe 'ComputeAdmin - Functional Tests' {
5959
It 'CreateGalleryItem = "$false" -and title = specified should throw' {
60-
{ Add-VMImage -publisher $publisher -offer $offer -sku $sku -version $version -osType $osType -osDiskLocalPath $osDiskPath -tenantID $AadTenant -AzureStackCredential $stackLoginCreds -CreateGalleryItem $false -title 'testTitle' } |
60+
{ Add-VMImage -publisher $publisher -offer $offer -sku $sku -version $version -osType $osType -osDiskLocalPath $osDiskPath -tenantID $AadTenant -ArmEndpoint $ArmEndpoint -AzureStackCredential $stackLoginCreds -CreateGalleryItem $false -title 'testTitle' } |
6161
Should Throw
6262
}
6363

6464
It 'CreateGalleryItem = "$false" -and description = specified should throw' {
65-
{ Add-VMImage -publisher $publisher -offer $offer -sku $sku -version $version -osType $osType -osDiskLocalPath $osDiskPath -tenantID $AadTenant -AzureStackCredential $stackLoginCreds -CreateGalleryItem $false -title 'testTitle' -CreateGalleryItem $false -description 'testdescription' } | Should Throw
65+
{ Add-VMImage -publisher $publisher -offer $offer -sku $sku -version $version -osType $osType -osDiskLocalPath $osDiskPath -tenantID $AadTenant -ArmEndpoint $ArmEndpoint -AzureStackCredential $stackLoginCreds -CreateGalleryItem $false -title 'testTitle' -CreateGalleryItem $false -description 'testdescription' } | Should Throw
6666
}
6767

6868
It 'Add-VMImage via local path and upload to storage account should succeed' {
69-
{ Add-VMImage -publisher $publisher -offer $offer -sku $sku -version $version -osType $osType -osDiskLocalPath $osDiskPath -tenantID $AadTenant -AzureStackCredential $stackLoginCreds -CreateGalleryItem $false } |
69+
{ Add-VMImage -publisher $publisher -offer $offer -sku $sku -version $version -osType $osType -osDiskLocalPath $osDiskPath -tenantID $AadTenant -ArmEndpoint $ArmEndpoint -AzureStackCredential $stackLoginCreds -CreateGalleryItem $false } |
7070
Should Not Throw
7171
}
7272

7373
It 'Remove-VMImage should successfully remove added VM Image' {
74-
{ Remove-VMImage -publisher $publisher -offer $offer -sku $sku -version $version -osType $osType -tenantID $AadTenant -AzureStackCredential $stackLoginCreds} |
74+
{ Remove-VMImage -publisher $publisher -offer $offer -sku $sku -version $version -tenantID $AadTenant -ArmEndpoint $ArmEndpoint -AzureStackCredential $stackLoginCreds} |
7575
Should Not Throw
7676
}
7777

7878
It 'Add-VMImage via local path and upload to storage account with gallery item should succeed' {
79-
{ Add-VMImage -publisher $publisher -offer $offer -sku $gallerySku -version $version -osType $osType -osDiskLocalPath $osDiskPath -tenantID $AadTenant -AzureStackCredential $stackLoginCreds } |
79+
{ Add-VMImage -publisher $publisher -offer $offer -sku $gallerySku -version $version -osType $osType -osDiskLocalPath $osDiskPath -tenantID $AadTenant -ArmEndpoint $ArmEndpoint -AzureStackCredential $stackLoginCreds } |
8080
Should Not Throw
8181
}
8282

8383
It 'Remove-VMImage and Removing Marketplace Item should successfully complete' {
8484
{
85-
Remove-VMImage -publisher $publisher -offer $offer -sku $gallerySku -version $version -osType $osType -tenantID $AadTenant -AzureStackCredential $stackLoginCreds
86-
Get-AzureRMGalleryItem -ApiVersion 2015-04-01
87-
Get-AzureRMGalleryItem -ApiVersion 2015-04-01 | Where-Object {$_.Name -contains "$publisher.$offer$gallerySku.$version"} | Remove-AzureRMGalleryItem -ApiVersion 2015-04-01
85+
Remove-VMImage -publisher $publisher -offer $offer -sku $gallerySku -version $version -tenantID $AadTenant -ArmEndpoint $ArmEndpoint -AzureStackCredential $stackLoginCreds
86+
if((Get-Module AzureStack).Version -ge [System.Version] "1.2.9"){
87+
Get-AzureRMGalleryItem
88+
Get-AzureRMGalleryItem | Where-Object {$_.Name -contains "$publisher.$offer$gallerySku.$version"} | Remove-AzureRMGalleryItem
89+
}else{
90+
Get-AzureRMGalleryItem -ApiVersion 2015-04-01
91+
Get-AzureRMGalleryItem -ApiVersion 2015-04-01 | Where-Object {$_.Name -contains "$publisher.$offer$gallerySku.$version"} | Remove-AzureRMGalleryItem -ApiVersion 2015-04-01
92+
}
8893
} | Should Not Throw
8994
}
9095

9196
It 'Adding Ubuntu Linux 16.04 Image and Marketplace Item Succeeds' {
92-
{ Add-VMImage -publisher "Canonical" -offer "UbuntuServer" -sku "16.04.1-LTS" -version "1.0.4" -osType Linux -osDiskLocalPath $ubuntuPath -tenantID $AadTenant -AzureStackCredential $stackLoginCreds} |
97+
{ Add-VMImage -publisher "Canonical" -offer "UbuntuServer" -sku "16.04.1-LTS" -version "1.0.4" -osType Linux -ArmEndpoint $ArmEndpoint -osDiskLocalPath $ubuntuPath -tenantID $AadTenant -AzureStackCredential $stackLoginCreds} |
9398
Should Not Throw
9499
}
95100

@@ -99,10 +104,14 @@ InModuleScope $script:ModuleName {
99104
$newOffer = "UbuntuServer"
100105
$newSKU = "16.04.1-LTS"
101106
$newVersion = "1.0.4"
102-
Remove-VMImage -publisher $newPub -offer $newOffer -sku $newSKU -version $newVersion -osType Linux -tenantID $AadTenant -AzureStackCredential $stackLoginCreds
107+
Remove-VMImage -publisher $newPub -offer $newOffer -sku $newSKU -version $newVersion -tenantID $AadTenant -ArmEndpoint $ArmEndpoint -AzureStackCredential $stackLoginCreds
103108
$GalleryItemName = "$newOffer$newSKU"
104109
$GalleryItemName = $GalleryItemName -replace "\.","-"
105-
Get-AzureRMGalleryItem -ApiVersion 2015-04-01 | Where-Object {$_.Name -contains "$newPub.$GalleryItemName.$newVersion"} | Remove-AzureRMGalleryItem -ApiVersion 2015-04-01
110+
if((Get-Module AzureStack).Version -ge [System.Version] "1.2.9"){
111+
Get-AzureRMGalleryItem | Where-Object {$_.Name -contains "$newPub.$GalleryItemName.$newVersion"} | Remove-AzureRMGalleryItem
112+
}else{
113+
Get-AzureRMGalleryItem -ApiVersion 2015-04-01 | Where-Object {$_.Name -contains "$newPub.$GalleryItemName.$newVersion"} | Remove-AzureRMGalleryItem -ApiVersion 2015-04-01
114+
}
106115
} | Should Not Throw
107116
}
108117

0 commit comments

Comments
 (0)