phosphor-mapper: Add service namespaces

The c++ mapper implements a dbus service namespace whitelist instead of
a path namespace whitelist.  A service namespace whitelist significantly
reduces the amount of introspection required by the mapper as compared
to path namespaces.

Add the service namespace whitelist to the mapper command line in the
mapper systemd unit and extend the existing framework for specifying
mapper command line arguments to include a service namespace whitelist.

Note that support for a _service_ blacklist is added and _path_ and
_interface_ blacklists are not being re-introduced.

Change-Id: Ia4636d338af2f87c7bc2a5041bcb685bca895060
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
diff --git a/recipes-phosphor/dbus/phosphor-dbus-interfaces-mapper-config-native.bb b/recipes-phosphor/dbus/phosphor-dbus-interfaces-mapper-config-native.bb
index c39e0a3..e87f225 100644
--- a/recipes-phosphor/dbus/phosphor-dbus-interfaces-mapper-config-native.bb
+++ b/recipes-phosphor/dbus/phosphor-dbus-interfaces-mapper-config-native.bb
@@ -8,4 +8,5 @@
 inherit obmc-phosphor-license
 
 PHOSPHOR_MAPPER_NAMESPACE_append = " /xyz/openbmc_project"
+PHOSPHOR_MAPPER_SERVICE_append = " xyz.openbmc_project"
 PHOSPHOR_MAPPER_INTERFACE_append = " xyz.openbmc_project"
diff --git a/recipes-phosphor/dbus/phosphor-legacy-namespace-mapper-config-native.bb b/recipes-phosphor/dbus/phosphor-legacy-namespace-mapper-config-native.bb
index 67199f9..69c7779 100644
--- a/recipes-phosphor/dbus/phosphor-legacy-namespace-mapper-config-native.bb
+++ b/recipes-phosphor/dbus/phosphor-legacy-namespace-mapper-config-native.bb
@@ -7,4 +7,5 @@
 inherit obmc-phosphor-license
 
 PHOSPHOR_MAPPER_NAMESPACE_append = " /org/openbmc"
+PHOSPHOR_MAPPER_SERVICE_append = " org.openbmc"
 PHOSPHOR_MAPPER_INTERFACE_append = " org.openbmc"
diff --git a/recipes-phosphor/dbus/phosphor-mapper-config-native.bb b/recipes-phosphor/dbus/phosphor-mapper-config-native.bb
index dcc5bd3..9e2f43f 100644
--- a/recipes-phosphor/dbus/phosphor-mapper-config-native.bb
+++ b/recipes-phosphor/dbus/phosphor-mapper-config-native.bb
@@ -24,10 +24,17 @@
 # Add path namespaces to be monitored.
 PHOSPHOR_MAPPER_NAMESPACE = ""
 
+# Add services to be monitored.
+PHOSPHOR_MAPPER_SERVICE = ""
+
 # Add interfaces to be monitored.
 PHOSPHOR_MAPPER_INTERFACE = ""
 
+# Blacklist services from being monitored.
+PHOSPHOR_MAPPER_SERVICE_BLACKLIST = ""
+
 do_install() {
         install -d ${D}/${namespace_dir}
         install -d ${D}/${interface_dir}
+        install -d ${D}/${serviceblacklist_dir}
 }
diff --git a/recipes-phosphor/dbus/phosphor-mapper/xyz.openbmc_project.ObjectMapper.service b/recipes-phosphor/dbus/phosphor-mapper/xyz.openbmc_project.ObjectMapper.service
index 394e0ed..69fb1e2 100644
--- a/recipes-phosphor/dbus/phosphor-mapper/xyz.openbmc_project.ObjectMapper.service
+++ b/recipes-phosphor/dbus/phosphor-mapper/xyz.openbmc_project.ObjectMapper.service
@@ -8,7 +8,9 @@
 Type=dbus
 ExecStart=/usr/bin/env phosphor-mapper \
         --path_namespaces="${{MAPPER_NAMESPACES}}" \
-        --interface_namespaces="${{MAPPER_INTERFACES}}"
+        --service_namespaces="${{MAPPER_SERVICES}}" \
+        --interface_namespaces="${{MAPPER_INTERFACES}}" \
+        --service_blacklists="${{MAPPER_SERVICEBLACKLISTS}}"
 SyslogIdentifier=phosphor-mapper
 BusName={BUSNAME}
 TimeoutStartSec=300
diff --git a/recipes-phosphor/dbus/phosphor-mapper_git.bb b/recipes-phosphor/dbus/phosphor-mapper_git.bb
index 9e0e7c2..c4c7f51 100644
--- a/recipes-phosphor/dbus/phosphor-mapper_git.bb
+++ b/recipes-phosphor/dbus/phosphor-mapper_git.bb
@@ -59,11 +59,23 @@
         paths.append(os.sep.join(p.split('-')))
 
     path = d.getVar('STAGING_DIR_NATIVE', True) + \
+        d.getVar('service_dir', True)
+    services = []
+    for s in os.listdir(path):
+        services.append('.'.join(s.split('-')))
+
+    path = d.getVar('STAGING_DIR_NATIVE', True) + \
         d.getVar('interface_dir', True)
     interfaces = []
     for i in os.listdir(path):
         interfaces.append('.'.join(i.split('-')))
 
+    path = d.getVar('STAGING_DIR_NATIVE', True) + \
+        d.getVar('serviceblacklist_dir', True)
+    service_blacklists = []
+    for x in os.listdir(path):
+        service_blacklists.append('.'.join(x.split('-')))
+
     path = [d.getVar('D', True) + d.getVar('envfiledir', True)]
     path.append('obmc')
     path.append('mapper')
@@ -75,8 +87,12 @@
     with open(path, 'w+') as fd:
         fd.write('MAPPER_NAMESPACES="{}"'.format(' '.join(paths)))
         fd.write('\n')
+        fd.write('MAPPER_SERVICES="{}"'.format(' '.join(services)))
+        fd.write('\n')
         fd.write('MAPPER_INTERFACES="{}"'.format(' '.join(interfaces)))
         fd.write('\n')
+        fd.write('MAPPER_SERVICEBLACKLISTS="{}"'.format(' '.join(service_blacklists)))
+        fd.write('\n')
 }
 
 do_install[postfuncs] += "do_emit_env"