示例#1
0
 def test_dict_to_objects(self):
     dict_list = importer.parse_csv_string(_TYPICAL_TESTCASE)
     pynag_objects = importer.dict_to_pynag_objects(dict_list)
     self.assertEqual(2, len(pynag_objects))
     self.assertEqual('generic-service', pynag_objects[0].use)
     self.assertEqual('generic-host', pynag_objects[1].use)
     self.assertEqual('service', pynag_objects[0].object_type)
     self.assertEqual('host', pynag_objects[1].object_type)
示例#2
0
 def test_dict_to_objects(self):
     dict_list = importer.parse_csv_string(_TYPICAL_TESTCASE)
     pynag_objects = importer.dict_to_pynag_objects(dict_list)
     self.assertEqual(2, len(pynag_objects))
     self.assertEqual('generic-service', pynag_objects[0].use)
     self.assertEqual('generic-host', pynag_objects[1].use)
     self.assertEqual('service', pynag_objects[0].object_type)
     self.assertEqual('host', pynag_objects[1].object_type)
示例#3
0
文件: forms.py 项目: wz3763/adagios
    def parse_objects_from_form(self):
        cleaned_data = self.clean()
        objects = cleaned_data['objects']
        object_type = cleaned_data['object_type']
        destination_filename = self.cleaned_data['destination_filename']
        seperator = cleaned_data['seperator']
        parsed_objects = importer.parse_csv_string(objects, seperator=seperator)
        pynag_objects = importer.dict_to_pynag_objects(parsed_objects, object_type=object_type)

        for pynag_object in pynag_objects:
            if destination_filename:
                pynag_object.set_filename(destination_filename)
            else:
                pynag_object.set_filename(pynag_object.get_suggested_filename())
        return pynag_objects
示例#4
0
    def parse_objects_from_form(self):
        cleaned_data = self.clean()
        objects = cleaned_data['objects']
        object_type = cleaned_data['object_type']
        destination_filename = self.cleaned_data['destination_filename']
        seperator = cleaned_data['seperator']
        parsed_objects = importer.parse_csv_string(objects,
                                                   seperator=seperator)
        pynag_objects = importer.dict_to_pynag_objects(parsed_objects,
                                                       object_type=object_type)

        for pynag_object in pynag_objects:
            if destination_filename:
                pynag_object.set_filename(destination_filename)
            else:
                pynag_object.set_filename(
                    pynag_object.get_suggested_filename())
        return pynag_objects