4545
4646class TestNiciraContoller (cloudstackTestCase ):
4747
48+ '''
49+ Example of marvin config with NSX specific values
50+ "niciraNvp": {
51+ "hosts": [ "nsxcon1.cloud.lan", "nsxcon2.cloud.lan", "nsxcon3.cloud.lan" ],
52+ "shared_network": {
53+ "l2gatewayserviceuuid": "3595ca67-959f-47d4-8f01-0492a8e96205",
54+ "iprange" : {
55+ "startip": "192.168.26.2",
56+ "endip": "192.168.26.20",
57+ "netmask": "255.255.255.0",
58+ "gateway": "192.168.26.1",
59+ "vlan": "50",
60+ "vlan_uuid": "5cdaa49d-06cd-488a-9ca4-e954a3181f54"
61+ }
62+ }
63+ }
64+ '''
4865 @classmethod
4966 def setUpClass (cls ):
5067 test_case = super (TestNiciraContoller , cls )
@@ -55,52 +72,55 @@ def setUpClass(cls):
5572
5673 cls .physical_networks = cls .config .zones [0 ].physical_networks
5774 cls .nicira_hosts = cls .config .niciraNvp .hosts
58-
59- cls .l2gatewayserviceuuid = cls .config .niciraNvp .l2gatewayserviceuuid
75+
76+ cls .nicira_shared_network_iprange = cls .config .niciraNvp .shared_network .iprange
77+ cls .l2gatewayserviceuuid = cls .config .niciraNvp .shared_network .l2gatewayserviceuuid
6078
6179 cls .physical_network_id = cls .get_nicira_enabled_physical_network_id (cls .physical_networks )
6280
6381 cls .network_offerring_services = [
64- {
65- 'name' : 'NiciraEnabledNetwork' ,
66- 'displaytext' : 'NiciraEnabledNetwork' ,
67- 'guestiptype' : 'Isolated' ,
68- 'supportedservices' : 'SourceNat,Dhcp,Dns,Firewall,PortForwarding,Connectivity' ,
69- 'traffictype' : 'GUEST' ,
70- 'availability' : 'Optional' ,
71- 'serviceProviderList' : {
72- 'SourceNat' : 'VirtualRouter' ,
73- 'Dhcp' : 'VirtualRouter' ,
74- 'Dns' : 'VirtualRouter' ,
75- 'Firewall' : 'VirtualRouter' ,
76- 'PortForwarding' : 'VirtualRouter' ,
77- 'Connectivity' : 'NiciraNvp'
78- }
79- },
80- {
81- 'name' : 'NiciraEnabledSharedNetwork' ,
82- 'displaytext' : 'NiciraEnabledSharedNetwork' ,
83- 'guestiptype' : 'Shared' ,
84- 'supportedservices' : 'Connectivity,Dhcp,UserData' ,
85- 'traffictype' : 'GUEST' ,
86- 'availability' : 'Optional' ,
87- 'specifyVlan' : 'true' ,
88- 'specifyIpRanges' : 'true' ,
89- 'serviceProviderList' : {
90- 'Connectivity' : 'NiciraNvp' ,
91- 'Dhcp' : 'VirtualRouter' ,
92- 'UserData' : 'VirtualRouter'
93- }
94- }
95- ]
82+ {
83+ 'name' : 'NiciraEnabledIsolatedNetwork' ,
84+ 'displaytext' : 'NiciraEnabledIsolatedNetwork' ,
85+ 'guestiptype' : 'Isolated' ,
86+ 'supportedservices' : 'SourceNat,Dhcp,Dns,Firewall,PortForwarding,Connectivity' ,
87+ 'traffictype' : 'GUEST' ,
88+ 'availability' : 'Optional' ,
89+ 'serviceProviderList' : {
90+ 'SourceNat' : 'VirtualRouter' ,
91+ 'Dhcp' : 'VirtualRouter' ,
92+ 'Dns' : 'VirtualRouter' ,
93+ 'Firewall' : 'VirtualRouter' ,
94+ 'PortForwarding' : 'VirtualRouter' ,
95+ 'Connectivity' : 'NiciraNvp'
96+ }
97+ },
98+ {
99+ 'name' : 'NiciraEnabledSharedNetwork' ,
100+ 'displaytext' : 'NiciraEnabledSharedNetwork' ,
101+ 'guestiptype' : 'Shared' ,
102+ 'supportedservices' : 'Connectivity,Dhcp,UserData,SourceNat,StaticNat,Lb,PortForwarding' ,
103+ 'traffictype' : 'GUEST' ,
104+ 'availability' : 'Optional' ,
105+ 'specifyVlan' : 'true' ,
106+ 'specifyIpRanges' : 'true' ,
107+ 'serviceProviderList' : {
108+ 'Connectivity' : 'NiciraNvp' ,
109+ 'Dhcp' : 'VirtualRouter' ,
110+ 'SourceNat' : 'VirtualRouter' ,
111+ 'StaticNat' : 'VirtualRouter' ,
112+ 'Lb' : 'VirtualRouter' ,
113+ 'PortForwarding' : 'VirtualRouter' ,
114+ 'UserData' : 'VirtualRouter'
115+ }
116+ }
117+ ]
96118
97119 cls .network_offering_isolated = NetworkOffering .create (cls .api_client , cls .network_offerring_services [0 ])
98120 cls .network_offering_isolated .update (cls .api_client , state = 'Enabled' )
99121
100122 cls .network_offering_shared = NetworkOffering .create (cls .api_client , cls .network_offerring_services [1 ])
101123 cls .network_offering_shared .update (cls .api_client , state = 'Enabled' )
102-
103- cls .ip_ranges_shared = cls .config .zones [0 ].ipranges [0 ]
104124
105125 cls .nicira_credentials = {
106126 'username' : 'admin' ,
@@ -117,7 +137,9 @@ def setUpClass(cls):
117137 cls .nicira_credentials
118138 )
119139
120- cls .domain = get_domain (cls .api_client )
140+ cls .admin_account = 'admin'
141+ cls .admin_domain = get_domain (cls .api_client )
142+
121143 cls .zone = get_zone (cls .api_client , test_client .getZoneForTests ())
122144
123145 template = get_template (
@@ -148,7 +170,7 @@ def setUpClass(cls):
148170 'cpunumber' : 1 ,
149171 'cpuspeed' : 100 ,
150172 'memory' : 64 ,
151- 'offerha' : 'true'
173+ 'offerha' : 'true'
152174 }
153175 }
154176 }
@@ -164,7 +186,7 @@ def setUpClass(cls):
164186 cls .cleanup = [
165187 cls .network_offering_isolated ,
166188 cls .service_offering ,
167- cls .network_offering_shared
189+ cls .network_offering_shared
168190 ]
169191
170192 cls .logger = logging .getLogger ('TestNiciraContoller' )
@@ -246,18 +268,7 @@ def determine_slave_conroller(self, hosts, master_controller):
246268 raise Exception ("None of the supplied hosts (%s) is a Nicira slave" % hosts )
247269
248270
249- def add_nicira_device (self , hostname ):
250- nicira_device = NiciraNvp .add (
251- self .api_client ,
252- None ,
253- self .physical_network_id ,
254- hostname = hostname ,
255- username = self .nicira_credentials ['username' ],
256- password = self .nicira_credentials ['password' ],
257- transportzoneuuid = self .transport_zone_uuid )
258- self .test_cleanup .append (nicira_device )
259-
260- def add_nicira_device_l2gateway (self , hostname ):
271+ def add_nicira_device (self , hostname , l2gatewayserviceuuid = None ):
261272 nicira_device = NiciraNvp .add (
262273 self .api_client ,
263274 None ,
@@ -266,7 +277,8 @@ def add_nicira_device_l2gateway(self, hostname):
266277 username = self .nicira_credentials ['username' ],
267278 password = self .nicira_credentials ['password' ],
268279 transportzoneuuid = self .transport_zone_uuid ,
269- l2gatewayserviceuuid = self .l2gatewayserviceuuid )
280+ l2gatewayserviceuuid = l2gatewayserviceuuid
281+ )
270282 self .test_cleanup .append (nicira_device )
271283
272284 def create_guest_isolated_network (self ):
@@ -279,8 +291,8 @@ def create_guest_isolated_network(self):
279291 network = Network .create (
280292 self .api_client ,
281293 network_services ,
282- accountid = 'admin' ,
283- domainid = self .domain .id ,
294+ accountid = self . admin_account ,
295+ domainid = self .admin_domain .id
284296 )
285297 self .test_cleanup .append (network )
286298 return network
@@ -291,17 +303,17 @@ def create_guest_shared_network_numerical_vlanid(self):
291303 'displaytext' : 'nicira_enabled_network_shared' ,
292304 'zoneid' : self .zone .id ,
293305 'networkoffering' : self .network_offering_shared .id ,
294- 'startip' : self .ip_ranges_shared .startip ,
295- 'endip' : self .ip_ranges_shared .endip ,
296- 'netmask' : self .ip_ranges_shared .netmask ,
297- 'gateway' : self .ip_ranges_shared .gateway
306+ 'startip' : self .nicira_shared_network_iprange .startip ,
307+ 'endip' : self .nicira_shared_network_iprange .endip ,
308+ 'netmask' : self .nicira_shared_network_iprange .netmask ,
309+ 'gateway' : self .nicira_shared_network_iprange .gateway ,
310+ 'vlan' : self .nicira_shared_network_iprange .vlan
298311 }
299312 network = Network .create (
300313 self .api_client ,
301314 network_services ,
302- accountid = 'admin' ,
303- domainid = self .domain .id ,
304- vlan = self .ip_ranges_shared .vlan
315+ accountid = self .admin_account ,
316+ domainid = self .admin_domain .id
305317 )
306318 self .test_cleanup .append (network )
307319 return network
@@ -312,17 +324,17 @@ def create_guest_shared_network_uuid_vlanid(self):
312324 'displaytext' : 'nicira_enabled_network_shared' ,
313325 'zoneid' : self .zone .id ,
314326 'networkoffering' : self .network_offering_shared .id ,
315- 'startip' : self .ip_ranges_shared .startip ,
316- 'endip' : self .ip_ranges_shared .endip ,
317- 'netmask' : self .ip_ranges_shared .netmask ,
318- 'gateway' : self .ip_ranges_shared .gateway
327+ 'startip' : self .nicira_shared_network_iprange .startip ,
328+ 'endip' : self .nicira_shared_network_iprange .endip ,
329+ 'netmask' : self .nicira_shared_network_iprange .netmask ,
330+ 'gateway' : self .nicira_shared_network_iprange .gateway ,
331+ 'vlan' : self .nicira_shared_network_iprange .vlan_uuid
319332 }
320333 network = Network .create (
321334 self .api_client ,
322335 network_services ,
323- accountid = 'admin' ,
324- domainid = self .domain .id ,
325- vlan = self .ip_ranges_shared .vlan_uuid
336+ accountid = self .admin_account ,
337+ domainid = self .admin_domain .id
326338 )
327339 self .test_cleanup .append (network )
328340 return network
@@ -333,16 +345,16 @@ def create_guest_shared_network_services(self):
333345 'displaytext' : 'nicira_enabled_network_shared' ,
334346 'zoneid' : self .zone .id ,
335347 'networkoffering' : self .network_offering_shared .id ,
336- 'startip' : self .ip_ranges_shared .startip ,
337- 'endip' : self .ip_ranges_shared .endip ,
338- 'netmask' : self .ip_ranges_shared .netmask ,
339- 'gateway' : self .ip_ranges_shared .gateway
348+ 'startip' : self .nicira_shared_network_iprange .startip ,
349+ 'endip' : self .nicira_shared_network_iprange .endip ,
350+ 'netmask' : self .nicira_shared_network_iprange .netmask ,
351+ 'gateway' : self .nicira_shared_network_iprange .gateway
340352 }
341353 network = Network .create (
342354 self .api_client ,
343355 network_services ,
344- accountid = 'admin' ,
345- domainid = self .domain .id ,
356+ accountid = self . admin_account ,
357+ domainid = self .admin_domain .id ,
346358 )
347359 self .test_cleanup .append (network )
348360 return network
@@ -352,8 +364,8 @@ def create_virtual_machine(self, network):
352364 virtual_machine = VirtualMachine .create (
353365 self .api_client ,
354366 self .vm_services ['small' ],
355- accountid = 'admin' ,
356- domainid = self .domain .id ,
367+ accountid = self . admin_account ,
368+ domainid = self .admin_domain .id ,
357369 serviceofferingid = self .service_offering .id ,
358370 networkids = [network .id ],
359371 mode = self .vm_services ['mode' ]
@@ -365,8 +377,8 @@ def create_virtual_machine_shared_networks(self, network):
365377 virtual_machine = VirtualMachine .create (
366378 self .api_client ,
367379 self .vm_services ['small' ],
368- accountid = 'admin' ,
369- domainid = self .domain .id ,
380+ accountid = self . admin_account ,
381+ domainid = self .admin_domain .id ,
370382 serviceofferingid = self .service_offering .id ,
371383 networkids = [network .id ],
372384 mode = 'BASIC'
@@ -378,17 +390,17 @@ def create_virtual_machine_shared_networks(self, network):
378390 def get_routers_for_network (self , network ):
379391 return list_routers (
380392 self .api_client ,
381- account = 'admin' ,
382- domainid = self .domain .id ,
393+ accountid = self . admin_account ,
394+ domainid = self .admin_domain .id ,
383395 networkid = network .id
384396 )
385397
386398
387399 def get_hosts (self ):
388400 return list_hosts (
389401 self .api_client ,
390- account = 'admin' ,
391- domainid = self .domain .id
402+ accountid = self . admin_account ,
403+ domainid = self .admin_domain .id
392404 )
393405
394406
@@ -421,9 +433,9 @@ def acquire_publicip(self, network):
421433 self .logger .debug ("Associating public IP for network: %s" % network .name )
422434 public_ip = PublicIPAddress .create (
423435 self .api_client ,
424- accountid = 'admin' ,
436+ accountid = self . admin_account ,
425437 zoneid = self .zone .id ,
426- domainid = self .domain .id ,
438+ domainid = self .admin_domain .id ,
427439 networkid = network .id
428440 )
429441 self .logger .debug ("Associated %s with network %s" % (public_ip .ipaddress .ipaddress , network .id ))
@@ -536,10 +548,10 @@ def test_04_nicira_shared_networks_numerical_vlanid(self):
536548 CASE 1) Numerical VLAN_ID provided in network creation
537549 """
538550 self .debug ("Starting test case 1 for Shared Networks" )
539- self .add_nicira_device_l2gateway (self .nicira_master_controller )
551+ self .add_nicira_device (self .nicira_master_controller , self . l2gatewayserviceuuid )
540552 network = self .create_guest_shared_network_numerical_vlanid ()
541553 virtual_machine = self .create_virtual_machine_shared_networks (network )
542-
554+
543555 list_vm_response = VirtualMachine .list (self .api_client , id = virtual_machine .id )
544556 self .debug ("Verify listVirtualMachines response for virtual machine: %s" % virtual_machine .id )
545557
@@ -557,10 +569,10 @@ def test_05_nicira_shared_networks_lrouter_uuid_vlan_id(self):
557569 CASE 2) Logical Router's UUID as VLAN_ID provided in network creation
558570 """
559571 self .debug ("Starting test case 2 for Shared Networks" )
560- self .add_nicira_device_l2gateway (self .nicira_master_controller )
572+ self .add_nicira_device (self .nicira_master_controller , self . l2gatewayserviceuuid )
561573 network = self .create_guest_shared_network_uuid_vlanid ()
562574 virtual_machine = self .create_virtual_machine_shared_networks (network )
563-
575+
564576 list_vm_response = VirtualMachine .list (self .api_client , id = virtual_machine .id )
565577 self .debug ("Verify listVirtualMachines response for virtual machine: %s" % virtual_machine .id )
566578
@@ -569,4 +581,4 @@ def test_05_nicira_shared_networks_lrouter_uuid_vlan_id(self):
569581
570582 vm_response = list_vm_response [0 ]
571583 self .assertEqual (vm_response .id , virtual_machine .id , 'Virtual machine in response does not match request' )
572- self .assertEqual (vm_response .state , 'Running' , 'VM is not in Running state' )
584+ self .assertEqual (vm_response .state , 'Running' , 'VM is not in Running state' )
0 commit comments