cfme.utils.net module

cfme.utils.net.ip_echo_socket(port=32123)[source]

A simple socket server, for use with my_ip_address()

cfme.utils.net.is_pingable(ip_addr)[source]

verifies the specified ip_address is reachable or not.

Parameters:ip_addr – ip_address to verify the PING.

returns: return True is ip_address is pinging else returns False.

cfme.utils.net.my_ip_address(http=False)[source]

Get the ip address of the host running tests using the service listed in cfme_data[‘ip_echo’]

The ip echo endpoint is expected to write the ip address to the socket and close the connection. See a working example of this in ip_echo_socket().

cfme.utils.net.net_check(port, addr=None, force=False)[source]

Checks the availablility of a port

cfme.utils.net.net_check_remote(port, addr=None, machine_addr=None, ssh_creds=None, force=False)[source]

Checks the availability of a port from outside using another machine (over SSH)

cfme.utils.net.random_port(tcp=True)[source]

Get a random port number for making a socket

Parameters:tcp – Return a TCP port number if True, UDP if False

This may not be reliable at all due to an inherent race condition. This works by creating a socket on an ephemeral port, inspecting it to see what port was used, closing it, and returning that port number. In the time between closing the socket and opening a new one, it’s possible for the OS to reopen that port for another purpose.

In practical testing, this race condition did not result in a failure to (re)open the returned port number, making this solution squarely “good enough for now”.

cfme.utils.net.resolve_hostname(hostname, force=False)[source]

Cached DNS resolver. If the hostname does not resolve to an IP, returns None.

cfme.utils.net.resolve_ips(host_iterable, force_dns=False)[source]

Takes list of hostnames, ips and another things. If the item is not an IP, it will be tried to be converted to an IP. If that succeeds, it is appended to the set together with original hostname. If it can’t be resolved, just the original hostname is appended.