def test_sync_dvses_dpgs( minimalistic_topology, vmware_controller, vcenter_api_client, vnc_test_client, vmware_dpg_1, vmware_dpg_2, ): # minimalistic_topology contains only dvs-1 # Only this DVS should be supported # The list of supported DVSes is created during sync vmware_controller.sync() # User creates a DPG (dpg-1) in dvs-1 dpg_created_update = vcenter_api_client.create_dpg(vmware_dpg_1) vmware_controller.handle_update(dpg_created_update) # dpg-1 is connected to dvs-1, so a VN should be created for it created_vn = vnc_test_client.read_vn(models.generate_uuid("dvportgroup-1")) assert created_vn is not None # User creates a DPG (dpg-2) in dvs-2 dpg_created_update = vcenter_api_client.create_dpg(vmware_dpg_2) vmware_controller.handle_update(dpg_created_update) # No VN should be created for dpg-2, since dvs-2 is not supported with pytest.raises(vnc_api.NoIdError): vnc_test_client.read_vn(models.generate_uuid("dvportgroup-2"))
def test_vm_created_no_pis( dvs_per_esxi_topology, vnc_test_client, vmware_controller, vcenter_api_client, vmware_vm_2, vmware_dpg_4, ): # User creates a DPG (dpg-4) on dvs-2 (dvs-2 is supported on esxi-2, # so a VN will be created in VNC) dpg_created_update = vcenter_api_client.create_dpg(vmware_dpg_4) vmware_controller.handle_update(dpg_created_update) created_vn = vnc_test_client.read_vn(models.generate_uuid("dvportgroup-4")) assert created_vn is not None # User creates a VM (vm-1) with one interface connected to dpg-4 vm_created_update = vcenter_api_client.create_vm(vmware_vm_2) vmware_controller.handle_update(vm_created_update) # No VPGs are created in VNC, since there are no PIs for esxi-1_dvs-2 with pytest.raises(vnc_api.NoIdError): vnc_test_client.read_vpg(models.generate_uuid("esxi-1_dvs-2")) # No VMIs are created in VNC, since there are no VPGs for esxi-1_dvs-2 with pytest.raises(vnc_api.NoIdError): vnc_test_client.read_vmi(models.generate_uuid("esxi-1_dvs-2_dpg-4"))
def test_dpg_reconfiguration_from_invalid_vlan( topology_with_two_nodes, vnc_test_client, vcenter_api_client, vmware_controller, vmware_dpg_invalid_vlan, vmware_vm_1_invalid_dpg, vmware_vm_2_invalid_dpg, ): # dpg-1 created in dvs-1 with invalid VLAN 0 dpg_created_update = vcenter_api_client.create_dpg(vmware_dpg_invalid_vlan) vmware_controller.handle_update(dpg_created_update) # vm-1 created on host esxi-1 with single interface in (dvs-1, dpg-1) vm_created_update_1 = vcenter_api_client.create_vm(vmware_vm_1_invalid_dpg) vmware_controller.handle_update(vm_created_update_1) # vm-2 created on host esxi-2 with single interface in (dvs-1, dpg-1) vm_created_update_2 = vcenter_api_client.create_vm(vmware_vm_2_invalid_dpg) vmware_controller.handle_update(vm_created_update_2) # No created objects in VNC API for invalid DPG vmis = vnc_test_client.read_all_vmis() assert len(vmis) == 0 with pytest.raises(vnc_api.NoIdError): vnc_test_client.read_vn(models.generate_uuid("dvportgroup-1")) # dpg-1 VLAN reconfigured from 0 to 5 dpg_reconfigured_update = vcenter_api_client.reconfigure_dpg( vmware_dpg_invalid_vlan, 5) vmware_controller.handle_update(dpg_reconfigured_update) vnc_vn = vnc_test_client.read_vn(models.generate_uuid("dvportgroup-1")) assert vnc_vn.name == "dvs-1_dpg-1" vmis = vnc_test_client.read_all_vmis() assert len(vmis) == 2 created_vmi = vmis["esxi-1_dvs-1_dpg-1"] utils.verify_vnc_vmi( vnc_vmi=created_vmi, vmi_name="esxi-1_dvs-1_dpg-1", vpg_name="esxi-1_dvs-1", vn_name="dvs-1_dpg-1", vlan=5, ) created_vmi = vmis["esxi-2_dvs-1_dpg-1"] utils.verify_vnc_vmi( vnc_vmi=created_vmi, vmi_name="esxi-2_dvs-1_dpg-1", vpg_name="esxi-2_dvs-1", vn_name="dvs-1_dpg-1", vlan=5, )
def test_create_vmi_model(vmi_service, vm_model): vmi_models = vmi_service.create_vmi_models_for_vm(vm_model) assert vmi_models[0].uuid == models.generate_uuid("esxi-1_dvs-1_dpg-1") assert vmi_models[0].host_name == "esxi-1" assert vmi_models[0].dpg_model.name == "dpg-1" assert ( vmi_models[0].dpg_model.uuid == "5a6bd262-1f96-3546-a762-6fa5260e9014") assert vmi_models[0].dpg_model.dvs_name == "dvs-1" assert vmi_models[0].dpg_model.vlan_id == 5 assert vmi_models[0].vpg_uuid == models.generate_uuid("esxi-1_dvs-1")
def test_from_vm_model(vm_model): vmi_models = models.VirtualMachineInterfaceModel.from_vm_model(vm_model) assert vmi_models[0].uuid == models.generate_uuid("esxi-1_dvs-1_dpg-1") assert vmi_models[0].name == "esxi-1_dvs-1_dpg-1" assert vmi_models[0].host_name == "esxi-1" assert vmi_models[0].dpg_model.dvs_name == "dvs-1" assert vmi_models[0].dpg_model.name == "dpg-1" assert vmi_models[0].dpg_model.uuid == models.generate_uuid( "dvportgroup-1") assert vmi_models[0].vpg_uuid == models.generate_uuid("esxi-1_dvs-1")
def test_vpg_exists( minimalistic_topology, vmware_controller, vcenter_api_client, vnc_test_client, vmware_vm, vmware_dpg, vmware_dpg_2, ): # User creates a DPG (dpg-1) and the event is properly handled dpg_created_update = vcenter_api_client.create_dpg(vmware_dpg) vmware_controller.handle_update(dpg_created_update) # User creates DPG (dpg-2) and the event is properly handled dpg_created_update = vcenter_api_client.create_dpg(vmware_dpg_2) vmware_controller.handle_update(dpg_created_update) # User creates a VM (vm-1) in dpg-1 and the event properly handled vm_created_update = vcenter_api_client.create_vm(vmware_vm) vmware_controller.handle_update(vm_created_update) # VMI (esxi-1_dvs-1_dpg-1) should be created in VNC previous_vmi = vnc_test_client.read_vmi( models.generate_uuid("esxi-1_dvs-1_dpg-1")) assert previous_vmi is not None previous_vpg = vnc_test_client.read_vpg( models.generate_uuid("esxi-1_dvs-1")) assert previous_vpg # CVFM shuts down # User connects vm-1 to dpg-2 vcenter_api_client.add_interface(vmware_vm, vmware_dpg_2) # CVFM starts up - sync vmware_controller.sync() # VPG (esxi-1_dvs-1) should stay the same in VNC current_vpg = vnc_test_client.read_vpg( models.generate_uuid("esxi-1_dvs-1")) assert utils.not_deleted_from_vnc(previous_vpg, current_vpg) # VMI (esxi-1_dvs-1_dpg-2) should be created in VNC and should be # attached to VPG (esxi-1_dvs-1) created_vmi = vnc_test_client.read_vmi( models.generate_uuid("esxi-1_dvs-1_dpg-2")) utils.verify_vnc_vmi( created_vmi, vmi_name="esxi-1_dvs-1_dpg-2", vpg_name="esxi-1_dvs-1", vn_name="dvs-1_dpg-2", vlan=6, )
def test_to_vnc_vn(project): dpg_model = models.DistributedPortGroupModel( uuid=models.generate_uuid("dvportgroup-1"), key="dvportgroup-1", name="dpg-1", dvs_name="dvs-1", vlan_id=5, ) vnc_vn = dpg_model.to_vnc_vn(project) assert vnc_vn.name == "dvs-1_dpg-1" assert vnc_vn.uuid == models.generate_uuid("dvportgroup-1") assert vnc_vn.parent_name == project.name assert vnc_vn.get_id_perms().get_creator() == "vcenter-fabric-manager"
def test_update_pis( minimalistic_topology, vmware_controller, vcenter_api_client, vnc_test_client, vmware_dpg, vmware_vm, ): # User creates a DPG (dpg-1) and the event is properly handled dpg_created_update = vcenter_api_client.create_dpg(vmware_dpg) vmware_controller.handle_update(dpg_created_update) # dpg-1 should be created in VNC created_vn = vnc_test_client.read_vn(models.generate_uuid(vmware_dpg.key)) assert created_vn is not None # User creates a VM (vm-1) in dpg-1 and the event properly handled vm_created_update = vcenter_api_client.create_vm(vmware_vm) vmware_controller.handle_update(vm_created_update) # VPG (esxi-1_dvs-1) should be created in VNC and connected to the # existing PI previous_vpg = vnc_test_client.read_vpg( models.generate_uuid("esxi-1_dvs-1")) utils.verify_vnc_vpg(previous_vpg, pi_names=["xe-0/0/0"]) # CVFM shuts down # The topology changes - existing PI's port is now connected to dvs-2 # Another PI and Port is created for esxi-1 - dvs-1 connection existing_pi_uuid = vnc_test_client.read_all_physical_interface_uuids()[0] existing_pi = vnc_test_client.read_physical_interface(existing_pi_uuid) existing_port_uuid = existing_pi.get_port_refs()[0]["uuid"] vnc_test_client.update_ports_dvs_name(existing_port_uuid, "dvs-2") pr = vnc_test_client.read_physical_router(existing_pi.parent_uuid) new_pi = vnc_test_client.create_physical_interface("xe-0/0/1", "11:22:33:44:55:04", pr) existing_port = vnc_test_client.read_port(existing_port_uuid) node = vnc_test_client.read_node(existing_port.parent_uuid) new_port = vnc_test_client.create_port("eth1", "11:22:33:44:55:03", node, "dvs-1") vnc_test_client.add_port_to_physical_interface(new_pi, new_port) # CVFM starts up - sync vmware_controller.sync() # VPG should be updated in VNC with the new PI current_vpg = vnc_test_client.read_vpg(previous_vpg.uuid) utils.verify_vnc_vpg(current_vpg, pi_names=["xe-0/0/1"])
def test_create_vpg_models(vpg_service, vm_model): vpg_models = vpg_service.create_vpg_models(vm_model) assert len(vpg_models) == 1 assert vpg_models[0].uuid == models.generate_uuid("esxi-1_dvs-1") assert vpg_models[0].host_name == "esxi-1" assert vpg_models[0].dvs_name == "dvs-1"
def create_fabric_network(vnc_test_client, vn_name, vn_key): project = vnc_test_client.vnc_lib.project_read( ["default-domain", vnc_test_client.project_name]) fab_vn = vnc_api.VirtualNetwork(name=vn_name, parent_obj=project) fab_vn.set_uuid(models.generate_uuid(vn_key)) vnc_test_client.vnc_lib.virtual_network_create(fab_vn) return vnc_test_client.vnc_lib.virtual_network_read(id=fab_vn.uuid)
def test_update_dpg_in_vm_models(vm_service, vm_model, vm_model_2, database): database.add_vm_model(vm_model) database.add_vm_model(vm_model_2) assert len(vm_model.dpg_models) == 1 assert len(vm_model_2.dpg_models) == 1 dpg_model = list(vm_model.dpg_models)[0] assert dpg_model.vlan_id == 5 dpg_model = list(vm_model_2.dpg_models)[0] assert dpg_model.vlan_id == 15 dpg_model = models.DistributedPortGroupModel( models.generate_uuid("dvportgroup-1"), "dvportgroup-1", "dpg-1", 6, "dvs-1", ) vm_service.update_dpg_in_vm_models(dpg_model) dpg_model = list(vm_model.dpg_models)[0] assert dpg_model.vlan_id == 6 dpg_model = list(vm_model_2.dpg_models)[0] assert dpg_model.vlan_id == 15
def test_from_vm_model(vm_model): vpg_models = models.VirtualPortGroupModel.from_vm_model(vm_model) assert vpg_models[0].uuid == models.generate_uuid("esxi-1_dvs-1") assert vpg_models[0].name == "esxi-1_dvs-1" assert vpg_models[0].host_name == "esxi-1" assert vpg_models[0].dvs_name == "dvs-1"
def vmi_2(project): vmi = vnc_api.VirtualMachineInterface( name="esxi-1_dvs-1_dpg-2", parent_obj=project ) vmi.set_uuid(models.generate_uuid(vmi.name)) vmi.set_id_perms(constants.ID_PERMS) return vmi
def test_has_interface_in_dpg(vm_model): dpg_model_1 = models.DistributedPortGroupModel( models.generate_uuid("dvportgroup-1"), "dvportgroup-1", "dpg-1", 5, "dvs-1", ) assert vm_model.has_interface_in_dpg(dpg_model_1) dpg_model_2 = models.DistributedPortGroupModel( models.generate_uuid("dvportgroup-2"), "dvportgroup-2", "dpg-2", 6, "dvs-1", ) assert not vm_model.has_interface_in_dpg(dpg_model_2)
def test_esxi_changed( topology_with_two_nodes, vmware_vm_1, vmware_vm_2, vmware_dpg, vmware_controller, vnc_test_client, vcenter_api_client, ): # User creates a DPG (dpg-1) on dvs-1 dpg_created_update = vcenter_api_client.create_dpg(vmware_dpg) vmware_controller.handle_update(dpg_created_update) # User creates a VM (vm-1) with one interface connected to dpg-1 vm_created_update_1 = vcenter_api_client.create_vm(vmware_vm_1) vmware_controller.handle_update(vm_created_update_1) # A VMI and VPG is created in VNC for dpg-1 on dvs-1 on esxi-1 vnc_vpg_1 = vnc_test_client.read_vpg(models.generate_uuid("esxi-1_dvs-1")) vnc_vmi_1 = vnc_test_client.read_vmi( models.generate_uuid("esxi-1_dvs-1_dpg-1")) assert vnc_vpg_1 is not None assert vnc_vmi_1 is not None # User creates a second VM (vm-2) with one interface connected to dpg-1 vm_created_update_2 = vcenter_api_client.create_vm(vmware_vm_2) vmware_controller.handle_update(vm_created_update_2) # The first VM (vm-1) is moved to esxi-2, where no other VM exists vm_moved_update = vcenter_api_client.change_host(vmware_vm_1, "esxi-2") vmware_controller.handle_update(vm_moved_update) # A VMI is created in VNC for dpg-1 on dvs-1 on esxi-2 # and is connected to a new VPG for dvs-1 on esxi-2 vnc_vpg_2 = vnc_test_client.read_vpg(models.generate_uuid("esxi-2_dvs-1")) vnc_vmi_2 = vnc_test_client.read_vmi( models.generate_uuid("esxi-2_dvs-1_dpg-1")) assert vnc_vpg_2 is not None assert vnc_vmi_2 is not None # The old VMI and VPG on esxi-1 still exists due to vm-2 existing on esxi-1 vnc_vpg_1 = vnc_test_client.read_vpg(models.generate_uuid("esxi-1_dvs-1")) vnc_vmi_1 = vnc_test_client.read_vmi( models.generate_uuid("esxi-1_dvs-1_dpg-1")) assert vnc_vpg_1 is not None assert vnc_vmi_1 is not None # The second VM (vm-2) is moved to esxi-2 vm_moved_update = vcenter_api_client.change_host(vmware_vm_2, "esxi-2") vmware_controller.handle_update(vm_moved_update) # esxi-1 is empty, so the old VMI and VPG are removed with pytest.raises(vnc_api.NoIdError): vnc_test_client.read_vmi(models.generate_uuid("esxi-1_dvs-1_dpg-1")) with pytest.raises(vnc_api.NoIdError): vnc_test_client.read_vpg(models.generate_uuid("esxi-1_dvs-1"))
def test_from_vmware_dpg(vmware_dpg): dpg_model = models.DistributedPortGroupModel.from_vmware_dpg(vmware_dpg) assert dpg_model.name == "dpg-1" assert dpg_model.key == "dvportgroup-1" assert dpg_model.uuid == models.generate_uuid("dvportgroup-1") assert dpg_model.vlan_id == 5 assert dpg_model.dvs_name == "dvs-1"
def test_pi_no_port_conn( topology_with_two_nodes, vmware_controller, vcenter_api_client, vnc_test_client, vmware_vm_1, vmware_vm_2, vmware_dpg, ): # There is a portgroup in vCenter (dpg-1) vcenter_api_client.create_dpg(vmware_dpg) # There are two VMs on two different ESXis (vm-1 and vm-2), connected to # dpg-1 vcenter_api_client.create_vm(vmware_vm_1) vcenter_api_client.create_vm(vmware_vm_2) # PI of esxi-2 is not connected to the port pi = [ pi for pi in vnc_test_client.read_all_physical_interfaces() if pi.name == "xe-0/0/2" ][0] vnc_test_client.remove_ports_from_physical_interface(pi) # Synchronization starts vmware_controller.sync() # The sync process should be successful for vm-1 and unsuccessful for vm-2 created_vpg = vnc_test_client.read_vpg( models.generate_uuid("esxi-1_dvs-1")) assert created_vpg is not None created_vmi = vnc_test_client.read_vmi( models.generate_uuid("esxi-1_dvs-1_dpg-1")) utils.verify_vnc_vmi( created_vmi, vmi_name="esxi-1_dvs-1_dpg-1", vpg_name="esxi-1_dvs-1", vn_name="dvs-1_dpg-1", vlan=5, ) with pytest.raises(vnc_api.NoIdError): vnc_test_client.read_vpg(models.generate_uuid("esxi-2_dvs-1")) with pytest.raises(vnc_api.NoIdError): vnc_test_client.read_vmi(models.generate_uuid("esxi-2_dvs-1-dpg-1"))
def dpg_model(): return models.DistributedPortGroupModel( uuid=models.generate_uuid("dvportgroup-1"), key="dvportgroup-1", name="dpg-1", vlan_id=5, dvs_name="dvs-1", )
def test_to_vnc_vmi(vmware_dpg, project, fabric_vn): dpg_model = models.DistributedPortGroupModel.from_vmware_dpg(vmware_dpg) vmi_model = models.VirtualMachineInterfaceModel( uuid=models.generate_uuid("esxi-1_dvs-1_dpg-1"), host_name="esxi-1", dpg_model=dpg_model, ) vnc_vmi = vmi_model.to_vnc_vmi(project, fabric_vn) assert vnc_vmi.uuid == models.generate_uuid("esxi-1_dvs-1_dpg-1") assert vnc_vmi.name == "esxi-1_dvs-1_dpg-1" assert vnc_vmi.parent_name == project.name assert len(vnc_vmi.virtual_network_refs) == 1 assert vnc_vmi.virtual_network_refs[0]["uuid"] == dpg_model.uuid assert (vnc_vmi.virtual_machine_interface_properties.sub_interface_vlan_tag == 5) assert vnc_vmi.get_id_perms().get_creator() == "vcenter-fabric-manager"
def vmi_1(project): vmi = vnc_api.VirtualMachineInterface(name="esxi-1_dvs-1_dpg-1", parent_obj=project) vmi.set_uuid(models.generate_uuid(vmi.name)) vmi.set_id_perms(constants.ID_PERMS) vmi_properties = vnc_api.VirtualMachineInterfacePropertiesType( sub_interface_vlan_tag=5) vmi.set_virtual_machine_interface_properties(vmi_properties) return vmi
def test_no_fabric_vn(vmware_dpg, project): dpg_model = models.DistributedPortGroupModel.from_vmware_dpg(vmware_dpg) vmi_model = models.VirtualMachineInterfaceModel( uuid=models.generate_uuid("esxi-1_dvs-1_dpg-1"), host_name="esxi-1", dpg_model=dpg_model, ) with pytest.raises(VNCVMICreationError): vmi_model.to_vnc_vmi(project, None)
def test_sync_delete(vmi_synchronizer, vm_service, vmi_service, vm_model): vm_service.get_all_vm_models.return_value = [vm_model] vmi_service.read_all_vmis.return_value = [ mock.Mock(uuid="non-existent-vmi-uuid"), mock.Mock(uuid=models.generate_uuid("esxi-1_dvs-1_dpg-1")), ] vmi_model = models.VirtualMachineInterfaceModel.from_vm_model(vm_model) vmi_service.create_vmi_models_for_vm.return_value = vmi_model vmi_synchronizer.sync_delete() vmi_service.delete_vmi.assert_called_once_with("non-existent-vmi-uuid")
def test_create_dpg_model_with_vpg_creation_in_vnc(vpg_service, vnc_api_client, pi_model, fabric): vnc_api_client.read_vpg.return_value = None vnc_api_client.read_fabric.return_value = fabric vpg_model = models.VirtualPortGroupModel( models.generate_uuid("esxi-1_dvs-1"), "esxi-1", "dvs-1") vpg_service.create_vpg_in_vnc(vpg_model, [pi_model]) vnc_api_client.read_vpg.assert_called_once() vnc_api_client.read_fabric.assert_called_once_with(pi_model.fabric_uuid) vnc_api_client.create_vpg.assert_called_once()
def test_create_dpg_model_without_vpg_creation_in_vnc(vpg_service, vnc_api_client, pi_model): vpg_mock = mock.Mock() vpg_mock.get_physical_interface_refs.return_value = [] vnc_api_client.read_vpg.return_value = vpg_mock vpg_model = models.VirtualPortGroupModel( models.generate_uuid("esxi-1_dvs-1"), "esxi-1", "dvs-1") vpg_service.create_vpg_in_vnc(vpg_model, [pi_model]) vnc_api_client.read_vpg.assert_called_once() vnc_api_client.create_vpg.assert_not_called()
def test_find_affected_vmis(vmi_service, vmware_vm, dpg_model): dpg_model_2 = models.DistributedPortGroupModel( uuid=models.generate_uuid("dvs-1_dpg-2"), key="dvportgroup-2", name="dpg-2", vlan_id=6, dvs_name="dvs-1", ) old_vm_model = models.VirtualMachineModel.from_vmware_vm( vmware_vm, {dpg_model}) new_vm_model = models.VirtualMachineModel.from_vmware_vm( vmware_vm, {dpg_model_2}) vmis_to_delete_2, vmis_to_create_2 = vmi_service.find_affected_vmis( old_vm_model, new_vm_model) assert len(vmis_to_delete_2) == 1 assert len(vmis_to_create_2) == 1 assert list(vmis_to_delete_2)[0].uuid == models.generate_uuid( "esxi-1_dvs-1_dpg-1") assert list(vmis_to_create_2)[0].uuid == models.generate_uuid( "esxi-1_dvs-1_dpg-2")
def test_two_vms_two_pgs( minimalistic_topology, vmware_controller, vcenter_api_client, vnc_test_client, vmware_vm_1, vmware_vm_3, vmware_dpg_1, vmware_dpg_2, ): dpg_created_update = vcenter_api_client.create_dpg(vmware_dpg_1) vmware_controller.handle_update(dpg_created_update) dpg_created_update = vcenter_api_client.create_dpg(vmware_dpg_2) vmware_controller.handle_update(dpg_created_update) vm_created_update_1 = vcenter_api_client.create_vm(vmware_vm_1) vmware_controller.handle_update(vm_created_update_1) vm_created_update_2 = vcenter_api_client.create_vm(vmware_vm_3) vmware_controller.handle_update(vm_created_update_2) vnc_vpg = vnc_test_client.read_vpg(models.generate_uuid("esxi-1_dvs-1")) vnc_vmi_1 = vnc_test_client.read_vmi( models.generate_uuid("esxi-1_dvs-1_dpg-1")) vnc_vmi_2 = vnc_test_client.read_vmi( models.generate_uuid("esxi-1_dvs-1_dpg-2")) assert vnc_vpg is not None assert vnc_vmi_1 is not None assert vnc_vmi_2 is not None vm_removed_update = vcenter_api_client.remove_vm(vmware_vm_1) vmware_controller.handle_update(vm_removed_update) vpg = vnc_test_client.read_vpg(vnc_vpg.uuid) with pytest.raises(vnc_api.NoIdError): vnc_test_client.read_vmi(vnc_vmi_1.uuid) vmi_2 = vnc_test_client.read_vmi(vnc_vmi_2.uuid) assert vpg is not None assert vmi_2 is not None
def test_attach_dpg(vm_model): dpg_model = models.DistributedPortGroupModel( models.generate_uuid("dvportgroup-2"), "dvportgroup-2", "dpg-2", 6, "dvs-1", ) vm_model.attach_dpg(dpg_model) assert len(vm_model.dpg_models) == 2 assert sorted(dpg.name for dpg in vm_model.dpg_models) == [ "dpg-1", "dpg-2", ]
def test_dpg_created( minimalistic_topology, vnc_test_client, vmware_controller, vcenter_api_client, vmware_dpg, ): dpg_created_update = vcenter_api_client.create_dpg(vmware_dpg) vmware_controller.handle_update(dpg_created_update) created_vn = vnc_test_client.read_vn(models.generate_uuid("dvportgroup-1")) assert created_vn is not None assert created_vn.name == "dvs-1_dpg-1"
def test_empty_dpg_destroyed( minimalistic_topology, vnc_test_client, vmware_controller, vcenter_api_client, vmware_dpg, ): dpg_created_update = vcenter_api_client.create_dpg(vmware_dpg) vmware_controller.handle_update(dpg_created_update) vn_uuid = models.generate_uuid("dvportgroup-1") assert vnc_test_client.read_vn(vn_uuid) is not None dpg_destroyed_update = vcenter_api_client.destroy_dpg(vmware_dpg) vmware_controller.handle_update(dpg_destroyed_update) with pytest.raises(vnc_api.NoIdError): vnc_test_client.read_vn(vn_uuid)
def test_dpg_sync_delete( minimalistic_topology, vmware_controller, vcenter_api_client, vnc_test_client, vmware_dpg_1, ): # User creates a DPG (dpg-1) and the event is properly handled dpg_created_update = vcenter_api_client.create_dpg(vmware_dpg_1) vmware_controller.handle_update(dpg_created_update) # CVFM shuts down # User deletes dpg-1 and the event is not handled vcenter_api_client.destroy_dpg(vmware_dpg_1) # CVFM starts up - sync vmware_controller.sync() # dpg-1 should be deleted in VNC with pytest.raises(vnc_api.NoIdError): vnc_test_client.read_vn(models.generate_uuid(vmware_dpg_1.key))