def _determine_size_for_control_plane(self, elem_r): LOG.info('%s()' % KenLog.fcn()) width = 0 height = self._padding_y clusters = ControlPlane.clusters(elem_r) for elem_c in clusters: (t_w, t_h) = self._determine_size_for_cluster(elem_r, elem_c) if t_w > width: width = t_w height += t_h + 1 width += (self._padding_x * 2) height += 1 res_height = self._determine_height_for_resource_nodes(elem_r) height += res_height return width, height
def _determine_size_for_control_plane(self, elem_r): LOG.info('%s()' % KenLog.fcn()) width = 0 height = self._padding_y clusters = ControlPlane.clusters(elem_r) for elem_c in clusters: (t_w, t_h) = self._determine_size_for_cluster(elem_r, elem_c) if t_w > width: width = t_w height += t_h + 1 width += (self._padding_x * 2) height += 1 res_height = self._determine_height_for_resource_nodes(elem_r) height += res_height return width, height
def _render_control_planes(self, fp): LOG.info('%s()' % KenLog.fcn()) control_planes = CloudModel.get(self._cloud_version, 'control-planes') for elem_r in control_planes: (r_w, r_h) = self._determine_size_for_control_plane(elem_r) r_box = Box(r_w, r_h) r_type = ControlPlane.name(elem_r) r_type_name = ControlPlane.region_name(elem_r) title = 'ControlPlane: %s (%s)' % (r_type_name, r_type) r_box.set_title(title) tier_y = 2 tot_box_w = 0 for elem_c in ControlPlane.clusters(elem_r): (t_w, t_h) = self._determine_size_for_cluster(elem_r, elem_c) t_box = Box(t_w, t_h) if tot_box_w == 0: tot_box_w = t_w title = 'Cluster %s (%s)' % (Cluster.name(elem_c), Cluster.id(elem_c)) t_box.set_title(title) r_box.add_layer(t_box, 2, tier_y) tier_y += t_h + (self._padding_y / 2) member_x = 2 for elem_s in Cluster.servers(elem_c): (m_w, m_h) = self._determine_size_for_server( elem_r, elem_c, elem_s) m_box = Box(m_w, m_h) ip = Server.address(elem_s) if ip: title = '%s (%s)' % (Server.name(elem_s), ip) else: title = '%s' % Server.name(elem_s) m_box.set_title(title) t_box.add_layer(m_box, member_x, 2) member_x += (self._server_width + self._padding_x) service_y = 2 services = Server.services(elem_s) for elem_c in sorted(services): m_box.add_string_absolute(elem_c, 2, service_y) service_y += 1 for elem_comp in sorted(services[elem_c]): m_box.add_string_absolute(elem_comp, 4, service_y) service_y += 1 service_y += 1 sep = "-" * m_w m_box.add_string_absolute(sep, 2, service_y) service_y += 2 interfaces = Server.interfaces(elem_s) routes = Server.routes(elem_s) for i in sorted(interfaces): elem_i = interfaces[i] device = elem_i['device']['name'] if 'bond-data' in elem_i: device += " (" first = True for bond_dev in elem_i['bond-data'].get( 'devices', []): if not first: device += ", " first = False device += "%s" % bond_dev['name'] device += ")" m_box.add_string_absolute(device, 2, service_y) service_y += 1 networks = Interface.networks(elem_i) for n in sorted(networks): elem_n = networks[n] name = Network.name(elem_n) if 'addr' in elem_n: name += " (%s)" % elem_n['addr'] m_box.add_string_absolute(name, 4, service_y) service_y += 1 net_routes = routes.get(n, {}) for r in sorted(net_routes): elem_route = net_routes[r] r_name = "-> %s " % r if elem_route['default']: r_name += "(default)" m_box.add_string_absolute(r_name, 6, service_y) service_y += 1 r_y = tier_y self._render_resource_nodes(r_box, r_y, elem_r, tot_box_w) r_box.display(fp)
def _render_control_planes(self, fp): LOG.info('%s()' % KenLog.fcn()) control_planes = CloudModel.get(self._cloud_version, 'control-planes') for elem_r in control_planes: (r_w, r_h) = self._determine_size_for_control_plane(elem_r) r_box = Box(r_w, r_h) r_type = ControlPlane.name(elem_r) r_type_name = ControlPlane.region_name(elem_r) title = 'ControlPlane: %s (%s)' % (r_type_name, r_type) r_box.set_title(title) tier_y = 2 tot_box_w = 0 for elem_c in ControlPlane.clusters(elem_r): (t_w, t_h) = self._determine_size_for_cluster( elem_r, elem_c) t_box = Box(t_w, t_h) if tot_box_w == 0: tot_box_w = t_w title = 'Cluster %s (%s)' % ( Cluster.name(elem_c), Cluster.id(elem_c)) t_box.set_title(title) r_box.add_layer(t_box, 2, tier_y) tier_y += t_h + (self._padding_y / 2) member_x = 2 for elem_s in Cluster.servers(elem_c): (m_w, m_h) = self._determine_size_for_server( elem_r, elem_c, elem_s) m_box = Box(m_w, m_h) ip = Server.address(elem_s) if ip: title = '%s (%s)' % (Server.name(elem_s), ip) else: title = '%s' % Server.name(elem_s) m_box.set_title(title) t_box.add_layer(m_box, member_x, 2) member_x += (self._server_width + self._padding_x) service_y = 2 services = Server.services(elem_s) for elem_c in sorted(services): m_box.add_string_absolute(elem_c, 2, service_y) service_y += 1 for elem_comp in sorted(services[elem_c]): m_box.add_string_absolute(elem_comp, 4, service_y) service_y += 1 service_y += 1 sep = "-" * m_w m_box.add_string_absolute(sep, 2, service_y) service_y += 2 interfaces = Server.interfaces(elem_s) routes = Server.routes(elem_s) for i in sorted(interfaces): elem_i = interfaces[i] device = elem_i['device']['name'] if 'bond-data' in elem_i: device += " (" first = True for bond_dev in elem_i['bond-data'].get('devices', []): if not first: device += ", " first = False device += "%s" % bond_dev['name'] device += ")" m_box.add_string_absolute(device, 2, service_y) service_y += 1 networks = Interface.networks(elem_i) for n in sorted(networks): elem_n = networks[n] name = Network.name(elem_n) if 'addr' in elem_n: name += " (%s)" % elem_n['addr'] m_box.add_string_absolute(name, 4, service_y) service_y += 1 net_routes = routes.get(n, {}) for r in sorted(net_routes): elem_route = net_routes[r] r_name = "-> %s " % r if elem_route['default']: r_name += "(default)" m_box.add_string_absolute(r_name, 6, service_y) service_y += 1 r_y = tier_y self._render_resource_nodes(r_box, r_y, elem_r, tot_box_w) r_box.display(fp)