コード例 #1
0
    def test_preexisting_endpoints_consume_imported_contract(self):
        self.setup_export_contract()
        self.consume_exported_contract()

        session2 = self._login_session(SITE2_URL, SITE2_LOGIN, SITE2_PASSWORD)

        tenant = Tenant('multisite')
        app = AppProfile('my-demo-app', tenant)
        new_epg_name = 'another-epg'
        web_epg = EPG(new_epg_name, app)

        # Create the Endpoint
        mac = '00:77:55:44:33:22'
        ip = '8.3.2.1'
        ep = Endpoint(mac, web_epg)
        ep.mac = mac
        ep.ip = ip

        intf = Interface('eth', '1', '101', '1', '38')
        # Create a VLAN interface and attach to the physical interface
        vlan_intf = L2Interface('vlan-5', 'vlan', '5')
        vlan_intf.attach(intf)
        # Attach the EPG to the VLAN interface
        web_epg.attach(vlan_intf)
        # Assign Endpoint to the L2Interface
        ep.attach(vlan_intf)

        resp = tenant.push_to_apic(session2)
        self.assertTrue(resp.ok)

        self.consume_exported_contract(epg_name=new_epg_name)

        tenants = Tenant.get_deep(session2, names=['multisite'])
        multisite_tenant = tenants[0]
        app = multisite_tenant.get_child(AppProfile, 'my-demo-app')
        self.assertIsNotNone(app)
        epg = app.get_child(EPG, new_epg_name)
        self.assertIsNotNone(epg)
        multisite_ep = epg.get_child(Endpoint, mac)
        self.assertIsNotNone(multisite_ep)

        session1 = self._login_session(SITE1_URL, SITE1_LOGIN, SITE1_PASSWORD)
        self._assert_l3extsubnet_exists(session1,
                                        tenant_name='multisite',
                                        mac=mac,
                                        ip=ip)

        self.unconsume_exported_contract(new_epg_name)
        time.sleep(2)

        self._assert_l3extsubnet_does_not_exist(session1,
                                                tenant_name='multisite',
                                                mac=mac,
                                                ip=ip)
        web_epg.mark_as_deleted()
        tenant.push_to_apic(session2)

        time.sleep(1)

        self.teardown_export_contract()
コード例 #2
0
    def test_preexisting_endpoints_consume_imported_contract(self):
        self.setup_export_contract()
        self.consume_exported_contract()

        session2 = self._login_session(SITE2_URL, SITE2_LOGIN, SITE2_PASSWORD)

        tenant = Tenant('multisite')
        app = AppProfile('my-demo-app', tenant)
        new_epg_name = 'another-epg'
        web_epg = EPG(new_epg_name, app)

        # Create the Endpoint
        mac = '00:77:55:44:33:22'
        ip = '8.3.2.1'
        ep = Endpoint(mac, web_epg)
        ep.mac = mac
        ep.ip = ip

        intf = Interface('eth', '1', '101', '1', '38')
        # Create a VLAN interface and attach to the physical interface
        vlan_intf = L2Interface('vlan-5', 'vlan', '5')
        vlan_intf.attach(intf)
        # Attach the EPG to the VLAN interface
        web_epg.attach(vlan_intf)
        # Assign Endpoint to the L2Interface
        ep.attach(vlan_intf)

        resp = tenant.push_to_apic(session2)
        self.assertTrue(resp.ok)

        self.consume_exported_contract(epg_name=new_epg_name)

        tenants = Tenant.get_deep(session2, names=['multisite'])
        multisite_tenant = tenants[0]
        app = multisite_tenant.get_child(AppProfile, 'my-demo-app')
        self.assertIsNotNone(app)
        epg = app.get_child(EPG, new_epg_name)
        self.assertIsNotNone(epg)
        multisite_ep = epg.get_child(Endpoint, mac)
        self.assertIsNotNone(multisite_ep)

        session1 = self._login_session(SITE1_URL, SITE1_LOGIN, SITE1_PASSWORD)
        self._assert_l3extsubnet_exists(session1,
                                        tenant_name='multisite',
                                        mac=mac,
                                        ip=ip)

        self.unconsume_exported_contract(new_epg_name)
        time.sleep(2)

        self._assert_l3extsubnet_does_not_exist(session1,
                                                tenant_name='multisite',
                                                mac=mac,
                                                ip=ip)
        web_epg.mark_as_deleted()
        tenant.push_to_apic(session2)

        time.sleep(1)

        self.teardown_export_contract()
コード例 #3
0
def del_epg(tenant_name, ap_name, epg_name, bd_name):
    session = Session(config_data.get('url'), config_data.get('login'), config_data.get('password'))
    resp = session.login()
    if not resp.ok:
        print('%% Could not login to APIC')

    tenant = Tenant(tenant_name)
    ap = AppProfile(ap_name, tenant)
    bd = BridgeDomain(bd_name, tenant)
    epg = EPG(epg_name, ap)
    epg.mark_as_deleted()
    resp = tenant.push_to_apic(session)

    if not resp.ok:
        print('%% Error: Could not push configuration to APIC')
        print(resp.text)