Example #1
0
def main():
    session = Session(URL, LOGIN, PASSWORD)
    session.login()
    vteps = VTEP.get(session)

    template = "{0:8} {1:10} {2:15} {3:15} {4:15}"
    for v in vteps:
        data = []
        vnis = v.get_vnis(session)
        print "NVE VNI's for switch %s" % vnis[0].switchname
        print "=" * 80
        print ""
        template = "{0:10} {1:10} {2:10} {3:20} {4:10} {5:10} {6:10}"
        print(
            template.format("Interface", 'Status', "VNI", "Multicast-Group",
                            "Vlan", "SwitchID", "Peers"))
        print(
            template.format("-" * 10, "-" * 10, "-" * 10, "-" * 20, "-" * 10,
                            "-" * 10, "-" * 10))

        for v in vnis:
            data.append((v.nve, v.status, v.vni, v.mcast, v.Vlan, v.switchid,
                         v.peers(session)))

        for rec in data:
            print(template.format(*rec))

        print ""
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)
Example #3
0
def create_network(data):
    session = Session(URL, LOGIN, PASSWORD)
    session.login()

    # create org
    print 'Creating org %s' % data['name']
    org = Org(data['name'])
    org.save(session)


    # create partitions
    for partition in data['partitions']:
        print 'Creating paritition %s' % partition['name']
        part = Partition(partition['name'], org)
        part.save(session)
        for network in partition['networks']:
            print 'Creating Network %s' % network['name']
            num = network['segment']
            gw = '{0}.{0}.{0}.1/24'.format(num)
            vni = '{0}{0}'.format(num)
            vlan = '2{}'.format(num)
            n = Network('net{}'.format(num), part)
            n.set_gateway(gw)
            n.segmentId = vni
            n.vlanId = vlan
            n.save(session)
Example #4
0
def create_network(data):
    session = Session(URL, LOGIN, PASSWORD)
    session.login()

    # create org
    print 'Creating org %s' % data['name']
    org = Org(data['name'])
    org.save(session)

    # create partitions
    for partition in data['partitions']:
        print 'Creating paritition %s' % partition['name']
        part = Partition(partition['name'], org)
        part.save(session)
        for network in partition['networks']:
            print 'Creating Network %s' % network['name']
            num = network['segment']
            gw = '{0}.{0}.{0}.1/24'.format(num)
            vni = '{0}{0}'.format(num)
            vlan = '2{}'.format(num)
            n = Network('net{}'.format(num), part)
            n.set_gateway(gw)
            n.segmentId = vni
            n.vlanId = vlan
            n.save(session)
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(url=None, cert=None):
    """My Main"""
    session = Session(url, LOGIN, PASSWORD, logging_lvl='INFO', verify=cert)
    session.login()

    kaboom = yes_no('Do you want to write erase the fabric: ')

    if kaboom:
        for switch in FABRIC:
            print 'Write Erase / Reload %s' % switch["serialNumber"]
            del_switch(session, switch["serialNumber"])
