Client for interacting with Tcpwave's IPAM
Project description
TCPWave's IPAM Client
Python client for communication with Tcpwave's IPAM.
Pre-requisites ############## Basic Authentication is not supported. Only certificates based authentication is supported. So client must have a proper certificate and these certificates must be added to IPAM.\
Certificate files required:
- client certificate.
- client key.
Supported Operations #################### Following operations are supported:
- Create/list/detail/delete Network
- Create/list/detail/delete Subnet
- Fetches Next Available IP in the Subnet
- Create/delete IP Object
Installing library ################## Run below command from python virtual environment::
pip install tcpwave-client
Sample Examples ###############
Create Network
Below is a complete program showing the use of this library.
This example shows how to create network in IPAM using this library::
from client.networks import NetworkManager
from client.exceptions import APICallFailedException
import json
def create_network():
"""
Create test network
:return:
"""
try:
nw_create_payload = {
'network_address': '153.168.0.0/16',
'name': 'Test Network 3',
'organization_name': 'Tcpwave',
'provider': provider
}
rsp = NetworkManager.create_network(network=json.dumps(nw_create_payload))
print(str(rsp))
except APICallFailedException as ex:
print(ex.msg)
if __name__ == "__main__":
provider = {
'cert': '/path/to/cert/client.crt',
'key': '/path/to/key/client.key',
'host': '192.168.0.116'
}
create_network()
List Network
This snippet shows only the complete payload required for thr API call to work for listing all networks::
def networks_list():
"""
List all networks
:return:
"""
try:
list_payload = {
'provider': {
'cert': '/path/to/client.crt',
'key': '/path/to/client.key',
'host': '192.168.0.116'
}
}
rsp = NetworkManager.list_all_networks(network=json.dumps(list_payload))
print("Networks Count : " + str(len(rsp)))
for i in range(0, len(rsp)):
print(str(rsp[i]))
except APICallFailedException as ex:
print(ex.msg)
Delete Network
This example shows the deletion of a network::
def test_network_delete():
"""
Deletes given network
:return:
"""
try:
nw_create_payload = {
'address': '153.168.0.0/16',
'organization_name': 'Tcpwave',
'provider': {
'cert': '/path/to/client.crt',
'key': '/path/to/client.key',
'host': '192.168.0.116'
}
}
rsp = NetworkManager.delete_network(network=json.dumps(nw_create_payload))
print(str(rsp))
except APICallFailedException as ex:
print(ex.msg)
Create Subnet
This example shows creation of a subnet::
def subnet_create():
"""
Creates test subnet
:return:
"""
try:
subnet_payload = {
'provider': {
'cert': '/path/to/client.crt',
'key': '/path/to/client.key',
'host': '192.168.0.116'
},
'organization_name': 'Tcpwave',
'name': 'Test Subnet 1',
'router_address': '153.168.0.1',
'network_address': '153.168.0.0/16',
'primary_domain': 'test.tcpwave.com'
}
rsp = NetworkManager.create_subnet(subnet=json.dumps(subnet_payload))
print(str(rsp))
except APICallFailedException as ex:
print(ex.msg)
Next Free IP
This fetch the next free IP::
def next_available_ip():
"""
Fetches next available ip
:return:
"""
try:
subnet_payload = {
'provider': {
'cert': '/path/to/client.crt',
'key': '/path/to/client.key',
'host': '192.168.0.116'
},
'organization_name': 'Tcpwave',
'subnet_address': '153.168.0.0/16'
}
rsp = NetworkManager.get_next_available_ip(subnet=json.dumps(subnet_payload))
print('Next available IP : ', str(rsp))
return str(rsp)
except APICallFailedException as ex:
print(ex.msg)
Creates IP Object
This example shows creating an object.::
def create_object():
"""
Creates IP Object
:return:
"""
try:
ip_payload = {
'provider': {
'cert': '/path/to/client.crt',
'key': '/path/to/client.key',
'host': '192.168.0.116'
},
'organization_name': 'Tcpwave',
'subnet_address': '153.168.0.0/16',
'ip_address': '153.168.0.5',
'name': 'tst obj 1',
'domain_name': 'test.tcpwave.com'
}
rsp = NetworkManager.create_ip(ip_payload=json.dumps(ip_payload))
print(str(rsp))
except APICallFailedException as ex:
print(ex.msg)
Deletes Object
This example shows deletion of an object::
def delete_object(ip):
"""
Releases the ip
:return:
"""
try:
ip_payload = {
'provider': {
'cert': '/path/to/client.crt',
'key': '/path/to/client.key',
'host': '192.168.0.116'
},
'organization_name': 'Tcpwave',
'ip_address': ip
}
rsp = NetworkManager.release_ip(ip_payload=json.dumps(ip_payload))
print(str(rsp))
except APICallFailedException as ex:
print(ex.msg)
1.0.2 (2020-04-15)
- packaging restructure
- imports reordering for bug fix
1.0.1 (2020-04-15)
- Updated README.rst with usage examples
1.0.0 (2020-04-15)
- code cleanup
0.0.1 (2020-04-15)
- Added connector to send API requests to Tcpwave's IPAM
- First release on PyPI.
- Supports operation as follows:
- Create/list/detail/delete Network
- Create/list/detail/delete Subnet
- Fetches Next Available IP in the Subnet
- Create/delete IP Object
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tcpwave-client-1.0.2.tar.gz.
File metadata
- Download URL: tcpwave-client-1.0.2.tar.gz
- Upload date:
- Size: 13.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
017f6e76b65d0e5b70e39df0376d5e50ae31583d2d4ca26f6d84fdaadf1c3110
|
|
| MD5 |
12f9dcb2c855b8c14e5c4bcf6be389af
|
|
| BLAKE2b-256 |
6b542b77e29670c3b05316b31699684fdb96d734777cc5103e7ddd0185e6ae0c
|
File details
Details for the file tcpwave_client-1.0.2-py3.7.egg.
File metadata
- Download URL: tcpwave_client-1.0.2-py3.7.egg
- Upload date:
- Size: 14.0 kB
- Tags: Egg
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0a4c2ec04d85e0b0ee9922a5f857bcae9fd508a9c9c507a98efd1b9992661135
|
|
| MD5 |
ca928407261a6aceac8225ba51460285
|
|
| BLAKE2b-256 |
a99d486de0dced31376a6ab0acbb2ebbabb664fd84e67a238c14ccfbd1f1ff0e
|