66import unittest
77import os
88import sys
9-
9+ from aci_multisite_config_test import setup_multisite_test
1010try :
1111 from multisite_credentials import *
1212except ImportError :
@@ -59,15 +59,11 @@ def setup_site(self, url, site1_local=True):
5959 driver .get (url )
6060 assert 'ACI Multisite' in driver .title
6161
62-
6362 driver .find_element_by_link_text ('Site Credentials' ).click ()
6463 assert 'Site Credentials' in driver .title
6564
66-
6765 driver .find_element_by_link_text ('Create' ).click ()
6866
69-
70-
7167 # Enter the Site 1 credentials
7268 typing = [('site_name' , 'Site1' ),
7369 ('ip_address' , SITE1_IP ),
@@ -80,14 +76,10 @@ def setup_site(self, url, site1_local=True):
8076 input_elem = driver .find_element_by_id ('local' )
8177 input_elem .click ()
8278
83-
84-
8579 # Save the credentials
8680 input_elem = driver .find_element_by_name ('_add_another' )
8781 input_elem .click ()
8882
89-
90-
9183 # Enter the Site 2 credentials
9284 typing = [('site_name' , 'Site2' ),
9385 ('ip_address' , SITE2_IP ),
@@ -100,14 +92,10 @@ def setup_site(self, url, site1_local=True):
10092 input_elem = driver .find_element_by_id ('local' )
10193 input_elem .click ()
10294
103-
104-
10595 # Save the credentials
10696 input_elem = driver .find_element_by_name ('_add_another' )
10797 input_elem .click ()
10898
109-
110-
11199 # Finished, click Cancel
112100 input_elem = driver .find_element_by_link_text ('Cancel' )
113101 input_elem .click ()
@@ -122,8 +110,8 @@ def test_02_site2(self):
122110
123111 def test_03_export_contract (self ):
124112 driver = self .__class__ .driver
125- # Switch to the second site tool
126- driver .get ('http://127.0.0.1:5001 ' )
113+ # Switch to the site 1 tool
114+ driver .get ('http://127.0.0.1:5000 ' )
127115
128116 # Click on Site Contracts
129117 driver .find_element_by_link_text ('Site Contracts' ).click ()
@@ -145,19 +133,18 @@ def test_03_export_contract(self):
145133 # Export the contract
146134 driver .find_element_by_id ('submit' ).click ()
147135
136+ time .sleep (1 )
148137 # Verify that the export to the other APIC was successful
149- session = Session (SITE1_URL , SITE1_LOGIN , SITE1_PASSWORD )
138+ session = Session (SITE2_URL , SITE2_LOGIN , SITE2_PASSWORD )
150139 resp = session .login ()
151140 self .assertTrue (resp .ok )
152141 tenants = Tenant .get_deep (session , names = ['multisite' ], limit_to = ['fvTenant' , 'vzBrCP' ])
153142 self .assertTrue (len (tenants ) > 0 )
154143 multisite_tenant = tenants [0 ]
155- self .assertIsNotNone (multisite_tenant .get_child (Contract , 'Site2 :mysql-contract' ))
144+ self .assertIsNotNone (multisite_tenant .get_child (Contract , 'Site1 :mysql-contract' ))
156145
157146 def test_04_consume_exported_contract (self ):
158- time .sleep (1 )
159-
160- session = Session (SITE1_URL , SITE1_LOGIN , SITE1_PASSWORD )
147+ session = Session (SITE2_URL , SITE2_LOGIN , SITE2_PASSWORD )
161148 resp = session .login ()
162149 self .assertTrue (resp .ok )
163150
@@ -167,7 +154,7 @@ def test_04_consume_exported_contract(self):
167154 app = AppProfile ('my-demo-app' , tenant )
168155 # Create the EPGs
169156 web_epg = EPG ('web-frontend' , app )
170- contract = Contract ('Site2 :mysql-contract' , tenant )
157+ contract = Contract ('Site1 :mysql-contract' , tenant )
171158 web_epg .consume (contract )
172159 tenant .push_to_apic (session )
173160
@@ -180,12 +167,12 @@ def test_04_consume_exported_contract(self):
180167 self .assertIsNotNone (app )
181168 epg = app .get_child (EPG , 'web-frontend' )
182169 self .assertIsNotNone (epg )
183- contract = multisite_tenant .get_child (Contract , 'Site2 :mysql-contract' )
170+ contract = multisite_tenant .get_child (Contract , 'Site1 :mysql-contract' )
184171 self .assertIsNotNone (contract )
185172 self .assertTrue (epg .does_consume (contract ))
186173
187174 def test_05_add_consuming_static_endpoint (self ):
188- session = Session (SITE1_URL , SITE1_LOGIN , SITE1_PASSWORD )
175+ session = Session (SITE2_URL , SITE2_LOGIN , SITE2_PASSWORD )
189176 resp = session .login ()
190177 self .assertTrue (resp .ok )
191178
@@ -220,39 +207,52 @@ def test_05_add_consuming_static_endpoint(self):
220207 ep = epg .get_child (Endpoint , '00:33:33:33:33:33' )
221208 self .assertIsNotNone (ep )
222209
223- @classmethod
224- def tearDownClass (cls ):
225- driver = cls .driver
226- driver .get ('http://127.0.0.1:5000/shutdown' )
227- driver .get ('http://127.0.0.1:5001/shutdown' )
228- driver .close ()
210+ def test_06_add_providing_static_endpoint (self ):
211+ session = Session (SITE1_URL , SITE1_LOGIN , SITE1_PASSWORD )
212+ resp = session .login ()
213+ self .assertTrue (resp .ok )
229214
215+ tenant = Tenant ('multisite' )
216+ app = AppProfile ('my-demo-app' , tenant )
217+ web_epg = EPG ('database-backend' , app )
230218
219+ # Create the Endpoint
220+ ep = Endpoint ('00:44:44:44:44:44' , web_epg )
221+ ep .mac = '00:44:44:44:44:44'
222+ ep .ip = '7.8.9.10'
231223
224+ intf = Interface ('eth' , '1' , '101' , '1' , '38' )
225+ # Create a VLAN interface and attach to the physical interface
226+ vlan_intf = L2Interface ('vlan-5' , 'vlan' , '5' )
227+ vlan_intf .attach (intf )
228+ # Attach the EPG to the VLAN interface
229+ web_epg .attach (vlan_intf )
230+ # Assign Endpoint to the L2Interface
231+ ep .attach (vlan_intf )
232232
233- def test_add_providing_static_endpoint ( session ):
234- tenant = Tenant ( 'multisite' )
235- app = AppProfile ( 'my-demo-app' , tenant )
236- web_epg = EPG ( 'database-backend' , app )
233+ print 'Pushing json to tenant' , tenant . get_json ()
234+ resp = tenant . push_to_apic ( session )
235+ if not resp . ok :
236+ print resp , resp . text
237237
238- # Create the Endpoint
239- ep = Endpoint ('00:44:44:44:44:44' , web_epg )
240- ep .mac = '00:44:44:44:44:44'
241- ep .ip = '7.8.9.10'
238+ time .sleep (1 )
239+ # Verify that the Endpoint was pushed successfully
240+ tenants = Tenant .get_deep (session , names = ['multisite' ])
241+ multisite_tenant = tenants [0 ]
242+ app = multisite_tenant .get_child (AppProfile , 'my-demo-app' )
243+ self .assertIsNotNone (app )
244+ epg = app .get_child (EPG , 'database-backend' )
245+ self .assertIsNotNone (epg )
246+ ep = epg .get_child (Endpoint , '00:44:44:44:44:44' )
247+ self .assertIsNotNone (ep )
242248
243- intf = Interface ('eth' , '1' , '101' , '1' , '38' )
244- # Create a VLAN interface and attach to the physical interface
245- vlan_intf = L2Interface ('vlan-5' , 'vlan' , '5' )
246- vlan_intf .attach (intf )
247- # Attach the EPG to the VLAN interface
248- web_epg .attach (vlan_intf )
249- # Assign Endpoint to the L2Interface
250- ep .attach (vlan_intf )
249+ @classmethod
250+ def tearDownClass (cls ):
251+ driver = cls .driver
252+ driver .get ('http://127.0.0.1:5000/shutdown' )
253+ driver .get ('http://127.0.0.1:5001/shutdown' )
254+ driver .close ()
251255
252- print 'Pushing json to tenant' , tenant .get_json ()
253- resp = tenant .push_to_apic (session )
254- if not resp .ok :
255- print resp , resp .text
256256
257257def verify_remote_l3extsubnet (session , mac ):
258258 class_query_url = ('/api/mo/uni/tn-multisite/out-multisite-l3out.json?'
@@ -279,6 +279,8 @@ def verify_remote_l3extsubnet(session, mac):
279279#
280280# time.sleep(2)
281281
282+ setup_multisite_test (delete = True )
283+ setup_multisite_test ()
282284live = unittest .TestSuite ()
283285live .addTest (unittest .makeSuite (TestBasicExport ))
284286unittest .main (defaultTest = 'live' )
0 commit comments