def test_security_groups_allow_icmp(system, ovs_cluster, host_in_ovs_cluster,
                                    host_0, host_1,
                                    default_ovn_provider_client,
                                    ovn_physnet_small_mtu,
                                    vm_in_ovn_network_up,
                                    vnic_attached_to_ovn_network):
    other_host = _other_host(host_in_ovs_cluster, [host_0, host_1])
    syncutil.sync(exec_func=_ping_successful,
                  exec_func_args=(other_host.address, other_host.root_password,
                                  VM0_NAME, MAX_ICMP_DATA_SIZE),
                  success_criteria=lambda success: success)

    with _enable_port_security(vnic_attached_to_ovn_network,
                               default_ovn_provider_client):
        with pytest.raises(PingFailed, match=r'status code 1'):
            ssh_ping(other_host.address,
                     other_host.root_password,
                     VM0_NAME,
                     data_size=MAX_ICMP_DATA_SIZE)

        with _allow_icmp_from_host(other_host):
            syncutil.sync(exec_func=_ping_successful,
                          exec_func_args=(other_host.address,
                                          other_host.root_password, VM0_NAME,
                                          MAX_ICMP_DATA_SIZE),
                          success_criteria=lambda success: success)
def test_security_groups_allow_icmp(
    system,
    ovs_cluster,
    host_not_in_ovs_cluster,
    ssh_host_not_in_ovs_cluster,
    default_ovn_provider_client,
    ovn_physnet_small_mtu,
    vm_in_ovn_network_up,
    vnic_attached_to_ovn_network,
    target,
    af,
    ansible_private_dir,
):
    syncutil.sync(
        exec_func=ssh_host_not_in_ovs_cluster.ping_successful,
        exec_func_args=(target, af.version, _max_icmp_data_size(af.family)),
        success_criteria=lambda success: success,
    )

    with _enable_port_security(vnic_attached_to_ovn_network, default_ovn_provider_client):
        time.sleep(10)
        ssh_host_not_in_ovs_cluster.assert_no_ping(target, af.version, _max_icmp_data_size(af.family))

        with _allow_icmp_from_host(host_not_in_ovs_cluster, af.version, ansible_private_dir):
            syncutil.sync(
                exec_func=ssh_host_not_in_ovs_cluster.ping_successful,
                exec_func_args=(target, af.version, _max_icmp_data_size(af.family)),
                success_criteria=lambda success: success,
            )
def _wait_for_running_vm(serial_vmconsole, vm_id):
    syncutil.sync(
        exec_func=serial_vmconsole.can_log_in,
        exec_func_args=(vm_id, ),
        success_criteria=lambda logged_in: logged_in,
        retry_interval=20,
    )
Example #4
0
def test_bond_active_slave(system, default_data_center, default_cluster,
                           host_0_up):
    bond_data = netattachlib.ActiveSlaveBonding(
        BOND_NAME, slave_names=(SLAVE1, SLAVE2)
    )
    with hostlib.setup_networks(host_0_up, bonding_data=(bond_data,)):
        bond = hostlib.Bond(host_0_up)
        bond.import_by_name(BOND_NAME)
        bond.wait_for_up_status()
        initial_active_slave = bond.active_slave
        inactive_slave = bond.inactive_slaves[0]
        sshlib.Node(
            host_0_up.address, host_0_up.root_password
        ).change_active_slave(BOND_NAME, inactive_slave.name)
        try:
            syncutil.sync(
                exec_func=lambda: bond.active_slave,
                exec_func_args=(),
                success_criteria=lambda active_slave:
                    active_slave.id != initial_active_slave.id,
                timeout=10
            )
        except syncutil.Timeout:
            raise ActiveSlaveNotChangedError(
                'active slave: {} initial active slave: {}'.format(
                    bond.active_slave.name, initial_active_slave.name
                )
            )
