def main(url=None, cert=None): """My Main""" update = False poap_url = '/rest/poap/definitions' template_name = None params = None session = Session(url, LOGIN, PASSWORD, logging_lvl='INFO', verify=cert) session.login() for node in FABRIC: if node['tier'] is 'Spine': template_name = 'LF_Spine' params = POAP_SPINE_TMPL['templateDetails'][0]['templateParams'] elif node['tier'] is 'DatacenterCore': template_name = 'LF_DCCore' params = POAP_SPINE_DCI_TMPL['templateDetails'][0][ 'templateParams'] elif node['tier'] is 'BorderGateway': template_name = 'LF_BorderGateway' params = POAP_LEAF_DCI_TMPL['templateDetails'][0]['templateParams'] elif node['tier'] is 'Leaf' or node['tier'] is 'BorderLeaf': template_name = 'LF_Leaf' params = POAP_LEAF_TMPL['templateDetails'][0]['templateParams'] if params and template_name: poap = POAPDefinition(attributes=node, params=params, template_name=template_name) # print json.dumps(poap.definition, indent=4) if update: session.put(poap_url, json.dumps(poap.definition)) else: session.post(poap_url, json.dumps(poap.definition))
def main(url=None, cert=None): """My Main""" poap_url = '/rest/poap/definitions' template_name = None params = None session = Session(url, LOGIN, PASSWORD, logging_lvl='INFO', verify=cert) session.login() for node in FABRIC: if node['tier'] is 'Spine': template_name = 'IPFabric_N9K_Spine_10_2_1_ST_1_TAG' params = POAP_SPINE_TMPL['templateDetails'][0]['templateParams'] elif node['tier'] is 'DatacenterCore': template_name = 'IPFabric_N9K_Spine_10_2_1_ST_1_TAG_DCI' params = POAP_SPINE_DCI_TMPL['templateDetails'][0]['templateParams'] elif node['tier'] is 'BorderGateway': template_name = 'IPFabric_N9K_Leaf_10_2_1_ST_1_TAG_DCI' params = POAP_LEAF_DCI_TMPL['templateDetails'][0]['templateParams'] elif node['tier'] is 'Leaf' or node['tier'] is 'BorderLeaf': template_name = 'IPFabric_N9K_Leaf_10_2_1_ST_1_TAG' params = POAP_LEAF_TMPL['templateDetails'][0]['templateParams'] if params and template_name: poap = POAPDefinition(attributes=node, params=params, template_name=template_name) resp = session.post(poap_url, json.dumps(poap.definition)) logging.info('HTTP POST response %s' % resp)
def main(url=None, cert=None): """My Main""" session = Session(url, LOGIN, PASSWORD, logging_lvl='INFO', verify=cert) session.login() special_keys = ["vrfTemplateConfig", "networkTemplateConfig"] ipv4_base = u'1.0.0.1' ipv6_base = u'c5c0::1' fabrics = ['3', '4'] overlay = { "fabric": "Fab2", "vrfExtensionTemplate": "Default_VRF_Extension", "vrfId": "30001", "vrfName": "OVERLAY1", "vrfTemplate": "Default_VRF", "vrfTemplateConfig": { "asn": "65502", "nveId": 1, "vrfName": "OVERLAY1", "vrfSegmentId": "30001", "vrfVlanId": 2 } } for fabric in fabrics: mcast_grp = '239.255.25' + fabric + '.0' for network_id in range(101, 106): network_params = { "fabric": 'Fab' + str(fabric), "networkExtensionTemplate": "Default_Network_Extension", "networkId": "20" + str(network_id), "networkName": "Network" + str(network_id), "networkTemplate": "Default_Network", "networkTemplateConfig": { "dhcpServerAddr1": "", "enableIR": False, "gatewayIpAddress": str(ipaddress.IPv4Address(ipv4_base) + 65536 * network_id) + '/22', "gatewayIpV6Address": str(ipaddress.IPv6Address(ipv6_base) + int(math.pow(256, 12)) * network_id) + '/64', "intfDescription": "", "isLayer2Only": False, "mcastGroup": mcast_grp, "mtu": "", "networkName": "Network" + str(network_id), "nveId": 1, "segmentId": "20" + str(network_id), "suppressArp": False, "vlanId": network_id, "vrfDhcp": "", "vrfName": "OVERLAY1" }, "vrf": "OVERLAY1" } network_params['networkTemplateConfig'] = json.dumps(network_params['networkTemplateConfig']) url = '/rest/top-down/fabrics/%s/networks' % ('Fab' + str(fabric)) resp = session.post(url, json.dumps(network_params)) if not resp.ok: print json.dumps(json.loads(resp.content), indent=4) logging.info('HTTP POST response %s' % resp)
def main(): session = Session(URL, LOGIN, PASSWORD) session.login() test = Org('sample-org') session.post(test.get_url(), test.get_json()) p1 = Partition('sample', test) session.post(p1.get_url(), p1.get_json()) n1 = Network('net1', p1) n1.segmentId = 333 n1.vlanId = n1.segmentId session.post(n1.get_url(), n1.get_json())