def main(): """ Main execution routine :return: None """ creds = Credentials('apic') creds.add_argument('--tenant', help='The name of Tenant') creds.add_argument('--app', help='The name of ApplicationProfile') creds.add_argument('--bd', help='The name of BridgeDomain') creds.add_argument('--epg', help='The name of EPG') creds.add_argument('--json', const='false', nargs='?', help='Json output only') args = creds.get() session = Session(args.url, args.login, args.password) session.login() tenant = Tenant(args.tenant) app = AppProfile(args.app, tenant) bd = BridgeDomain(args.bd, tenant) epg = EPG(args.epg, app) epg.add_bd(bd) if args.json: print(tenant.get_json()) else: resp = session.push_to_apic(tenant.get_url(), tenant.get_json()) if not resp.ok: print('%% Error: Could not push configuration to APIC') print(resp.text)
second_epg.add_bd(bd) # Create the physical interface objects representing the physical ethernet ports first_intf = Interface('eth', '1', '101', '1', '17') second_intf = Interface('eth', '1', '102', '1', '17') # Create a VLAN interface and attach to each physical interface first_vlan_intf = L2Interface('vlan5-on-eth1-101-1-17', 'vlan', '5') first_vlan_intf.attach(first_intf) second_vlan_intf = L2Interface('vlan5-on-eth1-102-1-17', 'vlan', '5') second_vlan_intf.attach(second_intf) # Attach the EPGs to the VLAN interfaces first_epg.attach(first_vlan_intf) second_epg.attach(second_vlan_intf) # Push the tenant configuration to the APIC resp = session.push_to_apic(tenant.get_url(), tenant.get_json()) if not resp.ok: print('%% Error: Could not push the tenant configuration to APIC') # Push the interface attachments to the APIC resp = first_intf.push_to_apic(session) if not resp.ok: print('%% Error: Could not push interface configuration to APIC') resp = second_intf.push_to_apic(session) if not resp.ok: print('%% Error: Could not push interface configuration to APIC')