Пример #1
0
    def test_conflict(self):
        """Add conflicting template"""
        okconfig.addtemplate('www.okconfig.org', template_name="http")

        self.assertRaises(okconfig.OKConfigError,
                          okconfig.addtemplate,
                          host_name='www.okconfig.org',
                          template_name='http')
Пример #2
0
    def test_basic(self):
        """Add a template to a host"""
        okconfig.addtemplate("www.okconfig.org", template_name="http")

        services = Model.Service.objects.filter(
            host_name="www.okconfig.org",
            use="okc-check_http",
            service_description="HTTP www.okconfig.org")

        self.assertEquals(len(services), 1, "There can be only one")
Пример #3
0
    def test_group(self):
        """Test adding template with group"""
        okconfig.addtemplate("aliased.okconfig.org",
                             "http",
                             group_name="webgroup")

        services = Model.Service.objects.filter(
            host_name="aliased.okconfig.org",
            service_description="HTTP aliased.okconfig.org",
        )
        self.assertEqual(1, len(services), "There can be only one")
        self.assertEqual(services[0].contact_groups, "webgroup")
Пример #4
0
 def save(self):
     host_name = self.cleaned_data['host_name']
     templates = self.cleaned_data['templates']
     force = self.cleaned_data['force']
     self.filelist = []
     for i in templates:
         self.filelist+=okconfig.addtemplate(host_name=host_name, template_name=i,force=force)
Пример #5
0
 def save(self):
     host_name = self.cleaned_data['host_name']
     templates = self.cleaned_data['templates']
     force = self.cleaned_data['force']
     self.filelist = []
     for i in templates:
         self.filelist+=okconfig.addtemplate(host_name=host_name, template_name=i,force=force)
Пример #6
0
 def save(self):
     host_name = self.cleaned_data["host_name"]
     templates = self.cleaned_data["templates"]
     force = self.cleaned_data["force"]
     self.filelist = []
     for i in templates:
         self.filelist += okconfig.addtemplate(host_name=host_name, template_name=i, force=force)
Пример #7
0
    def test_multiple(self):
        """Add multiple templates to a host"""
        okconfig.addtemplate('www.okconfig.org', template_name="http")
        okconfig.addtemplate('www.okconfig.org', template_name="linux")

        for use, description in [
            ('okc-check_http', 'HTTP www.okconfig.org', ),
            ('okc-linux-check_disks', 'Disk Usage', ),
            ('okc-linux-check_load', 'Load', ),
            ('okc-linux-check_swap', 'Swap Usage', ),
        ]:
            services = Model.Service.objects.filter(
                host_name="www.okconfig.org",
                use=use,
                service_description=description)
            self.assertEqual(1, len(services), "Unable to match %s %s" % (
                use, description))
Пример #8
0
 def test_force(self):
     """Test force adding a template"""
     okconfig.addtemplate('www.okconfig.org', template_name="http")
     okconfig.addtemplate('www.okconfig.org', template_name="http",
                          force=True)