-
Notifications
You must be signed in to change notification settings - Fork 142
IPAM API
Tim Danner edited this page Apr 12, 2017
·
19 revisions
Starting with IPAM 4.5 (currently in beta as of April 2017), an API is available for managing IP addresses.
Method returns first available IP node for the existing subnet. Error will be returned if non-existing subnet will be specified. It doesn't change status of the returned node.
/// <summary>
/// Get first available IP Address for specific subnet
/// </summary>
/// <param name="subnetAddress">Subnet IpAddress. Like "199.10.1.1"</param>
/// <param name="subnetCidr">Subnet CIDR.</param>
/// <returns>First Available IpAddress from Subnet</returns>
string GetFirstAvailableIp(string subnetAddress, string subnetCid)
Sample
Invoke-SwisVerb $swis IPAM.SubnetManagement GetFirstAvailableIp @("199.10.1.0", "24")
/// <summary>
/// Change IpNode Status
/// </summary>
/// <param name="ipAddress">IpNode Address. Like "199.10.1.1"</param>
/// <param name="status">New Status value. Status values: "Used", "Available", "Reserved", "Transient", "Blocked"</param>
void ChangeIpStatus(string ipAddress, string status)
Sample
Invoke-SwisVerb $swis IPAM.SubnetManagement ChangeIPStatus @("199.10.1.1", "Used")
When reservation time expires IP node status is set to available.
/// <summary>
/// Start IpAddress Reservation
/// </summary>
/// <param name="subnetAddress">Subnet IpAddress. Like "199.10.1.1"</param>
/// <param name="subnetCidr">Subnet CIDR</param>
/// <param name="reservationTimeInMinutes">Reservation Time In Minutes. Default value is "10"</param>
/// <returns>Reserved IpAddress</returns>
string StartIpReservation(string subnetAddress, string subnetCidr, int reservationTimeInMinutes = 10)
/// <summary>
/// Finish IpAddress Reservation with specific status.
/// Call after 'StartIpReservation'
/// </summary>
/// <param name="ipAddress">IpAddress for Reservation. Like "199.10.1.1"</param>
/// <param name="finalIpStatus">IpAddress Status. Possible status values: "Used", "Available", "Reserved", "Transient", "Blocked"</param>
void FinishIpReservation(string ipAddress, string finalIpStatus)
/// <summary>
/// Cancel IpAddress Reservation.
/// Call after 'StartIpReservation'
/// </summary>
/// <param name="reservedIpAddress">IpAddress for Reservation. Like "199.10.1.1"</param>
void CancelIpReservation(string reservedIpAddress)
Sample
Invoke-SwisVerb $swis IPAM.SubnetManagement StartIpReservation @("199.10.1.0", "24", "15")
Invoke-SwisVerb $swis IPAM.SubnetManagement FinishIpReservation @("199.10.1.1", "Reserved")
Invoke-SwisVerb $swis IPAM.SubnetManagement CancelIpReservation @("199.10.1.1")
Created subnet will be plaeced under the root folder in the IPAM group tree. Possible errors: overlapping with existing subnets.
/// <summary>
/// Create new Subnet
/// </summary>
/// <param name="subnetAddress">Subnet IpAddress.</param>
/// <param name="rawCidr">Subnet CIDR</param>
void CreateSubnet(string subnetAddress, string rawCidr)
Sample
```powershell
Invoke-SwisVerb $swis IPAM.SubnetManagement CreateSubnet @("10.10.1.0", "21")
If we have no connection issues this operation will be executed on the DNS server immediately (around 30 seconds). Admin can query IPAM.DnsZone, IPAM.DnsServer, IPAM.DnsRecord entities.
/// <summary>
/// Add DNS 'A' record for IP Address
/// </summary>
/// <param name="recordName">Dns Record Name</param>
/// <param name="nodeIPv4Address">IpNode Address. Like "199.10.1.1"</param>
/// <param name="dnsIpAddress">DnsServer IpAddress.</param>
/// <param name="dnsZoneName">DnsServer Zone name</param>
void AddDnsARecord(string recordName, string nodeIPv4Address, string dnsIpAddress, string dnsZoneName)
Sample
Invoke-SwisVerb $swis IPAM.IPAddressManagement AddDnsARecord @("zzz", "10.11.78.22", "10.199.7.83", "testZone")
/// <summary>
/// Change DNS 'A' record for IP Address
/// </summary>
/// <param name="recordName">Dns Record Name</param>
/// <param name="nodeIPv4Address">IpNode Address.</param>
/// <param name="dnsIpAddress">DnsServer IpAddress.</param>
/// <param name="dnsZoneName">DnsServer Zone name</param>
/// <param name="nodeIPv4AddressNew">New IpNode Address.</param>
void ChangeDnsARecord(string recordName, string nodeIPv4Address, string dnsIpAddress, string dnsZoneName, string nodeIPv4AddressNew)
Sample
Invoke-SwisVerb $swis IPAM.IPAddressManagement ChangeDnsARecord @("zzz.testZone.", "10.11.78.22", "10.199.7.83", "testZone", "10.11.78.33")
/// <summary>
/// Remove DNS 'A' record for IP Address
/// </summary>
/// <param name="recordName">Dns Record Name</param>
/// <param name="nodeIPv4Address">IpNode Address.</param>
/// <param name="dnsIpAddress">DnsServer IpAddress.</param>
/// <param name="dnsZoneName">DnsServer Zone name</param>
void RemoveDnsARecord(string recordName, string nodeIPv4Address, string dnsIpAddress, string dnsZoneName)
Sample
Invoke-SwisVerb $swis IPAM.IPAddressManagement RemoveDnsARecord @("zzz.testZone.", "10.11.78.33", "10.199.7.83", "testZone")
/// <summary>
/// Creates 'A' record with associated PTR for zone
/// </summary>
/// <param name="recordName">Dns Record Name</param>
/// <param name="nodeIPv4Address">IpNode Address.</param>
/// <param name="dnsIpAddress">DnsServer IpAddress.</param>
/// <param name="dnsZoneName">DnsServer Zone name</param>
void AddDnsARecordWithPtr(string recordName, string nodeIPv4Address, string dnsIpAddress, string dnsZoneName)
Sample
Invoke-SwisVerb $swis IPAM.IPAddressManagement AddDnsARecordWithPtr @("QQQ.TestZone.", "10.11.78.25", "10.199.7.82", "TestZone")
/// <summary>
/// Crate PTR record to existing 'A' record
/// </summary>
/// <param name="recordName">Dns Record Name</param>
/// <param name="nodeIPv4Address">IpNode Address.</param>
/// <param name="dnsIpAddress">DnsServer IpAddress.</param>
/// <param name="dnsZoneName">DnsServer Zone name</param>
void AddPtrToDnsARecord(string recordName, string nodeIPv4Address, string dnsIpAddress, string dnsZoneName)
Sample
Invoke-SwisVerb $swis IPAM.IPAddressManagement AddPtrToDnsARecord @("EEEwithPTR", "10.11.78.28", "10.199.7.82", "TestZone")
Operation affects both IPAM and target DHCP server. When verb returns "Operation was successful" , operation is done on DHCP server side. If it fails, "Operation failed" returns.
/// <summary>
/// Create IP Address reservation on DHCP server
/// </summary>
/// <param name="ipAddressToReserve">IpNode Address</param>
/// <param name="dhcpServerIpAddress">DHCP Server Address</param>
/// <param name="reservationName">ClientName</param>
/// <param name="reservationMAC">Reservation MAC Address. MAC Address must follow this format: 00:00:00:00:00:00"</param>
/// <param name="reservationType">Dhcp Reservation Type. ReservationType values: "DhcpOnly", "BootpOnly", "Both". Default value is "DhcpOnly"</param>
/// <returns>Operation result: "Operation was successful" or "Operation failed"</returns>
string CreateIpReservation(string ipAddressToReserve, string dhcpServerIpAddress, string reservationName, string reservationMAC, string reservationType = "DhcpOnly")
Sample
Invoke-SwisVerb $swis IPAM.DhcpDnsManagement CreateIpReservation @("199.10.1.1","199.10.1.0","testName", "01:23:45:67:89:AB","DhcpOnly")
/// <summary>
/// Remove IP Address reservation from DHCP
/// </summary>
/// <param name="ipRemoveReservation">IpNode Address</param>
/// <param name="dhcpServerIpAddress">DHCP Server Address</param>
/// <returns>Operation result: "Operation was successful" or "Operation failed"</returns>
string RemoveIpReservation(string ipRemoveReservation, string dhcpServerIpAddress)
Sample
Invoke-SwisVerb $swis IPAM.DhcpdnsManagement RemoveIPReservation @("10.1.1.2", "10.199.1.150")
When there's no matching A/PTR record pairs - empty list will be returned. For finding of matching pairs we use query with INNER JOIN.
/// <summary>
/// Get A & PTR pair from a specific zone of the given DNS server.
/// </summary>
/// <param name="zoneName">DnsServer Zone name</param>
/// <param name="dnsServerIp">DnsServer address</param>
/// <returns>
/// List of APtrRecordsPair.
/// where APtrRecordPair is type like :
/// {
/// string ARecordName;
/// string ARecordData;
/// string PtrRecordName;
/// string PtrRecordData
/// }
/// </returns>
List<APtrRecordsPair> GetAandPTRrecordsForDnsZone(string zoneName, string dnsServerIp)
Sample
Invoke-SwisVerb $swis IPAM.DhcpdnsManagement GetAandPTRrecordsForDnsZone @("255.in-addr.arpa","10.199.7.82")
/// <summary>
/// Create new Custom Property (IPAM.AttrDefine entity)
/// </summary>
/// <param name="propertyName">New unique Property name</param>
/// <param name="description">Property Description</param>
/// <param name="maxStringLength">Property ValueDbType size 'nvarchar(maxStringLength)'</param>
/// <param name="attributeType">Property AttributeType. AttributeType values: "Text", "Url"</param>
/// <param name="linkTitle">Property LinkTitle. Available for AttributeType.URL</param>
/// <param name="addToIpAddress">Add to IP addresses. ('True' or 'False' )</param>
/// <param name="addToGroups">Add to groups, supernets, subnets, DHCP servers, scopes and DNS servers, zones. ('True' or 'False' )</param>
/// <returns>Operation result. True='Operation was successful', False='Operation failed'</returns>
bool AddCustomField(string propertyName, string description, int maxStringLength, string attributeType = "Text", string linkTitle = "", bool addToIpAddress = false, bool addToGroups = false)
Sample
Invoke-SwisVerb $swis IPAM.AttrDefine AddCustomProperty @('Custom_12','description',10,'Text','','false','false')
/// <summary>
/// Update Custom Property (IPAM.AttrDefine entity)
/// </summary>
/// <param name="propertyName">Property name to update</param>
/// <param name="description">Property Description</param>
/// <param name="maxStringLength">Property ValueDbType size 'nvarchar(maxStringLength)'</param>
/// <param name="linkTitle">Property LinkTitle. Available for AttributeType.URL</param>
/// <param name="addToIpAddress">Add to IP addresses. ('True' or 'False' )</param>
/// <param name="addToGroups">Add to groups, supernets, subnets, DHCP servers, scopes and DNS servers, zones. ('True' or 'False' )</param>
/// <returns>Operation result. True='Operation was successful', False='Operation failed'</returns>
bool UpdateCustomProperty(string propertyName, string description, int maxStringLength, string linkTitle, bool addToIpAddress, bool addToGroups)
Sample
Invoke-SwisVerb $swis IPAM.AttrDefine UpdateCustomProperty @('Custom_2','description',10,'','false','false')
/// <summary>
/// Resequence Custom Property (IPAM.AttrDefine entity)
/// </summary>
/// <param name="propertyName">Property name to Resequence</param>
/// <param name="moveUp">Resequence operation {Up or Down}. True=Up; False=Down</param>
/// <returns>Operation result. True='Operation was successful', False='Operation failed'</returns>
bool ResequenceCustomProperty(string propertyName, bool moveUp)
Sample
Invoke-SwisVerb $swis IPAM.AttrDefine ResequenceCustomProperty @('Custom_2','false')
/// <summary>
/// Delete Custom Property (IPAM.AttrDefine entity)
/// </summary>
/// <param name="propertyName">Property name to delete</param>
/// <returns>Operation result. True='Operation was successful', False='Operation failed'</returns>
bool DeleteCustomProperty(string propertyName)
Sample
Invoke-SwisVerb $swis IPAM.AttrDefine DeleteCustomProperty @('Custom_1')
Available properties for changing:
Property name | Type | Default value | Create required | Comment |
---|---|---|---|---|
SubnetId | int | [Non editable] | ||
ParentId | int | 0 | ||
Address | string | required | must not be blank | |
AddressMask | string | [Non editable] | ||
CIDR | int | required | For IpV4 Address CIDR must be greater than 21 and less than or equal to 32. must not be blank | |
FriendlyName | string | 'Address'/'CIDR' | must not be blank | |
Comments | string | undefined | ||
VLAN | string | undefined | ||
Location | string | undefined | ||
ScanInterval | int | 240 | ||
RetainUserData | bool | false | ||
NeighborScanInterval | int | 240 | ||
NeighborScanAddress | string | undefined | ||
DisableNeighborScanning | bool | false | ||
DisableAutoScanning | bool | false |
Sample
Delete: Remove-SwisObject $swis -Uri 'swis://localhost/Orion/IPAM.Subnet/SubnetId=106,ParentId=101'
Update: Set-SwisObject $swis -Uri 'swis://localhost/Orion/Orion/IPAM.Subnet/SubnetId=100,ParentId=2' -Properties @{VLAN='test';CIDR=22}
Create: New-SwisObject $swis -EntityType 'IPAM.Subnet' -Properties @{Address='10.199.252.1'; CIDR:24;}
Available properties:
Property name | Type | Default value | Create required | Comment |
---|---|---|---|---|
IpNodeId | int | [Non editable] | ||
SubnetId | int | required | [Non editable] | |
IPAddress | string | required | [Non editable] | |
IPMapped | string | undefined | must be undefined when Status is Available | |
Alias | string | undefined | must be undefined when Status is Available | |
MAC | string | undefined | must be undefined when Status is Available must be defined when DHCP Reservation is going to be created MAC Address must follow this format: '00:00:00:00:00:00' |
|
DnsBackward | string | undefined | must be undefined when Status is Available | |
DhcpClientName | string | undefined | must be undefined when Status is Available must be defined when DHCP Reservation is going to be created |
|
Comments | string | undefined | must be undefined when Status is Available | |
ResponseTime | int | undefined | ||
Status | string (IPNodeStatus) | "Available" | IPNodeStatus values: "Used", "Available", "Reserved", "Transient", "Blocked" | |
AllocPolicy | string (IPAllocPolicy) | undefined | IPAllocPolicy values: "Static", "Dynamic" | |
SkipScan | bool | false |
Sample
Delete: Remove-SwisObject $swis -Uri 'swis://localhost/Orion/IPAM.IPNode/IpNodeId=2'
Update: Set-SwisObject $swis -Uri 'swis://localhost/Orion/IPAM.IPNode/IpNodeId=2' -Properties @{ Alias = 'test1' }
Create: New-SwisObject $swis -EntityType 'IPAM.IPNode' -Properties @{ SubnetId=22; IPAddress='10.20.30.40' }
- About SWIS
- Connecting to SWIS
- SWQL Functions
- REST
- PowerShell
- Alerts
- Creating custom properties
- Poller Types
- Network Performance Monitor
- NetFlow Traffic Analyzer
- Network Configuration Manager
- IP Address Manager
- Server & Application Monitor
- Log Analyzer
- Schema reference