Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
f4a2418
09-01-preview changes
Oct 31, 2023
f082dbe
removing examples for hidden cmdlets
Oct 31, 2023
f4896b8
removing extra example files
Oct 31, 2023
c876d0d
removing extra tests
Oct 31, 2023
049360b
adding updating examples
Nov 1, 2023
ca09226
updating docs
Nov 1, 2023
60dde45
adding log directory example back
Nov 1, 2023
b304a9e
removing envValues.json
Nov 1, 2023
8d8c21c
adding root module
Nov 1, 2023
62a07d5
getting rid of local paths
Nov 1, 2023
db11128
bug fixes
Nov 2, 2023
0282aff
fixes
Nov 2, 2023
8add0cb
updates
Nov 5, 2023
e8cd84a
removing ip config and subnet conig
Nov 5, 2023
e0bf112
fixing example formating
Nov 5, 2023
3dbd501
fixing get and update
Nov 6, 2023
1685426
Merge remote-tracking branch 'remotes/origin/generation' into dev/hv/…
Nov 6, 2023
b4d1807
updating folder name
Nov 6, 2023
e4c8dd3
using public repo
Nov 6, 2023
416eb2c
adding customization to rename commands
Nov 6, 2023
1f7ed0d
fixing all casing in custom code
Nov 6, 2023
84c5721
removing files
Nov 6, 2023
1a0094f
updating docs and examples
Nov 6, 2023
c7c0221
adding lnet,nic,and stroagepath test recording
Nov 6, 2023
8472a22
fixing links
Nov 6, 2023
31e3e94
test
Nov 6, 2023
b5b7869
fixing description and synopsis
Nov 6, 2023
a04d79d
trying to fix logical network doc
Nov 6, 2023
fc23b37
Fixing module name in get lnet
Nov 6, 2023
32c5ccc
updating readme to manually add description in swagger
Nov 6, 2023
bf8cdba
fixing disk ids, nic ids, and image output
Nov 6, 2023
a7ecf06
Changin Tags parameter to Tag
Nov 6, 2023
6c1cd89
removing dnsservers
Nov 6, 2023
9c2054b
removing address prefixes
Nov 6, 2023
bc9c219
removing ippools
Nov 6, 2023
213c0b9
removing routes
Nov 6, 2023
d24f542
removing subnets
Nov 6, 2023
bec0430
compiling docs
Nov 6, 2023
7ddb1b6
removing ip configurations
Nov 6, 2023
0a5142b
removing pulral params for new vhd
Nov 6, 2023
7770eaf
remooving diskids and disnames from remove disk
Nov 6, 2023
b42053b
removig nicids and nicnames from remove nic
Nov 6, 2023
8c692bc
removing vm processors
Nov 6, 2023
b5de666
getting rid of example stub in custom file
Nov 6, 2023
205597a
fixing parameters in VM create
Nov 6, 2023
1ac0eb0
removing example stub from each custom file
Nov 6, 2023
952fa17
updating example files
Nov 6, 2023
bce17c3
fixing subnet in logical network
Nov 6, 2023
e641f6b
adding logical network recording
Nov 6, 2023
01eae12
addig vhd and nic recording
Nov 7, 2023
c0cc7f5
adding storage path recording
Nov 7, 2023
a6178de
adding default param to new cmdlets
Nov 7, 2023
5592cdf
virtual machine recording
Nov 7, 2023
bf885fe
adding image recording
Nov 7, 2023
9d2577a
fixing lnet ippool and test reordings
Nov 7, 2023
34e97cf
fixing v disk addand nic add
Nov 7, 2023
4fb7568
addig passig tests
Nov 7, 2023
4f62593
adding passing recording for nic
Nov 7, 2023
e16110d
fixing nic json
Nov 7, 2023
e609038
fixing vm json
Nov 7, 2023
ceccc53
fixing vm recording
Nov 7, 2023
0a8c992
fixing network interface recording
Nov 7, 2023
ce125bf
passing default param through new-nic
Nov 7, 2023
20fb34d
fix file name for some examples and docs, fix online version uri
VeryEarly Nov 7, 2023
81e9466
add ux files
VeryEarly Nov 7, 2023
57ce56b
remove asjob for get cmdlets
VeryEarly Nov 7, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
453 changes: 453 additions & 0 deletions src/StackHCI/StackHCIVm/README.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
<#
.Synopsis
The operation to add a virtual hard disk to a virtual machine.

