Exemplo n.º 1
0
    def _determine_size_for_member(self, elem_cp, elem_t, elem_m):
        LOG.info('%s()' % KenLog.fcn())

        num_services = len(Member.get_services(elem_m))
        num_networks = 0

        tier_networks = self._get_tier_member_networks(elem_cp, elem_t)
        if tier_networks:
            num_networks = len(tier_networks)

        width = self._member_width - self._padding_x

        height = self._padding_y
        height += num_services
        height += 1  # Dashes
        height += num_networks
        height += self._padding_y

        return width, height
Exemplo n.º 2
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)