From 2e3a5d6a6bc60f1789296635f76d3663b30ce4a2 Mon Sep 17 00:00:00 2001 From: aviau Date: Thu, 23 Jul 2015 11:35:48 -0400 Subject: [PATCH] Disable unique constraints Change-Id: I894f7654b776bb430664b2cfd600696ab0fcb1dc --- .../api/storage/mongodb/config/businessimpactmodulation.py | 2 +- surveil/api/storage/mongodb/config/checkmodulation.py | 2 +- surveil/api/storage/mongodb/config/command.py | 7 +++++-- surveil/api/storage/mongodb/config/contact.py | 2 +- surveil/api/storage/mongodb/config/contactgroup.py | 2 +- surveil/api/storage/mongodb/config/host.py | 7 +++++-- surveil/api/storage/mongodb/config/hostgroup.py | 2 +- surveil/api/storage/mongodb/config/macromodulation.py | 2 +- surveil/api/storage/mongodb/config/notificationway.py | 2 +- surveil/api/storage/mongodb/config/realm.py | 2 +- surveil/api/storage/mongodb/config/service.py | 7 +++++-- surveil/api/storage/mongodb/config/servicegroup.py | 2 +- surveil/api/storage/mongodb/config/timeperiod.py | 2 +- .../api/controllers/v2/config/test_macromodulations.py | 2 +- 14 files changed, 26 insertions(+), 17 deletions(-) diff --git a/surveil/api/storage/mongodb/config/businessimpactmodulation.py b/surveil/api/storage/mongodb/config/businessimpactmodulation.py index 6bef122..dd29b06 100644 --- a/surveil/api/storage/mongodb/config/businessimpactmodulation.py +++ b/surveil/api/storage/mongodb/config/businessimpactmodulation.py @@ -17,6 +17,6 @@ import mongoengine class BusinessImpactModulation(mongoengine.Document): meta = {'collection': 'businessimpactmodulations'} - business_impact_modulation_name = mongoengine.StringField(unique=True) + business_impact_modulation_name = mongoengine.StringField() business_impact = mongoengine.IntField() modulation_period = mongoengine.StringField() \ No newline at end of file diff --git a/surveil/api/storage/mongodb/config/checkmodulation.py b/surveil/api/storage/mongodb/config/checkmodulation.py index a671dd6..160fa6c 100644 --- a/surveil/api/storage/mongodb/config/checkmodulation.py +++ b/surveil/api/storage/mongodb/config/checkmodulation.py @@ -17,6 +17,6 @@ import mongoengine class CheckModulation(mongoengine.Document): meta = {'collection': 'checkmodulations'} - checkmodulation_name = mongoengine.StringField(unique=True) + checkmodulation_name = mongoengine.StringField() check_command = mongoengine.StringField() check_period = mongoengine.StringField() \ No newline at end of file diff --git a/surveil/api/storage/mongodb/config/command.py b/surveil/api/storage/mongodb/config/command.py index 7b3b1d5..818a999 100644 --- a/surveil/api/storage/mongodb/config/command.py +++ b/surveil/api/storage/mongodb/config/command.py @@ -16,7 +16,10 @@ import mongoengine class Command(mongoengine.Document): - meta = {'collection': 'commands'} - command_name = mongoengine.StringField(unique=True) + meta = { + 'collection': 'commands', + 'strict': False + } + command_name = mongoengine.StringField() command_line = mongoengine.StringField() module_type = mongoengine.StringField() diff --git a/surveil/api/storage/mongodb/config/contact.py b/surveil/api/storage/mongodb/config/contact.py index e41044d..2a0048e 100644 --- a/surveil/api/storage/mongodb/config/contact.py +++ b/surveil/api/storage/mongodb/config/contact.py @@ -17,7 +17,7 @@ import mongoengine class Contact(mongoengine.Document): meta = {'collection': 'contacts'} - contact_name = mongoengine.StringField(unique=True) + contact_name = mongoengine.StringField() host_notifications_enabled = mongoengine.StringField() service_notifications_enabled = mongoengine.StringField() host_notification_period = mongoengine.StringField() diff --git a/surveil/api/storage/mongodb/config/contactgroup.py b/surveil/api/storage/mongodb/config/contactgroup.py index a4347bb..793ed8e 100644 --- a/surveil/api/storage/mongodb/config/contactgroup.py +++ b/surveil/api/storage/mongodb/config/contactgroup.py @@ -17,7 +17,7 @@ import mongoengine class ContactGroup(mongoengine.Document): meta = {'collection': 'contactgroups'} - contactgroup_name = mongoengine.StringField(unique=True) + contactgroup_name = mongoengine.StringField() members = mongoengine.StringField() alias = mongoengine.StringField() contactgroup_members = mongoengine.StringField() \ No newline at end of file diff --git a/surveil/api/storage/mongodb/config/host.py b/surveil/api/storage/mongodb/config/host.py index ab73116..8ab548c 100644 --- a/surveil/api/storage/mongodb/config/host.py +++ b/surveil/api/storage/mongodb/config/host.py @@ -16,8 +16,11 @@ import mongoengine class Host(mongoengine.Document): - meta = {'collection': 'hosts'} - host_name = mongoengine.StringField(unique=True) + meta = { + 'collection': 'hosts', + 'strict': False + } + host_name = mongoengine.StringField() address = mongoengine.StringField() max_check_attempts = mongoengine.IntField() check_period = mongoengine.StringField() diff --git a/surveil/api/storage/mongodb/config/hostgroup.py b/surveil/api/storage/mongodb/config/hostgroup.py index 907e955..4695b49 100644 --- a/surveil/api/storage/mongodb/config/hostgroup.py +++ b/surveil/api/storage/mongodb/config/hostgroup.py @@ -17,7 +17,7 @@ import mongoengine class HostGroup(mongoengine.Document): meta = {'collection': 'hostgroups'} - hostgroup_name = mongoengine.StringField(unique=True) + hostgroup_name = mongoengine.StringField() members = mongoengine.StringField() alias = mongoengine.StringField() hostgroup_members = mongoengine.StringField() diff --git a/surveil/api/storage/mongodb/config/macromodulation.py b/surveil/api/storage/mongodb/config/macromodulation.py index 7f40c7d..8611c8a 100644 --- a/surveil/api/storage/mongodb/config/macromodulation.py +++ b/surveil/api/storage/mongodb/config/macromodulation.py @@ -17,6 +17,6 @@ import mongoengine class MacroModulation(mongoengine.Document): meta = {'collection': 'macromodulations'} - macromodulation_name = mongoengine.StringField(unique=True) + macromodulation_name = mongoengine.StringField() modulation_period = mongoengine.StringField() macros = mongoengine.DictField() diff --git a/surveil/api/storage/mongodb/config/notificationway.py b/surveil/api/storage/mongodb/config/notificationway.py index a88d131..e4e3ce7 100644 --- a/surveil/api/storage/mongodb/config/notificationway.py +++ b/surveil/api/storage/mongodb/config/notificationway.py @@ -17,7 +17,7 @@ import mongoengine class NotificationWays(mongoengine.Document): meta = {'collection': 'notificationways'} - notificationway_name = mongoengine.StringField(unique=True) + notificationway_name = mongoengine.StringField() host_notification_period = mongoengine.StringField() service_notification_period = mongoengine.StringField() host_notification_options = mongoengine.StringField() diff --git a/surveil/api/storage/mongodb/config/realm.py b/surveil/api/storage/mongodb/config/realm.py index 10f9da2..b3cd05c 100644 --- a/surveil/api/storage/mongodb/config/realm.py +++ b/surveil/api/storage/mongodb/config/realm.py @@ -17,6 +17,6 @@ import mongoengine class Realm(mongoengine.Document): meta = {'collection': 'realms'} - realm_name = mongoengine.StringField(unique=True) + realm_name = mongoengine.StringField() realm_members = mongoengine.StringField() default = mongoengine.IntField() \ No newline at end of file diff --git a/surveil/api/storage/mongodb/config/service.py b/surveil/api/storage/mongodb/config/service.py index b6521de..77df377 100644 --- a/surveil/api/storage/mongodb/config/service.py +++ b/surveil/api/storage/mongodb/config/service.py @@ -16,8 +16,11 @@ import mongoengine class Service(mongoengine.Document): - meta = {'collection': 'services'} - host_name = mongoengine.StringField(unique=True) + meta = { + 'collection': 'services', + 'strict': False + } + host_name = mongoengine.StringField() service_description = mongoengine.StringField() contacts = mongoengine.StringField() check_command = mongoengine.StringField() diff --git a/surveil/api/storage/mongodb/config/servicegroup.py b/surveil/api/storage/mongodb/config/servicegroup.py index a5404ec..4b63dc9 100644 --- a/surveil/api/storage/mongodb/config/servicegroup.py +++ b/surveil/api/storage/mongodb/config/servicegroup.py @@ -17,7 +17,7 @@ import mongoengine class ServiceGroup(mongoengine.Document): meta = {'collection': 'servicegroups'} - servicegroup_name = mongoengine.StringField(unique=True) + servicegroup_name = mongoengine.StringField() members = mongoengine.StringField() alias = mongoengine.StringField() servicegroup_members = mongoengine.StringField() diff --git a/surveil/api/storage/mongodb/config/timeperiod.py b/surveil/api/storage/mongodb/config/timeperiod.py index bd35a49..b59e67d 100644 --- a/surveil/api/storage/mongodb/config/timeperiod.py +++ b/surveil/api/storage/mongodb/config/timeperiod.py @@ -17,6 +17,6 @@ import mongoengine class TimePeriod(mongoengine.Document): meta = {'collection': 'timeperiods'} - timeperiod_name = mongoengine.StringField(unique=True) + timeperiod_name = mongoengine.StringField() exclude = mongoengine.StringField() periods = mongoengine.DictField() diff --git a/surveil/tests/api/controllers/v2/config/test_macromodulations.py b/surveil/tests/api/controllers/v2/config/test_macromodulations.py index 44c9120..1bdd53e 100644 --- a/surveil/tests/api/controllers/v2/config/test_macromodulations.py +++ b/surveil/tests/api/controllers/v2/config/test_macromodulations.py @@ -101,7 +101,7 @@ class TestMacroModulationController(functionalTest.FunctionalTest): self.assertIsNotNone( self.mongoconnection.shinken.macromodulations.find_one( - m + {'macromodulation_name': 'TEST_CREATE_MODULATION'} ) )