.Description
The operation to add a virtual hard disk to a virtual machine.
.Example
PS C:\> {{Add-AzStackHciVMVirtualMachineDataDisk -Name "sampleVirtualMachine-1030" -ResourceGroupName mkclus0824-rg -SubscriptionId "0709bd7a-8383-4e1d-98c8-f81d1b3443fc" -DataDiskNames testDataDisk-1030 }}

.Outputs
Microsoft.Azure.PowerShell.Cmdlets.StackHciVM.Models.Api20230901Preview.IVirtualMachineInstance
.Link
https://learn.microsoft.com/powershell/module/az.stackhcivm/add-azstackhcivmvirtualmachinedatadisk
#>


function Add-AzStackHciVMVirtualMachineDataDisk {
[OutputType([Microsoft.Azure.PowerShell.Cmdlets.StackHciVM.Models.Api20230901Preview.IVirtualMachineInstance])]
[CmdletBinding(PositionalBinding=$false, SupportsShouldProcess, ConfirmImpact='Medium')]
param(
[Parameter(ParameterSetName='ByName', Mandatory)]
[Alias('VirtualMachineName')]
[Microsoft.Azure.PowerShell.Cmdlets.StackHciVM.Category('Path')]
[System.String]
# Name of the virtual machine
${Name},

[Parameter(ParameterSetName='ByName', Mandatory)]
[Microsoft.Azure.PowerShell.Cmdlets.StackHciVM.Category('Path')]
[System.String]
# The name of the resource group.
# The name is case insensitive.
${ResourceGroupName},

[Parameter(ParameterSetName='ByResourceId', Mandatory)]
[Microsoft.Azure.PowerShell.Cmdlets.StackHciVM.Category('Path')]
[System.String]
# The ARM Resource ID of the VM
${ResourceId},

[Parameter(ParameterSetName='ByName')]
[Microsoft.Azure.PowerShell.Cmdlets.StackHciVM.Category('Path')]
[Microsoft.Azure.PowerShell.Cmdlets.StackHciVM.Runtime.DefaultInfo(Script='(Get-AzContext).Subscription.Id')]
[System.String]
# The ID of the target subscription.
${SubscriptionId},

[Parameter(ParameterSetName='ByResourceId')]
[Parameter(ParameterSetName='ByName')]
[AllowEmptyCollection()]
[Microsoft.Azure.PowerShell.Cmdlets.StackHciVM.Category('Body')]
[System.String[]]
# List of data disks to be attached to the virtual machine passed in Id format
${DataDiskIds},

[Parameter(ParameterSetName='ByResourceId')]
[Parameter(ParameterSetName='ByName')]
[AllowEmptyCollection()]
[Microsoft.Azure.PowerShell.Cmdlets.StackHciVM.Category('Body')]
[System.String[]]
# List of data disks to be attached to the virtual machine passed by Name
${DataDiskNames},

[Parameter(ParameterSetName='ByResourceId')]
[Parameter(ParameterSetName='ByName')]
[AllowEmptyCollection()]
[Microsoft.Azure.PowerShell.Cmdlets.StackHciVM.Category('Body')]
[System.String]
# Resource Group of the Data Disks
${DataDiskResourceGroup}
)

if (($ResourceId -match $vmRegex) -or ($Name -and $ResourceGroupName -and $SubscriptionId)){
if ($ResourceId -match $vmRegex){
$SubscriptionId = $($Matches['subscriptionId'])
$ResourceGroupName = $($Matches['resourceGroupName'])
$Name = $($Matches['machineName'])
}
$null = $PSBoundParameters.Remove("Name")
$null = $PSBoundParameters.Remove("ResourceGroupName")
$null = $PSBoundParameters.Remove("SubscriptionId")
$null = $PSBoundParameters.Remove("ResourceId")
$resourceUri = "/subscriptions/" + $subscriptionId + "/resourceGroups/" + $ResourceGroupName + "/providers/Microsoft.HybridCompute/machines/" + $Name
$PSBoundParameters.Add("ResourceUri", $resourceUri)
} else {
Write-Error "One or more input parameters are invalid. Resource ID is: $ResourceId, name is $name, resource group name is $resourcegroupname, subscription id is $subscriptionid"
}
$StorageProfileDataDisk = [System.Collections.ArrayList]::new()

if($DataDiskIds){
foreach ($DataDiskId in $DataDiskIds){
if ($DataDiskId -notmatch $vhdRegex){
Write-Error "Invalid Data Disk Id provided: $DataDiskId." -ErrorAction Stop
}
$DataDisk = @{Id = $DataDiskId}
[void]$StorageProfileDataDisk.Add($DataDisk)
}

$null = $PSBoundParameters.Remove("DataDiskIds")

} elseif ($DataDiskNames){
$rg = $ResourceGroupName
if($DataDiskResourceGroup){
$rg = $DataDiskResourceGroup
}

foreach ($DataDiskName in $DataDiskNames){
$DataDiskId = "/subscriptions/$SubscriptionId/resourceGroups/$rg/providers/Microsoft.AzureStackHCI/virtualharddisks/$DataDiskName"
$DataDisk = @{Id = $DataDiskId}
[void]$StorageProfileDataDisk.Add($DataDisk)
}

$null = $PSBoundParameters.Remove("DataDiskNames")
$null = $PSBoundParameters.Remove("DataDiskResourceGroup")
}

$vm = Az.StackHciVM.internal\Get-AzStackHciVMVirtualMachine @PSBoundParameters
$disks = $vm.StorageProfileDataDisk

foreach ($disk in $disks){
$DataDisk = @{Id = $disk.Id}
[void]$StorageProfileDataDisk.Add($DataDisk)
}

$PSBoundParameters.Add('StorageProfileDataDisk', $StorageProfileDataDisk)
return Az.StackHciVM.internal\Update-AzStackHciVMVirtualMachine @PSBoundParameters
}
127 changes: 127 additions & 0 deletions src/StackHCI/StackHCIVm/custom/Add-AzStackHCIVMVirtualMachineNic.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
<#
.Synopsis
The operation to add a network interface to a virtual machine.

