コード例 #1
0
 def test_create(self):
     eon_dict = {}
     eon_dict['cluster_dvs_mapping'] = 'DC/host/cluster:Trunk-DVS'
     with contextlib.nested(
             patch.object(VMwareUtils,
                          "get_cluster",
                          return_value=fake_inputs.fake_clusters),
             patch.object(OVSvAppUtil,
                          "get_ovsvapps",
                          return_value=fake_inputs.fake_datacenter),
             patch.object(VappInstaller,
                          "run_installer",
                          return_value=eon_dict),
             patch.object(VMwareUtils,
                          "get_vcenter_session",
                          return_value=fake_inputs.MOB()),
             patch.object(VMwareUtils,
                          "get_data_center",
                          return_value=fake_inputs.fake_datacenter),
             patch.object(OvsvappInstaller,
                          '_ovsvapp_input',
                          return_value=fake_inputs.data)) as (
                              mock_get_cluster, mock_get_ovsvapp,
                              mock_run_installer, mock_get_vecenter_session,
                              mock_get_data_center, mock_ovsvapp_input):
         inputs = copy.deepcopy(fake_inputs.data)
         mock_result = self.ovsvapp_installer.create(inputs)
         self.assertTrue(mock_ovsvapp_input.called)
         self.assertTrue(mock_get_cluster.called)
         self.assertTrue(mock_get_ovsvapp.called)
         self.assertTrue(mock_run_installer.called)
         self.assertTrue(mock_get_vecenter_session.called)
         self.assertTrue(mock_get_data_center.called)
         self.assertEqual(mock_result, eon_dict)
コード例 #2
0
 def test_tear_down_network(self):
     with contextlib.nested(
             patch.object(VMwareUtils,
                          "get_vcenter_session",
                          return_value=fake_inputs.MOB()),
             patch.object(VMwareUtils,
                          "get_data_center",
                          return_value=fake_inputs.fake_datacenter),
             patch.object(VMwareUtils,
                          "get_cluster",
                          return_value=fake_inputs.fake_clusters),
             patch.object(Cleanup, 'teardown_network'),
             patch.object(OvsvappInstaller,
                          '_ovsvapp_input',
                          return_value=fake_inputs.data)) as (
                              mock_get_vcenter_session,
                              mock_get_data_center, mock_get_cluster,
                              mock_teardown_network, mock_ovsvapp_input):
         inputs = copy.deepcopy(fake_inputs.data)
         self.ovsvapp_installer.teardown_network(inputs)
         self.assertTrue(mock_ovsvapp_input.called)
         self.assertTrue(mock_get_vcenter_session.called)
         self.assertTrue(mock_get_data_center.called)
         self.assertTrue(mock_get_cluster.called)
         self.assertTrue(mock_teardown_network.called)
コード例 #3
0
 def test_configure_network_infra(self):
     with contextlib.nested(
             patch.object(VMwareUtils,
                          "get_vcenter_session",
                          return_value=fake_inputs.MOB()),
             patch.object(VMwareUtils,
                          "get_data_center",
                          return_value=fake_inputs.fake_datacenter),
             patch.object(VMwareUtils, "get_cluster"),
             patch.object(VMwareUtils, "get_all_hosts"),
             patch.object(NetworkAdapter, "_create_dvs"),
             patch.object(NetworkAdapter, "_create_dvpg"),
             patch.object(NetworkAdapter, "_configure_dvs"),
             patch.object(NetworkAdapter, "_configure_dvpg"),
     ) as (mock_vc_session, mock_get_dc, mock_get_cluster,
           mock_get_all_hosts, mock_create_dvs, mock_create_dvpg,
           mock_configure_dvs, mock_configure_dvpg):
         proxy_utility = ProxyInstallerUtility(fake_inputs.data)
         proxy_utility.configure_network_infrastructure()
         self.assertTrue(mock_vc_session.called)
         self.assertTrue(mock_get_dc.called)
         self.assertTrue(mock_get_cluster.called)
         self.assertTrue(mock_get_all_hosts.called)
         self.assertTrue(mock_create_dvs.called)
         self.assertTrue(mock_create_dvpg.called)
         self.assertTrue(mock_configure_dvs.called)
         self.assertTrue(mock_configure_dvpg.called)
コード例 #4
0
 def setUp(self):
     super(TestInvokeVappInstaller, self).setUp()
     with contextlib.nested(
         patch.object(VMwareUtils, 'get_vcenter_session',
                      return_value=fake_inputs.MOB()),
         patch.object(VMwareUtils, 'get_data_center',
                      return_value=fake_inputs.fake_datacenter)) as (
             mock_get_vcenter_session, mock_get_data_center):
         self.invoke_vapp_installer = \
             OVSvAppInstallerUtility(fake_inputs.data)
         self.assertTrue(mock_get_vcenter_session.called)
         self.assertTrue(mock_get_data_center.called)