def main():
    session = Session(URL, LOGIN, PASSWORD)
    session.login()
    vteps = VTEP.get(session)
    data = []
    for v in vteps:
        data.append((v.switchid, v.ip, v.nve))
    template = "{0:19} {1:20} {2:15}"
    print(template.format("switchId", "ip", "NVE"))
    print(template.format("------", "-----------", "---"))
    for rec in data:
        print(template.format(*rec))
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())
def main(url=None, cert=None):
    """My Main"""
    session = Session(url, LOGIN, PASSWORD, logging_lvl='INFO', verify=cert)
    session.login()

    save_objs_details_to_file(LANFabric.get(session), 'VXLAN_EVPN_Fabric/json/LANFabric.json')
    save_objs_details_to_file(SwitchDetails.get(session), 'VXLAN_EVPN_Fabric/json/SwitchDefinition.json')
    save_objs_details_to_file(TemplateDetails.get(session), 'VXLAN_EVPN_Fabric/json/PoapTemplateLeaf.json')

    fabric_elements = ['BorderLeaf', 'DatacenterCore', 'Spine', 'Leaf', 'BorderGateway']

    for switch_definitions in fabric_elements:
        dict_to_csv(FABRIC[switch_definitions], 'VXLAN_EVPN_Fabric/csv/' + switch_definitions + '.csv')
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"""
    session = Session(url, LOGIN, PASSWORD, logging_lvl='INFO', verify=cert)
    session.login()

    # build_vrf(session, "Fab2", 65502)
    # build_vrf(session, "Fab3", 65503)
    # build_vrf(session, "Fab4", 65504)
    # build_networks(session, "Fab2", 'OVERLAY1', '101-300', 101-300', "239.255.252.1")
    # build_networks(session, "Fab3", 'OVERLAY1', '101-300', 101-300', "239.255.253.1")
    # build_networks(session, "Fab4", 'OVERLAY1', '101-300', 101-300', "239.255.254.1")
    attach_and_deploy(session, "Fab3", '101-132', topology='all', deployment=True)
    attach_and_deploy(session, "Fab4", '101-132', topology='all', deployment=True)
    attach_and_deploy(session, "Fab3", '133-250', topology='vpc', deployment=True)
    attach_and_deploy(session, "Fab4", '251-300', topology='vpc', deployment=True)
def main():
    session = Session(URL, LOGIN, PASSWORD)
    session.login()

    test = Org('sample-org')
    session.push_to_dcnm(test.get_url(), test.get_json())

    p1 = Partition('sample', test)
    session.push_to_dcnm(p1.get_url(), p1.get_json())
    n1 = Network('net1', p1)
    n1.segmentId = 333
    n1.vlanId = n1.segmentId
    session.push_to_dcnm(n1.get_url(), n1.get_json())
Example #13
0
def main(url=None, cert=None):
    """My Main"""
    session = Session(url, LOGIN, PASSWORD, logging_lvl='INFO', verify=cert)
    session.login()

    save_objs_details_to_file(LANFabric.get(session), 'json/LANFabric.json')
    save_objs_details_to_file(Switch.get(session),
                              'json/SwitchDefinition.json')
    save_objs_details_to_file(Template.get(session),
                              'json/PoapTemplateLeaf.json')

    tiers = ['BorderLeaf', 'DatacenterCore', 'Spine', 'Leaf', 'BorderGateway']

    for tier in tiers:
        found_tiers = filter(lambda attribute: attribute['tier'] == tier,
                             FABRIC)
        dict_to_csv(found_tiers, 'csv/' + tier + '.csv')
Example #14
0
def main(url=None, cert=None):
    """My Main"""
    session = Session(url, LOGIN, PASSWORD, logging_lvl='INFO', verify=cert)
    session.login()

    topology = Topology.get(session)
    node_list = topology.__getattribute__('sw_attributes')['nodeList']

    for node in FABRIC:
        found_switch = filter(
            lambda attribute: attribute['displayName'] == node['switchName'],
            node_list)
        if found_switch:
            switch_id = found_switch[0]['id']
            url = '/fm/fmrest/topology/role/%s?newRole=%s' % (switch_id,
                                                              node['role'])
            resp = session.put(url, None)
            logging.info('HTTP POST response %s' % resp)
            logging.debug('%s(%s)--role-->%s' %
                          (node['switchName'], switch_id, node['role']))
Example #15
0
def main():
    session = Session(URL, LOGIN, PASSWORD)
    session.login()
    vteps = VTEP.get(session)

    template = "{0:8} {1:10} {2:15} {3:15} {4:15}"
    for v in vteps:
        data = []
        vnis = v.get_vnis(session)
        print "NVE VNI's for switch %s" % vnis[0].switchname
        print "=" * 80
        print ""
        template = "{0:10} {1:10} {2:10} {3:20} {4:10} {5:10} {6:10}"
        print(template.format("Interface", 'Status', "VNI", "Multicast-Group", "Vlan", "SwitchID","Peers"))
        print(template.format("-" * 10, "-" * 10, "-"* 10, "-" * 20, "-" * 10, "-" * 10, "-" * 10))

        for v in vnis:
            data.append((v.nve, v.status, v.vni, v.mcast, v.Vlan, v.switchid, v.peers(session)))

        for rec in data:
            print(template.format(*rec))

        print ""
def main(url=None, cert=None):
    """My Main"""
    poap_url = '/rest/poap/definitions'
    session = Session(url, LOGIN, PASSWORD, logging_lvl='INFO', verify=cert)
    session.login()

    fabric_elements = ['BorderLeaf', 'DatacenterCore', 'Spine', 'Leaf', 'BorderGateway']

    for switch_definitions in fabric_elements:
        for definitions in FABRIC[switch_definitions]:
            if switch_definitions is 'Spine' or switch_definitions is 'DatacenterCore':
                template_name = 'IPFabric_N9K_Spine_10_2_1_ST_1_TAG'
                template_params = POAP_SPINE_TMPL['templateDetails'][0]['templateParams']
            else:
                template_name = 'IPFabric_N9K_Leaf_10_2_1_ST_1_TAG'
                template_params = POAP_LEAF_TMPL['templateDetails'][0]['templateParams']

            switch_details = SwitchDetails(definitions=definitions)
            template_params = TemplateDetails(template_params=template_params, definitions=definitions)
            body = build_poap_def(switch_details.get_details(), template_name, template_params.get_details())
            resp = session.push_to_dcnm(poap_url, json.dumps(body))

            logging.info('HTTP POST response %s' % resp)
Example #17
0
def delete_network(data):
    session = Session(URL, LOGIN, PASSWORD)
    session.login()

    # create org

    org = Org(data['name'])

    # create partitions
    for partition in data['partitions']:

        part = Partition(partition['name'], org)
        part.save(session)
        for network in partition['networks']:
            print 'Deleting Network %s' % network['name']
            num = network['segment']
            vni = '{0}{0}'.format(num)
            n = Network('net{}'.format(num), part)
            n.segmentId = vni
            n.delete(session)
        print 'Deleting paritition %s' % partition['name']
        part.delete(session)
    print 'Deleting org %s' % data['name']
    org.delete(session)
Example #18
0
def delete_network(data):
    session = Session(URL, LOGIN, PASSWORD)
    session.login()

    # create org

    org = Org(data['name'])

    # create partitions
    for partition in data['partitions']:

        part = Partition(partition['name'], org)
        part.save(session)
        for network in partition['networks']:
            print 'Deleting Network %s' % network['name']
            num = network['segment']
            vni = '{0}{0}'.format(num)
            n = Network('net{}'.format(num), part)
            n.segmentId = vni
            n.delete(session)
        print 'Deleting paritition %s' % partition['name']
        part.delete(session)
    print 'Deleting org %s' % data['name']
    org.delete(session)
Example #19
0
 def session(self):
     session = Session(URL, LOGIN, PASSWORD)
     res = session.login()
     return session
Example #20
0
 def session(self):
     session = Session(URL, LOGIN, PASSWORD)
     res = session.login()
     return session
def main(url=None, cert=None):
    """My Main"""
    session = Session(url, LOGIN, PASSWORD, logging_lvl='INFO', verify=cert)
    session.login()

    add_fab_ext(session)