.Description
The operation to add a network interface to a virtual machine.
.Example
PS C:\> {{Add-AzStackHciVMVirtualMachineNic -Name "sampleVirtualMachine-1030" -ResourceGroupName mkclus0824-rg -SubscriptionId "0709bd7a-8383-4e1d-98c8-f81d1b3443fc" -NicNames testNic }}

.Outputs
Microsoft.Azure.PowerShell.Cmdlets.StackHciVM.Models.Api20230901Preview.IVirtualMachineInstance
.Link
https://learn.microsoft.com/powershell/module/az.stackhcivm/add-azstackhcivmvirtualmachinenic
#>

function Add-AzStackHciVMVirtualMachineNic {
[OutputType([Microsoft.Azure.PowerShell.Cmdlets.StackHciVM.Models.Api20230901Preview.IVirtualMachineInstance])]
[CmdletBinding(PositionalBinding=$false, SupportsShouldProcess, ConfirmImpact='Medium')]
param(
[Parameter(ParameterSetName='ByName', Mandatory)]
[Alias('VirtualMachineName')]
[Microsoft.Azure.PowerShell.Cmdlets.StackHciVM.Category('Path')]
[System.String]
# Name of the virtual machine
${Name},

[Parameter(ParameterSetName='ByName', Mandatory)]
[Microsoft.Azure.PowerShell.Cmdlets.StackHciVM.Category('Path')]
[System.String]
# The name of the resource group.
# The name is case insensitive.
${ResourceGroupName},

[Parameter(ParameterSetName='ByResourceId', Mandatory)]
[Microsoft.Azure.PowerShell.Cmdlets.StackHciVM.Category('Path')]
[System.String]
# The ARM Id of the Virtual Machine
${ResourceId},

[Parameter(ParameterSetName='ByName')]
[Microsoft.Azure.PowerShell.Cmdlets.StackHciVM.Category('Path')]
[Microsoft.Azure.PowerShell.Cmdlets.StackHciVM.Runtime.DefaultInfo(Script='(Get-AzContext).Subscription.Id')]
[System.String]
# The ID of the target subscription.
${SubscriptionId},

[Parameter(ParameterSetName='ByResourceId')]
[Parameter(ParameterSetName='ByName')]
[AllowEmptyCollection()]
[Microsoft.Azure.PowerShell.Cmdlets.StackHciVM.Category('Body')]
[System.String[]]
# NetworkInterfaces - list of network interfaces to be attached to the virtual machine in id format
${NicIds},

[Parameter(ParameterSetName='ByResourceId')]
[Parameter(ParameterSetName='ByName')]
[AllowEmptyCollection()]
[Microsoft.Azure.PowerShell.Cmdlets.StackHciVM.Category('Body')]
[System.String[]]
# NetworkInterfaces - list of network interfaces to be attached to the virtual machine in name format
${NicNames},

[Parameter(ParameterSetName='ByResourceId')]
[Parameter(ParameterSetName='ByName')]
[AllowEmptyCollection()]
[Microsoft.Azure.PowerShell.Cmdlets.StackHciVM.Category('Body')]
[System.String]
# Resource Group of the Network Interfaces
${NicResourceGroup}
)

if (($ResourceId -match $vmRegex) -or ($Name -and $ResourceGroupName -and $SubscriptionId)){
if ($ResourceId -match $vmRegex){
$SubscriptionId = $($Matches['subscriptionId'])
$ResourceGroupName = $($Matches['resourceGroupName'])
$Name = $($Matches['machineName'])
}
$null = $PSBoundParameters.Remove("Name")
$null = $PSBoundParameters.Remove("ResourceGroupName")
$null = $PSBoundParameters.Remove("SubscriptionId")
$null = $PSBoundParameters.Remove("ResourceId")
$resourceUri = "/subscriptions/" + $subscriptionId + "/resourceGroups/" + $ResourceGroupName + "/providers/Microsoft.HybridCompute/machines/" + $Name
$PSBoundParameters.Add("ResourceUri", $resourceUri)
} else {
Write-Error "One or more input parameters are invalid. Resource ID is: $ResourceId, name is $name, resource group name is $resourcegroupname, subscription id is $subscriptionid"
}

$NetworkProfileNetworkInterface = [System.Collections.ArrayList]::new()
if ($NicIds){
foreach ($NicId in $NicIds){
if ($NicId -notmatch $nicRegex){
Write-Error "Invalid Nic Id provided: $NicId." -ErrorAction Stop
}
$Nic = @{Id = $NicId}
[void]$NetworkProfileNetworkInterface.Add($Nic)
}

$null = $PSBoundParameters.Remove("NicIds")

} elseif ($NicNames){
$rg = $ResourceGroupName
if($NicResourceGroup){
$rg = $NicResourceGroup
}

foreach ($NicName in $NicNames){
$NicId = "/subscriptions/$SubscriptionId/resourceGroups/$rg/providers/Microsoft.AzureStackHCI/networkinterfaces/$NicName"
$Nic = @{Id = $NicId}
[void]$NetworkProfileNetworkInterface.Add($Nic)
}

$null = $PSBoundParameters.Remove("NicNames")
$null = $PSBoundParameters.Remove("NicResourceGroup")

}

$vm = Az.StackHciVM.internal\Get-AzStackHciVMVirtualMachine @PSBoundParameters
$nics = $vm.NetworkProfileNetworkInterface

foreach ($nic in $nics){
$Nic= @{Id = $nic.Id}
[void]$NetworkProfileNetworkInterface.Add($Nic)
}

$PSBoundParameters.Add('NetworkProfileNetworkInterface', $NetworkProfileNetworkInterface)
return Az.StackHciVM.internal\Update-AzStackHciVMVirtualMachine @PSBoundParameters
}
17 changes: 17 additions & 0 deletions src/StackHCI/StackHCIVm/custom/Az.StackHCIVm.custom.psm1
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# region Generated
# Load the private module dll
$null = Import-Module -PassThru -Name (Join-Path $PSScriptRoot '..\bin\Az.StackHCIVm.private.dll')

