def test_post_create_port_nic_devices_none(self):
     try:
         vm_id = fake_vmware_api.Constants.VM_UUID
         network_uuid = fake_vmware_api.Constants.PORTGROUP_NAME
         port = model.Port(
             name=None,
             mac_address=None,
             ipaddresses=None,
             vm_id=vm_id,
             port_status=constants.PORT_STATUS_UP,
             network_uuid=network_uuid,
         )
         updateSet = fake_vmware_api.DataObject()
         updateSet.version = 1
         filterSet = []
         updateSet.filterSet = filterSet
         propFilterUpdate = fake_vmware_api.DataObject()
         filterSet.append(propFilterUpdate)
         objectSet = []
         propFilterUpdate.objectSet = objectSet
         objectUpdate = fake_vmware_api.DataObject()
         objectSet.append(objectUpdate)
         with mock.patch.object(vim_util, "wait_for_updates_ex", return_value=updateSet):
             self.vc_driver.post_create_port(port)
     except Exception:
         self.assertFalse(fake_vmware_api.is_task_done("ReconfigureDVPort_Task"))
Example #2
0
 def test_post_create_port_nic_devices_none(self):
     try:
         vm_id = fake_vmware_api.Constants.VM_UUID
         network_uuid = fake_vmware_api.Constants.PORTGROUP_NAME
         port = model.Port(name=None,
                           mac_address=None,
                           ipaddresses=None,
                           vm_id=vm_id,
                           port_status=constants.PORT_STATUS_UP,
                           network_uuid=network_uuid)
         updateSet = fake_vmware_api.DataObject()
         updateSet.version = 1
         filterSet = []
         updateSet.filterSet = filterSet
         propFilterUpdate = fake_vmware_api.DataObject()
         filterSet.append(propFilterUpdate)
         objectSet = []
         propFilterUpdate.objectSet = objectSet
         objectUpdate = fake_vmware_api.DataObject()
         objectSet.append(objectUpdate)
         with mock.patch.object(vim_util,
                                "wait_for_updates_ex",
                                return_value=updateSet):
             self.vc_driver.post_create_port(port)
     except Exception:
         self.assertFalse(
             fake_vmware_api.is_task_done("ReconfigureDVPort_Task"))
 def test_create_network(self):
     vlan = model.Vlan(vlanIds=["1001"])
     network_config = model.NetworkConfig(vlan)
     network = model.Network(name="net-1234", network_type=constants.NETWORK_VLAN, config=network_config)
     vswitch = model.VirtualSwitch("test_dvs", hosts=None)
     with mock.patch.object(network_util, "get_portgroup_mor_by_name", return_value=None):
         self.vc_driver.create_network(network, vswitch)
         self.assertTrue(fake_vmware_api.is_task_done("AddDVPortgroup_Task"))
 def test_wait_for_port_update_on_vm_exception(self):
     vm_mor = None
     pg_mor = None
     try:
         with mock.path.object(self.vc_driver, "_register_vm_for_updates"), mock.patch.object(
             vim_util, "wait_for_updates_ex", side_effect=Exception()
         ):
             self.vc_driver._wait_for_port_update_on_vm(vm_mor, pg_mor)
     except Exception:
         self.assertFalse(fake_vmware_api.is_task_done("ReconfigureDVPort_Task"))
Example #5
0
 def test_post_create_port(self):
     vm_id = fake_vmware_api.Constants.VM_UUID
     network_uuid = fake_vmware_api.Constants.PORTGROUP_NAME
     port = model.Port(name=None,
                       mac_address=None,
                       ipaddresses=None,
                       vm_id=vm_id,
                       port_status=constants.PORT_STATUS_UP,
                       network_uuid=network_uuid)
     self.vc_driver.post_create_port(port)
     self.assertTrue(fake_vmware_api.is_task_done("ReconfigureDVPort_Task"))