def test_security_groups_allow_icmp(system, ovs_cluster, host_in_ovs_cluster,
                                    host_0, host_1,
                                    default_ovn_provider_client,
                                    ovn_physnet_small_mtu,
                                    vm_in_ovn_network_up,
                                    vnic_attached_to_ovn_network):
    other_host = _other_host(host_in_ovs_cluster, [host_0, host_1])
    syncutil.sync(exec_func=_ping_successful,
                  exec_func_args=(
                      other_host.address,
                      other_host.root_password,
                      VM0_NAME,
                      MAX_ICMP_DATA_SIZE
                  ),
                  success_criteria=lambda success: success)

    with _enable_port_security(vnic_attached_to_ovn_network,
                               default_ovn_provider_client):
        with pytest.raises(PingFailed, match=r'status code 1'):
            ssh_ping(other_host.address,
                     other_host.root_password,
                     VM0_NAME,
                     data_size=MAX_ICMP_DATA_SIZE)

        with _allow_icmp_from_host(other_host):
            syncutil.sync(exec_func=_ping_successful,
                          exec_func_args=(
                              other_host.address,
                              other_host.root_password,
                              VM0_NAME,
                              MAX_ICMP_DATA_SIZE
                          ),
                          success_criteria=lambda success: success)
Example #6
0
 def deactivate(self):
     self.wait_for_up_status()
     syncutil.sync(exec_func=self._service.deactivate,
                   exec_func_args=(),
                   timeout=3 * 60,
                   error_criteria=Host._is_error_non_transient)
     self.wait_for_maintenance_status()
Example #7
0
 def wait_for_done(self):
     self._report_started()
     self._report_ill_fated()
     syncutil.sync(exec_func=lambda: self.done,
                   exec_func_args=(),
                   success_criteria=lambda done: done)
     self._report_started()
     self._report_ill_fated()
def test_max_mtu_size(
    system, ovs_cluster, ssh_host_not_in_ovs_cluster, ovn_physnet_small_mtu, vm_in_ovn_network_up, target, af
):
    syncutil.sync(
        exec_func=ssh_host_not_in_ovs_cluster.ping_successful,
        exec_func_args=(target, af.version, _max_icmp_data_size(af.family)),
        success_criteria=lambda success: success,
    )
Example #9
0
 def wait_until_available(self):
     syncutil.sync(
         exec_func=lambda: self.is_provider_available(
             self.get_sdk_type().name
         ),
         exec_func_args=(),
         success_criteria=lambda s: s
     )
Example #10
0
 def deactivate(self):
     self.wait_for_up_status()
     syncutil.sync(
         exec_func=self._service.deactivate,
         exec_func_args=(),
         timeout=3 * 60,
         error_criteria=Host._is_error_non_transient
     )
     self.wait_for_maintenance_status()
def test_connect_vm_to_external_physnet(system, ovs_cluster,
                                        host_in_ovs_cluster, host_0, host_1,
                                        vm_in_ovn_network_up):
    other_host = _other_host(host_in_ovs_cluster, [host_0, host_1])

    syncutil.sync(exec_func=_ping_successful,
                  exec_func_args=(other_host.address, other_host.root_password,
                                  VM0_NAME, MAX_ICMP_DATA_SIZE),
                  success_criteria=lambda success: success)
Example #12
0
def ovirt_engine_service_up(ovirt_engine_setup, engine_facts,
                            engine_full_username, engine_password):
    syncutil.sync(exec_func=_create_engine_connection,
                  exec_func_args=(engine_facts.ipv4_default_address,
                                  engine_full_username,
                                  engine_password),
                  success_criteria=lambda api: isinstance(api, Connection),
                  timeout=10*60)
    yield
Example #13
0
 def activate(self):
     syncutil.sync(exec_func=self._service.activate,
                   exec_func_args=(),
                   success_criteria=lambda s: self.is_up,
                   error_criteria=lambda e: error.is_not_ovirt_or_unlisted(
                       e, [
                           'Related operation is currently in progress',
                           'Cannot activate Host. Host in Up status',
                       ]),
                   timeout=3 * 60)
     joblib.AllJobs(self.system).wait_for_done()
Example #14
0
 def force_select_spm(self):
     syncutil.sync(
         exec_func=self.service.force_select_spm,
         exec_func_args=(),
         success_criteria=lambda r: self.is_spm,
         error_criteria=lambda e: error.
         is_not_ovirt_or_unlisted(e, [
             'Cannot force select SPM. The Storage Pool has running tasks',
             'Cannot force select SPM. Unknown Data Center status',
             'is already SPM or contending',
         ]))