# Load the internal module
$internalModulePath = Join-Path $PSScriptRoot '..\internal\Az.StackHCIVm.internal.psm1'
if(Test-Path $internalModulePath) {
$null = Import-Module -Name $internalModulePath
}

# Export nothing to clear implicit exports
Export-ModuleMember

# Export script cmdlets
Get-ChildItem -Path $PSScriptRoot -Recurse -Include '*.ps1' -File | ForEach-Object { . $_.FullName }
Export-ModuleMember -Function (Get-ScriptCmdlet -ScriptFolder $PSScriptRoot) -Alias (Get-ScriptCmdlet -ScriptFolder $PSScriptRoot -AsAlias)
# endregion
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@

# ----------------------------------------------------------------------------------
#
# Copyright Microsoft Corporation
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ----------------------------------------------------------------------------------

<#
.Synopsis
Gets a Logical Network

.Description
Gets a Logical Network

.Example
PS C:\> {Get-AzStackHciVMLogicalNetwork -Name "testLnet" -ResourceGroupName "test-rg" }

.Outputs
Microsoft.Azure.PowerShell.Cmdlets.StackHCIVm.Models.Api20230901Preview.ILogicalNetworks

.Link
https://learn.microsoft.com/powershell/module/az.stackhcivm/get-azstackhcivmlogicalnetwork
#>
function Get-AzStackHciVMLogicalNetwork_ByResourceId {
[OutputType([Microsoft.Azure.PowerShell.Cmdlets.StackHciVM.Models.Api20230901Preview.ILogicalNetworks])]
[CmdletBinding(PositionalBinding=$false)]

param(
[Microsoft.Azure.PowerShell.Cmdlets.StackHciVM.Category('Path')]
[System.String]
# The ARM ID of the logical network.
${ResourceId},


[Alias('AzureRMContext', 'AzureCredential')]
[ValidateNotNull()]
[Microsoft.Azure.PowerShell.Cmdlets.StackHciVM.Category('Azure')]
[System.Management.Automation.PSObject]
# The credentials, account, tenant, and subscription used for communication with Azure.
${DefaultProfile}

)
process {

if ($ResourceId -match $lnetRegex){

$subscriptionId = $($Matches['subscriptionId'])
$resourceGroupName = $($Matches['resourceGroupName'])
$resourceName = $($Matches['logicalNetworkName'])
$null = $PSBoundParameters.Remove("ResourceId")
$PSBoundParameters.Add("Name", $resourceName)
$PSBoundParameters.Add("ResourceGroupName", $resourceGroupName)
$null = $PSBoundParameters.Remove("SubscriptionId")
$PSBoundParameters.Add("SubscriptionId", $subscriptionId)

return Az.StackHciVM\Get-AzStackHciVMLogicalNetwork @PSBoundParameters

} else {
Write-Error "Resource ID is invalid: $ResourceId"
}

}
}
Loading