Example #6
0
 def test_create_network(self):
     vlan = model.Vlan(vlan_ids=["1001"])
     network_config = model.NetworkConfig(vlan)
     network = model.Network(
         name="net-1234", network_type=p_const.TYPE_VLAN,
         config=network_config)
     vswitch = model.VirtualSwitch("test_dvs", hosts=None)
     with mock.patch.object(network_util, "get_portgroup_mor_by_name",
                            return_value=None):
         self.vc_driver.create_network(network, vswitch)
         self.assertTrue(fake_vmware_api.is_task_done(
             "AddDVPortgroup_Task"))
 def test_post_create_port_status_down(self):
     vm_id = fake_vmware_api.Constants.VM_UUID
     network_uuid = fake_vmware_api.Constants.PORTGROUP_NAME
     port = model.Port(name=None,
                       mac_address=None,
                       ipaddresses=None,
                       vm_id=vm_id,
                       port_status=constants.PORT_STATUS_DOWN,
                       network_uuid=network_uuid)
     self.vc_driver.post_create_port(port)
     self.assertFalse(fake_vmware_api.is_task_done(
         "ReconfigureDVPort_Task"))
 def test_wait_for_port_update_on_vm_exception(self):
     vm_mor = None
     pg_mor = None
     try:
         with mock.path.object(self.vc_driver,
                               '_register_vm_for_updates'), \
                 mock.patch.object(vim_util, "wait_for_updates_ex",
                                   side_effect=Exception()):
             self.vc_driver._wait_for_port_update_on_vm(vm_mor, pg_mor)
     except Exception:
         self.assertFalse(fake_vmware_api.is_task_done(
             "ReconfigureDVPort_Task"))
 def test_post_create_port_excp1(self):
     vm_id = fake_vmware_api.Constants.VM_UUID
     network_uuid = fake_vmware_api.Constants.PORTGROUP_NAME
     port = model.Port(
         name=None,
         mac_address=None,
         ipaddresses=None,
         vm_id=vm_id,
         port_status=constants.PORT_STATUS_UP,
         network_uuid=network_uuid,
     )
     with mock.patch.object(network_util, "get_portgroup_mor_by_name", return_value=None):
         self.assertRaises(error_util.RunTimeError, self.vc_driver.post_create_port, port)
         self.assertFalse(fake_vmware_api.is_task_done("ReconfigureDVPort_Task"))
 def test_post_create_port_excp1(self):
     vm_id = fake_vmware_api.Constants.VM_UUID
     network_uuid = fake_vmware_api.Constants.PORTGROUP_NAME
     port = model.Port(name=None,
                       mac_address=None,
                       ipaddresses=None,
                       vm_id=vm_id,
                       port_status=constants.PORT_STATUS_UP,
                       network_uuid=network_uuid)
     with mock.patch.object(network_util, "get_portgroup_mor_by_name",
                            return_value=None):
         self.assertRaises(error_util.RunTimeError,
                           self.vc_driver.post_create_port,
                           port)
         self.assertFalse(fake_vmware_api.is_task_done(
             "ReconfigureDVPort_Task"))
Example #11
0
 def test_post_create_port_excp3(self):
     vm_id = fake_vmware_api.Constants.VM_UUID
     network_uuid = fake_vmware_api.Constants.PORTGROUP_NAME
     port = model.Port(name=None,
                       mac_address=None,
                       ipaddresses=None,
                       vm_id=vm_id,
                       port_status=constants.PORT_STATUS_UP,
                       network_uuid=network_uuid)
     with mock.patch.object(dvs_driver.DvsNetworkDriver,
                            "_register_vm_for_updates",
                            side_effect=error_util.RunTimeError(
                                "Exception in registering vm for updates")):
         self.assertRaises(error_util.RunTimeError,
                           self.vc_driver.post_create_port, port)
         self.assertFalse(
             fake_vmware_api.is_task_done("ReconfigureDVPort_Task"))
Example #12
0
 def test_update_port_up(self):
     port_id = "PORT-1234-5678"
     vm_id = fake_vmware_api.Constants.VM_UUID
     mac_address = fake_vmware_api.Constants.VM_MAC
     vlan = model.Vlan(vlan_ids=["1001"])
     network_config = model.NetworkConfig(vlan)
     network = model.Network(name="net-1234",
                             network_type=p_const.TYPE_VLAN,
                             config=network_config)
     port = model.Port(uuid=port_id,
                       name=None,
                       mac_address=mac_address,
                       ipaddresses=None,
                       vm_id=vm_id,
                       port_status=constants.PORT_STATUS_UP)
     self.vc_driver.update_port(network, port, None)
     self.assertTrue(fake_vmware_api.is_task_done("ReconfigureDVPort_Task"))
 def test_update_port_up(self):
     port_id = "PORT-1234-5678"
     vm_id = fake_vmware_api.Constants.VM_UUID
     mac_address = fake_vmware_api.Constants.VM_MAC
     vlan = model.Vlan(vlanIds=["1001"])
     network_config = model.NetworkConfig(vlan)
     network = model.Network(name="net-1234", network_type=constants.NETWORK_VLAN, config=network_config)
     port = model.Port(
         uuid=port_id,
         name=None,
         mac_address=mac_address,
         ipaddresses=None,
         vm_id=vm_id,
         port_status=constants.PORT_STATUS_UP,
     )
     self.vc_driver.update_port(network, port, None)
     self.assertTrue(fake_vmware_api.is_task_done("ReconfigureDVPort_Task"))
