2022-12-06 13:34:52 -05:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
function New-NetboxIPAMAddress {
|
2021-03-30 16:34:25 +02:00
|
|
|
|
<#
|
2020-03-23 12:18:01 -04:00
|
|
|
|
.SYNOPSIS
|
|
|
|
|
|
Create a new IP address to Netbox
|
2021-03-30 16:34:25 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
.DESCRIPTION
|
|
|
|
|
|
Create a new IP address to Netbox with a status of Active by default.
|
2021-03-30 16:34:25 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
.PARAMETER Address
|
|
|
|
|
|
IP address in CIDR notation: 192.168.1.1/24
|
2021-03-30 16:34:25 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
.PARAMETER Status
|
|
|
|
|
|
Status of the IP. Defaults to Active
|
2021-03-30 16:34:25 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
.PARAMETER Tenant
|
|
|
|
|
|
Tenant ID
|
2021-03-30 16:34:25 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
.PARAMETER VRF
|
|
|
|
|
|
VRF ID
|
2021-03-30 16:34:25 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
.PARAMETER Role
|
|
|
|
|
|
Role such as anycast, loopback, etc... Defaults to nothing
|
2021-03-30 16:34:25 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
.PARAMETER NAT_Inside
|
|
|
|
|
|
ID of IP for NAT
|
2021-03-30 16:34:25 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
.PARAMETER Custom_Fields
|
|
|
|
|
|
Custom field hash table. Will be validated by the API service
|
2021-03-30 16:34:25 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
.PARAMETER Interface
|
|
|
|
|
|
ID of interface to apply IP
|
2021-03-30 16:34:25 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
.PARAMETER Description
|
|
|
|
|
|
Description of IP address
|
2021-03-30 16:34:25 +02:00
|
|
|
|
|
|
|
|
|
|
.PARAMETER Dns_name
|
|
|
|
|
|
DNS Name of IP address (example : netbox.example.com)
|
|
|
|
|
|
|
2021-07-23 22:03:07 +02:00
|
|
|
|
.PARAMETER Assigned_Object_Type
|
|
|
|
|
|
Assigned Object Type dcim.interface or virtualization.vminterface
|
|
|
|
|
|
|
|
|
|
|
|
.PARAMETER Assigned_Object_Id
|
|
|
|
|
|
Assigned Object ID
|
2021-03-30 16:34:25 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
.PARAMETER Raw
|
|
|
|
|
|
Return raw results from API service
|
2021-03-30 16:34:25 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
.EXAMPLE
|
2021-07-23 22:03:07 +02:00
|
|
|
|
New-NetboxIPAMAddress -Address 192.0.2.1/32
|
|
|
|
|
|
|
|
|
|
|
|
Add new IP Address 192.0.2.1/32 with status active
|
2021-03-30 16:34:25 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
.NOTES
|
|
|
|
|
|
Additional information about the function.
|
|
|
|
|
|
#>
|
2021-03-30 16:34:25 +02:00
|
|
|
|
|
2021-03-25 16:52:08 -04:00
|
|
|
|
[CmdletBinding(ConfirmImpact = 'Low',
|
2021-03-30 16:34:25 +02:00
|
|
|
|
SupportsShouldProcess = $true)]
|
2020-03-23 12:18:01 -04:00
|
|
|
|
[OutputType([pscustomobject])]
|
|
|
|
|
|
param
|
|
|
|
|
|
(
|
2021-03-25 16:52:08 -04:00
|
|
|
|
[Parameter(Mandatory = $true,
|
2021-03-30 16:34:25 +02:00
|
|
|
|
ValueFromPipelineByPropertyName = $true)]
|
2020-03-23 12:18:01 -04:00
|
|
|
|
[string]$Address,
|
2021-03-30 16:34:25 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
[object]$Status = 'Active',
|
2021-03-30 16:34:25 +02:00
|
|
|
|
|
2023-11-07 10:30:05 -05:00
|
|
|
|
[uint64]$Tenant,
|
2021-03-30 16:34:25 +02:00
|
|
|
|
|
2023-11-07 10:30:05 -05:00
|
|
|
|
[uint64]$VRF,
|
2021-03-30 16:34:25 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
[object]$Role,
|
2021-03-30 16:34:25 +02:00
|
|
|
|
|
2023-11-07 10:30:05 -05:00
|
|
|
|
[uint64]$NAT_Inside,
|
2021-03-30 16:34:25 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
[hashtable]$Custom_Fields,
|
2021-03-30 16:34:25 +02:00
|
|
|
|
|
2023-11-07 10:30:05 -05:00
|
|
|
|
[uint64]$Interface,
|
2021-03-30 16:34:25 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
[string]$Description,
|
2021-03-30 16:34:25 +02:00
|
|
|
|
|
|
|
|
|
|
[string]$Dns_name,
|
|
|
|
|
|
|
2021-07-23 22:03:07 +02:00
|
|
|
|
[ValidateSet('dcim.interface', 'virtualization.vminterface', IgnoreCase = $true)]
|
|
|
|
|
|
[string]$Assigned_Object_Type,
|
|
|
|
|
|
|
2023-11-07 10:30:05 -05:00
|
|
|
|
[uint64]$Assigned_Object_Id,
|
2021-03-30 16:34:25 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
[switch]$Raw
|
|
|
|
|
|
)
|
2021-03-30 16:34:25 +02:00
|
|
|
|
|
|
|
|
|
|
process {
|
|
|
|
|
|
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'ip-addresses'))
|
|
|
|
|
|
$Method = 'POST'
|
|
|
|
|
|
|
|
|
|
|
|
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
|
|
|
|
|
|
|
|
|
|
|
|
$URI = BuildNewURI -Segments $URIComponents.Segments
|
|
|
|
|
|
|
2021-07-23 22:03:07 +02:00
|
|
|
|
if ($PSCmdlet.ShouldProcess($Address, 'Create new IP address')) {
|
2021-03-30 16:34:25 +02:00
|
|
|
|
InvokeNetboxRequest -URI $URI -Method $Method -Body $URIComponents.Parameters -Raw:$Raw
|
|
|
|
|
|
}
|
2021-03-25 16:52:08 -04:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|