Exemplo n.º 1
0
    def _render_control_planes(self, fp):
        LOG.info('%s()' % KenLog.fcn())

        svc_controller = self._controllers['Service']
        res_controller = self._controllers['Resource']
        es_resource = res_controller.resource('external-service')
        cloud_model = self._models['CloudModel']

        for elem_cp in self._models['CloudModel']['control-planes']:
            if not ControlPlane.is_active(elem_cp):
                continue

            (cp_w, cp_h) = self._determine_size_for_control_plane(elem_cp)
            cp_box = Box(cp_w, cp_h)

            cp_type = elem_cp['type']
            if elem_cp['type'].lower() == 'rcp':
                cp_type = '%s%s' % (elem_cp['type'], elem_cp['id'])

            cp_type_name = ControlPlane.get_name(elem_cp)

            title = '%s (%s, Region: %s)' % (
                cp_type.upper(), cp_type_name, elem_cp['region-name'])
            cp_box.set_title(title)

            tier_y = 2
            tot_box_w = 0
            for elem_t in elem_cp['tiers']:
                if not Tier.is_active_or_empty(elem_t):
                    continue

                (t_w, t_h) = self._determine_size_for_tier(elem_cp, elem_t)
                t_box = Box(t_w, t_h)

                if tot_box_w == 0:
                    tot_box_w = t_w

                title = 'T%d (Service Tier)' % int(elem_t['id'])

                t_box.set_title(title)
                cp_box.add_layer(t_box, 2, tier_y)

                tier_y += t_h + (self._padding_y / 2)

                member_x = 2
                for m, elem_m in six.iteritems(elem_t['members']):
                    if not Member.is_active(elem_m):
                        continue

                    if m.lower() == 'vip':
                        continue

                    (m_w, m_h) = self._determine_size_for_member(
                        elem_cp, elem_t, elem_m)
                    m_box = Box(m_w, m_h)

                    title = 'M%s (Member)' % m
                    m_box.set_title(title)

                    t_box.add_layer(m_box, member_x, 2)
                    member_x += (self._member_width + self._padding_x)

                    service_y = 2
                    for elem_s in Member.get_services(elem_m):
                        svc_name = svc_controller.service_output(
                            elem_s['name'])

                        if not es_resource.is_external(cloud_model, svc_name):
                            m_box.add_string_centered(svc_name, service_y)

                        else:
                            ext_string = '%s (ext)' % svc_name
                            ex, ey = m_box.get_centered_pos(
                                svc_name, service_y)

                            m_box.add_string_absolute(ext_string, ex, ey)

                        service_y += 1

                    tm_networks = self._get_tier_member_networks(elem_cp,
                                                                 elem_t)
                    if len(tm_networks) > 0:
                        m_box.add_string_centered('-------', service_y)
                        service_y += 1

                        for k, v in six.iteritems(tm_networks):
                            text = '%s - %s' % (k, v[m][-14:])
                            m_box.add_string_centered(text, service_y)
                            service_y += 1

            cp_y = tier_y
            cp_y = self._render_resource_nodes(cp_box, cp_y, elem_cp,
                                               tot_box_w)

            self._render_control_plane_networks(cp_box, cp_y, elem_cp,
                                                tot_box_w)

            cp_box.display(fp)