Example #14
0
 def test_update_port_invalid_mac(self):
     port_id = "PORT-1234-5678"
     vm_id = fake_vmware_api.Constants.VM_UUID
     mac_address = "in:va:li:d0:ma:c0"
     vlan = model.Vlan(vlan_ids=["1001"])
     network_config = model.NetworkConfig(vlan)
     network = model.Network(name="net-1234", network_type=p_const.TYPE_VLAN, config=network_config)
     port = model.Port(
         uuid=port_id,
         name=None,
         mac_address=mac_address,
         ipaddresses=None,
         vm_id=vm_id,
         port_status=constants.PORT_STATUS_UP,
     )
     self.vc_driver.update_port(network, port, None)
     self.assertFalse(fake_vmware_api.is_task_done("ReconfigureDVPort_Task"))
 def test_post_create_port_excp3(self):
     vm_id = fake_vmware_api.Constants.VM_UUID
     network_uuid = fake_vmware_api.Constants.PORTGROUP_NAME
     port = model.Port(name=None,
                       mac_address=None,
                       ipaddresses=None,
                       vm_id=vm_id,
                       port_status=constants.PORT_STATUS_UP,
                       network_uuid=network_uuid)
     with mock.patch.object(dvs_driver.DvsNetworkDriver,
                            "_register_vm_for_updates",
                            side_effect=error_util.RunTimeError(
                                "Exception in registering vm for updates")):
         self.assertRaises(error_util.RunTimeError,
                           self.vc_driver.post_create_port,
                           port)
         self.assertFalse(fake_vmware_api.is_task_done(
             "ReconfigureDVPort_Task"))
 def test_post_create_port_excp2(self):
     vm_id = fake_vmware_api.Constants.VM_UUID
     network_uuid = fake_vmware_api.Constants.PORTGROUP_NAME
     port = model.Port(
         name=None,
         mac_address=None,
         ipaddresses=None,
         vm_id=vm_id,
         port_status=constants.PORT_STATUS_UP,
         network_uuid=network_uuid,
     )
     with mock.patch.object(
         dvs_driver.DvsNetworkDriver, "_find_cluster_switch_for_vm", return_value=[None, None, "test_vds"]
     ), mock.patch.object(network_util, "get_portgroup_mor_by_name", return_value="pg_mor"), mock.patch.object(
         resource_util, "get_vm_mor_for_uuid", return_value=None
     ):
         self.assertRaises(error_util.RunTimeError, self.vc_driver.post_create_port, port)
         self.assertFalse(fake_vmware_api.is_task_done("ReconfigureDVPort_Task"))
Example #17
0
 def test_post_create_port_excp2(self):
     vm_id = fake_vmware_api.Constants.VM_UUID
     network_uuid = fake_vmware_api.Constants.PORTGROUP_NAME
     port = model.Port(name=None,
                       mac_address=None,
                       ipaddresses=None,
                       vm_id=vm_id,
                       port_status=constants.PORT_STATUS_UP,
                       network_uuid=network_uuid)
     with mock.patch.object(dvs_driver.DvsNetworkDriver,
                            "_find_cluster_switch_for_vm",
                            return_value=[None, None, "test_vds"]), \
             mock.patch.object(network_util, "get_portgroup_mor_by_name",
                               return_value="pg_mor"), \
             mock.patch.object(resource_util, "get_vm_mor_for_uuid",
                               return_value=None):
         self.assertRaises(error_util.RunTimeError,
                           self.vc_driver.post_create_port, port)
         self.assertFalse(
             fake_vmware_api.is_task_done("ReconfigureDVPort_Task"))