Example #1
0
def details(request, hostname):
    """
    Compute node details.
    """
    dc1_settings = get_dc1_settings(request)
    context = collect_view_data(request, 'node_list')
    context['node'] = node = get_node(request, hostname, sr=('owner', ))
    context['nodes'] = Node.all()
    context['node_dcs'] = node.dc.all().values_list('alias', flat=True)
    context['node_vms'] = node.vm_set.count()
    context['node_real_vms'] = node.vm_set.filter(slavevm__isnull=True).count()
    context['form'] = NodeForm(request, node, initial=node.web_data)
    context[
        'mon_sla_enabled'] = settings.MON_ZABBIX_ENABLED and dc1_settings.MON_ZABBIX_NODE_SLA

    if node.is_backup:
        context['node_backups'] = node.backup_set.count()
    else:
        context['node_backups'] = 0

    view_node_details.send(sender='gui.node.views.details',
                           request=request,
                           context=context)

    return render(request, 'gui/node/details.html', context)
Example #2
0
    def __init__(self, request, node, *args, **kwargs):
        super(NodeForm, self).__init__(request, node, *args, **kwargs)
        self.fields['owner'].choices = get_owners(request).values_list('username', 'username')
        self.fields['address'].choices = [(ip, ip) for ip in node.ips]
        dc1_settings = get_dc1_settings(request)

        if dc1_settings.MON_ZABBIX_HOSTGROUPS_NODE:
            self.fields['monitoring_hostgroups'].help_text += _(' Automatically added hostgroups: ') \
                                                              + ', '.join(dc1_settings.MON_ZABBIX_HOSTGROUPS_NODE)

        if node.is_unlicensed():
            self.fields['status'].choices = Node.STATUS_DB
            self.fields['status'].widget.attrs['disabled'] = 'disabled'
        elif node.is_unreachable():
            self.fields['status'].choices = Node.STATUS_DB[:-1]
            self.fields['status'].widget.attrs['disabled'] = 'disabled'
Example #3
0
def common_stuff(request):
    """
    Make common settings and variables available in templates.
    """
    from core.version import __version__, __edition__
    from gui.node.utils import get_dc1_settings
    from api.system.update.api_views import UpdateView

    return {
        'settings': settings,
        'dc_settings': request.dc.settings,
        'dc1_settings': get_dc1_settings(request),
        'ANALYTICS': None if request.user.is_authenticated() else settings.ANALYTICS,
        'DEBUG': _get_debug_settings(),
        'SOCKETIO_URL': settings.SOCKETIO_URL,
        'THIRD_PARTY_JS': get_third_party_js(),
        'THIRD_PARTY_CSS': get_third_party_css(),
        'SYSTEM_UPDATE_RUNNING': UpdateView.is_task_running(),
        'SYSTEM_VERSION': __version__,
        'SYSTEM_EDITION': __edition__
    }
Example #4
0
def monitoring(request, hostname, graph_type='cpu'):
    """
    Compute node related monitoring.
    """
    dc1_settings = get_dc1_settings(request)
    context = collect_view_data(request, 'node_list')
    context['node'] = node = get_node(request, hostname)
    context['nodes'] = Node.all()

    if not dc1_settings.MON_ZABBIX_NODE_SYNC:
        return render(request, 'gui/node/monitoring_disabled.html', context)

    from api.mon.node.graphs import GRAPH_ITEMS

    context['graph_items'] = GRAPH_ITEMS
    context['obj_lifetime'] = node.lifetime
    context[
        'obj_operational'] = node.status != Node.STATUS_AVAILABLE_MONITORING and (
            not graph_type.startswith('vm-') or node.vm_set.exclude(
                status=Vm.NOTCREATED).filter(slavevm__isnull=True).exists())

    if graph_type == 'memory':
        graphs = (Graph('mem-usage'), Graph('swap-usage'))
    elif graph_type == 'network':
        context['node_nics'] = node_nics = node.used_nics.keys()
        graphs = list(
            chain(*[(Graph('net-bandwidth', nic=i),
                     Graph('net-packets', nic=i)) for i in node_nics]))
    elif graph_type == 'storage':
        context['zpools'] = node_zpools = node.zpools
        graphs = list(
            chain(*[(Graph('storage-throughput', zpool=i),
                     Graph('storage-io', zpool=i),
                     Graph('storage-space', zpool=i)) for i in node_zpools]))
    elif graph_type == 'vm-cpu':
        graphs = (Graph('vm-cpu-usage'), )
    elif graph_type == 'vm-memory':
        graphs = (Graph('vm-mem-usage'), )
    elif graph_type == 'vm-disk-throughput':
        graphs = (
            Graph('vm-disk-logical-throughput-reads'),
            Graph('vm-disk-logical-throughput-writes'),
            Graph('vm-disk-physical-throughput-reads'),
            Graph('vm-disk-physical-throughput-writes'),
        )
    elif graph_type == 'vm-disk-io':
        graphs = (
            Graph('vm-disk-logical-io-reads'),
            Graph('vm-disk-logical-io-writes'),
            Graph('vm-disk-physical-io-reads'),
            Graph('vm-disk-physical-io-writes'),
        )
    else:
        graph_type = 'cpu'
        graphs = (
            Graph('cpu-usage'),
            Graph('cpu-jumps'),
            Graph('cpu-load'),
        )

    context['graphs'] = graphs
    context['graph_type'] = graph_type

    return render(request, 'gui/node/monitoring_%s.html' % graph_type, context)