Exemplo n.º 2
0
    def _render_resource_nodes(self, r_box, r_y, elem_r, w):
        LOG.info('%s()' % KenLog.fcn())

        for elem_rn in ControlPlane.resources(elem_r):

            # Build a list of server types by AZ and role
            server_types = {}
            AZs = set()
            for elem_s in ResourceNode.servers(elem_rn):
                role = ResourceNode.server_role(elem_s)
                if role not in server_types:
                    rn_h = self._determine_height_for_resource_node(
                        elem_r, elem_rn, elem_s)
                    server_types[role] = {'height': rn_h, 'zones': {}}
                AZ = ResourceNode.failure_zone(elem_s)
                AZs.add(AZ)
                if AZ not in server_types[role]['zones']:
                    server_types[role]['zones'][AZ] = {
                        'server': elem_s,
                        'count': 1
                    }
                else:
                    server_types[role]['zones'][AZ]['count'] += 1

            # Work out how height we're going to be
            res_h = 1
            for role, data in server_types.iteritems():
                res_h += data['height'] + self._padding_y
            res_w = len(AZs) * (self._server_width + self._padding_x)

            res_box = Box(res_w, res_h)
            res_box.set_title(ResourceNode.name(elem_rn))
            r_box.add_layer(res_box, 2, r_y)
            r_y += res_h + 1

            res_x = 2
            res_y = 2
            for roles, data in server_types.iteritems():
                for AZ in sorted(data['zones']):
                    elem_s = data['zones'][AZ]['server']
                    w = self._server_width - self._padding_x
                    rn_h = self._determine_height_for_resource_node(
                        elem_r, elem_rn, elem_s)
                    rn_box = Box(w, rn_h)

                    res_box.add_layer(rn_box, res_x, res_y)
                    res_x += (self._server_width + self._padding_x)

                    name = ResourceNode.name(elem_rn)

                    title = '%s (%s) (%s servers)' % (
                        role, AZ, data['zones'][AZ]['count'])
                    rn_box.set_title(title)

                    service_y = 2
                    services = Server.services(elem_s)
                    for elem_c in sorted(services):
                        rn_box.add_string_absolute(elem_c, 2, service_y)
                        service_y += 1
                        for elem_comp in sorted(services[elem_c]):
                            rn_box.add_string_absolute(elem_comp, 4, service_y)
                            service_y += 1

                    service_y += 1
                    sep = "-" * w
                    rn_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 += ")"
                        rn_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['cidr']
                            rn_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)"
                                rn_box.add_string_absolute(
                                    r_name, 6, service_y)
                                service_y += 1

        return r_y
    def _render_resource_nodes(self, r_box, r_y, elem_r, w):
        LOG.info('%s()' % KenLog.fcn())

        for elem_rn in ControlPlane.resources(elem_r):

            # Build a list of server types by AZ and role
            server_types = {}
            AZs = set()
            for elem_s in ResourceNode.servers(elem_rn):
                role = ResourceNode.server_role(elem_s)
                if role not in server_types:
                    rn_h = self._determine_height_for_resource_node(
                        elem_r, elem_rn, elem_s)
                    server_types[role] = {'height': rn_h,
                                          'zones': {}}
                AZ = ResourceNode.failure_zone(elem_s)
                AZs.add(AZ)
                if AZ not in server_types[role]['zones']:
                    server_types[role]['zones'][AZ] = {'server': elem_s,
                                                       'count': 1}
                else:
                    server_types[role]['zones'][AZ]['count'] += 1

            # Work out how height we're going to be
            res_h = 1
            for role, data in server_types.iteritems():
                res_h += data['height'] + self._padding_y
            res_w = len(AZs) * (self._server_width + self._padding_x)

            res_box = Box(res_w, res_h)
            res_box.set_title(ResourceNode.name(elem_rn))
            r_box.add_layer(res_box, 2, r_y)
            r_y += res_h + 1

            res_x = 2
            res_y = 2
            for roles, data in server_types.iteritems():
                for AZ in sorted(data['zones']):
                    elem_s = data['zones'][AZ]['server']
                    w = self._server_width - self._padding_x
                    rn_h = self._determine_height_for_resource_node(
                        elem_r, elem_rn, elem_s)
                    rn_box = Box(w, rn_h)

                    res_box.add_layer(rn_box, res_x, res_y)
                    res_x += (self._server_width + self._padding_x)

                    name = ResourceNode.name(elem_rn)

                    title = '%s (%s) (%s servers)' % (role, AZ, data['zones'][AZ]['count'])
                    rn_box.set_title(title)

                    service_y = 2
                    services = Server.services(elem_s)
                    for elem_c in sorted(services):
                        rn_box.add_string_absolute(elem_c, 2, service_y)
                        service_y += 1
                        for elem_comp in sorted(services[elem_c]):
                            rn_box.add_string_absolute(elem_comp, 4, service_y)
                            service_y += 1

                    service_y += 1
                    sep = "-" * w
                    rn_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 += ")"
                        rn_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['cidr']
                            rn_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)"
                                rn_box.add_string_absolute(r_name, 6, service_y)
                                service_y += 1

        return r_y
Exemplo n.º 4
0
    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)