-
Notifications
You must be signed in to change notification settings - Fork 1
/
autoprovisioncycle.py
executable file
·70 lines (49 loc) · 2.32 KB
/
autoprovisioncycle.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/python3
#import logging
#logging.basicConfig(level=logging.DEBUG)
from infoblox_client import connector
#from infoblox_client.connector import Connector
#from infoblox_client.exceptions import InfobloxException
#try:
# from infoblox_client.connector import Connector
# from infoblox_client.exceptions import InfobloxException
# HAS_INFOBLOX_CLIENT = True
#except Import Error:
# HAS_INFOBLOX_CLIENT = False
# WAPI 2.2.2 minimum requirement - NIOS 7.2
nios_provider_spec = {
'host': dict(),
'username': dict(),
'password': dict(no_log=True),
'ssl_verify': dict(type='bool', default=False),
'silent_ssl_warnings': dict(type='bool', default=True),
'http_request_timeout': dict(type='int', default=10),
'http_pool_connections': dict(type='int', default=10),
'http_pool_maxsize': dict(type='int', default=10),
'max_retries': dict(type='int', default=3),
'wapi_version': dict(default='2.7.1'),
'max_results': dict(type='int', default=1000)
}
host = "10.60.27.4"
username = "admin"
password = "infoblox"
wapi_version = "2.7.1"
membername = "testpreprov1.blairlab"
memberip = "10.60.27.21"
membernetmask = "255.255.255.0"
membergateway = "10.60.27.1"
opts = {'host': host, 'username': username, 'password': password, 'wapi_version': wapi_version, 'ssl_verify': False, 'silent_ssl_warnings': True}
conn = connector.Connector(opts)
#networks = conn.get_object('network')
#print(networks)
createpayload = {"host_name": membername, "vip_setting": {"_struct":"setting:network","address": memberip, "gateway": membergateway, "subnet_mask": membernetmask}, "platform": "VNIOS"}
newmember = conn.create_object('member', createpayload)
print(newmember)
updatepayload = {"host_name": membername, "vip_setting": {"_struct":"setting:network","address": memberip, "gateway": membergateway, "subnet_mask": membernetmask}, "pre_provisioning": {"_struct": "preprovision", "hardware_info": [{"_struct": "preprovisionhardware", "hwmodel": "IB-VM-820", "hwtype": "IB-VNIOS"}], "licenses": ["dhcp", "dns", "enterprise", "vnios"]}}
preprov = conn.update_object(newmember, updatepayload)
print(preprov)
#funccall = newmember + "?_function=create_token"
gettoken = conn.call_func("create_token", newmember, "")
print(gettoken["pnode_tokens"][0]["token"])
deletemember = conn.delete_object(newmember)
print(deletemember)