need global configuration file to mostly replace local ones

Bug #627735 reported by danh
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Scribe2
New
Undecided
Unassigned

Bug Description

Right now, we have a series of files named petabox-sw-config-CENTER.xml,
where CENTER is the name of one of our scanning centers, such as toronto
or sfdowntown.

These files define the locations of software in the system.

They are also nearly identical, so that if we make a system-wide change
(typically to add the location of a program to invoke), all of them have to be edited.

What would be better would be to have a single configuration file, plus perhaps
some small customized versions for storing local information (such as time zone).

We might be able to do this by using xinclude
(see http://en.wikipedia.org/wiki/Xinclude). This would involve putting
all the common data in one file and xinclud'ing it.

Or perhaps we could change some of the code in Config.inc or setup.php.

Or we might pursue something else entirely.

Revision history for this message
Hank Bromley (hank-archive) wrote :

Confirmed that we can use Xinclude with php DOMDocument objects. (SimpleXML doesn't support Xinclude, but if we want to work in SimpleXML, we can simply convert to DOMDocument, do the Xinclude, and convert back to SimpleXML.) Wasn't aware of Xinclude until now - thanks, Dan!

The only thing that's slightly tricky is that we need the Xinclude to resolve to multiple nodes (all the second-level elements in the included xml), so that the inherited values don't end up one level deeper in the resulting xml structure than the local ones.

Our scancenter config files look like:

<?xml version="1.0" encoding="UTF-8"?>
<settings>
  <domain>scribe.archive.org</domain>
  <www-domain>archive.org</www-domain>
  ...
</settings>

Let's say we have a shared petabox-sw-config-scancenters.xml file like the above, and we want to overlay it with with some location-specific values. Then we'd have a location-specific file, say petabox-sw-config-sfdowntown.xml, that would look like this:

<?xml version="1.0" encoding="UTF-8"?>
<settings>
  <xi:include href="petabox-sw-config-scancenters.xml#xpointer(/settings/*)"/>
  <timezone-name>PST</timezone-name>
  <timezone-value>-0800</timezone-value>
</settings>

When resolved, the <xi:include> element will be replaced with all the elements immediately below <settings> in petabox-sw-config-scancenters.xml. Without the xpointer, the <settings> element itself would be inserted, burying the intended info one level too deep.

And here's how to make the substitution happen:

$dom = new DOMDocument();
$dom->load("sfdowntown.xml");
$dom->xinclude();

Our DOMDocument now contains the merged values.

We could also take it one step further, and put elements that are in petabox-sw-config-us.xml (the cluster-node config file), as well as the scribe config files, in a base config file that's shared across both the cluster and scancenters. Let's say we call that petabox-sw-config-base.xml. Then we move all the common stuff to there from petabox-sw-config-us.xml and petabox-sw-config-scancenters.xml, replacing it with an xi:include element. The dependencies would look like this:

petabox-sw-config-sfdowntown.xml => petabox-sw-config-scancenter.xml \
                                                                                                                        => petabox-sw-config-base.xml
                                                                            petabox-sw-config-us.xml /

Revision history for this message
Hank Bromley (hank-archive) wrote :

Oh well, the indenting didn't work so well at the end of that comment, but I'm sure you get the idea...

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.