コード例 #5
0
 def test_teardown_network(self):
     with contextlib.nested(
             patch.object(VMwareUtils,
                          "get_vcenter_session",
                          return_value=fake_inputs.MOB()),
             patch.object(VMwareUtils,
                          "get_data_center",
                          return_value=fake_inputs.fake_datacenter),
             patch.object(VMwareUtils, "get_cluster"),
             patch.object(Cleanup, 'teardown_network'),
     ) as (mock_vc_session, mock_get_dc, mock_get_cluster,
           mock_teardown_net):
         proxy_utility = ProxyInstallerUtility(fake_inputs.data)
         proxy_utility.teardown_network(fake_inputs.data)
         self.assertTrue(mock_vc_session.called)
         self.assertTrue(mock_get_dc.called)
         self.assertTrue(mock_get_cluster.called)
         self.assertTrue(mock_teardown_net.called)
コード例 #6
0
 def setUp(self):
     super(TestCleanup, self).setUp()
     self.ovs_vapp = {'name': 'fake-ovsvapp',
                      'obj': OVSvapp(),
                      'runtime.powerState': 'poweredOff',
                      'runtime.host': OVSvapp.runtime.host}
     self.cluster = {'obj': Cluster()}
     with contextlib.nested(
         patch.object(VMwareUtils, 'get_vcenter_session',
                      return_value=fake_inputs.MOB()),
         patch.object(VMwareUtils, 'get_data_center',
                      return_value=fake_inputs.fake_datacenter),
         patch.object(VMwareUtils, 'get_cluster',
                      return_value=self.cluster)) as (
             mock_get_vcenter_session, mock_get_data_center,
             mock_get_cluster):
         self.cleanup = Cleanup(fake_inputs.data)
         self.assertTrue(mock_get_vcenter_session.called)
         self.assertTrue(mock_get_data_center.called)
         self.assertTrue(mock_get_cluster.called)
コード例 #7
0
 def test_delete(self):
     with contextlib.nested(
             patch.object(VMwareUtils,
                          "get_vcenter_session",
                          return_value=fake_inputs.MOB()),
             patch.object(VMwareUtils,
                          "get_data_center",
                          return_value=fake_inputs.fake_datacenter),
             patch.object(VMwareUtils,
                          "get_cluster",
                          return_value=fake_inputs.fake_clusters),
             patch.object(Cleanup, "_remove_affinity_rule"),
             patch.object(Cleanup, "_delete_ovsvapps_task"),
             patch.object(Cleanup, "_remove_cluster_vni_allocation"),
             patch.object(OvsvappInstaller,
                          '_ovsvapp_input',
                          return_value=fake_inputs.data),
             patch.object(
                 OVSvAppUtil, 'get_ovsvapps',
                 return_value=VmMap())) as (mock_get_vcenter_session,
                                            mock_get_data_center,
                                            mock_get_cluster,
                                            mock_remove_affinity_rule,
                                            mock_delete_all_vapp,
                                            mock_remove_cluster,
                                            mock_ovsvapp_input,
                                            mock_get_ovsvapps):
         inputs = copy.deepcopy(fake_inputs.data)
         mock_delete_result = self.ovsvapp_installer.delete(inputs)
         self.assertTrue(mock_ovsvapp_input.called)
         self.assertEqual(True, mock_delete_result)
         self.assertTrue(mock_get_vcenter_session.called)
         self.assertTrue(mock_get_data_center.called)
         self.assertTrue(mock_get_cluster.called)
         self.assertTrue(mock_remove_affinity_rule.called)
         self.assertTrue(mock_delete_all_vapp.called)
         self.assertTrue(mock_remove_cluster.called)
         self.assertTrue(mock_get_ovsvapps.called)
コード例 #8
0
 def test_setup_network(self):
     with contextlib.nested(
             patch.object(NetworkAdapter, "_create_dvs"),
             patch.object(VMwareUtils,
                          "get_vcenter_session",
                          return_value=fake_inputs.MOB()),
             patch.object(VMwareUtils,
                          "get_data_center",
                          return_value=fake_inputs.fake_datacenter),
             patch.object(NetworkAdapter, "_create_dvpg"),
             patch.object(
                 OvsvappInstaller,
                 '_ovsvapp_input',
                 return_value=fake_inputs.data)) as (dvs_object, vmwareutil,
                                                     ovsvapputil,
                                                     mock_create_dvpg,
                                                     mock_ovsvapp_input):
         inputs = copy.deepcopy(fake_inputs.data)
         self.ovsvapp_installer.setup_network(inputs)
         self.assertTrue(mock_ovsvapp_input.called)
         self.assertTrue(vmwareutil.called)
         self.assertTrue(ovsvapputil.called)
         self.assertTrue(dvs_object.called)
         self.assertTrue(mock_create_dvpg.called)