mirror of
https://github.com/benclaussen/NetboxPS.git
synced 2025-12-13 01:42:28 +00:00
v1.5.0 (#22)
* Connect(Setup): Fix indent (using Visual code Formatter) * Setup(Functions): Fix indent (using Visual Code Formatter) * Support(Setup): Fix indent (using Visual Code Formatter) * InvokeNetboxRequest(Helpers): Fix indent (using Visual Code Formatter) * Add Set-netboxCipherSSL for enable TLS1.1 and TLS1.2 (for PS 5.0) From PowerAruba/FortiPower Module :) * Add Set-NetboxUnstrustedSSL for disable SSL chain test (for PS 5.0 From PowerAruba/FortiPwoer Module :) * Add Get/Set netboxInvokeParms for Get and Set Invoke Params (array) Like -SkipCertificate, Timeout... * InvokeNetboxRequest: Add to Splat NetboxInvokeParams * Connect: Add SkipCertificateCheck parameter (for PS5 and Core) Also enable TLS 1.1 and 1.2 for PS5 * PSSA: Add Github Actions for launch PSSA (PowerShell Script Analyzer) when launch PR (#11) Add also vscode/PSScriptAnalyzerSettings.psd1 for Settings for PSSA (can be reuse also for vscode...) * Update psproj * Correct typo * Correct brace formatting * Add Get/Set timeout functions * Add Get/Set timeout functions * Add TimeoutSeconds parameter and logic to Connect-NetboxAPI - Updated `InvokeNetboxRequest` to use `NetboxConfig.Timeout` - Updated `Get-NetboxAPIDefinition` to use `NetboxConfig.Timeout` * Trim whitespaces * Add Get-NetboxVersion function * Remove API Definition caching and replace with Netbox version check * Increment version to 1.4 * Fix Typo and Enhance AvailableIP Example (#18) * AvailableIP(IPAM/Address): Fix typo * AvailableIP(IAPM/Address): Enhance Example * NetboxPS(.psm1): Fix typo (paramters => parameters * Update deployment files * Add Assigned Object (Type and ID) to New IPAM Address (#19) * IPAMAddress(New): Remove tab (use 4 spaces) * IPAMAddress(New): Remove not longer needed code about value validation * IPAMAddress(New): Add Assigned Object Type and ID Fix #17 * IPAMAddress(New): add Parameter example * IPAMAddress(New): Add Validate for Assigned Object Type Can be only dcim.interface or virtualization.vminterface * IPAMAddress(New): Fix Example (it is New and not Create Verb !) * IPAMAddress(New): Remove -Force parameter, use -Confirm if you want a confirmation it is the standard with ShouldProcess * Fix PSSA Warning (#20) * Fix trailing white space using Invoke-ScriptAnalyzer -Fix -Path . -Recurse * add settings.json for configure Visual Code (Formatter) * PSSA: Fix Command accepts pipeline input but has not defined a process block * PSSA: Fix PSUseDeclaredVarsMoreThanAssignments The variable 'I_B' is assigned but never used The variable 'I_A' is assigned but never used * PSSA: Fix PSUseShouldProcessForStateChangingFunctions Function New-/Set-... has verb that could change system state. Therefore, the function has to support 'ShouldProcess' * Add release.(yml) Github Actions (#21) It will push on PSGallery module when release a new version ! * Update deploy.ps1 docs * Update readme * Remove unused files * Increment version to 1.5.0 Co-authored-by: Alexis La Goutte <alexis.lagoutte@gmail.com> Co-authored-by: Ben Claussen <claussen@neonet.org>
This commit is contained in:
parent
739f5e98e2
commit
26c7ccfdd0
68 changed files with 3017 additions and 2997 deletions
16
.github/workflows/release.yml
vendored
Normal file
16
.github/workflows/release.yml
vendored
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
name: Release
|
||||
|
||||
on:
|
||||
release:
|
||||
types: [published]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Publish
|
||||
run: |
|
||||
pwsh -Command "Publish-Module -Path ./NetboxPS -NuGetApiKey ${{ secrets.PSGALLERY_API_KEY }}"
|
||||
10
.vscode/settings.json
vendored
Normal file
10
.vscode/settings.json
vendored
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
// Place your settings in this file to overwrite default and user settings.
|
||||
{
|
||||
"editor.formatOnSave": true,
|
||||
"files.trimTrailingWhitespace": true,
|
||||
"powershell.scriptAnalysis.settingsPath": ".vscode/PSScriptAnalyzerSettings.psd1",
|
||||
"powershell.codeFormatting.newLineAfterCloseBrace": false,
|
||||
"[markdown]": {
|
||||
"files.trimTrailingWhitespace": false,
|
||||
}
|
||||
}
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
<#
|
||||
.NOTES
|
||||
===========================================================================
|
||||
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2018 v5.5.148
|
||||
Created on: 2/28/2018 4:06 PM
|
||||
Created by: Ben Claussen
|
||||
Organization: NEOnet
|
||||
Filename: Circuits.ps1
|
||||
===========================================================================
|
||||
.DESCRIPTION
|
||||
Circuit object functions
|
||||
#>
|
||||
|
||||
|
||||
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
|
||||
function Get-NetboxCircuit {
|
||||
<#
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Gets one or more circuits
|
||||
|
||||
|
|
@ -105,6 +105,7 @@ function Get-NetboxCircuit {
|
|||
[switch]$Raw
|
||||
)
|
||||
|
||||
process {
|
||||
switch ($PSCmdlet.ParameterSetName) {
|
||||
'ById' {
|
||||
foreach ($i in $ID) {
|
||||
|
|
@ -128,4 +129,5 @@ function Get-NetboxCircuit {
|
|||
InvokeNetboxRequest -URI $URI -Raw:$Raw
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -54,6 +54,7 @@ function New-NetboxCircuit {
|
|||
[switch]$Raw
|
||||
)
|
||||
|
||||
process {
|
||||
$Segments = [System.Collections.ArrayList]::new(@('circuits', 'circuits'))
|
||||
$Method = 'POST'
|
||||
|
||||
|
|
@ -64,4 +65,5 @@ function New-NetboxCircuit {
|
|||
if ($Force -or $PSCmdlet.ShouldProcess($CID, 'Create new circuit')) {
|
||||
InvokeNetboxRequest -URI $URI -Method $Method -Body $URIComponents.Parameters -Raw:$Raw
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -85,6 +85,7 @@ function Get-NetboxDCIMDevice {
|
|||
|
||||
#endregion Parameters
|
||||
|
||||
process {
|
||||
if ($null -ne $Status) {
|
||||
$PSBoundParameters.Status = ValidateDCIMChoice -ProvidedValue $Status -DeviceStatus
|
||||
}
|
||||
|
|
@ -96,4 +97,5 @@ function Get-NetboxDCIMDevice {
|
|||
$URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||
|
||||
InvokeNetboxRequest -URI $URI -Raw:$Raw
|
||||
}
|
||||
}
|
||||
|
|
@ -13,7 +13,8 @@
|
|||
|
||||
|
||||
function New-NetboxDCIMDevice {
|
||||
[CmdletBinding()]
|
||||
[CmdletBinding(ConfirmImpact = 'low',
|
||||
SupportsShouldProcess = $true)]
|
||||
[OutputType([pscustomobject])]
|
||||
#region Parameters
|
||||
param
|
||||
|
|
@ -64,21 +65,21 @@ function New-NetboxDCIMDevice {
|
|||
)
|
||||
#endregion Parameters
|
||||
|
||||
# if ($null -ne $Device_Role) {
|
||||
# # Validate device role?
|
||||
# }
|
||||
#
|
||||
# if ($null -ne $Device_Type) {
|
||||
# # Validate device type?
|
||||
# }
|
||||
#
|
||||
# if ($null -ne $Status) {
|
||||
# $PSBoundParameters.Status = ValidateDCIMChoice -ProvidedValue $Status -DeviceStatus
|
||||
# }
|
||||
#
|
||||
# if ($null -ne $Face) {
|
||||
# $PSBoundParameters.Face = ValidateDCIMChoice -ProvidedValue $Face -DeviceFace
|
||||
# }
|
||||
# if ($null -ne $Device_Role) {
|
||||
# # Validate device role?
|
||||
# }
|
||||
|
||||
# if ($null -ne $Device_Type) {
|
||||
# # Validate device type?
|
||||
# }
|
||||
|
||||
# if ($null -ne $Status) {
|
||||
# $PSBoundParameters.Status = ValidateDCIMChoice -ProvidedValue $Status -DeviceStatus
|
||||
# }
|
||||
|
||||
# if ($null -ne $Face) {
|
||||
# $PSBoundParameters.Face = ValidateDCIMChoice -ProvidedValue $Face -DeviceFace
|
||||
# }
|
||||
|
||||
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'devices'))
|
||||
|
||||
|
|
@ -86,5 +87,7 @@ function New-NetboxDCIMDevice {
|
|||
|
||||
$URI = BuildNewURI -Segments $URIComponents.Segments
|
||||
|
||||
if ($PSCmdlet.ShouldProcess($Name, 'Create new Device')) {
|
||||
InvokeNetboxRequest -URI $URI -Body $URIComponents.Parameters -Method POST
|
||||
}
|
||||
}
|
||||
|
|
@ -67,7 +67,7 @@ function Set-NetboxDCIMDevice {
|
|||
# if ($null -ne $Status) {
|
||||
# $PSBoundParameters.Status = ValidateDCIMChoice -ProvidedValue $Status -DeviceStatus
|
||||
# }
|
||||
#
|
||||
|
||||
# if ($null -ne $Face) {
|
||||
# $PSBoundParameters.Face = ValidateDCIMChoice -ProvidedValue $Face -DeviceFace
|
||||
# }
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
|
||||
function Add-NetboxDCIMInterfaceConnection {
|
||||
<#
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Create a new connection between two interfaces
|
||||
|
||||
|
|
@ -54,8 +54,8 @@ function Add-NetboxDCIMInterfaceConnection {
|
|||
}
|
||||
|
||||
# Verify if both Interfaces exist
|
||||
$I_A = Get-NetboxDCIMInterface -Id $Interface_A -ErrorAction Stop
|
||||
$I_B = Get-NetboxDCIMInterface -Id $Interface_B -ErrorAction Stop
|
||||
Get-NetboxDCIMInterface -Id $Interface_A -ErrorAction Stop | Out-null
|
||||
Get-NetboxDCIMInterface -Id $Interface_B -ErrorAction Stop | Out-null
|
||||
|
||||
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'interface-connections'))
|
||||
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ function Get-NetboxDCIMInterface {
|
|||
[switch]$Raw
|
||||
)
|
||||
|
||||
process {
|
||||
if ($null -ne $Form_Factor) {
|
||||
$PSBoundParameters.Form_Factor = ValidateDCIMChoice -ProvidedValue $Form_Factor -InterfaceFormFactor
|
||||
}
|
||||
|
|
@ -58,4 +59,5 @@ function Get-NetboxDCIMInterface {
|
|||
$URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||
|
||||
InvokeNetboxRequest -URI $URI -Raw:$Raw
|
||||
}
|
||||
}
|
||||
|
|
@ -13,7 +13,8 @@
|
|||
|
||||
|
||||
function Set-NetboxDCIMInterface {
|
||||
[CmdletBinding()]
|
||||
[CmdletBinding(ConfirmImpact = 'Medium',
|
||||
SupportsShouldProcess = $true)]
|
||||
[OutputType([pscustomobject])]
|
||||
param
|
||||
(
|
||||
|
|
@ -50,9 +51,9 @@ function Set-NetboxDCIMInterface {
|
|||
)
|
||||
|
||||
begin {
|
||||
# if ($null -ne $Form_Factor) {
|
||||
# $PSBoundParameters.Form_Factor = ValidateDCIMChoice -ProvidedValue $Form_Factor -InterfaceFormFactor
|
||||
# }
|
||||
# if ($null -ne $Form_Factor) {
|
||||
# $PSBoundParameters.Form_Factor = ValidateDCIMChoice -ProvidedValue $Form_Factor -InterfaceFormFactor
|
||||
# }
|
||||
|
||||
if (-not [System.String]::IsNullOrWhiteSpace($Mode)) {
|
||||
$PSBoundParameters.Mode = switch ($Mode) {
|
||||
|
|
@ -88,9 +89,11 @@ function Set-NetboxDCIMInterface {
|
|||
|
||||
$URI = BuildNewURI -Segments $Segments
|
||||
|
||||
if ($Force -or $pscmdlet.ShouldProcess("Interface ID $($CurrentInterface.Id)", "Set")) {
|
||||
InvokeNetboxRequest -URI $URI -Body $URIComponents.Parameters -Method PATCH
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
end {
|
||||
|
||||
|
|
|
|||
|
|
@ -81,6 +81,7 @@ function Get-NetboxDCIMSite {
|
|||
[switch]$Raw
|
||||
)
|
||||
|
||||
process {
|
||||
switch ($PSCmdlet.ParameterSetName) {
|
||||
'ById' {
|
||||
foreach ($Site_ID in $ID) {
|
||||
|
|
@ -104,5 +105,6 @@ function Get-NetboxDCIMSite {
|
|||
InvokeNetboxRequest -URI $URI -Raw:$Raw
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -34,7 +34,14 @@ function Get-NetboxIPAMAvailableIP {
|
|||
A description of the NumberOfIPs parameter.
|
||||
|
||||
.EXAMPLE
|
||||
PS C:\> Get-NetboxIPAMAvaiableIP -Prefix_ID $value1
|
||||
Get-NetboxIPAMAvailableIP -Prefix_ID (Get-NetboxIPAMPrefix -Prefix 192.0.2.0/24).id
|
||||
|
||||
Get (Next) Available IP on the Prefix 192.0.2.0/24
|
||||
|
||||
.EXAMPLE
|
||||
Get-NetboxIPAMAvailableIP -Prefix_ID 2 -NumberOfIPs 3
|
||||
|
||||
Get 3 (Next) Available IP on the Prefix 192.0.2.0/24
|
||||
|
||||
.NOTES
|
||||
Additional information about the function.
|
||||
|
|
|
|||
|
|
@ -50,14 +50,19 @@ function New-NetboxIPAMAddress {
|
|||
.PARAMETER Dns_name
|
||||
DNS Name of IP address (example : netbox.example.com)
|
||||
|
||||
.PARAMETER Force
|
||||
Do not prompt for confirmation to create IP.
|
||||
.PARAMETER Assigned_Object_Type
|
||||
Assigned Object Type dcim.interface or virtualization.vminterface
|
||||
|
||||
.PARAMETER Assigned_Object_Id
|
||||
Assigned Object ID
|
||||
|
||||
.PARAMETER Raw
|
||||
Return raw results from API service
|
||||
|
||||
.EXAMPLE
|
||||
PS C:\> Create-NetboxIPAMAddress
|
||||
New-NetboxIPAMAddress -Address 192.0.2.1/32
|
||||
|
||||
Add new IP Address 192.0.2.1/32 with status active
|
||||
|
||||
.NOTES
|
||||
Additional information about the function.
|
||||
|
|
@ -90,7 +95,10 @@ function New-NetboxIPAMAddress {
|
|||
|
||||
[string]$Dns_name,
|
||||
|
||||
[switch]$Force,
|
||||
[ValidateSet('dcim.interface', 'virtualization.vminterface', IgnoreCase = $true)]
|
||||
[string]$Assigned_Object_Type,
|
||||
|
||||
[int]$Assigned_Object_Id,
|
||||
|
||||
[switch]$Raw
|
||||
)
|
||||
|
|
@ -99,22 +107,11 @@ function New-NetboxIPAMAddress {
|
|||
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'ip-addresses'))
|
||||
$Method = 'POST'
|
||||
|
||||
# # Value validation
|
||||
# $ModelDefinition = GetModelDefinitionFromURIPath -Segments $Segments -Method $Method
|
||||
# $EnumProperties = GetModelEnumProperties -ModelDefinition $ModelDefinition
|
||||
#
|
||||
# foreach ($Property in $EnumProperties.Keys) {
|
||||
# if ($PSBoundParameters.ContainsKey($Property)) {
|
||||
# Write-Verbose "Validating property [$Property] with value [$($PSBoundParameters.$Property)]"
|
||||
# $PSBoundParameters.$Property = ValidateValue -ModelDefinition $ModelDefinition -Property $Property -ProvidedValue $PSBoundParameters.$Property
|
||||
# }
|
||||
# }
|
||||
#
|
||||
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
|
||||
|
||||
$URI = BuildNewURI -Segments $URIComponents.Segments
|
||||
|
||||
if ($Force -or $PSCmdlet.ShouldProcess($Address, 'Create new IP address')) {
|
||||
if ($PSCmdlet.ShouldProcess($Address, 'Create new IP address')) {
|
||||
InvokeNetboxRequest -URI $URI -Method $Method -Body $URIComponents.Parameters -Raw:$Raw
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@
|
|||
|
||||
|
||||
function New-NetboxIPAMPrefix {
|
||||
[CmdletBinding(ConfirmImpact = 'low',
|
||||
SupportsShouldProcess = $true)]
|
||||
[CmdletBinding()]
|
||||
param
|
||||
(
|
||||
|
|
@ -40,7 +42,7 @@ function New-NetboxIPAMPrefix {
|
|||
[switch]$Raw
|
||||
)
|
||||
|
||||
# $PSBoundParameters.Status = ValidateIPAMChoice -ProvidedValue $Status -PrefixStatus
|
||||
# $PSBoundParameters.Status = ValidateIPAMChoice -ProvidedValue $Status -PrefixStatus
|
||||
|
||||
<#
|
||||
# As of 2018/10/18, this does not appear to be a validated IPAM choice
|
||||
|
|
@ -55,5 +57,7 @@ function New-NetboxIPAMPrefix {
|
|||
|
||||
$URI = BuildNewURI -Segments $URIComponents.Segments
|
||||
|
||||
if ($PSCmdlet.ShouldProcess($Prefix, 'Create new Prefix')) {
|
||||
InvokeNetboxRequest -URI $URI -Method POST -Body $URIComponents.Parameters -Raw:$Raw
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
function New-NetboxIPAMVLAN {
|
||||
<#
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Create a new VLAN
|
||||
|
||||
|
|
@ -40,7 +40,8 @@
|
|||
Additional information about the function.
|
||||
#>
|
||||
|
||||
[CmdletBinding()]
|
||||
[CmdletBinding(ConfirmImpact = 'low',
|
||||
SupportsShouldProcess = $true)]
|
||||
[OutputType([pscustomobject])]
|
||||
param
|
||||
(
|
||||
|
|
@ -63,11 +64,11 @@
|
|||
[switch]$Raw
|
||||
)
|
||||
|
||||
# $PSBoundParameters.Status = ValidateIPAMChoice -ProvidedValue $Status -VLANStatus
|
||||
#
|
||||
# if ($null -ne $Role) {
|
||||
# $PSBoundParameters.Role = ValidateIPAMChoice -ProvidedValue $Role -IPAddressRole
|
||||
# }
|
||||
# $PSBoundParameters.Status = ValidateIPAMChoice -ProvidedValue $Status -VLANStatus
|
||||
|
||||
# if ($null -ne $Role) {
|
||||
# $PSBoundParameters.Role = ValidateIPAMChoice -ProvidedValue $Role -IPAddressRole
|
||||
# }
|
||||
|
||||
$segments = [System.Collections.ArrayList]::new(@('ipam', 'vlans'))
|
||||
|
||||
|
|
@ -75,5 +76,7 @@
|
|||
|
||||
$URI = BuildNewURI -Segments $URIComponents.Segments
|
||||
|
||||
if ($PSCmdlet.ShouldProcess($nae, 'Create new Vlan $($vid)')) {
|
||||
InvokeNetboxRequest -URI $URI -Method POST -Body $URIComponents.Parameters -Raw:$Raw
|
||||
}
|
||||
}
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
<#
|
||||
.NOTES
|
||||
===========================================================================
|
||||
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2018 v5.5.152
|
||||
Created on: 5/29/2018 1:45 PM
|
||||
Created by: Ben Claussen
|
||||
Organization: NEOnet
|
||||
Filename: Tenancy.ps1
|
||||
===========================================================================
|
||||
.DESCRIPTION
|
||||
A description of the file.
|
||||
#>
|
||||
|
||||
|
||||
|
||||
|
||||
#region GET commands
|
||||
|
||||
|
||||
|
||||
#endregion GET commands
|
||||
|
||||
|
||||
#region SET commands
|
||||
|
||||
#endregion SET commands
|
||||
|
||||
|
||||
#region ADD/NEW commands
|
||||
|
||||
#endregion ADD/NEW commands
|
||||
|
||||
|
||||
#region REMOVE commands
|
||||
|
||||
#endregion REMOVE commands
|
||||
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
|
||||
function Get-NetboxVirtualMachine {
|
||||
<#
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Obtains virtual machines from Netbox.
|
||||
|
||||
|
|
@ -141,6 +141,7 @@ function Get-NetboxVirtualMachine {
|
|||
[switch]$Raw
|
||||
)
|
||||
|
||||
process {
|
||||
if ($null -ne $Status) {
|
||||
$PSBoundParameters.Status = ValidateVirtualizationChoice -ProvidedValue $Status -VirtualMachineStatus
|
||||
}
|
||||
|
|
@ -152,4 +153,5 @@ function Get-NetboxVirtualMachine {
|
|||
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||
|
||||
InvokeNetboxRequest -URI $uri -Raw:$Raw
|
||||
}
|
||||
}
|
||||
|
|
@ -13,7 +13,8 @@
|
|||
|
||||
|
||||
function New-NetboxVirtualMachine {
|
||||
[CmdletBinding()]
|
||||
[CmdletBinding(ConfirmImpact = 'low',
|
||||
SupportsShouldProcess = $true)]
|
||||
[OutputType([pscustomobject])]
|
||||
param
|
||||
(
|
||||
|
|
@ -46,13 +47,13 @@ function New-NetboxVirtualMachine {
|
|||
[string]$Comments
|
||||
)
|
||||
|
||||
# $ModelDefinition = $script:NetboxConfig.APIDefinition.definitions.WritableVirtualMachineWithConfigContext
|
||||
#
|
||||
# # Validate the status against the APIDefinition
|
||||
# if ($ModelDefinition.properties.status.enum -inotcontains $Status) {
|
||||
# throw ("Invalid value [] for Status. Must be one of []" -f $Status, ($ModelDefinition.properties.status.enum -join ', '))
|
||||
# }
|
||||
#
|
||||
# $ModelDefinition = $script:NetboxConfig.APIDefinition.definitions.WritableVirtualMachineWithConfigContext
|
||||
|
||||
# # Validate the status against the APIDefinition
|
||||
# if ($ModelDefinition.properties.status.enum -inotcontains $Status) {
|
||||
# throw ("Invalid value [] for Status. Must be one of []" -f $Status, ($ModelDefinition.properties.status.enum -join ', '))
|
||||
# }
|
||||
|
||||
#$PSBoundParameters.Status = ValidateVirtualizationChoice -ProvidedValue $Status -VirtualMachineStatus
|
||||
|
||||
$Segments = [System.Collections.ArrayList]::new(@('virtualization', 'virtual-machines'))
|
||||
|
|
@ -61,7 +62,9 @@ function New-NetboxVirtualMachine {
|
|||
|
||||
$URI = BuildNewURI -Segments $URIComponents.Segments
|
||||
|
||||
if ($PSCmdlet.ShouldProcess($name, 'Create new Virtual Machine')) {
|
||||
InvokeNetboxRequest -URI $URI -Method POST -Body $URIComponents.Parameters
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -50,10 +50,11 @@ function Set-NetboxVirtualMachine {
|
|||
[switch]$Force
|
||||
)
|
||||
|
||||
# if ($null -ne $Status) {
|
||||
# $PSBoundParameters.Status = ValidateVirtualizationChoice -ProvidedValue $Status -VirtualMachineStatus
|
||||
# }
|
||||
#
|
||||
# if ($null -ne $Status) {
|
||||
# $PSBoundParameters.Status = ValidateVirtualizationChoice -ProvidedValue $Status -VirtualMachineStatus
|
||||
# }
|
||||
|
||||
process {
|
||||
$Segments = [System.Collections.ArrayList]::new(@('virtualization', 'virtual-machines', $Id))
|
||||
|
||||
Write-Verbose "Obtaining VM from ID $Id"
|
||||
|
|
@ -69,4 +70,5 @@ function Set-NetboxVirtualMachine {
|
|||
|
||||
InvokeNetboxRequest -URI $URI -Body $URIComponents.Parameters -Method PATCH
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
|
||||
function Get-NetboxVirtualMachineInterface {
|
||||
<#
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Gets VM interfaces
|
||||
|
||||
|
|
@ -84,6 +84,7 @@ function Get-NetboxVirtualMachineInterface {
|
|||
[switch]$Raw
|
||||
)
|
||||
|
||||
process {
|
||||
$Segments = [System.Collections.ArrayList]::new(@('virtualization', 'interfaces'))
|
||||
|
||||
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
|
||||
|
|
@ -91,4 +92,5 @@ function Get-NetboxVirtualMachineInterface {
|
|||
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||
|
||||
InvokeNetboxRequest -URI $uri -Raw:$Raw
|
||||
}
|
||||
}
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
# Generated by: Ben Claussen
|
||||
#
|
||||
# Generated on: 2021-07-22
|
||||
# Generated on: 2021-07-23
|
||||
#
|
||||
|
||||
@{
|
||||
|
|
@ -12,7 +12,7 @@
|
|||
RootModule = 'NetboxPS.psm1'
|
||||
|
||||
# Version number of this module.
|
||||
ModuleVersion = '1.4'
|
||||
ModuleVersion = '1.5.0'
|
||||
|
||||
# Supported PSEditions
|
||||
# CompatiblePSEditions = @()
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
Script generated by PowerShell Studio 2020
|
||||
#>
|
||||
|
||||
# Build a list of common paramters so we can omit them to build URI parameters
|
||||
# Build a list of common parameters so we can omit them to build URI parameters
|
||||
$script:CommonParameterNames = New-Object System.Collections.ArrayList
|
||||
[void]$script:CommonParameterNames.AddRange(@([System.Management.Automation.PSCmdlet]::CommonParameters))
|
||||
[void]$script:CommonParameterNames.AddRange(@([System.Management.Automation.PSCmdlet]::OptionalCommonParameters))
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
# Generated by: Ben Claussen
|
||||
#
|
||||
# Generated on: 2021-07-22
|
||||
# Generated on: 2021-07-23
|
||||
#
|
||||
|
||||
@{
|
||||
|
|
@ -12,7 +12,7 @@
|
|||
RootModule = 'NetboxPS.psm1'
|
||||
|
||||
# Version number of this module.
|
||||
ModuleVersion = '1.4'
|
||||
ModuleVersion = '1.5.0'
|
||||
|
||||
# Supported PSEditions
|
||||
# CompatiblePSEditions = @()
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ function Add-NetboxDCIMInterface {
|
|||
|
||||
|
||||
function Add-NetboxDCIMInterfaceConnection {
|
||||
<#
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Create a new connection between two interfaces
|
||||
|
||||
|
|
@ -147,8 +147,8 @@ function Add-NetboxDCIMInterfaceConnection {
|
|||
}
|
||||
|
||||
# Verify if both Interfaces exist
|
||||
$I_A = Get-NetboxDCIMInterface -Id $Interface_A -ErrorAction Stop
|
||||
$I_B = Get-NetboxDCIMInterface -Id $Interface_B -ErrorAction Stop
|
||||
Get-NetboxDCIMInterface -Id $Interface_A -ErrorAction Stop | Out-null
|
||||
Get-NetboxDCIMInterface -Id $Interface_B -ErrorAction Stop | Out-null
|
||||
|
||||
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'interface-connections'))
|
||||
|
||||
|
|
@ -428,25 +428,6 @@ function CheckNetboxIsConnected {
|
|||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region File Circuits.ps1
|
||||
|
||||
<#
|
||||
.NOTES
|
||||
===========================================================================
|
||||
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2018 v5.5.148
|
||||
Created on: 2/28/2018 4:06 PM
|
||||
Created by: Ben Claussen
|
||||
Organization: NEOnet
|
||||
Filename: Circuits.ps1
|
||||
===========================================================================
|
||||
.DESCRIPTION
|
||||
Circuit object functions
|
||||
#>
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region File Clear-NetboxCredential.ps1
|
||||
|
|
@ -829,7 +810,7 @@ function GetNetboxAPIErrorBody {
|
|||
|
||||
|
||||
function Get-NetboxCircuit {
|
||||
<#
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Gets one or more circuits
|
||||
|
||||
|
|
@ -921,6 +902,7 @@ function Get-NetboxCircuit {
|
|||
[switch]$Raw
|
||||
)
|
||||
|
||||
process {
|
||||
switch ($PSCmdlet.ParameterSetName) {
|
||||
'ById' {
|
||||
foreach ($i in $ID) {
|
||||
|
|
@ -944,6 +926,7 @@ function Get-NetboxCircuit {
|
|||
InvokeNetboxRequest -URI $URI -Raw:$Raw
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
@ -1291,6 +1274,7 @@ function Get-NetboxDCIMDevice {
|
|||
|
||||
#endregion Parameters
|
||||
|
||||
process {
|
||||
if ($null -ne $Status) {
|
||||
$PSBoundParameters.Status = ValidateDCIMChoice -ProvidedValue $Status -DeviceStatus
|
||||
}
|
||||
|
|
@ -1302,6 +1286,7 @@ function Get-NetboxDCIMDevice {
|
|||
$URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||
|
||||
InvokeNetboxRequest -URI $URI -Raw:$Raw
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
@ -1490,6 +1475,7 @@ function Get-NetboxDCIMInterface {
|
|||
[switch]$Raw
|
||||
)
|
||||
|
||||
process {
|
||||
if ($null -ne $Form_Factor) {
|
||||
$PSBoundParameters.Form_Factor = ValidateDCIMChoice -ProvidedValue $Form_Factor -InterfaceFormFactor
|
||||
}
|
||||
|
|
@ -1501,6 +1487,7 @@ function Get-NetboxDCIMInterface {
|
|||
$URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||
|
||||
InvokeNetboxRequest -URI $URI -Raw:$Raw
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
@ -1709,6 +1696,7 @@ function Get-NetboxDCIMSite {
|
|||
[switch]$Raw
|
||||
)
|
||||
|
||||
process {
|
||||
switch ($PSCmdlet.ParameterSetName) {
|
||||
'ById' {
|
||||
foreach ($Site_ID in $ID) {
|
||||
|
|
@ -1732,6 +1720,7 @@ function Get-NetboxDCIMSite {
|
|||
InvokeNetboxRequest -URI $URI -Raw:$Raw
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -2021,7 +2010,14 @@ function Get-NetboxIPAMAvailableIP {
|
|||
A description of the NumberOfIPs parameter.
|
||||
|
||||
.EXAMPLE
|
||||
PS C:\> Get-NetboxIPAMAvaiableIP -Prefix_ID $value1
|
||||
Get-NetboxIPAMAvailableIP -Prefix_ID (Get-NetboxIPAMPrefix -Prefix 192.0.2.0/24).id
|
||||
|
||||
Get (Next) Available IP on the Prefix 192.0.2.0/24
|
||||
|
||||
.EXAMPLE
|
||||
Get-NetboxIPAMAvailableIP -Prefix_ID 2 -NumberOfIPs 3
|
||||
|
||||
Get 3 (Next) Available IP on the Prefix 192.0.2.0/24
|
||||
|
||||
.NOTES
|
||||
Additional information about the function.
|
||||
|
|
@ -2819,7 +2815,7 @@ function Get-NetboxVirtualizationClusterGroup {
|
|||
|
||||
|
||||
function Get-NetboxVirtualMachine {
|
||||
<#
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Obtains virtual machines from Netbox.
|
||||
|
||||
|
|
@ -2947,6 +2943,7 @@ function Get-NetboxVirtualMachine {
|
|||
[switch]$Raw
|
||||
)
|
||||
|
||||
process {
|
||||
if ($null -ne $Status) {
|
||||
$PSBoundParameters.Status = ValidateVirtualizationChoice -ProvidedValue $Status -VirtualMachineStatus
|
||||
}
|
||||
|
|
@ -2958,6 +2955,7 @@ function Get-NetboxVirtualMachine {
|
|||
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||
|
||||
InvokeNetboxRequest -URI $uri -Raw:$Raw
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
@ -2979,7 +2977,7 @@ function Get-NetboxVirtualMachine {
|
|||
|
||||
|
||||
function Get-NetboxVirtualMachineInterface {
|
||||
<#
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Gets VM interfaces
|
||||
|
||||
|
|
@ -3050,6 +3048,7 @@ function Get-NetboxVirtualMachineInterface {
|
|||
[switch]$Raw
|
||||
)
|
||||
|
||||
process {
|
||||
$Segments = [System.Collections.ArrayList]::new(@('virtualization', 'interfaces'))
|
||||
|
||||
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
|
||||
|
|
@ -3057,6 +3056,7 @@ function Get-NetboxVirtualMachineInterface {
|
|||
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||
|
||||
InvokeNetboxRequest -URI $uri -Raw:$Raw
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
@ -3231,6 +3231,7 @@ function New-NetboxCircuit {
|
|||
[switch]$Raw
|
||||
)
|
||||
|
||||
process {
|
||||
$Segments = [System.Collections.ArrayList]::new(@('circuits', 'circuits'))
|
||||
$Method = 'POST'
|
||||
|
||||
|
|
@ -3241,6 +3242,7 @@ function New-NetboxCircuit {
|
|||
if ($Force -or $PSCmdlet.ShouldProcess($CID, 'Create new circuit')) {
|
||||
InvokeNetboxRequest -URI $URI -Method $Method -Body $URIComponents.Parameters -Raw:$Raw
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
@ -3262,7 +3264,8 @@ function New-NetboxCircuit {
|
|||
|
||||
|
||||
function New-NetboxDCIMDevice {
|
||||
[CmdletBinding()]
|
||||
[CmdletBinding(ConfirmImpact = 'low',
|
||||
SupportsShouldProcess = $true)]
|
||||
[OutputType([pscustomobject])]
|
||||
#region Parameters
|
||||
param
|
||||
|
|
@ -3313,21 +3316,21 @@ function New-NetboxDCIMDevice {
|
|||
)
|
||||
#endregion Parameters
|
||||
|
||||
# if ($null -ne $Device_Role) {
|
||||
# # Validate device role?
|
||||
# }
|
||||
#
|
||||
# if ($null -ne $Device_Type) {
|
||||
# # Validate device type?
|
||||
# }
|
||||
#
|
||||
# if ($null -ne $Status) {
|
||||
# $PSBoundParameters.Status = ValidateDCIMChoice -ProvidedValue $Status -DeviceStatus
|
||||
# }
|
||||
#
|
||||
# if ($null -ne $Face) {
|
||||
# $PSBoundParameters.Face = ValidateDCIMChoice -ProvidedValue $Face -DeviceFace
|
||||
# }
|
||||
# if ($null -ne $Device_Role) {
|
||||
# # Validate device role?
|
||||
# }
|
||||
|
||||
# if ($null -ne $Device_Type) {
|
||||
# # Validate device type?
|
||||
# }
|
||||
|
||||
# if ($null -ne $Status) {
|
||||
# $PSBoundParameters.Status = ValidateDCIMChoice -ProvidedValue $Status -DeviceStatus
|
||||
# }
|
||||
|
||||
# if ($null -ne $Face) {
|
||||
# $PSBoundParameters.Face = ValidateDCIMChoice -ProvidedValue $Face -DeviceFace
|
||||
# }
|
||||
|
||||
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'devices'))
|
||||
|
||||
|
|
@ -3335,7 +3338,9 @@ function New-NetboxDCIMDevice {
|
|||
|
||||
$URI = BuildNewURI -Segments $URIComponents.Segments
|
||||
|
||||
if ($PSCmdlet.ShouldProcess($Name, 'Create new Device')) {
|
||||
InvokeNetboxRequest -URI $URI -Body $URIComponents.Parameters -Method POST
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
@ -3394,14 +3399,19 @@ function New-NetboxIPAMAddress {
|
|||
.PARAMETER Dns_name
|
||||
DNS Name of IP address (example : netbox.example.com)
|
||||
|
||||
.PARAMETER Force
|
||||
Do not prompt for confirmation to create IP.
|
||||
.PARAMETER Assigned_Object_Type
|
||||
Assigned Object Type dcim.interface or virtualization.vminterface
|
||||
|
||||
.PARAMETER Assigned_Object_Id
|
||||
Assigned Object ID
|
||||
|
||||
.PARAMETER Raw
|
||||
Return raw results from API service
|
||||
|
||||
.EXAMPLE
|
||||
PS C:\> Create-NetboxIPAMAddress
|
||||
New-NetboxIPAMAddress -Address 192.0.2.1/32
|
||||
|
||||
Add new IP Address 192.0.2.1/32 with status active
|
||||
|
||||
.NOTES
|
||||
Additional information about the function.
|
||||
|
|
@ -3434,7 +3444,10 @@ function New-NetboxIPAMAddress {
|
|||
|
||||
[string]$Dns_name,
|
||||
|
||||
[switch]$Force,
|
||||
[ValidateSet('dcim.interface', 'virtualization.vminterface', IgnoreCase = $true)]
|
||||
[string]$Assigned_Object_Type,
|
||||
|
||||
[int]$Assigned_Object_Id,
|
||||
|
||||
[switch]$Raw
|
||||
)
|
||||
|
|
@ -3443,22 +3456,11 @@ function New-NetboxIPAMAddress {
|
|||
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'ip-addresses'))
|
||||
$Method = 'POST'
|
||||
|
||||
# # Value validation
|
||||
# $ModelDefinition = GetModelDefinitionFromURIPath -Segments $Segments -Method $Method
|
||||
# $EnumProperties = GetModelEnumProperties -ModelDefinition $ModelDefinition
|
||||
#
|
||||
# foreach ($Property in $EnumProperties.Keys) {
|
||||
# if ($PSBoundParameters.ContainsKey($Property)) {
|
||||
# Write-Verbose "Validating property [$Property] with value [$($PSBoundParameters.$Property)]"
|
||||
# $PSBoundParameters.$Property = ValidateValue -ModelDefinition $ModelDefinition -Property $Property -ProvidedValue $PSBoundParameters.$Property
|
||||
# }
|
||||
# }
|
||||
#
|
||||
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
|
||||
|
||||
$URI = BuildNewURI -Segments $URIComponents.Segments
|
||||
|
||||
if ($Force -or $PSCmdlet.ShouldProcess($Address, 'Create new IP address')) {
|
||||
if ($PSCmdlet.ShouldProcess($Address, 'Create new IP address')) {
|
||||
InvokeNetboxRequest -URI $URI -Method $Method -Body $URIComponents.Parameters -Raw:$Raw
|
||||
}
|
||||
}
|
||||
|
|
@ -3488,6 +3490,8 @@ function New-NetboxIPAMAddress {
|
|||
|
||||
|
||||
function New-NetboxIPAMPrefix {
|
||||
[CmdletBinding(ConfirmImpact = 'low',
|
||||
SupportsShouldProcess = $true)]
|
||||
[CmdletBinding()]
|
||||
param
|
||||
(
|
||||
|
|
@ -3515,7 +3519,7 @@ function New-NetboxIPAMPrefix {
|
|||
[switch]$Raw
|
||||
)
|
||||
|
||||
# $PSBoundParameters.Status = ValidateIPAMChoice -ProvidedValue $Status -PrefixStatus
|
||||
# $PSBoundParameters.Status = ValidateIPAMChoice -ProvidedValue $Status -PrefixStatus
|
||||
|
||||
<#
|
||||
# As of 2018/10/18, this does not appear to be a validated IPAM choice
|
||||
|
|
@ -3530,7 +3534,9 @@ function New-NetboxIPAMPrefix {
|
|||
|
||||
$URI = BuildNewURI -Segments $URIComponents.Segments
|
||||
|
||||
if ($PSCmdlet.ShouldProcess($Prefix, 'Create new Prefix')) {
|
||||
InvokeNetboxRequest -URI $URI -Method POST -Body $URIComponents.Parameters -Raw:$Raw
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
@ -3538,7 +3544,7 @@ function New-NetboxIPAMPrefix {
|
|||
#region File New-NetboxIPAMVLAN.ps1
|
||||
|
||||
function New-NetboxIPAMVLAN {
|
||||
<#
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Create a new VLAN
|
||||
|
||||
|
|
@ -3579,7 +3585,8 @@ function New-NetboxIPAMVLAN {
|
|||
Additional information about the function.
|
||||
#>
|
||||
|
||||
[CmdletBinding()]
|
||||
[CmdletBinding(ConfirmImpact = 'low',
|
||||
SupportsShouldProcess = $true)]
|
||||
[OutputType([pscustomobject])]
|
||||
param
|
||||
(
|
||||
|
|
@ -3602,11 +3609,11 @@ function New-NetboxIPAMVLAN {
|
|||
[switch]$Raw
|
||||
)
|
||||
|
||||
# $PSBoundParameters.Status = ValidateIPAMChoice -ProvidedValue $Status -VLANStatus
|
||||
#
|
||||
# if ($null -ne $Role) {
|
||||
# $PSBoundParameters.Role = ValidateIPAMChoice -ProvidedValue $Role -IPAddressRole
|
||||
# }
|
||||
# $PSBoundParameters.Status = ValidateIPAMChoice -ProvidedValue $Status -VLANStatus
|
||||
|
||||
# if ($null -ne $Role) {
|
||||
# $PSBoundParameters.Role = ValidateIPAMChoice -ProvidedValue $Role -IPAddressRole
|
||||
# }
|
||||
|
||||
$segments = [System.Collections.ArrayList]::new(@('ipam', 'vlans'))
|
||||
|
||||
|
|
@ -3614,7 +3621,9 @@ function New-NetboxIPAMVLAN {
|
|||
|
||||
$URI = BuildNewURI -Segments $URIComponents.Segments
|
||||
|
||||
if ($PSCmdlet.ShouldProcess($nae, 'Create new Vlan $($vid)')) {
|
||||
InvokeNetboxRequest -URI $URI -Method POST -Body $URIComponents.Parameters -Raw:$Raw
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
@ -3636,7 +3645,8 @@ function New-NetboxIPAMVLAN {
|
|||
|
||||
|
||||
function New-NetboxVirtualMachine {
|
||||
[CmdletBinding()]
|
||||
[CmdletBinding(ConfirmImpact = 'low',
|
||||
SupportsShouldProcess = $true)]
|
||||
[OutputType([pscustomobject])]
|
||||
param
|
||||
(
|
||||
|
|
@ -3669,13 +3679,13 @@ function New-NetboxVirtualMachine {
|
|||
[string]$Comments
|
||||
)
|
||||
|
||||
# $ModelDefinition = $script:NetboxConfig.APIDefinition.definitions.WritableVirtualMachineWithConfigContext
|
||||
#
|
||||
# # Validate the status against the APIDefinition
|
||||
# if ($ModelDefinition.properties.status.enum -inotcontains $Status) {
|
||||
# throw ("Invalid value [] for Status. Must be one of []" -f $Status, ($ModelDefinition.properties.status.enum -join ', '))
|
||||
# }
|
||||
#
|
||||
# $ModelDefinition = $script:NetboxConfig.APIDefinition.definitions.WritableVirtualMachineWithConfigContext
|
||||
|
||||
# # Validate the status against the APIDefinition
|
||||
# if ($ModelDefinition.properties.status.enum -inotcontains $Status) {
|
||||
# throw ("Invalid value [] for Status. Must be one of []" -f $Status, ($ModelDefinition.properties.status.enum -join ', '))
|
||||
# }
|
||||
|
||||
#$PSBoundParameters.Status = ValidateVirtualizationChoice -ProvidedValue $Status -VirtualMachineStatus
|
||||
|
||||
$Segments = [System.Collections.ArrayList]::new(@('virtualization', 'virtual-machines'))
|
||||
|
|
@ -3684,7 +3694,9 @@ function New-NetboxVirtualMachine {
|
|||
|
||||
$URI = BuildNewURI -Segments $URIComponents.Segments
|
||||
|
||||
if ($PSCmdlet.ShouldProcess($name, 'Create new Virtual Machine')) {
|
||||
InvokeNetboxRequest -URI $URI -Method POST -Body $URIComponents.Parameters
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -4153,7 +4165,7 @@ function Set-NetboxDCIMDevice {
|
|||
# if ($null -ne $Status) {
|
||||
# $PSBoundParameters.Status = ValidateDCIMChoice -ProvidedValue $Status -DeviceStatus
|
||||
# }
|
||||
#
|
||||
|
||||
# if ($null -ne $Face) {
|
||||
# $PSBoundParameters.Face = ValidateDCIMChoice -ProvidedValue $Face -DeviceFace
|
||||
# }
|
||||
|
|
@ -4199,7 +4211,8 @@ function Set-NetboxDCIMDevice {
|
|||
|
||||
|
||||
function Set-NetboxDCIMInterface {
|
||||
[CmdletBinding()]
|
||||
[CmdletBinding(ConfirmImpact = 'Medium',
|
||||
SupportsShouldProcess = $true)]
|
||||
[OutputType([pscustomobject])]
|
||||
param
|
||||
(
|
||||
|
|
@ -4236,9 +4249,9 @@ function Set-NetboxDCIMInterface {
|
|||
)
|
||||
|
||||
begin {
|
||||
# if ($null -ne $Form_Factor) {
|
||||
# $PSBoundParameters.Form_Factor = ValidateDCIMChoice -ProvidedValue $Form_Factor -InterfaceFormFactor
|
||||
# }
|
||||
# if ($null -ne $Form_Factor) {
|
||||
# $PSBoundParameters.Form_Factor = ValidateDCIMChoice -ProvidedValue $Form_Factor -InterfaceFormFactor
|
||||
# }
|
||||
|
||||
if (-not [System.String]::IsNullOrWhiteSpace($Mode)) {
|
||||
$PSBoundParameters.Mode = switch ($Mode) {
|
||||
|
|
@ -4274,9 +4287,11 @@ function Set-NetboxDCIMInterface {
|
|||
|
||||
$URI = BuildNewURI -Segments $Segments
|
||||
|
||||
if ($Force -or $pscmdlet.ShouldProcess("Interface ID $($CurrentInterface.Id)", "Set")) {
|
||||
InvokeNetboxRequest -URI $URI -Body $URIComponents.Parameters -Method PATCH
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
end {
|
||||
|
||||
|
|
@ -4764,10 +4779,11 @@ function Set-NetboxVirtualMachine {
|
|||
[switch]$Force
|
||||
)
|
||||
|
||||
# if ($null -ne $Status) {
|
||||
# $PSBoundParameters.Status = ValidateVirtualizationChoice -ProvidedValue $Status -VirtualMachineStatus
|
||||
# }
|
||||
#
|
||||
# if ($null -ne $Status) {
|
||||
# $PSBoundParameters.Status = ValidateVirtualizationChoice -ProvidedValue $Status -VirtualMachineStatus
|
||||
# }
|
||||
|
||||
process {
|
||||
$Segments = [System.Collections.ArrayList]::new(@('virtualization', 'virtual-machines', $Id))
|
||||
|
||||
Write-Verbose "Obtaining VM from ID $Id"
|
||||
|
|
@ -4783,6 +4799,7 @@ function Set-NetboxVirtualMachine {
|
|||
|
||||
InvokeNetboxRequest -URI $URI -Body $URIComponents.Parameters -Method PATCH
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
@ -4882,47 +4899,6 @@ function SetupNetboxConfigVariable {
|
|||
|
||||
#endregion
|
||||
|
||||
#region File Tenancy.ps1
|
||||
|
||||
<#
|
||||
.NOTES
|
||||
===========================================================================
|
||||
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2018 v5.5.152
|
||||
Created on: 5/29/2018 1:45 PM
|
||||
Created by: Ben Claussen
|
||||
Organization: NEOnet
|
||||
Filename: Tenancy.ps1
|
||||
===========================================================================
|
||||
.DESCRIPTION
|
||||
A description of the file.
|
||||
#>
|
||||
|
||||
|
||||
|
||||
|
||||
#region GET commands
|
||||
|
||||
|
||||
|
||||
#endregion GET commands
|
||||
|
||||
|
||||
#region SET commands
|
||||
|
||||
#endregion SET commands
|
||||
|
||||
|
||||
#region ADD/NEW commands
|
||||
|
||||
#endregion ADD/NEW commands
|
||||
|
||||
|
||||
#region REMOVE commands
|
||||
|
||||
#endregion REMOVE commands
|
||||
|
||||
#endregion
|
||||
|
||||
#region File ThrowNetboxRESTError.ps1
|
||||
|
||||
<#
|
||||
|
|
@ -4979,7 +4955,7 @@ function VerifyAPIConnectivity {
|
|||
Script generated by PowerShell Studio 2020
|
||||
#>
|
||||
|
||||
# Build a list of common paramters so we can omit them to build URI parameters
|
||||
# Build a list of common parameters so we can omit them to build URI parameters
|
||||
$script:CommonParameterNames = New-Object System.Collections.ArrayList
|
||||
[void]$script:CommonParameterNames.AddRange(@([System.Management.Automation.PSCmdlet]::CommonParameters))
|
||||
[void]$script:CommonParameterNames.AddRange(@([System.Management.Automation.PSCmdlet]::OptionalCommonParameters))
|
||||
|
|
|
|||
19
README.md
19
README.md
|
|
@ -4,6 +4,8 @@
|
|||
# Disclaimer
|
||||
This module is beta. Use it at your own risk. I have only added functions as I have needed them, so not everything is available.
|
||||
|
||||
All functions are exported at the moment, including internal/private functions.
|
||||
|
||||
# Description
|
||||
This module is a wrapper for the [Netbox](https://github.com/netbox-community/netbox) API.
|
||||
|
||||
|
|
@ -11,3 +13,20 @@ This module is a wrapper for the [Netbox](https://github.com/netbox-community/ne
|
|||
1. Install module from the `netboxPS` folder
|
||||
2. Import module
|
||||
3. Connect to an API endpoint by using `Connect-NetboxAPI -Hostname netbox.example.com`
|
||||
|
||||
# Notes
|
||||
I started this project years ago with Powershell Studio using the built in deployment methods, learning Git, and learning PS best practices. So please forgive any "obvious" mistakes 😅
|
||||
Over time I have had to adjust my methods for deployment... change the design of functions, and refactor code as I learn new and better things.
|
||||
|
||||
This was built out of a need at my job to interact with Netbox for automation. Only recently has it become a "public" project with other collaborators (which I truly appreciate!).
|
||||
I have done my best to ensure each function does exactly one thing according to the API.
|
||||
|
||||
I will do my best to keep up, but please understand it is given attention as I can at work. As time permits, I will open issues for TODOs for things I have wanted to do for a while, just haven't had time or enough "need" to do them.
|
||||
|
||||
# Contributing
|
||||
- Follow [Powershell Practice and Style Guidelines](https://poshcode.gitbook.io/powershell-practice-and-style/) when writing code
|
||||
- Use discussions for general questions
|
||||
- Open issues for bug fixes or enhancements
|
||||
- Submit all pull requests against the dev branch
|
||||
|
||||
I am always open to suggestions for improvement with reasons and data to back up the suggestion.
|
||||
23
deploy.ps1
23
deploy.ps1
|
|
@ -1,18 +1,31 @@
|
|||
<#
|
||||
.SYNOPSIS
|
||||
A brief description of the Invoke-deploy_ps1 file.
|
||||
Concatenate files into single PSM1 and PSD1 files
|
||||
|
||||
.DESCRIPTION
|
||||
A description of the file.
|
||||
Concatenate all ps1 files in the Functions directory, plus the root PSM1,
|
||||
into a single PSM1 file in the NetboxPS directory.
|
||||
|
||||
By default, this script will increment version by 0.0.1
|
||||
|
||||
.PARAMETER SkipVersion
|
||||
A description of the SkipVersion parameter.
|
||||
Do not increment the version.
|
||||
|
||||
.PARAMETER VersionIncrease
|
||||
A description of the VersionIncrease parameter.
|
||||
Increase the version by a user defined amount
|
||||
|
||||
.PARAMETER NewVersion
|
||||
A description of the NewVersion parameter.
|
||||
Override the new version with this version
|
||||
|
||||
.EXAMPLE
|
||||
Use all defaults and concatenate all files
|
||||
|
||||
.\deploy.ps1
|
||||
|
||||
.EXAMPLE
|
||||
Increment the version by 0.2.0. Given version 1.2.0, the resulting version will be 1.4.0
|
||||
|
||||
.\deploy.ps1 -VersionIncrease 0.2.0
|
||||
|
||||
.NOTES
|
||||
===========================================================================
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue