phosphor-settings-defaults: refactor defaults settings for multihost support

separate host items from defaults.yaml to host-template.yaml
add host items to defaults.yaml based on OBMC_HOST_INSTANCES to support multi-host.

TESTED:
a. build with default OBMC_HOST_INSTANCES="0"

`busctl tree xyz.openbmc_project.Settings`
└─/xyz
  └─/xyz/openbmc_project
    ├─/xyz/openbmc_project/control
    │ ├─/xyz/openbmc_project/control/host0
    │ │ ├─/xyz/openbmc_project/control/host0/TPMEnable
    │ │ ├─/xyz/openbmc_project/control/host0/auto_reboot
    │ │ │ └─/xyz/openbmc_project/control/host0/auto_reboot/one_time
    │ │ ├─/xyz/openbmc_project/control/host0/boot
    │ │ │ └─/xyz/openbmc_project/control/host0/boot/one_time
    │ │ ├─/xyz/openbmc_project/control/host0/power_cap
    │ │ ├─/xyz/openbmc_project/control/host0/power_restore_policy
    │ │ │ └─/xyz/openbmc_project/control/host0/power_restore_policy/one_time
    │ │ ├─/xyz/openbmc_project/control/host0/restriction_mode
    │ │ └─/xyz/openbmc_project/control/host0/turbo_allowed
    │ ├─/xyz/openbmc_project/control/minimum_ship_level_required
    │ ├─/xyz/openbmc_project/control/power_supply_attributes
    │ └─/xyz/openbmc_project/control/power_supply_redundancy
    ├─/xyz/openbmc_project/logging
    │ ├─/xyz/openbmc_project/logging/rest_api_logs
    │ └─/xyz/openbmc_project/logging/settings
    ├─/xyz/openbmc_project/network
    │ └─/xyz/openbmc_project/network/host0
    │   └─/xyz/openbmc_project/network/host0/intf
    │     └─/xyz/openbmc_project/network/host0/intf/addr
    ├─/xyz/openbmc_project/software
    │ └─/xyz/openbmc_project/software/apply_time
    └─/xyz/openbmc_project/time
      └─/xyz/openbmc_project/time/sync_method

b. build with Bletchley platform: OBMC_HOST_INSTANCES = "1 2 3 4 5 6"
`busctl tree xyz.openbmc_project.Settings`
└─/xyz
  └─/xyz/openbmc_project
    ├─/xyz/openbmc_project/control
    │ ├─/xyz/openbmc_project/control/host1
    │ │ ├─/xyz/openbmc_project/control/host1/TPMEnable
    │ │ ├─/xyz/openbmc_project/control/host1/auto_reboot
    │ │ │ └─/xyz/openbmc_project/control/host1/auto_reboot/one_time
    │ │ ├─/xyz/openbmc_project/control/host1/boot
    │ │ │ └─/xyz/openbmc_project/control/host1/boot/one_time
    │ │ ├─/xyz/openbmc_project/control/host1/power_cap
    │ │ ├─/xyz/openbmc_project/control/host1/power_restore_policy
    │ │ │ └─/xyz/openbmc_project/control/host1/power_restore_policy/one_time
    │ │ ├─/xyz/openbmc_project/control/host1/restriction_mode
    │ │ └─/xyz/openbmc_project/control/host1/turbo_allowed
    │ ├─/xyz/openbmc_project/control/host2
    │ │ ├─/xyz/openbmc_project/control/host2/TPMEnable
    │ │ ├─/xyz/openbmc_project/control/host2/auto_reboot
    │ │ │ └─/xyz/openbmc_project/control/host2/auto_reboot/one_time
    │ │ ├─/xyz/openbmc_project/control/host2/boot
    │ │ │ └─/xyz/openbmc_project/control/host2/boot/one_time
    │ │ ├─/xyz/openbmc_project/control/host2/power_cap
    │ │ ├─/xyz/openbmc_project/control/host2/power_restore_policy
    │ │ │ └─/xyz/openbmc_project/control/host2/power_restore_policy/one_time
    │ │ ├─/xyz/openbmc_project/control/host2/restriction_mode
    │ │ └─/xyz/openbmc_project/control/host2/turbo_allowed
    │ ├─/xyz/openbmc_project/control/host3
    (.......repeat util host6)
    │ ├─/xyz/openbmc_project/control/minimum_ship_level_required
    │ ├─/xyz/openbmc_project/control/power_supply_attributes
    │ └─/xyz/openbmc_project/control/power_supply_redundancy
    ├─/xyz/openbmc_project/logging
    │ ├─/xyz/openbmc_project/logging/rest_api_logs
    │ └─/xyz/openbmc_project/logging/settings
    ├─/xyz/openbmc_project/network
    │ ├─/xyz/openbmc_project/network/host1
    │ │ └─/xyz/openbmc_project/network/host1/intf
    │ │   └─/xyz/openbmc_project/network/host1/intf/addr
    │ ├─/xyz/openbmc_project/network/host2
    │ │ └─/xyz/openbmc_project/network/host2/intf
    │ │   └─/xyz/openbmc_project/network/host2/intf/addr
    │ ├─/xyz/openbmc_project/network/host3
    │ │ └─/xyz/openbmc_project/network/host3/intf
    │ │   └─/xyz/openbmc_project/network/host3/intf/addr
    │ ├─/xyz/openbmc_project/network/host4
    │ │ └─/xyz/openbmc_project/network/host4/intf
    │ │   └─/xyz/openbmc_project/network/host4/intf/addr
    │ ├─/xyz/openbmc_project/network/host5
    │ │ └─/xyz/openbmc_project/network/host5/intf
    │ │   └─/xyz/openbmc_project/network/host5/intf/addr
    │ └─/xyz/openbmc_project/network/host6
    │   └─/xyz/openbmc_project/network/host6/intf
    │     └─/xyz/openbmc_project/network/host6/intf/addr
    ├─/xyz/openbmc_project/software
    │ └─/xyz/openbmc_project/software/apply_time
    └─/xyz/openbmc_project/time
      └─/xyz/openbmc_project/time/sync_method

Change-Id: I4b70fb7e19647ea2ba5c985cb7c6bf851cb971b2
Signed-off-by: Allen.Wang <Allen_Wang@quantatw.com>
diff --git a/meta-phosphor/recipes-phosphor/settings/phosphor-settings-defaults-native.bb b/meta-phosphor/recipes-phosphor/settings/phosphor-settings-defaults-native.bb
index 77693af..79fe68a 100644
--- a/meta-phosphor/recipes-phosphor/settings/phosphor-settings-defaults-native.bb
+++ b/meta-phosphor/recipes-phosphor/settings/phosphor-settings-defaults-native.bb
@@ -7,6 +7,7 @@
 inherit native
 
 SRC_URI += "file://defaults.yaml"
+SRC_URI += "file://host-template.yaml"
 
 PROVIDES += "virtual/phosphor-settings-defaults"
 
@@ -16,4 +17,10 @@
         DEST=${D}${settings_datadir}
         install -d ${DEST}
         install defaults.yaml ${DEST}
+
+        for i in ${OBMC_HOST_INSTANCES};
+        do
+                cat host-template.yaml | sed "s/{}/${i}/g" >> ${DEST}/defaults.yaml
+
+        done
 }
diff --git a/meta-phosphor/recipes-phosphor/settings/phosphor-settings-defaults/defaults.yaml b/meta-phosphor/recipes-phosphor/settings/phosphor-settings-defaults/defaults.yaml
index 68649f6..768d080 100644
--- a/meta-phosphor/recipes-phosphor/settings/phosphor-settings-defaults/defaults.yaml
+++ b/meta-phosphor/recipes-phosphor/settings/phosphor-settings-defaults/defaults.yaml
@@ -4,112 +4,12 @@
           MinimumShipLevelRequired:
              Default: 'true'
 
-/xyz/openbmc_project/control/host0/auto_reboot:
-    - Interface: xyz.openbmc_project.Control.Boot.RebootPolicy
-      Properties:
-          AutoReboot:
-             Default: 'true'
-
-/xyz/openbmc_project/control/host0/auto_reboot/one_time:
-    - Interface: xyz.openbmc_project.Control.Boot.RebootPolicy
-      Properties:
-          AutoReboot:
-             Default: 'true'
-
-/xyz/openbmc_project/control/host0/boot:
-    - Interface: xyz.openbmc_project.Control.Boot.Source
-      Properties:
-          BootSource:
-              Default: Source::Sources::Default
-    - Interface: xyz.openbmc_project.Control.Boot.Mode
-      Properties:
-          BootMode:
-              Default: Mode::Modes::Regular
-    - Interface: xyz.openbmc_project.Object.Enable
-      Properties:
-          Enabled:
-              Default: 'false'
-
-/xyz/openbmc_project/control/host0/boot/one_time:
-    - Interface: xyz.openbmc_project.Object.Enable
-      Properties:
-          Enabled:
-              Default: 'false'
-
-/xyz/openbmc_project/control/host0/power_cap:
-    - Interface: xyz.openbmc_project.Control.Power.Cap
-      Properties:
-          PowerCap:
-              Default: 0
-              Validation:
-                  Type: "range"
-                  Validator: "0..1000"
-                  Unit: "Watts"
-          PowerCapEnable:
-               Default: 'false'
-
-/xyz/openbmc_project/control/host0/power_restore_policy:
-    - Interface: xyz.openbmc_project.Control.Power.RestorePolicy
-      Properties:
-          PowerRestorePolicy:
-              Default: RestorePolicy::Policy::AlwaysOff
-          PowerRestoreDelay:
-              Default: 0
-
-/xyz/openbmc_project/control/host0/power_restore_policy/one_time:
-    - Interface: xyz.openbmc_project.Control.Power.RestorePolicy
-      Properties:
-          PowerRestorePolicy:
-              Default: RestorePolicy::Policy::None
-          PowerRestoreDelay:
-              Default: 0
-
 /xyz/openbmc_project/time/sync_method:
     - Interface: xyz.openbmc_project.Time.Synchronization
       Properties:
           TimeSyncMethod:
               Default: Synchronization::Method::NTP
 
-/xyz/openbmc_project/network/host0/intf:
-    - Interface: xyz.openbmc_project.Network.MACAddress
-      Properties:
-          MACAddress:
-              Default: '"00:00:00:00:00:00"'
-              Validation:
-                  Type: "regex"
-                  Validator: '^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$'
-
-#needs to implement address validation TODO openbmc/issues/2046
-/xyz/openbmc_project/network/host0/intf/addr:
-    - Interface: xyz.openbmc_project.Network.IP
-      Properties:
-          Address:
-              Default: '"0.0.0.0"'
-          PrefixLength:
-              Default: 0
-              Validation:
-                  Type: "range"
-                  Validator: 0..128
-                  Unit: "bits"
-          Origin:
-              Default: IP::AddressOrigin::Static
-          Gateway:
-              Default: '"0.0.0.0"'
-          Type:
-              Default: IP::Protocol::IPv4
-
-/xyz/openbmc_project/control/host0/restriction_mode:
-    - Interface: xyz.openbmc_project.Control.Security.RestrictionMode
-      Properties:
-          RestrictionMode:
-              Default: RestrictionMode::Modes::None
-
-/xyz/openbmc_project/control/host0/TPMEnable:
-    - Interface: xyz.openbmc_project.Control.TPM.Policy
-      Properties:
-          TPMEnable:
-             Default: 'false'
-
 /xyz/openbmc_project/control/power_supply_attributes:
     - Interface: xyz.openbmc_project.Control.PowerSupplyAttributes
       Properties:
@@ -122,11 +22,6 @@
           PowerSupplyRedundancyEnabled:
              Default: 'true'
 
-/xyz/openbmc_project/control/host0/turbo_allowed:
-    - Interface: xyz.openbmc_project.Control.Host.TurboAllowed
-      Properties:
-          TurboAllowed:
-             Default: 'true'
 
 /xyz/openbmc_project/logging/rest_api_logs:
     - Interface: xyz.openbmc_project.Object.Enable
