mirror of
https://github.com/benclaussen/NetboxPS.git
synced 2025-12-17 03:35:46 +00:00
add Get-NetboxIPAMVRF and New-NetboxIPAMVRF
This commit is contained in:
parent
3abf2264d9
commit
7de7bbc304
5 changed files with 316 additions and 12 deletions
70
Functions/IPAM/VRF/Get-NetboxIPAMVRF.ps1
Normal file
70
Functions/IPAM/VRF/Get-NetboxIPAMVRF.ps1
Normal file
|
|
@ -0,0 +1,70 @@
|
||||||
|
|
||||||
|
function Get-NetboxIPAMVRF {
|
||||||
|
[CmdletBinding(DefaultParameterSetName = 'Query')]
|
||||||
|
param
|
||||||
|
(
|
||||||
|
[Parameter(ParameterSetName = 'ByID')]
|
||||||
|
[uint64[]]$Id,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[string]$Name,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[string]$RD,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[string]$Tenant,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[uint64]$Tenant_Id,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[string]$TenantGroup,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[uint64]$TenantGroup_Id,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[object]$Status,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[uint16]$Limit,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[uint16]$Offset,
|
||||||
|
|
||||||
|
[switch]$Raw
|
||||||
|
)
|
||||||
|
|
||||||
|
switch ($PSCmdlet.ParameterSetName) {
|
||||||
|
'ById' {
|
||||||
|
foreach ($VRF_ID in $Id) {
|
||||||
|
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'vrfs', $VRF_ID))
|
||||||
|
|
||||||
|
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id'
|
||||||
|
|
||||||
|
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||||
|
|
||||||
|
InvokeNetboxRequest -URI $uri -Raw:$Raw
|
||||||
|
}
|
||||||
|
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
default {
|
||||||
|
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'vrfs'))
|
||||||
|
|
||||||
|
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
|
||||||
|
|
||||||
|
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||||
|
|
||||||
|
InvokeNetboxRequest -URI $uri -Raw:$Raw
|
||||||
|
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
77
Functions/IPAM/VRF/New-NetboxIPAMVRF.ps1
Normal file
77
Functions/IPAM/VRF/New-NetboxIPAMVRF.ps1
Normal file
|
|
@ -0,0 +1,77 @@
|
||||||
|
function New-NetboxIPAMVRF {
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Create a new VRF
|
||||||
|
|
||||||
|
.DESCRIPTION
|
||||||
|
Create a new VRF in Netbox.
|
||||||
|
|
||||||
|
.PARAMETER Name
|
||||||
|
The name of the VRF.
|
||||||
|
|
||||||
|
.PARAMETER RD
|
||||||
|
The Route Distinguisher (RFC 4364). Defaults to nothing
|
||||||
|
|
||||||
|
.PARAMETER Tenant
|
||||||
|
Tenant ID
|
||||||
|
|
||||||
|
.PARAMETER enforce_unique
|
||||||
|
Force unique IP Addresses in this VRF.
|
||||||
|
|
||||||
|
.PARAMETER import_targets
|
||||||
|
Arrays of Route Targest
|
||||||
|
|
||||||
|
.PARAMETER export_targets
|
||||||
|
Arrays of Route Targest
|
||||||
|
|
||||||
|
.PARAMETER Description
|
||||||
|
Description of VRF
|
||||||
|
|
||||||
|
.PARAMETER Custom_Fields
|
||||||
|
Custom field hash table. Will be validated by the API service
|
||||||
|
|
||||||
|
.PARAMETER Raw
|
||||||
|
Return raw results from API service
|
||||||
|
|
||||||
|
.EXAMPLE
|
||||||
|
PS C:\> New-NetboxIPAMVRF -Name MyVRF -Tenant 1 -import_targets @(1,2) -export_targets @(1,2) -RD 65000:100 -enforce_unique $false
|
||||||
|
|
||||||
|
.NOTES
|
||||||
|
Additional information about the function.
|
||||||
|
#>
|
||||||
|
|
||||||
|
[CmdletBinding(ConfirmImpact = 'low',
|
||||||
|
SupportsShouldProcess = $true)]
|
||||||
|
[OutputType([pscustomobject])]
|
||||||
|
param
|
||||||
|
(
|
||||||
|
[Parameter(Mandatory = $true)]
|
||||||
|
[string]$Name,
|
||||||
|
|
||||||
|
[object]$RD,
|
||||||
|
|
||||||
|
[uint64]$Tenant,
|
||||||
|
|
||||||
|
[object]$enforce_unique = 1,
|
||||||
|
|
||||||
|
[string]$Description,
|
||||||
|
|
||||||
|
[uint64[]]$import_targets,
|
||||||
|
|
||||||
|
[uint64[]]$export_targets,
|
||||||
|
|
||||||
|
[hashtable]$Custom_Fields,
|
||||||
|
|
||||||
|
[switch]$Raw
|
||||||
|
)
|
||||||
|
|
||||||
|
$segments = [System.Collections.ArrayList]::new(@('ipam', 'vrfs'))
|
||||||
|
|
||||||
|
$URIComponents = BuildURIComponents -URISegments $segments -ParametersDictionary $PSBoundParameters
|
||||||
|
|
||||||
|
$URI = BuildNewURI -Segments $URIComponents.Segments
|
||||||
|
|
||||||
|
if ($PSCmdlet.ShouldProcess($nae, 'Create new VRF $($Name)')) {
|
||||||
|
InvokeNetboxRequest -URI $URI -Method POST -Body $URIComponents.Parameters -Raw:$Raw
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
#
|
#
|
||||||
# Generated by: Ben Claussen
|
# Generated by: Ben Claussen
|
||||||
#
|
#
|
||||||
# Generated on: 01/09/2024
|
# Generated on: 10/3/2024
|
||||||
#
|
#
|
||||||
|
|
||||||
@{
|
@{
|
||||||
|
|
@ -90,8 +90,8 @@ FunctionsToExport = 'Add-NetboxDCIMFrontPort', 'Add-NetboxDCIMInterface',
|
||||||
'Get-NetboxIPAMAddress', 'Get-NetboxIPAMAddressRange',
|
'Get-NetboxIPAMAddress', 'Get-NetboxIPAMAddressRange',
|
||||||
'Get-NetboxIPAMAggregate', 'Get-NetboxIPAMAvailableIP',
|
'Get-NetboxIPAMAggregate', 'Get-NetboxIPAMAvailableIP',
|
||||||
'Get-NetboxIPAMPrefix', 'Get-NetboxIPAMRole', 'Get-NetboxIPAMVLAN',
|
'Get-NetboxIPAMPrefix', 'Get-NetboxIPAMRole', 'Get-NetboxIPAMVLAN',
|
||||||
'Get-NetboxObjectType', 'Get-NetboxTag', 'Get-NetboxTenant',
|
'Get-NetboxIPAMVRF', 'Get-NetboxObjectType', 'Get-NetboxTag',
|
||||||
'Get-NetboxTimeout', 'Get-NetboxVersion',
|
'Get-NetboxTenant', 'Get-NetboxTimeout', 'Get-NetboxVersion',
|
||||||
'Get-NetboxVirtualizationCluster',
|
'Get-NetboxVirtualizationCluster',
|
||||||
'Get-NetboxVirtualizationClusterGroup', 'Get-NetboxVirtualMachine',
|
'Get-NetboxVirtualizationClusterGroup', 'Get-NetboxVirtualMachine',
|
||||||
'Get-NetboxVirtualMachineInterface', 'InvokeNetboxRequest',
|
'Get-NetboxVirtualMachineInterface', 'InvokeNetboxRequest',
|
||||||
|
|
@ -99,9 +99,9 @@ FunctionsToExport = 'Add-NetboxDCIMFrontPort', 'Add-NetboxDCIMInterface',
|
||||||
'New-NetboxContactAssignment', 'New-NetboxContactRole',
|
'New-NetboxContactAssignment', 'New-NetboxContactRole',
|
||||||
'New-NetboxDCIMDevice', 'New-NetboxDCIMSite', 'New-NetboxIPAMAddress',
|
'New-NetboxDCIMDevice', 'New-NetboxDCIMSite', 'New-NetboxIPAMAddress',
|
||||||
'New-NetboxIPAMAddressRange', 'New-NetboxIPAMPrefix',
|
'New-NetboxIPAMAddressRange', 'New-NetboxIPAMPrefix',
|
||||||
'New-NetboxIPAMVLAN', 'New-NetboxTenant', 'New-NetboxVirtualMachine',
|
'New-NetboxIPAMVLAN', 'New-NetboxIPAMVRF', 'New-NetboxTenant',
|
||||||
'Remove-NetboxDCIMDevice', 'Remove-NetboxDCIMFrontPort',
|
'New-NetboxVirtualMachine', 'Remove-NetboxDCIMDevice',
|
||||||
'Remove-NetboxDCIMInterface',
|
'Remove-NetboxDCIMFrontPort', 'Remove-NetboxDCIMInterface',
|
||||||
'Remove-NetboxDCIMInterfaceConnection', 'Remove-NetboxDCIMRearPort',
|
'Remove-NetboxDCIMInterfaceConnection', 'Remove-NetboxDCIMRearPort',
|
||||||
'Remove-NetboxDCIMSite', 'Remove-NetboxIPAMAddress',
|
'Remove-NetboxDCIMSite', 'Remove-NetboxIPAMAddress',
|
||||||
'Remove-NetboxIPAMAddressRange', 'Remove-NetboxVirtualMachine',
|
'Remove-NetboxIPAMAddressRange', 'Remove-NetboxVirtualMachine',
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
#
|
#
|
||||||
# Generated by: Ben Claussen
|
# Generated by: Ben Claussen
|
||||||
#
|
#
|
||||||
# Generated on: 01/09/2024
|
# Generated on: 10/3/2024
|
||||||
#
|
#
|
||||||
|
|
||||||
@{
|
@{
|
||||||
|
|
@ -90,8 +90,8 @@ FunctionsToExport = 'Add-NetboxDCIMFrontPort', 'Add-NetboxDCIMInterface',
|
||||||
'Get-NetboxIPAMAddress', 'Get-NetboxIPAMAddressRange',
|
'Get-NetboxIPAMAddress', 'Get-NetboxIPAMAddressRange',
|
||||||
'Get-NetboxIPAMAggregate', 'Get-NetboxIPAMAvailableIP',
|
'Get-NetboxIPAMAggregate', 'Get-NetboxIPAMAvailableIP',
|
||||||
'Get-NetboxIPAMPrefix', 'Get-NetboxIPAMRole', 'Get-NetboxIPAMVLAN',
|
'Get-NetboxIPAMPrefix', 'Get-NetboxIPAMRole', 'Get-NetboxIPAMVLAN',
|
||||||
'Get-NetboxObjectType', 'Get-NetboxTag', 'Get-NetboxTenant',
|
'Get-NetboxIPAMVRF', 'Get-NetboxObjectType', 'Get-NetboxTag',
|
||||||
'Get-NetboxTimeout', 'Get-NetboxVersion',
|
'Get-NetboxTenant', 'Get-NetboxTimeout', 'Get-NetboxVersion',
|
||||||
'Get-NetboxVirtualizationCluster',
|
'Get-NetboxVirtualizationCluster',
|
||||||
'Get-NetboxVirtualizationClusterGroup', 'Get-NetboxVirtualMachine',
|
'Get-NetboxVirtualizationClusterGroup', 'Get-NetboxVirtualMachine',
|
||||||
'Get-NetboxVirtualMachineInterface', 'InvokeNetboxRequest',
|
'Get-NetboxVirtualMachineInterface', 'InvokeNetboxRequest',
|
||||||
|
|
@ -99,9 +99,9 @@ FunctionsToExport = 'Add-NetboxDCIMFrontPort', 'Add-NetboxDCIMInterface',
|
||||||
'New-NetboxContactAssignment', 'New-NetboxContactRole',
|
'New-NetboxContactAssignment', 'New-NetboxContactRole',
|
||||||
'New-NetboxDCIMDevice', 'New-NetboxDCIMSite', 'New-NetboxIPAMAddress',
|
'New-NetboxDCIMDevice', 'New-NetboxDCIMSite', 'New-NetboxIPAMAddress',
|
||||||
'New-NetboxIPAMAddressRange', 'New-NetboxIPAMPrefix',
|
'New-NetboxIPAMAddressRange', 'New-NetboxIPAMPrefix',
|
||||||
'New-NetboxIPAMVLAN', 'New-NetboxTenant', 'New-NetboxVirtualMachine',
|
'New-NetboxIPAMVLAN', 'New-NetboxIPAMVRF', 'New-NetboxTenant',
|
||||||
'Remove-NetboxDCIMDevice', 'Remove-NetboxDCIMFrontPort',
|
'New-NetboxVirtualMachine', 'Remove-NetboxDCIMDevice',
|
||||||
'Remove-NetboxDCIMInterface',
|
'Remove-NetboxDCIMFrontPort', 'Remove-NetboxDCIMInterface',
|
||||||
'Remove-NetboxDCIMInterfaceConnection', 'Remove-NetboxDCIMRearPort',
|
'Remove-NetboxDCIMInterfaceConnection', 'Remove-NetboxDCIMRearPort',
|
||||||
'Remove-NetboxDCIMSite', 'Remove-NetboxIPAMAddress',
|
'Remove-NetboxDCIMSite', 'Remove-NetboxIPAMAddress',
|
||||||
'Remove-NetboxIPAMAddressRange', 'Remove-NetboxVirtualMachine',
|
'Remove-NetboxIPAMAddressRange', 'Remove-NetboxVirtualMachine',
|
||||||
|
|
|
||||||
|
|
@ -2814,6 +2814,81 @@ function Get-NetboxIPAMVLAN {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region File Get-NetboxIPAMVRF.ps1
|
||||||
|
|
||||||
|
|
||||||
|
function Get-NetboxIPAMVRF {
|
||||||
|
[CmdletBinding(DefaultParameterSetName = 'Query')]
|
||||||
|
param
|
||||||
|
(
|
||||||
|
[Parameter(ParameterSetName = 'ByID')]
|
||||||
|
[uint64[]]$Id,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[string]$Name,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[string]$RD,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[string]$Tenant,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[uint64]$Tenant_Id,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[string]$TenantGroup,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[uint64]$TenantGroup_Id,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[object]$Status,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[uint16]$Limit,
|
||||||
|
|
||||||
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
|
[uint16]$Offset,
|
||||||
|
|
||||||
|
[switch]$Raw
|
||||||
|
)
|
||||||
|
|
||||||
|
switch ($PSCmdlet.ParameterSetName) {
|
||||||
|
'ById' {
|
||||||
|
foreach ($VRF_ID in $Id) {
|
||||||
|
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'vrfs', $VRF_ID))
|
||||||
|
|
||||||
|
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id'
|
||||||
|
|
||||||
|
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||||
|
|
||||||
|
InvokeNetboxRequest -URI $uri -Raw:$Raw
|
||||||
|
}
|
||||||
|
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
default {
|
||||||
|
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'vrfs'))
|
||||||
|
|
||||||
|
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
|
||||||
|
|
||||||
|
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||||
|
|
||||||
|
InvokeNetboxRequest -URI $uri -Raw:$Raw
|
||||||
|
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region File Get-NetboxObjectType.ps1
|
#region File Get-NetboxObjectType.ps1
|
||||||
|
|
@ -4414,6 +4489,88 @@ function New-NetboxIPAMVLAN {
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region File New-NetboxIPAMVRF.ps1
|
||||||
|
|
||||||
|
function New-NetboxIPAMVRF {
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Create a new VRF
|
||||||
|
|
||||||
|
.DESCRIPTION
|
||||||
|
Create a new VRF in Netbox.
|
||||||
|
|
||||||
|
.PARAMETER Name
|
||||||
|
The name of the VRF.
|
||||||
|
|
||||||
|
.PARAMETER RD
|
||||||
|
The Route Distinguisher (RFC 4364). Defaults to nothing
|
||||||
|
|
||||||
|
.PARAMETER Tenant
|
||||||
|
Tenant ID
|
||||||
|
|
||||||
|
.PARAMETER enforce_unique
|
||||||
|
Force unique IP Addresses in this VRF.
|
||||||
|
|
||||||
|
.PARAMETER import_targets
|
||||||
|
Arrays of Route Targest
|
||||||
|
|
||||||
|
.PARAMETER export_targets
|
||||||
|
Arrays of Route Targest
|
||||||
|
|
||||||
|
.PARAMETER Description
|
||||||
|
Description of VRF
|
||||||
|
|
||||||
|
.PARAMETER Custom_Fields
|
||||||
|
Custom field hash table. Will be validated by the API service
|
||||||
|
|
||||||
|
.PARAMETER Raw
|
||||||
|
Return raw results from API service
|
||||||
|
|
||||||
|
.EXAMPLE
|
||||||
|
PS C:\> New-NetboxIPAMVRF -Name MyVRF -Tenant 1 -import_targets @(1,2) -export_targets @(1,2) -RD 65000:100 -enforce_unique $false
|
||||||
|
|
||||||
|
.NOTES
|
||||||
|
Additional information about the function.
|
||||||
|
#>
|
||||||
|
|
||||||
|
[CmdletBinding(ConfirmImpact = 'low',
|
||||||
|
SupportsShouldProcess = $true)]
|
||||||
|
[OutputType([pscustomobject])]
|
||||||
|
param
|
||||||
|
(
|
||||||
|
[Parameter(Mandatory = $true)]
|
||||||
|
[string]$Name,
|
||||||
|
|
||||||
|
[object]$RD,
|
||||||
|
|
||||||
|
[uint64]$Tenant,
|
||||||
|
|
||||||
|
[object]$enforce_unique = 1,
|
||||||
|
|
||||||
|
[string]$Description,
|
||||||
|
|
||||||
|
[uint64[]]$import_targets,
|
||||||
|
|
||||||
|
[uint64[]]$export_targets,
|
||||||
|
|
||||||
|
[hashtable]$Custom_Fields,
|
||||||
|
|
||||||
|
[switch]$Raw
|
||||||
|
)
|
||||||
|
|
||||||
|
$segments = [System.Collections.ArrayList]::new(@('ipam', 'vrfs'))
|
||||||
|
|
||||||
|
$URIComponents = BuildURIComponents -URISegments $segments -ParametersDictionary $PSBoundParameters
|
||||||
|
|
||||||
|
$URI = BuildNewURI -Segments $URIComponents.Segments
|
||||||
|
|
||||||
|
if ($PSCmdlet.ShouldProcess($nae, 'Create new VRF $($Name)')) {
|
||||||
|
InvokeNetboxRequest -URI $URI -Method POST -Body $URIComponents.Parameters -Raw:$Raw
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region File New-NetboxTenant.ps1
|
#region File New-NetboxTenant.ps1
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue