Salve a tutti, vi espongo una problematica in cui stiamo incappando su di un server di test.
L'ambiente è composto di:
CMDBuild 1.3.1.0
Shark
Geoserver
OCSreport
Il tutto sembra essere perfettamente funzionante e riusciamo a muoverci abbastanza agilmente tra workflow e georiferimenti.
Con l'implementazione degli ocsreports, volevamo tentare anche l'importazione dei dati nel database cmdbuild, trovandoci però di fronte ad alcune problematiche.
La struttura che stiamo seguendo è quella basilare e le tabelle sono state configurate come da schema di esempio dell'external connector 1.3.1.0, con l'aggiunta di una tabella "software" (abbiamo mantenuto il file importocs.xpdl):
<?xml version="1.0"?>
<CMDBUILD>
<Computer>
<Code/>
<Description/>
<NumeroSerie/>
<SO/>
<RAM/>
</Computer>
<Software>
<Nome/>
<Versione/>
</Software>
<SchedaRete>
<IndirizzoIP/>
<MACAddress/>
</SchedaRete>
</CMDBUILD>
Il file transform è strutturato come segue, sempre come da esempio e con l'aggiunta dei tag "Software":
<?xml version="1.0" encoding="UTF-8"?>
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<CMDBUILD>
<xsl:apply-templates/>
</CMDBUILD>
</xsl:template>
<xsl:template match="*">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="text()"></xsl:template>
<xsl:template match="/inventory/device">
<Computer key="Code">
<Code>
<xsl:value-of select="/inventory/device/TAG"/>
</Code>
<Description>
<xsl:value-of select="NAME"/>
</Description>
<SO>
<xsl:value-of select="/inventory/device/OSNAME"/>
</SO>
<RAM>
<xsl:value-of select="sum(/inventory/memory/CAPACITY)"/>
</RAM>
</Computer>
</xsl:template>
<xsl:template match="/CMDBUILD/Computer">
<Computer key="Code">
<xsl:attribute name="objid">
<xsl:value-of select="./@objid"/>
</xsl:attribute>
<Code>
<xsl:value-of select="./Code"/>
</Code>
<Description>
<xsl:value-of select="./Description"/>
</Description>
<SO>
<xsl:value-of select="./SO"/>
</SO>
<RAM>
<xsl:value-of select="./RAM"/>
</RAM>
</Computer>
</xsl:template>
<xsl:template match="/inventory/network">
<SchedaRete domain="AssetSchedaRete" domaindirection="inverted" identifiers="MACAddress">
<IndirizzoIP>
<xsl:value-of select="./IPADDRESS"/>
</IndirizzoIP>
<MACAddress>
<xsl:value-of select="./MACADDR"/>
</MACAddress>
</SchedaRete>
</xsl:template>
<xsl:template match="/CMDBUILD/SchedaRete">
<SchedaRete domain="AssetSchedaRete" domaindirection="inverted" identifiers="MACAddress">
<xsl:attribute name="objid">
<xsl:value-of select="./@objid"/>
</xsl:attribute>
<IndirizzoIP>
<xsl:value-of select="./IndirizzoIP"/>
</IndirizzoIP>
<MACAddress>
<xsl:value-of select="./MACAddress"/>
</MACAddress>
</SchedaRete>
</xsl:template>
<xsl:template match="/inventory/software">
<Software domain="SoftwareInstallato" domaindirection="directed" identifiers="Nome,Versione">
<Nome>
<xsl:value-of select="NAME"/>
</Nome>
<Versione>
<xsl:value-of select="VERSION"/>
</Versione>
</SchedaRete>
</xsl:template>
<xsl:template match="/CMDBUILD/Software">
<SchedaRete domain="SoftwareInstallato" domaindirection="directed" identifiers="Nome,Versione">
<xsl:attribute name="objid">
<xsl:value-of select="./@objid"/>
</xsl:attribute>
<Nome>
<xsl:value-of select="./Nome"/>
</Nome>
<Versione>
<xsl:value-of select="./Versione"/>
</Versione>
</Software>
</xsl:template>
</xsl:stylesheet>
Sono state correttamente create le viste sul DB OCS e riusciamo ad eseguire l'importazione di ogni singola tabella senza nessun problema, finché non proviamo ad eseguire la migrazione dei dati utilizzando questo file transform. La situazione è la seguente:
- se i 3 computer inseriti come device (nel DB OCS) hanno lo stesso medesimo TAG, allora viene effettuata la copia dati e le relative associazioni, ma sia software(N:N) che scheda di rete(N:1) vengono associati tutti al primo computer in elenco
- mentre se i 3 record contengono un valore differente nel campo TAG (pc1, pc2, pc3) viene effettuata l'importazione dei soli record relativi al computer
Sono state effettuate diverse prove, alterando anche le configurazioni dei domini o tentando l'inserimento dei soli computer/software o computer/schedarete, ma qualunque tentativo ha lo stesso medesimo risultato.
Ci siamo persi in un bicchier d'acqua?