Refactor the underlay.ssh update process for VCP minions

fuel-devops node names in the underlay.yaml can be
different from actual hostnames configured on hosts:
  underlay.yaml: ctl01
  hostname -f: ctl01.cookied-cicd-k8s-calico.local

Shorter names are connected to qemu limitation for
monitor.lock path and how the fuel-devops creates
unique names for the environment nodes.

1. To not double the same nodes in the underlay.ssh, match
   the VCP nodes to underlay.ssh nodes not by name, but by
   IP address and address_pool.
   Add new method update_ssh_data_from_minions() to
   SaltManager with this functional.

2. Add new attribute to underlay.ssh:  minion_id , which will
   provide mapping from underlay.ssh to the minion_id for the
   nodes.

3. Add helper method host_by_minion_id() to UnderlayManager
   to get host IP by minion_id

Change-Id: I510d9a777df8f308c1a7fede7b4ec2feb314c5bd
diff --git a/tcp_tests/managers/saltmanager.py b/tcp_tests/managers/saltmanager.py
index 6fad0e4..a468b02 100644
--- a/tcp_tests/managers/saltmanager.py
+++ b/tcp_tests/managers/saltmanager.py
@@ -188,13 +188,14 @@
         if len(hosts) == 0:
             raise LookupError("Hosts is empty or absent")
 
-        def host(node_name, ip):
+        def host(minion_id, ip):
             return {
                 'roles': ['salt_minion'],
                 'keys': [
                     k['private'] for k in self.__config.underlay.ssh_keys
                 ],
-                'node_name': node_name,
+                'node_name': minion_id,
+                'minion_id': minion_id,
                 'host': ip,
                 'address_pool': pool_name,
                 'login': settings.SSH_NODE_CREDENTIALS['login'],
@@ -216,6 +217,25 @@
                        host_list={k: v['ipv4'] for k, v in hosts.items()}))
             raise StopIteration(msg)
 
+    def update_ssh_data_from_minions(self):
+        """Combine existing underlay.ssh with VCP salt minions"""
+        salt_nodes = self.get_ssh_data()
+
+        for salt_node in salt_nodes:
+            nodes = [n for n in self.__config.underlay.ssh
+                     if salt_node['host'] == n['host']
+                     and salt_node['address_pool'] == n['address_pool']]
+            if nodes:
+                # Assume that there can be only one node with such IP address
+                # Just update minion_id for this node
+                nodes[0]['minion_id'] = salt_node['minion_id']
+            else:
+                # New node, add to config.underlay.ssh
+                self.__config.underlay.ssh.append(salt_node)
+
+        self.__underlay.config_ssh = []
+        self.__underlay.add_config_ssh(self.__config.underlay.ssh)
+
     def service_status(self, tgt, service):
         result = self.local(tgt=tgt, fun='service.status', args=service)
         return result['return']