Example #15
0
 def deactivate(self):
     syncutil.sync(exec_func=self._service.deactivate,
                   exec_func_args=(),
                   timeout=3 * 60,
                   success_criteria=lambda s: self.is_in_maintenance,
                   error_criteria=lambda e: error.is_not_ovirt_or_unlisted(
                       e, [
                           'Host has asynchronous running tasks',
                           'Host is contending',
                           'Host is already in Maintenance mode',
                       ]))
     joblib.AllJobs(self.system).wait_for_done()
def test_connect_vm_to_external_physnet(system, ovs_cluster,
                                        host_in_ovs_cluster, host_0, host_1,
                                        vm_in_ovn_network_up):
        other_host = _other_host(host_in_ovs_cluster, [host_0, host_1])

        syncutil.sync(exec_func=_ping_successful,
                      exec_func_args=(
                          other_host.address,
                          other_host.root_password,
                          VM0_NAME,
                          MAX_ICMP_DATA_SIZE
                      ),
                      success_criteria=lambda success: success)
def test_max_mtu_size(system, ovs_cluster, host_in_ovs_cluster, host_0, host_1,
                      ovn_physnet_small_mtu, vm_in_ovn_network_up):
    other_host = _other_host(host_in_ovs_cluster, [host_0, host_1])

    syncutil.sync(exec_func=_ping_successful,
                  exec_func_args=(other_host.address, other_host.root_password,
                                  VM0_NAME, MAX_ICMP_DATA_SIZE),
                  success_criteria=lambda success: success)

    with pytest.raises(PingFailed, match=r'status code 1'):
        ssh_ping(other_host.address,
                 other_host.root_password,
                 VM0_NAME,
                 data_size=MAX_ICMP_DATA_SIZE + 1)
Example #18
0
 def change_cluster(self, cluster):
     spm_before_deactivate = self.is_spm
     self.deactivate()
     syncutil.sync(exec_func=self.update,
                   exec_func_args={'cluster': cluster.get_sdk_type()},
                   success_criteria=lambda sdk_type:
                   (hasattr(sdk_type, 'cluster') and sdk_type.cluster.id ==
                    cluster.id))
     self.activate()
     if spm_before_deactivate:
         # Deactivation removed SPM status from this host and caused the DC
         # to become Non Responsive. This is an unstable state.
         # Wait for stabilization indicated by DC state UP when either:
         # - another host becomes SPM after deactivating this host
         # - this host becomes SPM after its reactivation
         self._get_data_center().wait_for_up_status()
Example #19
0
 def update(self, **kwargs):
     return syncutil.sync(
         exec_func=super(Host, self).update,
         exec_func_args=kwargs,
         error_criteria=lambda e: error.
         is_not_ovirt_or_unlisted(e, [
             'Cannot edit Host. Related operation is currently in progress'
         ]))
Example #20
0
def engine(fqdn, env, artifacts_path):
    with suite.collect_artifacts(env, artifacts_path, 'pre-tests'):
        engine = env.get_vms()[ENGINE_DOMAIN]

        ANSWER_FILE_TMP = '/tmp/answer-file'

        engine.copy_to(ANSWER_FILE_SRC, ANSWER_FILE_TMP)
        engine.ssh(
            [
                'engine-setup',
                '--config-append={}'.format(ANSWER_FILE_TMP),
                '--accept-defaults',
            ]
        )
        syncutil.sync(exec_func=_get_engine_api,
                      exec_func_args=(engine,),
                      success_criteria=lambda api: isinstance(api, Connection))
        return engine
def test_max_mtu_size(system, ovs_cluster, host_in_ovs_cluster, host_0, host_1,
                      ovn_physnet_small_mtu, vm_in_ovn_network_up):
    other_host = _other_host(host_in_ovs_cluster, [host_0, host_1])

    syncutil.sync(exec_func=_ping_successful,
                  exec_func_args=(
                      other_host.address,
                      other_host.root_password,
                      VM0_NAME,
                      MAX_ICMP_DATA_SIZE
                  ),
                  success_criteria=lambda success: success)

    with pytest.raises(PingFailed, match=r'status code 1'):
        ssh_ping(other_host.address,
                 other_host.root_password,
                 VM0_NAME,
                 data_size=MAX_ICMP_DATA_SIZE + 1)
