Commit 5d472fdce440a2083738e8086254146abbe9b461

Thomas de Grivel 2015-09-23T06:34:38

Host probes.

diff --git a/core/defs.lisp b/core/defs.lisp
index f0555eb..3b8e06d 100644
--- a/core/defs.lisp
+++ b/core/defs.lisp
@@ -184,7 +184,9 @@
   ((probe-os-using-uname :properties (:os))
    (probe-hostname :properties (:hostname))
    (probe-boot-time :properties (:boot-time))
-   (probe-host-user :properties (:user))))
+   (probe-host-user :properties (:user))
+   (probe-host-packages :properties (:packages)))
+  ((op-hostname :properties (:hostname))))
 
 (defgeneric probe-os-using-uname (host os))
 (defgeneric probe-hostname (host os))
diff --git a/core/spec.lisp b/core/spec.lisp
index ecffa16..082c5fa 100644
--- a/core/spec.lisp
+++ b/core/spec.lisp
@@ -100,6 +100,11 @@
 (defmethod match-specified-value (resource property specified probed)
   (equalp specified (describe-probed-property-value resource property probed)))
 
+(defmethod match-specified-value (resource (property (eql :ensure))
+                                  (specified (eql :present))
+                                  (probed null))
+  t)
+
 ;;  Methods to get current status of resource
 
 (defgeneric resource-diff (resource)
diff --git a/unix/defs.lisp b/unix/defs.lisp
index d311676..3ede6ef 100644
--- a/unix/defs.lisp
+++ b/unix/defs.lisp
@@ -21,20 +21,30 @@
 ;;  Group
 
 (define-resource-class group () ()
-  ((probe-group-in-/etc/group :properties (:name :passwd :gid :members))))
+  ((probe-group-in-/etc/group :properties (:ensure :name :passwd :gid :members)))
+  ((op-update-group :properties (:ensure :gid))))
 
 (defgeneric probe-group-in-/etc/group (resource os))
+(defgeneric op-update-group (resource os &key ensure gid))
 
 ;;  User
 
 (define-resource-class user ()
   ()
-  ((probe-user-in-/etc/passwd :properties (:login :uid :gid :realname :home
-                                           :shell))
-   (probe-user-groups-in-/etc/group :properties (:groups))))
+  ((probe-user-in-/etc/passwd :properties (:ensure :login :uid :gid :realname
+                                                   :home :shell))
+   (probe-user-groups-in-/etc/group :properties (:groups)))
+  ((op-update-user :properties (:ensure :uid :gid :realname :home :shell
+                                        :login-class :groups))))
 
 (defgeneric probe-user-in-/etc/passwd (resource os))
 (defgeneric probe-user-groups-in-/etc/group (resource os))
+(defgeneric op-update-user (resource os &key ensure uid gid realname home shell
+                                          login-class
+                                          groups))
+
+(defmethod resource-before-p ((r1 group) (r2 user))
+  t)
 
 ;;  Filesystem virtual node