Validate user inputs in settings daemon

Currently, the properties defined under /org/openbmc/settings/host0 can take any
value and it is upto the consumer daemons to act only if the valid data was
given.

This patch will provide a validation logic for all the properties and will raise
an exception in the case of invalid inputs. Only on a valid input, will the data
gets written and saved.

Validation methods and types per property are provided in the configuration file
and used by the manager whenever a particular property is changed.

Change-Id: I0731ce6e00ab3cb4e11deb98c03fda8d5adad913
Signed-off-by: Vishwanatha Subbanna <vishwa@linux.vnet.ibm.com>
diff --git a/settings.yaml b/settings.yaml
index 9e08e29..ca26840 100644
--- a/settings.yaml
+++ b/settings.yaml
@@ -1,6 +1,6 @@
 ---
 # Settings Config File
-host:
+org.openbmc.settings.Host:
     powercap:
         name: power_cap
         type: i
@@ -8,39 +8,66 @@
         min: 0
         max: 1000
         unit: watts
+        validation: range
     bootflags:
         name: boot_flags
         type: s
         default: "default"
+        validation: list
+        allowed: ["Network", "Disk", "Safe", "CDROM", "Setup", "default"]
     sysstate:
         name: system_state
         type: s
         default: ""
+        validation: None
     powerpolicy:
         name: power_policy
         type: s
         default: "RESTORE_LAST_STATE"
+        validation: list
+        allowed: ["ALWAYS_POWER_ON", "RESTORE_LAST_STATE", "LEAVE_OFF"]
     restrictedmode:
         name: restricted_mode
         type: b
         default: false
+        min: 0
+        max: 1
+        validation: range
     bootpolicy:
         name: boot_policy
         type: s
         default: "ONETIME"
+        validation: list
+        allowed: ["ONETIME", "PERMANENT"]
     networkconfig:
         name: network_config
         type: s
         default: "ipaddress=,prefix=,gateway=,mac=,addr_type="
+        validation: custom
+        method: validate_net_config
     TimeMode:
         name: time_mode
         type: s
         default: "NTP"
+        validation: list
+        allowed: ["NTP", "MANUAL"]
     TimeOwner:
         name: time_owner
         type: s
         default: "BMC"
+        validation: list
+        allowed: ["BMC", "HOST", "SPLIT", "BOTH"]
     UseDhcpNtp:
         name: use_dhcp_ntp
         type: s
         default: "yes"
+        validation: list
+        allowed: ["yes", "no"]
+
+# Example of using regex
+#    macaddress:
+#        name: mac_address
+#        type: s
+#        default: "aa:bb:cc:dd:ee:ff"
+#        validation: regex
+#        regex: '([a-fA-F0-9]{2}[:|\-]?){6}'