aboutsummaryrefslogtreecommitdiffstats
path: root/deploy/adapters/ansible/roles/open-contrail/files/provision/test_vif.py.patch
blob: 3e12c72a1d9b3a9fa69437880eb9e9f6a36356a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
*** a/test_vif.py	Mon Sep 28 15:12:56 2015
--- b/test_vif.py	Mon Sep 28 15:19:20 2015
***************
*** 235,240 ****
--- 235,253 ----
                                              subnets=[subnet_bridge_4],
                                              interface='eth0')
  
+     network_vrouter = network_model.Network(id='network-id-xxx-yyy-zzz',
+                                             label=None,
+                                             bridge=None,
+                                             subnets=[subnet_bridge_4,
+                                                      subnet_bridge_6],
+                                             interface='eth0')
+ 
+     vif_vrouter = network_model.VIF(id='vif-xxx-yyy-zzz',
+                                     address='ca:fe:de:ad:be:ef',
+                                     network=network_vrouter,
+                                     type=network_model.VIF_TYPE_VROUTER,
+                                     devname='tap-xxx-yyy-zzz')
+ 
      vif_mlnx = network_model.VIF(id='vif-xxx-yyy-zzz',
                                   address='ca:fe:de:ad:be:ef',
                                   network=network_mlnx,
***************
*** 796,801 ****
--- 809,851 ----
                                self.vif_mlnx)
              self.assertEqual(0, execute.call_count)
  
+     def test_unplug_vrouter_with_details(self):
+         d = vif.LibvirtGenericVIFDriver()
+         with mock.patch.object(utils, 'execute') as execute:
+             d.unplug_vrouter(None, self.vif_vrouter)
+             execute.assert_called_once_with(
+                 'vrouter-port-control',
+                 '--oper=delete --uuid=vif-xxx-yyy-zzz',
+                 run_as_root=True)
+ 
+     def test_plug_vrouter_with_details(self):
+         d = vif.LibvirtGenericVIFDriver()
+         instance = mock.Mock()
+         instance.name = 'instance-name'
+         instance.uuid = '46a4308b-e75a-4f90-a34a-650c86ca18b2'
+         instance.project_id = 'b168ea26fa0c49c1a84e1566d9565fa5'
+         instance.display_name = 'instance1'
+         with mock.patch.object(utils, 'execute') as execute:
+             d.plug_vrouter(instance, self.vif_vrouter)
+             execute.assert_has_calls([
+                 mock.call('ip', 'tuntap', 'add', 'tap-xxx-yyy-zzz', 'mode',
+                     'tap', run_as_root=True, check_exit_code=[0, 2, 254]),
+                 mock.call('ip', 'link', 'set', 'tap-xxx-yyy-zzz', 'up',
+                     run_as_root=True, check_exit_code=[0, 2, 254]),
+                 mock.call('vrouter-port-control',
+                     '--oper=add --uuid=vif-xxx-yyy-zzz '
+                     '--instance_uuid=46a4308b-e75a-4f90-a34a-650c86ca18b2 '
+                     '--vn_uuid=network-id-xxx-yyy-zzz '
+                     '--vm_project_uuid=b168ea26fa0c49c1a84e1566d9565fa5 '
+                     '--ip_address=0.0.0.0 '
+                     '--ipv6_address=None '
+                     '--vm_name=instance1 '
+                     '--mac=ca:fe:de:ad:be:ef '
+                     '--tap_name=tap-xxx-yyy-zzz '
+                     '--port_type=NovaVMPort '
+                     '--tx_vlan_id=-1 '
+                     '--rx_vlan_id=-1', run_as_root=True)])
+ 
      def test_ivs_ethernet_driver(self):
          d = vif.LibvirtGenericVIFDriver(self._get_conn(ver=9010))
          self._check_ivs_ethernet_driver(d,