[icinga-checkins] icinga.org: icinga2/master: ido: Add stubs for contacts/contactstatus.

git at icinga.org git at icinga.org
Wed Jul 31 09:10:01 CEST 2013


Module: icinga2
Branch: master
Commit: a9ffe83f7138b96ae368e6e2be052bf4579ac132
URL:    https://git.icinga.org/?p=icinga2.git;a=commit;h=a9ffe83f7138b96ae368e6e2be052bf4579ac132

Author: Gunnar Beutner <gunnar.beutner at netways.de>
Date:   Wed Jul 31 09:09:39 2013 +0200

ido: Add stubs for contacts/contactstatus.

---

 lib/ido/Makefile.am      |    4 ++-
 lib/ido/userdbobject.cpp |   77 ++++++++++++++++++++++++++++++++++++++++++++++
 lib/ido/userdbobject.h   |   47 ++++++++++++++++++++++++++++
 3 files changed, 127 insertions(+), 1 deletions(-)

diff --git a/lib/ido/Makefile.am b/lib/ido/Makefile.am
index 0867fa2..bff7d70 100644
--- a/lib/ido/Makefile.am
+++ b/lib/ido/Makefile.am
@@ -26,7 +26,9 @@ libido_la_SOURCES = \
 	hostdbobject.h \
 	ido-type.cpp \
 	servicedbobject.cpp \
-	servicedbobject.h
+	servicedbobject.h \
+	userdbobject.cpp \
+	userdbobject.h
 
 libido_la_CPPFLAGS = \
 	$(LTDLINCL) \
diff --git a/lib/ido/userdbobject.cpp b/lib/ido/userdbobject.cpp
new file mode 100644
index 0000000..bde9883
--- /dev/null
+++ b/lib/ido/userdbobject.cpp
@@ -0,0 +1,77 @@
+/******************************************************************************
+ * Icinga 2                                                                   *
+ * Copyright (C) 2012 Icinga Development Team (http://www.icinga.org/)        *
+ *                                                                            *
+ * This program is free software; you can redistribute it and/or              *
+ * modify it under the terms of the GNU General Public License                *
+ * as published by the Free Software Foundation; either version 2             *
+ * of the License, or (at your option) any later version.                     *
+ *                                                                            *
+ * This program is distributed in the hope that it will be useful,            *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              *
+ * GNU General Public License for more details.                               *
+ *                                                                            *
+ * You should have received a copy of the GNU General Public License          *
+ * along with this program; if not, write to the Free Software Foundation     *
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.             *
+ ******************************************************************************/
+
+#include "ido/userdbobject.h"
+#include "ido/dbtype.h"
+#include "ido/dbvalue.h"
+#include "icinga/user.h"
+#include "base/objectlock.h"
+#include <boost/foreach.hpp>
+
+using namespace icinga;
+
+REGISTER_DBTYPE("User", "contact", 10, UserDbObject);
+
+UserDbObject::UserDbObject(const String& name1, const String& name2)
+	: DbObject(DbType::GetByName("User"), name1, name2)
+{ }
+
+Dictionary::Ptr UserDbObject::GetConfigFields(void) const
+{
+	Dictionary::Ptr fields = boost::make_shared<Dictionary>();
+	User::Ptr user = static_pointer_cast<User>(GetObject());
+
+	fields->Set("alias", Empty);
+	fields->Set("email_address", Empty);
+	fields->Set("pager_address", Empty);
+	fields->Set("host_timeperiod_object_id", Empty);
+	fields->Set("service_timeperiod_object_id", Empty);
+	fields->Set("host_notifications_enabled", Empty);
+	fields->Set("service_notifications_enabled", Empty);
+	fields->Set("can_submit_commands", Empty);
+	fields->Set("notify_service_recovery", Empty);
+	fields->Set("notify_service_warning", Empty);
+	fields->Set("notify_service_unknown", Empty);
+	fields->Set("notify_service_critical", Empty);
+	fields->Set("notify_service_flapping", Empty);
+	fields->Set("notify_service_downtime", Empty);
+	fields->Set("notify_host_recovery", Empty);
+	fields->Set("notify_host_down", Empty);
+	fields->Set("notify_host_unreachable", Empty);
+	fields->Set("notify_host_flapping", Empty);
+	fields->Set("notify_host_downtime", Empty);
+
+	return fields;
+}
+
+Dictionary::Ptr UserDbObject::GetStatusFields(void) const
+{
+	Dictionary::Ptr fields = boost::make_shared<Dictionary>();
+	User::Ptr user = static_pointer_cast<User>(GetObject());
+
+	fields->Set("host_notifications_enabled", Empty);
+	fields->Set("service_notifications_enabled", Empty);
+	fields->Set("last_host_notification", Empty);
+	fields->Set("last_service_notification", Empty);
+	fields->Set("modified_attributes", Empty);
+	fields->Set("modified_host_attributes", Empty);
+	fields->Set("modified_service_attributes", Empty);
+
+	return fields;
+}
diff --git a/lib/ido/userdbobject.h b/lib/ido/userdbobject.h
new file mode 100644
index 0000000..c8eaf0c
--- /dev/null
+++ b/lib/ido/userdbobject.h
@@ -0,0 +1,47 @@
+/******************************************************************************
+ * Icinga 2                                                                   *
+ * Copyright (C) 2012 Icinga Development Team (http://www.icinga.org/)        *
+ *                                                                            *
+ * This program is free software; you can redistribute it and/or              *
+ * modify it under the terms of the GNU General Public License                *
+ * as published by the Free Software Foundation; either version 2             *
+ * of the License, or (at your option) any later version.                     *
+ *                                                                            *
+ * This program is distributed in the hope that it will be useful,            *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              *
+ * GNU General Public License for more details.                               *
+ *                                                                            *
+ * You should have received a copy of the GNU General Public License          *
+ * along with this program; if not, write to the Free Software Foundation     *
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.             *
+ ******************************************************************************/
+
+#ifndef USERDBOBJECT_H
+#define USERDBOBJECT_H
+
+#include "ido/dbobject.h"
+#include "base/dynamicobject.h"
+
+namespace icinga
+{
+
+/**
+ * A User database object.
+ *
+ * @ingroup ido
+ */
+class UserDbObject : public DbObject
+{
+public:
+	DECLARE_PTR_TYPEDEFS(UserDbObject);
+
+	UserDbObject(const String& name1, const String& name2);
+
+	virtual Dictionary::Ptr GetConfigFields(void) const;
+	virtual Dictionary::Ptr GetStatusFields(void) const;
+};
+
+}
+
+#endif /* USERDBOBJECT_H */





More information about the icinga-checkins mailing list