Example #1
0
 def setUp(self):
     self.url = 'http://localhost'
     self.tree = pyaci.Node(self.url).mit
Example #2
0
def main():
    """ Main function """

    global DATA

    # Parse options
    parser = argparse.ArgumentParser(description="""
    Check for double 0.0.0.0/0 and overlapping in external networks of 
    L3OUTs""")
    parser.add_argument('APIC_IP_List',
                        type=str,
                        help="A list of APIC IPs using the format:  " +
                        """'["1.1.1.1","2.2.2.2"]'""")
    parser.add_argument('-l',
                        '--loglevel',
                        help="Set loglevel. Currently implemented: " +
                        "'DEBUG', 'INFO' and 'ERROR'")
    parser.add_argument('-d',
                        '--disablewarnings',
                        help="Disable certificate warnings",
                        action="store_true")
    parser.add_argument('-u',
                        '--username',
                        help="Your username to connect to the APIC")
    parser.add_argument('-o',
                        '--outfile',
                        help="Path to outputfile in XLSX format")

    args = parser.parse_args()

    # If needed, set loglevel
    if args.loglevel:
        logging.basicConfig(level=getattr(logging, args.loglevel.upper(),
                                          'INFO'),
                            format="%(asctime)s %(levelname)s: %(message)s")
        logging.debug("{l} Mode enabled".format(l=args.loglevel.upper()))

    outfile = args.outfile

    # If needed, disable HTTPS warnings
    if args.disablewarnings:
        logging.info("Disabling URLLIB3 warnings")
        disable_warnings()
        logging.info("Disabling successfull")

    # Parse IP-List Argument
    logging.info("Parsing APIC_IP_LIST")
    ip_list = json.loads(args.APIC_IP_List)
    logging.info(
        "Parsing successfull, APIC_IP_LIST = {list}".format(list=ip_list))

    # Generate apicUrls
    generate_apic_urls(ip_list)

    # Connect to APIC
    logging.info("connecting to the APIC")

    for node_url in DATA:
        logging.info("creating Node-Object for {url}".format(url=node_url))
        DATA[node_url] = dict()
        DATA[node_url]["node"] = pyaci.Node(node_url)
        DATA[node_url]["relation"] = dict()

    logging.info("Nodes:\n{nodes}".format(nodes=pformat(DATA)))

    for node in DATA:
        logging.info(
            "Logging in to Node {node}".format(node=DATA[node]["node"]._url))
        password = getpass.getpass("Password for {url}".format(url=node))

        DATA[node]["node"].methods.Login(args.username, password).POST()

    logging.info("Nodes: {nodes}".format(nodes=DATA))

    # Get all Tenants
    get_tenant_names()

    # Get all VRFs
    get_vrfs()

    # get L3OUTs
    get_l3outs()

    # Get External Networks
    get_ENs()

    # Analyze Data
    analyze()

    # print summary
    summary()

    # write Excel-File
    if args.outfile:
        write_excel(args.outfile)

    return 0
Example #3
0
 def setUp(self):
     self.node = pyaci.Node('http://localhost')
     self.rfs = self.node.methods.RefreshSubscriptions('100001')
Example #4
0
 def setUp(self):
     self.resolve = pyaci.Node('http://localhost').methods.ResolveClass(
         'fvTenant')
Example #5
0
 def setUp(self):
     self.node = pyaci.Node('http://localhost')
     self.login = self.node.methods.Login('admin',
                                          'password',
                                          autoRefresh=True)
Example #6
0
 def setUp(self):
     self.login = pyaci.Node('http://localhost').methods.LoginRefresh()
Example #7
0
 def setUp(self):
     self.node = pyaci.Node('http://localhost')
     self.login = self.node.methods.Login('jsmith', 'secret')
     self.logout = self.node.methods.Logout('jsmith')
Example #8
0
 def setUp(self):
     self.login = pyaci.Node('http://localhost').methods.Login(
         'jsmith', 'secret')
Example #9
0
 def setUp(self):
     self.api = pyaci.Node(url)
     self.tree = self.api.mit