This article shows how to extract some ITSMO metadata form a subversione repository.
ITSMO is a vocabulary to annotate IT services. "Configuration Item" it is one of its main concept. An important Configuration item property is its relation with a "configuration" stored in a CMDB . Subversion it is an easy way to manage such configuration .
The command svn info, committed in a directory controlled by subversion produces an output like this:
Path: .
URL: https://subversion.assembla.com/svn/itsmo/trunk/v1
Repository Root: https://subversion.assembla.com/svn/itsmo
Repository UUID: aa9e2203-f931-4cdb-89b8-cce8243f9edb
Revision: 127
Node Kind: directory
Schedule: normal
Last Changed Author: e-artspace
Last Changed Rev: 127
Last Changed Date: 2011-09-04 10:01:38 +0000 (Sun, 04 Sep 2011)
From this output we can extract some meta-data that we can annotate with ITSMO ontology, mainly:
- Configuration URI ( itsmo:hasConfiguration) from URL field
- CMDB URI ( itsmo:hasCMDB) from Repository Root field
- Baseline URI ( itsmo:hasBaseline ) that you can obtain from Revision field. A quick and dirty way to produce a valid URI is to concatenate the revision to the configuration URI like this:
https://subversion.assembla.com/svn/itsmo/trunk/v1#127
Unfortunately this UTI is not perfect dereferenziato (it does not dereference well). Another method is to compose the snapshot URI using the hints contained in this this articole likehttps://subversion.assembla.com/svn/itsmo/trunk/!svn/bc/127/trunk/v1
Here is a sample php code fragment to extract and present subversion metadata:
<?php
//Place this code in the configuration directory
class SvnITSMOMetadata{
protected function parseInfo($s){
return preg_match("/$s:s+(.*)/",$this->svninfo, $matches)?trim($matches[1]):"unknown";
}
public function __construct($subject) {
$this->subject=$subject;
exec('svn info', $out);
$this->svninfo=implode("n",$out);
$this->CMDB=$this->parseInfo('Repository Root');
$this->configuration=$this->parseInfo('URL');
$this->revision=$this->parseInfo('Revision');
$this->baselinePath=substr($this->configuration, strlen($this->CMDB));
$this->baselineURI= $this->CMDB.'/!svn/bc/'.$this->revision.$this->baselinePath;
}
public function showTurtle(){
echo "
@prefix itsmo: <http://ontology.it/itsmo/v1#>
<$metadata->subject> itsmo:hasConfiguration <$metadata->configuration>;
rdfs:comment 'The based subversion configuration for $this->subject'.
itsmo:hasCMDB <$metadata->CMDB>;
itsmo:hasBaseline <$this->baselineURI>;
<$this->baselineURI> rdfs:label 'Revision $this->revision';
rdfs:comment '$this->svninfo'.
";
}
}
$metadata= New SvnITSMOMetadata("http://example.com/MyConfigUri");
$metadata->showTurtle();

