Esempio n. 1
0
 def options(self, widget):
     hosts = get_hosts(widget.user)
     return  {
         'host_detail_widget_host': {
             'label': _("Host"),
             'choices': [(h.pk, h.name) for h in hosts],
             'default': hosts[0].pk if hosts else 0,
             'return_func': lambda value: get_host(value)
         },
         'host_detail_widget_days': {
             'label': _("Days"),
             'choices': self.DAYS_CHOICES,
             'default': 1,
             'return_func': lambda value: int(value)
         },
         'host_detail_widget_alerts': {
             'label': _("Show alerts"),
             'choices': self.SHOW_CHOICES,
             'default': 'yes',
             'return_func': lambda value: True if value == 'yes' else False
         },
         'host_detail_widget_chart': {
             'label': _("Show chart"),
             'choices': self.SHOW_CHOICES,
             'default': 'yes',
             'return_func': lambda value: True if value == 'yes' else False
         },
     }
Esempio n. 2
0
 def options(self, widget):
     hosts = get_hosts(self.user)
     return {
         'host_detail_widget_host': {
             'label': _("Host"),
             'choices': [(h.pk, h.name) for h in hosts],
             'default': hosts[0].pk if hosts else 0,
             'return_func': lambda value: get_host(value)
         },
         'host_detail_widget_days': {
             'label': _("Days"),
             'choices': self.DAYS_CHOICES,
             'default': 1,
             'return_func': lambda value: int(value)
         },
         'host_detail_widget_alerts': {
             'label': _("Show alerts"),
             'choices': self.SHOW_CHOICES,
             'default': 'yes',
             'return_func': lambda value: True if value == 'yes' else False
         },
         'host_detail_widget_chart': {
             'label': _("Show chart"),
             'choices': self.SHOW_CHOICES,
             'default': 'yes',
             'return_func': lambda value: True if value == 'yes' else False
         },
     }
Esempio n. 3
0
 def context(self, widget):
     user = widget.widgets_area.user
     #hosts = get_hosts(user=user)
     geoIP = []
     geo_final = []
     for host in get_hosts(user=user):
         geo_range = self.range_check(host.ipv4)
         if geo_range:
             geoIP.append('%s' % (geo_range[0][0]))
     if geoIP:
         geo_LatLng = self.get_LatLng(geoIP)
     if geo_LatLng:
         for i in range(0, len(geo_LatLng)):
             geo_final.append('[%s,%s], ' %
                              (geo_LatLng[i][0], geo_LatLng[i][1]))
     return {'geoIP': geo_final[:10]}
Esempio n. 4
0
	def context(self, widget):
		user = widget.widgets_area.user
		#hosts = get_hosts(user=user)
		geoIP = []
		geo_final = []
		for host in get_hosts(user=user):
		 geo_range = self.range_check(host.ipv4)
		 if geo_range:
			geoIP.append( '%s' % (geo_range[0][0]) )
		if geoIP:
			geo_LatLng = self.get_LatLng(geoIP)
		if geo_LatLng:
			for i in range(0,len(geo_LatLng)):
				geo_final.append( '[%s,%s], ' % (geo_LatLng[i][0], geo_LatLng[i][1]))
		return {
		'geoIP': geo_final[:10]
		}
Esempio n. 5
0
    def options(self, widget):
        hosts = get_hosts(self.user)
        hosts_choices = [(-1, '-- all --')] + \
            [(h.pk, h.name) for h in hosts]

        alert_levels = [(-1, _('-- any --')), (1, _('Low')), (2, _('Medium')),
                        (3, _('High'))]
        return {
            'latest_events_widget_number_of_events': {
                'label': _("Number of events to show"),
                'choices': [(i, i) for i in xrange(1, 16)],
                'default': 5
            },
            'latest_events_widget_title': {
                'label': _("Title of the widget"),
                'default': _("Latest events"),
                'return_func': lambda value: str(value)
            },
            'latest_events_widget_host': {
                'label':
                _("Events from host"),
                'choices':
                hosts_choices,
                'default':
                -1,
                'return_func':
                lambda value: None if value == '-1' else get_host(value)
            },
            'latest_events_widget_alert_level': {
                'label': _("Alert level"),
                'choices': alert_levels,
                'default': -1,
                'return_func': lambda value: int(value)
            },
            'latest_events_widget_checked': {
                'label': _("Hide events marked as checked"),
                'choices': [(0, 'No'), (1, 'Yes')],
                'default': 0,
                'return_func': lambda value: True if value == '1' else False
            }
        }
Esempio n. 6
0
 def options(self, widget):
     hosts = get_hosts(self.user)
     hosts_choices = [(-1, '-- all --')] + \
         [(h.pk, h.name) for h in hosts]
         
     alert_levels = [(-1, _('-- any --')), (1, _('Low')),
                     (2, _('Medium')), (3, _('High'))]
     return {
         'latest_events_widget_number_of_events': {
             'label': _("Number of events to show"),
             'choices': [(i, i) for i in xrange(1, 16)],
             'default': 5
         },
         'latest_events_widget_title': {
             'label': _("Title of the widget"),
             'default': _("Latest events"),
             'return_func': lambda value: str(value)
         },
         'latest_events_widget_host': {
             'label': _("Events from host"),
             'choices': hosts_choices,
             'default': -1,
             'return_func': lambda value: None if value == '-1' else get_host(value)
         },
         'latest_events_widget_alert_level': {
             'label': _("Alert level"),
             'choices': alert_levels,
             'default': -1,
             'return_func': lambda value: int(value)
         },
         'latest_events_widget_checked': {
             'label': _("Hide events marked as checked"),
             'choices': [(0, 'No'), (1, 'Yes')],
             'default': 0,
             'return_func': lambda value: True if value == '1' else False
         }
     }
Esempio n. 7
0
def subnet_network(request):
    if request.method == 'POST':
        form = SubnetCreateFrom(request.POST)
        if form.is_valid():
            subnet = form.cleaned_data['Subnet_Address']
            ip = form.cleaned_data['IP_Address']
            user_host = get_hosts(user=request.user)
            hosts_list = get_subnet(user_host, subnet,ip)
            subnet_network = form.save()
            network_obj = Network.objects.get(name__exact = form.cleaned_data['name'])
            for hosts in hosts_list:
                network_entry = NetworkHost(network_id = network_obj.id, host_id = hosts.id)
                network_entry.save()
            extra_context = {
                'form': SubnetCreateFrom(initial={'user': request.user.pk}),
                'host_list': hosts_list
                }
            return redirect_to(request, url=subnet_network.get_absolute_url())
    else:
        form = SubnetCreateFrom()
    extra_context = {
        'form':SubnetCreateFrom(initial={'user': request.user.pk})
        }
    return direct_to_template(request,'networks/subnet_form.html',extra_context)