Ejemplo n.º 1
0
    def is_resource_node_active(cloud_model, elem_s):
        control_planes = CloudModel.control_planes(cloud_model)

        control_plane = ResourceNode.get_control_plane_id(elem_s)
        node_type = ResourceNode.get_type(elem_s)
        for elem_cp in control_planes:
            cp_name = ControlPlane.get_name(elem_cp)

            if cp_name.lower() != control_plane.lower():
                continue

            if not ResourceNode.is_active(elem_cp, node_type, elem_s):
                return False

        return True
Ejemplo n.º 2
0
    def is_active(cloud_model, elem_s):
        if isinstance(elem_s, dict):
            if 'state' in elem_s:
                state = elem_s.get('state', CPState.ACTIVE)
                return CPState.is_active(state)

            if Server.is_allocated(elem_s):
                name = Server.hostname(elem_s)
                if ResourceNode.is_resource_node(name):
                    return Server.is_resource_node_active(cloud_model, name)

        elif ResourceNode.is_resource_node(elem_s):
            return Server.is_resource_node_active(cloud_model, elem_s)

        return True
Ejemplo n.º 3
0
    def is_resource_node_active(cloud_model, elem_s):
        control_planes = CloudModel.control_planes(cloud_model)

        control_plane = ResourceNode.get_control_plane_id(elem_s)
        node_type = ResourceNode.get_type(elem_s)
        for elem_cp in control_planes:
            cp_name = ControlPlane.get_name(elem_cp)

            if cp_name.lower() != control_plane.lower():
                continue

            if not ResourceNode.is_active(elem_cp, node_type, elem_s):
                return False

        return True
Ejemplo n.º 4
0
    def is_active(cloud_model, elem_s):
        if isinstance(elem_s, dict):
            if 'state' in elem_s:
                state = elem_s.get('state', CPState.ACTIVE)
                return CPState.is_active(state)

            if Server.is_allocated(elem_s):
                name = Server.hostname(elem_s)
                if ResourceNode.is_resource_node(name):
                    return Server.is_resource_node_active(cloud_model, name)

        elif ResourceNode.is_resource_node(elem_s):
            return Server.is_resource_node_active(cloud_model, elem_s)

        return True
Ejemplo n.º 5
0
    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
Ejemplo n.º 6
0
    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