Пример #1
0
def autoconfigure_monitoring(*args, **kwargs):
    from geonode.contrib.monitoring.models import Service, do_autoconfigure
    # run autoconfigure only if there are no services defined
    if not Service.objects.all():
        do_autoconfigure()
    for s in Service.objects.all():
        if s.last_check is None:
            s.last_check = datetime.now()
            s.save()
Пример #2
0
    def test_autoconfig(self):
        with self.settings(OGC_SERVER=self.OGC_SERVER, SITEURL=self.OGC_GS_2):
            do_autoconfigure()
        h1 = Host.objects.get(name='localhost')
        h2 = Host.objects.get(name='google.com')
        s1 = Service.objects.get(name='geoserver1-geoserver')
        self.assertEqual(s1.host, h1)
        s2 = Service.objects.get(name='external1-geoserver')
        self.assertEqual(s2.host, h2)

        autoconf_url = reverse('monitoring:api_autoconfigure')
        resp = self.client.post(autoconf_url)
        self.assertEqual(resp.status_code, 401)
        self.client.login(username=self.user, password=self.passwd)

        resp = self.client.post(autoconf_url)
        self.assertEqual(resp.status_code, 200)
Пример #3
0
    def test_autoconfig(self):
        with self.settings(OGC_SERVER=self.OGC_SERVER, SITEURL=self.OGC_GS_2):
            do_autoconfigure()
        h1 = Host.objects.get(name='localhost')
        h2 = Host.objects.get(name='google.com')
        s1 = Service.objects.get(name='geoserver1-geoserver')
        self.assertEqual(s1.host, h1)
        s2 = Service.objects.get(name='external1-geoserver')
        self.assertEqual(s2.host, h2)

        autoconf_url = reverse('monitoring:api_autoconfigure')
        resp = self.client.post(autoconf_url)
        self.assertEqual(resp.status_code, 401)
        self.client.login(username=self.user, password=self.passwd)

        resp = self.client.post(autoconf_url)
        self.assertEqual(resp.status_code, 200)
Пример #4
0
 def post(self, request, *args, **kwargs):
     if not request.user.is_authenticated():
         out = {'success': False,
                'status': 'error',
                'errors': {'user': ['User is not authenticated']}
                }
         return json_response(out, status=401)
     if not (request.user.is_superuser or request.user.is_staff):
         out = {'success': False,
                'status': 'error',
                'errors': {'user': ['User is not permitted']}
                }
         return json_response(out, status=401)
     do_autoconfigure()
     out = {'success': True,
            'status': 'ok',
            'errors': {}
            }
     return json_response(out)
Пример #5
0
 def post(self, request, *args, **kwargs):
     if not request.user.is_authenticated():
         out = {'success': False,
                'status': 'error',
                'errors': {'user': ['User is not authenticated']}
                }
         return json_response(out, status=401)
     if not (request.user.is_superuser or request.user.is_staff):
         out = {'success': False,
                'status': 'error',
                'errors': {'user': ['User is not permitted']}
                }
         return json_response(out, status=401)
     do_autoconfigure()
     out = {'success': True,
            'status': 'ok',
            'errors': {}
            }
     return json_response(out)