Example #22
0
def engine(fqdn, env, artifacts_path):
    with suite.collect_artifacts(env, artifacts_path, 'pre-tests'):
        engine = env.get_vms()[ENGINE_DOMAIN]

        ANSWER_FILE_TMP = '/tmp/answer-file'

        engine.copy_to(ANSWER_FILE_SRC, ANSWER_FILE_TMP)
        engine.ssh(
            [
                'engine-setup',
                '--config-append={}'.format(ANSWER_FILE_TMP),
                '--accept-defaults',
            ]
        )

        syncutil.sync(exec_func=_get_engine_api,
                      exec_func_args=(engine,),
                      success_criteria=lambda api: isinstance(api, Connection),
                      timeout=10*60)
        yield engine
Example #23
0
def test_hotplug_multiple_vnics(running_cirros_vm):
    for i in range(10):
        for name in NIC_NAMES.values():
            vnic = running_cirros_vm.get_vnic(name)
            plugged = vnic.plugged
            LOGGER.debug(
                f'test hot {"unplug" if plugged else "plug"} multiple rounds: vnic {vnic.name}, round {i}'
            )
            if plugged:
                vnic.hotunplug()
            else:
                vnic.hotplug()
            syncutil.sync(
                exec_func=lambda: vnic.plugged,
                exec_func_args=(),
                success_criteria=lambda p: p is not plugged,
                delay_start=1,
                retry_interval=1,
                timeout=10,
            )
Example #24
0
 def lookup_ip_address_with_dns_query(self, hostname):
     """
     Wait for the ip address to update in the dns lookup
     :param hostname: str
     :return: ipv4 address as a string
     """
     return syncutil.sync(
         exec_func=self._lookup_ip_address_with_dns_query,
         exec_func_args=(hostname,),
         success_criteria=lambda ip: ip != '',
         timeout=TIMEOUT
     )
Example #25
0
def _enable_dynamic_ipv6(lago_host, nic_name):
    """
    this function connects to the specified lago VM using its ssh API to:
    * request the host OS to dynamically assign an ipv6 address to the
      specified NIC
    * wait for the address to be assigned (it might take up to a few seconds)
    * retrieve the address
    :return: the ipv6 address as string
    :raise: timeout exception if global ipv6 address not found on NIC
    """
    _assign_ipv6(lago_host, nic_name)
    return syncutil.sync(exec_func=_get_ipv6,
                         exec_func_args=(lago_host, nic_name),
                         success_criteria=lambda ipv6: ipv6 != '',
                         timeout=10)
Example #26
0
def engine_storage_ipv6(engine):
    """
    lago creates a storage network with an ipv6 subnet and connects it to NIC
    eth1 of its VMs but does not assign an ip (v6) to the NIC.
    this function connects to the engine VM using its ssh API to:
    * assign an ipv6 address to the NIC
    * wait for the address to be assigned (it might take up to a few seconds)
    * retrieve the address
    :return: the ipv6 address as string
    :raise: timeout exception if global ipv6 address not found on NIC
    """
    STORAGE_NET_NIC_NAME = 'eth1'
    _assign_ipv6(engine, STORAGE_NET_NIC_NAME)
    return syncutil.sync(exec_func=_get_ipv6,
                         exec_func_args=(engine, STORAGE_NET_NIC_NAME),
                         success_criteria=lambda ipv6: ipv6 != '',
                         timeout=10)
Example #27
0
 def _sync_disk_attachment(self, disk_attachment_id):
     syncutil.sync(
         exec_func=self._is_disk_attachment_active,
         exec_func_args=(disk_attachment_id,),
         success_criteria=lambda s: s
     )
Example #28
0
 def wait_for_non_operational_status(self):
     NONOP = HostStatus.NON_OPERATIONAL
     syncutil.sync(exec_func=lambda: self.get_sdk_type().status,
                   exec_func_args=(),
                   success_criteria=lambda s: s == NONOP)
Example #29
0
 def wait_for_up_status(self, timeout=HOST_TIMEOUT_SHORT):
     syncutil.sync(exec_func=lambda: self.get_sdk_type().status,
                   exec_func_args=(),
                   success_criteria=self._host_up_status_success_criteria,
                   timeout=timeout)
Example #30
0
 def wait_for_up_status(self):
     syncutil.sync(exec_func=lambda: self.status,
                   exec_func_args=(),
                   success_criteria=lambda s: s == types.DiskStatus.OK)
