- # get fields indexes
- fields = lines[0].rsplit(' | ')
-
- index_id = -1
- index_status = -1
- index_name = -1
- index_cluster = -1
- index_ip = -1
- index_mac = -1
- index_roles = -1
- index_online = -1
-
- for i in range(len(fields)):
- if "group_id" in fields[i]:
- break
- elif "id" in fields[i]:
- index_id = i
- elif "status" in fields[i]:
- index_status = i
- elif "name" in fields[i]:
- index_name = i
- elif "cluster" in fields[i]:
- index_cluster = i
- elif "ip" in fields[i]:
- index_ip = i
- elif "mac" in fields[i]:
- index_mac = i
- elif "roles " in fields[i] and "pending_roles" not in fields[i]:
- index_roles = i
- elif "online" in fields[i]:
- index_online = i
-
- # order nodes info
- for i in range(2, len(lines)):
- fields = lines[i].rsplit(' | ')
- id = fields[index_id].strip().encode()
- ip = fields[index_ip].strip().encode()
- status_node = fields[index_status].strip().encode().lower()
- name = fields[index_name].strip().encode()
- roles_all = fields[index_roles].strip().encode().lower()
-
- roles = [x for x in [manager.Role.CONTROLLER,
- manager.Role.COMPUTE,
- manager.Role.ODL] if x in roles_all]
-
- dict = {"cluster": fields[index_cluster].strip().encode(),
- "mac": fields[index_mac].strip().encode(),
- "status_node": status_node,
- "online": fields[index_online].strip().encode()}
-
- ssh_client = None
- if status_node == 'ready':
- status = manager.NodeStatus.STATUS_OK
- proxy = {'ip': self.installer_ip,
- 'username': self.installer_user,
- 'password': self.installer_pwd}
- ssh_client = ssh_utils.get_ssh_client(hostname=ip,
- username='root',
- proxy=proxy)
- elif 'error' in status_node:
- status = manager.NodeStatus.STATUS_ERROR
- elif 'off' in status_node:
- status = manager.NodeStatus.STATUS_OFFLINE
- elif 'discover' in status_node:
- status = manager.NodeStatus.STATUS_UNUSED
- else:
- status = manager.NodeStatus.STATUS_INACTIVE
-
+ try:
+ yaml_output = safe_load(output)
+ except YAMLError as exc:
+ LOGGER.error(exc)
+ for node_name in yaml_output.keys():
+ ip_addr = yaml_output[node_name]['_param:pxe_admin_address']
+ ssh_client = ssh_utils.get_ssh_client(hostname=ip_addr,
+ username='ubuntu',
+ pkey_file=self.pkey_file)