def _build_node_columns(self, unit, charm_class): """ builds columns of node status """ node_cols = [] status_txt = "{:20}".format("[{}]".format(unit.agent_state)) # unit.agent_state may be "pending" despite errors elsewhere, # so we check for error_info first. # if the agent_state is "error", _detect_errors returns that. error_info = self._detect_errors(unit, charm_class) if error_info: status = Color.error_icon(Text("\N{TETRAGRAM FOR FAILURE} ")) if unit.agent_state != "error": status_txt = "{:20}".format("[{} (error)]" "".format(unit.agent_state)) elif unit.agent_state == "pending": pending_status = [ Color.pending_icon(Text("\N{CIRCLED BULLET} ")), Color.pending_icon(Text("\N{CIRCLED WHITE BULLET} ")), Color.pending_icon_on(Text("\N{FISHEYE} ")) ] status = random.choice(pending_status) elif unit.agent_state == "installed": status = Color.pending_icon(Text("\N{HOURGLASS} ")) elif unit.agent_state == "started": status = Color.success_icon(Text("\u2713 ")) elif unit.agent_state == "stopped": status = Color.error_icon(Text("\N{BLACK FLAG} ")) elif unit.agent_state == "down": status = Color.error_icon(Text("\N{DOWNWARDS BLACK ARROW} ")) else: # NOTE: Should not get here, if we do make sure we account # for that error type above. status = Color.error_icon(Text(unit.agent_state)) node_cols.append(('pack', status)) node_cols.append(('pack', Text(status_txt))) if unit.public_address: node_cols.append( ('pack', Text("{0:<12}".format(unit.public_address)))) elif error_info: node_cols.append(('pack', Text("{:<12}".format("Error")))) else: node_cols.append(('pack', Text("{:<12}".format("IP Pending")))) if error_info: infos = [('pack', Text(" | {}".format(error_info)))] else: hw_text = Text([" | "] + self._get_hardware_info(unit)) if 'glance-simplestreams-sync' in unit.unit_name: status_oneline = get_sync_status().replace("\n", " - ") sync_text = Text(' ' + status_oneline) infos = [hw_text, sync_text] else: infos = [hw_text] if self.config.getopt('show_logs'): log_text = Text([('label', self.get_log_text(unit.unit_name))]) infos.append(log_text) node_cols.append(Pile(infos)) return Columns(node_cols)
def _build_node_columns(self, unit, charm_class): """ builds columns of node status """ node_cols = [] status_txt = "{:20}".format("[{}]".format(unit.agent_state)) # unit.agent_state may be "pending" despite errors elsewhere, # so we check for error_info first. # if the agent_state is "error", _detect_errors returns that. error_info = self._detect_errors(unit, charm_class) if error_info: status = Color.error_icon(Text("\N{TETRAGRAM FOR FAILURE} ")) if unit.agent_state != "error": status_txt = "{:20}".format("[{} (error)]" "".format(unit.agent_state)) elif unit.agent_state == "pending": pending_status = [ Color.pending_icon(Text("\N{CIRCLED BULLET} ")), Color.pending_icon(Text("\N{CIRCLED WHITE BULLET} ")), Color.pending_icon_on(Text("\N{FISHEYE} ")), ] status = random.choice(pending_status) elif unit.agent_state == "installed": status = Color.pending_icon(Text("\N{HOURGLASS} ")) elif unit.agent_state == "started": status = Color.success_icon(Text("\u2713 ")) elif unit.agent_state == "stopped": status = Color.error_icon(Text("\N{BLACK FLAG} ")) elif unit.agent_state == "down": status = Color.error_icon(Text("\N{DOWNWARDS BLACK ARROW} ")) else: # NOTE: Should not get here, if we do make sure we account # for that error type above. status = Color.error_icon(Text(unit.agent_state)) node_cols.append(("pack", status)) node_cols.append(("pack", Text(status_txt))) if unit.public_address: node_cols.append(("pack", Text("{0:<12}".format(unit.public_address)))) elif error_info: node_cols.append(("pack", Text("{:<12}".format("Error")))) else: node_cols.append(("pack", Text("{:<12}".format("IP Pending")))) if error_info: infos = [("pack", Text(" | {}".format(error_info)))] else: hw_text = Text([" | "] + self._get_hardware_info(unit)) if "glance-simplestreams-sync" in unit.unit_name: status_oneline = get_sync_status().replace("\n", " - ") sync_text = Text(" " + status_oneline) infos = [hw_text, sync_text] else: infos = [hw_text] if self.config.getopt("show_logs"): log_text = Text([("label", self.get_log_text(unit.unit_name))]) infos.append(log_text) node_cols.append(Pile(infos)) return Columns(node_cols)