def vms_up_on_same_host(system, default_cluster, cirros_template, port_isolation_network, ovirtmgmt_vnic_profile): """ Since the isolated_network is set up only on one host, both virtual machines will be on the same host. """ with virtlib.vm_pool(system, size=2) as (vm_0, vm_1): vms = [(vm_0, VM0_NAME), (vm_1, VM1_NAME)] for vm, name in vms: vm.create(vm_name=name, cluster=default_cluster, template=cirros_template) vm_vnic0 = netlib.Vnic(vm) vm_vnic0.create( name=VNIC0_NAME, vnic_profile=ovirtmgmt_vnic_profile, ) vm_vnic1 = netlib.Vnic(vm) vm_vnic1.create( name=VNIC1_NAME, vnic_profile=port_isolation_network.vnic_profile(), ) vm.wait_for_down_status() vm.run_once(cloud_init_hostname=name) vm_0.wait_for_up_status() vm_1.wait_for_up_status() joblib.AllJobs(system).wait_for_done() yield
def vms_up_on_host_1( system, default_cluster, cirros_template, port_isolation_network, ovirtmgmt_vnic_profile, cirros_serial_console, vms_conf, ): """ Since the isolated_network is set up only on host_1, both virtual machines will be on it. """ with virtlib.vm_pool(system, size=2) as (vm_0, vm_1): for i, vm in enumerate([vm_0, vm_1]): vm.create(vm_name=vms_conf[i].name, cluster=default_cluster, template=cirros_template) vm_vnic0 = netlib.Vnic(vm) vm_vnic0.create(name=vms_conf[i].mgmt_iface.name, vnic_profile=ovirtmgmt_vnic_profile) vm_vnic1 = netlib.Vnic(vm) vm_vnic1.create(name=vms_conf[i].isolated_iface.name, vnic_profile=port_isolation_network.vnic_profile()) vm.wait_for_down_status() vm.run_once(cloud_init_hostname=vms_conf[i].name) vm_0.wait_for_up_status() vm_1.wait_for_up_status() joblib.AllJobs(system).wait_for_done() for vm in (vm_0, vm_1): ip_a = cirros_serial_console.shell(vm.id, ('ip addr', )) LOGGER.debug(f'before applying ips: vm={vm.name} has ip_a={ip_a}') yield vm_0, vm_1
def vnic_attached_to_ovn_network(system, vm_in_ovs_cluster_down, ovn_physnet_small_mtu): vnic_profile = netlib.VnicProfile(system) vnic_profile.import_by_name(ovn_physnet_small_mtu.name) vm_vnic = netlib.Vnic(vm_in_ovs_cluster_down) vm_vnic.create(name=VNIC0_NAME, vnic_profile=vnic_profile) return vm_vnic
def running_vm_0( ovirt_external_network, system, default_cluster, default_storage_domain, cirros_template, ): cluster_network = clusterlib.ClusterNetwork(default_cluster) cluster_network.assign(ovirt_external_network) with virtlib.vm_pool(system, size=1) as (vm_0, ): vm_0.create(vm_name=VM0_NAME, cluster=default_cluster, template=cirros_template) vnic_profile0 = ovirt_external_network.vnic_profile() vm0_vnic_0 = netlib.Vnic(vm_0) vm0_vnic_0.create(name=VNIC0_NAME, vnic_profile=vnic_profile0, mac_addr=VNIC0_MAC) vm_0.wait_for_down_status() vm_0.run() vm_0.wait_for_up_status() joblib.AllJobs(system).wait_for_done() yield vm_0
def test_hot_update_vm_interface(running_vm_0, ovirtmgmt_vnic_profile): vnic = netlib.Vnic(running_vm_0) vnic.create(name=NIC2_NAME, vnic_profile=netlib.EmptyVnicProfile()) assert not vnic.vnic_profile.id vnic.vnic_profile = ovirtmgmt_vnic_profile assert vnic.vnic_profile.name == ovirtmgmt_vnic_profile.name vnic.vnic_profile = netlib.EmptyVnicProfile() assert not vnic.vnic_profile.id
def vnics(self): for nic_service in self._service.nics_service().list(): vnic = netlib.Vnic(self) vnic.import_by_id(nic_service.id) yield vnic
def get_vnic(self, vnic_name): vnic = netlib.Vnic(self) vnic.import_by_name(vnic_name) return vnic
def create_vnic(self, vnic_name, vnic_profile, mac_addr=None): vnic = netlib.Vnic(self) vnic.create(name=vnic_name, vnic_profile=vnic_profile, mac_addr=mac_addr) return vnic
def _attach_new_vnic(vm, vnic_profile): vnic = netlib.Vnic(vm) vnic.create(name=NIC1_NAME, vnic_profile=vnic_profile) vm.wait_for_down_status()
def test_vnic_cannot_connect_physical_network(vm_in_ovs_cluster_down, ovirtmgmt_vnic_profile): vnic = netlib.Vnic(vm_in_ovs_cluster_down) with pytest.raises(sdkentity.EntityCreationError, match=EXTERNAL_NETWORK): vnic.create(name=VNIC_INTERNAL, vnic_profile=ovirtmgmt_vnic_profile)