Extract configure_host_network
Remote exec - separate connection checking

remote_exec was executing the script in a loop, thus if the script's
result value is non zero, it would have been executed many times. This
patch performs connection attempts in a loop, and executes the script
afterwards.
Fix: Configure host network before configuring nodes

If the node network is not connected to any physical networks, its
bridge might not exist if no vifs are attached to it. In these
situations, the gateway's IP config need to be performed after the
bridge exists.

This fix makes sure that the gateway's IP configuration takes places
before each node's network configuration.