- resp = k8s_utils.get_pod_list()
- hosts = ({'name': n.metadata.name,
- 'ip': n.status.pod_ip,
- 'user': 'root',
- 'key_filename': self.key_path,
- 'private_ip': n.status.pod_ip}
- for n in resp.items if n.metadata.name.startswith(name))
-
- return next(hosts, None)
+ node_ports = self._get_service_ports(name)
+ for sn_port in (sn_port for sn_port in node_ports
+ if sn_port['port'] == constants.SSH_PORT):
+ node_port = sn_port['node_port']
+ break
+ else:
+ raise exceptions.KubernetesSSHPortNotDefined()
+
+ return {
+ 'name': name,
+ 'ip': self._get_node_ip(),
+ 'private_ip': k8s_utils.get_pod_by_name(name).status.pod_ip,
+ 'ssh_port': node_port,
+ 'user': 'root',
+ 'key_filename': self.key_path,
+ 'interfaces': self._get_interfaces(name),
+ 'service_ports': node_ports
+ }
+
+ def _get_network(self, net_name):
+ """Retrieves the network object, searching by name
+
+ :param net_name: (str) replication controller name
+ :return: (dict) network information (name)
+ """
+ network = self._networks.get(net_name)
+ if not network:
+ return
+ return {'name': net_name}
+
+ def _get_interfaces(self, rc_name):
+ """Retrieves the network list of a replication controller
+
+ :param rc_name: (str) replication controller name
+ :return: (dict) names and information of the networks used in this
+ replication controller; those networks must be defined in the
+ Kubernetes cluster
+ """
+ rc = self.template.get_rc_by_name(rc_name)
+ if not rc:
+ return {}
+ return {name: {'network_name': name,
+ 'local_mac': None,
+ 'local_ip': None}
+ for name in rc.networks}
+
+ def _get_node_ip(self):
+ return k8s_utils.get_node_list().items[0].status.addresses[0].address
+
+ def _get_physical_nodes(self):
+ return None