diff --git a/meta-phosphor/recipes-phosphor/settings/phosphor-settings-defaults/host-template.yaml b/meta-phosphor/recipes-phosphor/settings/phosphor-settings-defaults/host-template.yaml
new file mode 100644
index 0000000..4088b82
--- /dev/null
+++ b/meta-phosphor/recipes-phosphor/settings/phosphor-settings-defaults/host-template.yaml
@@ -0,0 +1,105 @@
+/xyz/openbmc_project/control/host{}/auto_reboot:
+    - Interface: xyz.openbmc_project.Control.Boot.RebootPolicy
+      Properties:
+          AutoReboot:
+             Default: 'true'
+
+/xyz/openbmc_project/control/host{}/auto_reboot/one_time:
+    - Interface: xyz.openbmc_project.Control.Boot.RebootPolicy
+      Properties:
+          AutoReboot:
+             Default: 'true'
+
+/xyz/openbmc_project/control/host{}/boot:
+    - Interface: xyz.openbmc_project.Control.Boot.Source
+      Properties:
+          BootSource:
+              Default: Source::Sources::Default
+    - Interface: xyz.openbmc_project.Control.Boot.Mode
+      Properties:
+          BootMode:
+              Default: Mode::Modes::Regular
+    - Interface: xyz.openbmc_project.Object.Enable
+      Properties:
+          Enabled:
+              Default: 'false'
+
+/xyz/openbmc_project/control/host{}/boot/one_time:
+    - Interface: xyz.openbmc_project.Object.Enable
+      Properties:
+          Enabled:
+              Default: 'false'
+
+/xyz/openbmc_project/control/host{}/power_cap:
+    - Interface: xyz.openbmc_project.Control.Power.Cap
+      Properties:
+          PowerCap:
+              Default: 0
+              Validation:
+                  Type: "range"
+                  Validator: "0..1000"
+                  Unit: "Watts"
+          PowerCapEnable:
+               Default: 'false'
+
+/xyz/openbmc_project/control/host{}/power_restore_policy:
+    - Interface: xyz.openbmc_project.Control.Power.RestorePolicy
+      Properties:
+          PowerRestorePolicy:
+              Default: RestorePolicy::Policy::AlwaysOff
+          PowerRestoreDelay:
+              Default: 0
+
+/xyz/openbmc_project/control/host{}/power_restore_policy/one_time:
+    - Interface: xyz.openbmc_project.Control.Power.RestorePolicy
+      Properties:
+          PowerRestorePolicy:
+              Default: RestorePolicy::Policy::None
+          PowerRestoreDelay:
+              Default: 0
+
+/xyz/openbmc_project/control/host{}/restriction_mode:
+    - Interface: xyz.openbmc_project.Control.Security.RestrictionMode
+      Properties:
+          RestrictionMode:
+              Default: RestrictionMode::Modes::None
+
+/xyz/openbmc_project/control/host{}/TPMEnable:
+    - Interface: xyz.openbmc_project.Control.TPM.Policy
+      Properties:
+          TPMEnable:
+             Default: 'false'
+
+/xyz/openbmc_project/control/host{}/turbo_allowed:
+    - Interface: xyz.openbmc_project.Control.Host.TurboAllowed
+      Properties:
+          TurboAllowed:
+             Default: 'true'
+
+/xyz/openbmc_project/network/host{}/intf:
+    - Interface: xyz.openbmc_project.Network.MACAddress
+      Properties:
+          MACAddress:
+              Default: '"00:00:00:00:00:00"'
+              Validation:
+                  Type: "regex"
+                  Validator: '^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$'
+
+#needs to implement address validation TODO openbmc/issues/2046
+/xyz/openbmc_project/network/host{}/intf/addr:
+    - Interface: xyz.openbmc_project.Network.IP
+      Properties:
+          Address:
+              Default: '"0.0.0.0"'
+          PrefixLength:
+              Default: 0
+              Validation:
+                  Type: "range"
+                  Validator: 0..128
+                  Unit: "bits"
+          Origin:
+              Default: IP::AddressOrigin::Static
+          Gateway:
+              Default: '"0.0.0.0"'
+          Type:
+              Default: IP::Protocol::IPv4