Difference between revisions of "Database Asset Relationship Import"

From Hornbill
Jump to navigation Jump to search
 
(6 intermediate revisions by one other user not shown)
Line 1: Line 1:
 +
This document can now be found at its new location in the [https://docs.hornbill.com/data-imports-guide/asset-relationships/overview Hornbill Document Library].
 +
 +
[[file:hornbill-document-library.png|Data Imports Guide|link=https://docs.hornbill.com/data-imports-guide/asset-relationships/overview]]
 +
 +
<!--
 +
 
= Database Asset Relationship Import - [https://golang.org/ GO] =
 
= Database Asset Relationship Import - [https://golang.org/ GO] =
  
Line 5: Line 11:
 
== Installation ==
 
== Installation ==
  
* Download the [https://github.com/hornbill/goDBAssetRelationships/releases/latest ZIP archive] containing the import executable relevant for your operating system and architecture
+
* Download the [https://github.com/hornbill/asset-rel-import/releases/latest ZIP archive] containing the import executable relevant for your architecture
* Extract zip into a folder you would like the application to run from e.g. <code>C:\assetrelationshipimport\</code>
+
* Extract zip into a folder you would like the application to run from e.g. <code>C:\Users\YourServiceAccount\HornbillImports</code>
 
* Open <code>conf.json</code> and add in the necessary configration
 
* Open <code>conf.json</code> and add in the necessary configration
 
* Open a Command Line/Terminal as Administrator
 
* Open a Command Line/Terminal as Administrator
* Change Directory to the folder with the executable and config file <code>C:\assetrelationshipimport\</code>
+
* Change Directory to the folder with the executable and config file <code>C:\Users\YourServiceAccount\HornbillImports</code>
* Run the command :
+
* Run the command : asset_rel_import.exe
** For Windows Systems: goDBAssetRelationships.exe
 
** For *nix Systems: ./goDBAssetRelationships
 
  
 
= Configuration =
 
= Configuration =
Line 19: Line 23:
 
<pre>
 
<pre>
 
{
 
{
     "APIKey": "",
+
     "KeySafeKeyID": 0,
     "InstanceId": "",
+
     "Database": {
    "DBConf": {
+
         "Source": "mssql",
         "Driver": "mysql",
 
        "Server": "127.0.0.1",
 
        "Database": "assetdb",
 
 
         "Authentication": "SQL",
 
         "Authentication": "SQL",
        "UserName": "dbuserid",
 
        "Password": "dbpassword",
 
        "Port": 3306,
 
 
         "Encrypt": false
 
         "Encrypt": false
 
     },
 
     },
Line 66: Line 64:
 
}
 
}
 
</pre>
 
</pre>
* <code>APIKey</code> - a Hornbill API key for a user account with the correct permissions to carry out all of the required API calls
+
* <code>KeySafeKeyID</code> - The ID (primary key) of the KeySafe Key that contains your database connection authentication information. Note, this KeySafe Key should be of type `Database Authentication`
* <code>InstanceId</code> - the Hornbill Instance ID (case sensitive)
+
* <code>Database</code>
* <code>DBConf</code>
+
** <code>Source</code> - the driver to use to connect to the database that holds the asset information:
** <code>Driver</code> - the driver to use to connect to the database that holds the asset information:
 
 
*** mssql = Microsoft SQL Server (2005 or above)
 
*** mssql = Microsoft SQL Server (2005 or above)
 
*** mysql = MySQL Server 4.1+, MariaDB
 
*** mysql = MySQL Server 4.1+, MariaDB
Line 78: Line 75:
 
***** UserName - this should be the SQL authentication Username to connect to the Database
 
***** UserName - this should be the SQL authentication Username to connect to the Database
 
***** Password - this should be the password for the above username
 
***** Password - this should be the password for the above username
** <code>Server</code> - The address of the SQL server
 
** <code>Database</code> - The name of the Database to connect to
 
 
** <code>Authentication</code> - The tupe of authentication to use to connect to the SQL server. Can be either:
 
** <code>Authentication</code> - The tupe of authentication to use to connect to the SQL server. Can be either:
 
*** Windows - Windows Account authentication, uses the logged-in Windows account to authenticate
 
*** Windows - Windows Account authentication, uses the logged-in Windows account to authenticate
 
*** SQL - uses SQL Server authentication, and requires the Username and Password parameters (below) to be populated
 
*** SQL - uses SQL Server authentication, and requires the Username and Password parameters (below) to be populated
** <code>UserName</code> The username for the SQL database - only used when Authentication is set to SQL: for Windows authentication this field can be left as an empty string
 
** <code>Password</code> Password for above User Name - only used when Authentication is set to SQL: for Windows authentication this field can be left as an empty string
 
** <code>Port</code> SQL port
 
 
** <code>Encrypt</code> Boolean value to specify wether the connection between the script and the database should be encrypted. NOTE: There is a bug in SQL Server 2008 and below that causes the connection to fail if the connection is encrypted. Only set this to true if your SQL Server has been patched accordingly
 
** <code>Encrypt</code> Boolean value to specify wether the connection between the script and the database should be encrypted. NOTE: There is a bug in SQL Server 2008 and below that causes the connection to fail if the connection is encrypted. Only set this to true if your SQL Server has been patched accordingly
 
* <code>Query</code> The basic SQL query to retrieve asset relationship information from the data source
 
* <code>Query</code> The basic SQL query to retrieve asset relationship information from the data source
Line 128: Line 120:
 
== Command Line Parameters ==
 
== Command Line Parameters ==
  
* <code>file</code> - Defaults to <code>conf.json</code> - Name of the Configuration file to load
+
* file - Defaults to `conf.json` - Name of the Configuration file to load.
* <code>dryrun</code> - Defaults to <code>false</code> - Set to <code>true</code> and the XML for all XMLMC operations will be dumped to the log file, and any CREATE or UPDATE operations will be skipped. This is to aid in debugging the initial connection information.
+
* dryrun - Defaults to `false` - Set to true and the XMLMC for the creation and update of assets will not be called, and instead the generated XML for each asset will be dumped to the log file. This is to aid in debugging the initial connection information.
* <code>version</code> - Defaults to <code>false</code> - when set to <code>true</code>, the tool will output its version number before exiting
+
* creds - Defaults to `false` - Set to true to return the API key that is stored in your import configuration. See NOTE in First Run, below. As well as user & computer specific access, you will also be prompted to input the ID of the instance that the API key was generated on.
 +
* version - Defaults to `false` - Set to true to return the version number of the tool, then exit
 +
 
 +
=== First Run ===
 +
 
 +
From version '''2.0.0''' of this utility, when you first run the utility it will prompt you for the ID of your Hornbill instance (case-sensitive), and the API key (also case-sensitive) that will be used to authenticate the API calls back into Hornbill. This information will be encrypted, and stored locally on the client PC that will be running the tool. For each subsequent import run, the utility will decrypt your instance ID and API key, and will use those to make the API calls back into Hornbill.
 +
 
 +
NOTE - the encrypted instance ID and API key can only be decrypted on the computer, and by the user, that performed the encryption, so please keep this in mind when scheduling your imports.
 +
 
 +
Should you wish to use a different API key to what has been previously encrypted, just delete the '''import.cfg''' file from the folder where the import binary resides, and re-run your import from the command line inputting the Instance ID and new API Key as you would have on its first run.
  
 
= Testing =
 
= Testing =
Line 136: Line 137:
 
If you run the application with the argument dryrun=true then no asset relationships will be created or updated, the XML used to create or update will be saved in the log file so you can ensure the data mappings are correct before running the import.
 
If you run the application with the argument dryrun=true then no asset relationships will be created or updated, the XML used to create or update will be saved in the log file so you can ensure the data mappings are correct before running the import.
  
<code>goDBAssetRelationships.exe -dryrun=true</code>
+
<code>asset_rel_import.exe -dryrun=true</code>
  
 
= Scheduling =
 
= Scheduling =
  
 
== Windows ==
 
== Windows ==
You can schedule goDBAssetRelationships.exe to run with any optional command line argument from Windows Task Scheduler:
+
You can schedule asset_rel_import.exe to run with any optional command line argument from Windows Task Scheduler:
* Ensure the user account running the task has rights to goDBAssetRelationships.exe and the containing folder.
+
* Ensure the user account running the task has rights to asset_rel_import.exe and the containing folder.
* Make sure the Start In parameter contains the folder where goDBAssetRelationships.exe resides in otherwise it will not be able to pick up the correct path.
+
* Make sure the Start In parameter contains the folder where asset_rel_import.exe resides in otherwise it will not be able to pick up the correct path.
  
 
= Logging =
 
= Logging =
  
All Logging output is saved in the log directory in the same directory as the executable the file name contains the date and time the import was run <code>assetRelationships20190925140000.log</code>
+
All Logging output is saved in the log directory in the same directory as the executable the file name contains the date and time the import was run <code>asset_rel_log_20190925140000.log</code>
 +
 
 +
-->
 +
[[Category:HDOC]]

Latest revision as of 18:39, 11 April 2024

This document can now be found at its new location in the Hornbill Document Library.

Data Imports Guide