def _render_resource_nodes(self, cp_box, cp_y, elem_cp, w): LOG.info('%s()' % KenLog.fcn()) svc_controller = self._controllers['Service'] for nt, elem_rn in six.iteritems(elem_cp['resource-nodes']): if not elem_rn: continue rn_h = self._determine_height_for_resource_node(elem_cp, nt, elem_rn) rn_box = Box(w, rn_h) cp_box.add_layer(rn_box, 2, cp_y) cp_y += (rn_h + (self._padding_y / 2)) idx_start = 'N%04d' % 1 idx_end = 'N%04d' % elem_rn['count'] hostname_start = '%s-%s' % (nt.upper(), idx_start) hostname_start = Hostname.output_format( self._instructions, hostname_start) hostname_end = '%s-%s' % (nt.upper(), idx_end) hostname_end = Hostname.output_format( self._instructions, hostname_end) title = '%s -> %s (Compute Node)' % (hostname_start, hostname_end) rn_box.set_title(title) service_y = 2 for elem_s in ResourceNode.get_services(elem_rn): s_name = svc_controller.service_output(elem_s) rn_box.add_string_centered(s_name, service_y) service_y += 1 allocations = self._get_resource_node_allocations(elem_cp, nt) if allocations: rn_box.add_string_centered('-------', service_y) service_y += 1 for k, v in six.iteritems(allocations): if 'start' in v and 'end' in v: text = '%s - %s -> %s' % ( k.upper(), v['start'], v['end']) rn_box.add_string_centered( text, service_y) service_y += 1 return cp_y
def _determine_height_for_resource_node(self, elem_cp, node_type, elem_rn): LOG.info('%s(elem_cp="%s", node_type="%s", elem_rn="%s")' % ( KenLog.fcn(), ControlPlane.get_name(elem_cp), node_type, ResourceNode.get_hostname(elem_rn))) num_rn_allocations = 0 allocations = self._get_resource_node_allocations(elem_cp, node_type) LOG.info('-------------------------------------') for k, v in six.iteritems(allocations): LOG.info(v) if 'start' in v and 'end' in v: num_rn_allocations += 1 LOG.info('------------------------------------- %d' % num_rn_allocations) height = self._padding_y height += len(ResourceNode.get_services(elem_rn)) height += 1 # Dashes height += num_rn_allocations height += self._padding_y return height