Example #31
0
 def wait_for_maintenance_status(self):
     syncutil.sync(exec_func=lambda: self.get_sdk_type().status,
                   exec_func_args=(),
                   success_criteria=lambda s: s == HostStatus.MAINTENANCE)
Example #32
0
 def wait_for_preview_status(self):
     syncutil.sync(
         exec_func=lambda: self.get_sdk_type().snapshot_status,
         exec_func_args=(),
         success_criteria=lambda status: status == SnapshotStatus.IN_PREVIEW
     )
Example #33
0
 def _wait_for_status(self, status):
     syncutil.sync(exec_func=lambda: self.status,
                   exec_func_args=(),
                   success_criteria=lambda s: s == status)
Example #34
0
 def _sync_disk_attachment(self, disk_attachment_id):
     syncutil.sync(exec_func=self._is_disk_attachment_active,
                   exec_func_args=(disk_attachment_id, ),
                   success_criteria=lambda s: s)
Example #35
0
 def wait_for_preview_status(self):
     syncutil.sync(exec_func=lambda: self.get_sdk_type().snapshot_status,
                   exec_func_args=(),
                   success_criteria=lambda status: status == SnapshotStatus.
                   IN_PREVIEW)
Example #36
0
 def wait_until_empty(self):
     self._report_is_empty('before')
     syncutil.sync(exec_func=self.is_empty,
                   exec_func_args=(),
                   success_criteria=lambda empty: empty)
     self._report_is_empty('after')
Example #37
0
def wait_for_template_ok_status(system, template_name):
    syncutil.sync(exec_func=_get_template,
                  exec_func_args=(system.templates_service, template_name),
                  success_criteria=_check_template)
Example #38
0
 def wait_until_available(self):
     syncutil.sync(exec_func=lambda: self.is_provider_available(
         self.get_sdk_type().name),
                   exec_func_args=(),
                   success_criteria=lambda s: s)
Example #39
0
 def _wait_for_status(self, status):
     syncutil.sync(exec_func=lambda: self.status,
                   exec_func_args=(),
                   success_criteria=lambda s: s == status,
                   timeout=60 * 5)
Example #40
0
 def _wait_for_sd_status(self, sd, status):
     sd_service = self._sd_service(sd)
     syncutil.sync(exec_func=lambda: sd_service.get().status,
                   exec_func_args=(),
                   success_criteria=lambda s: s == status)
Example #41
0
 def deactivate_storage_domain_sync(self, sd):
     syncutil.sync(
         exec_func=self.deactivate_storage_domain,
         exec_func_args=(sd, ),
         error_criteria=error.sd_deactivation_error_not_due_to_busy)
Example #42
0
 def wait_for_ready_status(self):
     syncutil.sync(
         exec_func=lambda: self.get_sdk_type().snapshot_status,
         exec_func_args=(),
         success_criteria=lambda status: status == SnapshotStatus.READY
     )
Example #43
0
 def _wait_for_status(self, statuses):
     syncutil.sync(exec_func=lambda: self.status,
                   exec_func_args=(),
                   success_criteria=lambda s: s in statuses)
Example #44
0
 def wait_for_networks_out_of_sync(self, networks=None):
     syncutil.sync(exec_func=self.networks_out_of_sync,
                   exec_func_args=(networks,),
                   success_criteria=lambda s: s)
Example #45
0
 def wait_for_ready_status(self):
     syncutil.sync(
         exec_func=lambda: self.get_sdk_type().snapshot_status,
         exec_func_args=(),
         success_criteria=lambda status: status == SnapshotStatus.READY)
Example #46
0
 def destroy_sync(self):
     syncutil.sync(
         exec_func=self.destroy,
         exec_func_args=(),
         error_criteria=error.sd_destroy_error_not_due_to_busy)
Example #47
0
 def wait_for_snapshot_removal(self, snapshot_id):
     syncutil.sync(exec_func=self._is_snapshot_present,
                   exec_func_args=(),
                   success_criteria=lambda present: not present)
Example #48
0
 def wait_for_snapshot_removal(self, snapshot_id):
     syncutil.sync(
         exec_func=self._is_snapshot_present,
         exec_func_args=(),
         success_criteria=lambda present: not present
     )