parent
01b85f5758
commit
8929b41df0
|
@ -15,14 +15,14 @@ class ExportCommand extends Command
|
|||
*
|
||||
* USAGE
|
||||
*
|
||||
* icingacli director export importsource [options]
|
||||
* icingacli director export importsources [options]
|
||||
*
|
||||
* OPTIONS
|
||||
*
|
||||
* --no-pretty JSON is pretty-printed per default
|
||||
* Use this flag to enforce unformatted JSON
|
||||
*/
|
||||
public function importsourceAction()
|
||||
public function importsourcesAction()
|
||||
{
|
||||
$export = new ImportExport($this->db());
|
||||
echo $this->renderJson(
|
||||
|
@ -36,14 +36,14 @@ class ExportCommand extends Command
|
|||
*
|
||||
* USAGE
|
||||
*
|
||||
* icingacli director syncrule export [options]
|
||||
* icingacli director export syncrules [options]
|
||||
*
|
||||
* OPTIONS
|
||||
*
|
||||
* --no-pretty JSON is pretty-printed per default
|
||||
* Use this flag to enforce unformatted JSON
|
||||
*/
|
||||
public function syncruleAction()
|
||||
public function syncrulesAction()
|
||||
{
|
||||
$export = new ImportExport($this->db());
|
||||
echo $this->renderJson(
|
||||
|
@ -57,14 +57,14 @@ class ExportCommand extends Command
|
|||
*
|
||||
* USAGE
|
||||
*
|
||||
* icingacli director export job [options]
|
||||
* icingacli director export jobs [options]
|
||||
*
|
||||
* OPTIONS
|
||||
*
|
||||
* --no-pretty JSON is pretty-printed per default
|
||||
* Use this flag to enforce unformatted JSON
|
||||
*/
|
||||
public function jobAction()
|
||||
public function jobsAction()
|
||||
{
|
||||
$export = new ImportExport($this->db());
|
||||
echo $this->renderJson(
|
||||
|
@ -78,14 +78,14 @@ class ExportCommand extends Command
|
|||
*
|
||||
* USAGE
|
||||
*
|
||||
* icingacli director export datafield [options]
|
||||
* icingacli director export datafields [options]
|
||||
*
|
||||
* OPTIONS
|
||||
*
|
||||
* --no-pretty JSON is pretty-printed per default
|
||||
* Use this flag to enforce unformatted JSON
|
||||
*/
|
||||
public function datafieldAction()
|
||||
public function datafieldsAction()
|
||||
{
|
||||
$export = new ImportExport($this->db());
|
||||
echo $this->renderJson(
|
||||
|
@ -99,14 +99,14 @@ class ExportCommand extends Command
|
|||
*
|
||||
* USAGE
|
||||
*
|
||||
* icingacli director export datafield [options]
|
||||
* icingacli director export datalists [options]
|
||||
*
|
||||
* OPTIONS
|
||||
*
|
||||
* --no-pretty JSON is pretty-printed per default
|
||||
* Use this flag to enforce unformatted JSON
|
||||
*/
|
||||
public function datalistAction()
|
||||
public function datalistsAction()
|
||||
{
|
||||
$export = new ImportExport($this->db());
|
||||
echo $this->renderJson(
|
||||
|
@ -115,61 +115,61 @@ class ExportCommand extends Command
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Export all IcingaHostGroup definitions
|
||||
*
|
||||
* USAGE
|
||||
*
|
||||
* icingacli director export hostgroup [options]
|
||||
*
|
||||
* OPTIONS
|
||||
*
|
||||
* --no-pretty JSON is pretty-printed per default
|
||||
* Use this flag to enforce unformatted JSON
|
||||
*/
|
||||
public function hostgroupAction()
|
||||
{
|
||||
$export = new ImportExport($this->db());
|
||||
echo $this->renderJson(
|
||||
$export->serializeAllHostGroups(),
|
||||
!$this->params->shift('no-pretty')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Export all IcingaServiceGroup definitions
|
||||
*
|
||||
* USAGE
|
||||
*
|
||||
* icingacli director export servicegroup [options]
|
||||
*
|
||||
* OPTIONS
|
||||
*
|
||||
* --no-pretty JSON is pretty-printed per default
|
||||
* Use this flag to enforce unformatted JSON
|
||||
*/
|
||||
public function servicegroupAction()
|
||||
{
|
||||
$export = new ImportExport($this->db());
|
||||
echo $this->renderJson(
|
||||
$export->serializeAllServiceGroups(),
|
||||
!$this->params->shift('no-pretty')
|
||||
);
|
||||
}
|
||||
// /**
|
||||
// * Export all IcingaHostGroup definitions
|
||||
// *
|
||||
// * USAGE
|
||||
// *
|
||||
// * icingacli director export hostgroup [options]
|
||||
// *
|
||||
// * OPTIONS
|
||||
// *
|
||||
// * --no-pretty JSON is pretty-printed per default
|
||||
// * Use this flag to enforce unformatted JSON
|
||||
// */
|
||||
// public function hostgroupAction()
|
||||
// {
|
||||
// $export = new ImportExport($this->db());
|
||||
// echo $this->renderJson(
|
||||
// $export->serializeAllHostGroups(),
|
||||
// !$this->params->shift('no-pretty')
|
||||
// );
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Export all IcingaServiceGroup definitions
|
||||
// *
|
||||
// * USAGE
|
||||
// *
|
||||
// * icingacli director export servicegroup [options]
|
||||
// *
|
||||
// * OPTIONS
|
||||
// *
|
||||
// * --no-pretty JSON is pretty-printed per default
|
||||
// * Use this flag to enforce unformatted JSON
|
||||
// */
|
||||
// public function servicegroupAction()
|
||||
// {
|
||||
// $export = new ImportExport($this->db());
|
||||
// echo $this->renderJson(
|
||||
// $export->serializeAllServiceGroups(),
|
||||
// !$this->params->shift('no-pretty')
|
||||
// );
|
||||
// }
|
||||
|
||||
/**
|
||||
* Export all IcingaTemplateChoiceHost definitions
|
||||
*
|
||||
* USAGE
|
||||
*
|
||||
* icingacli director export hosttemplatechoice [options]
|
||||
* icingacli director export hosttemplatechoices [options]
|
||||
*
|
||||
* OPTIONS
|
||||
*
|
||||
* --no-pretty JSON is pretty-printed per default
|
||||
* Use this flag to enforce unformatted JSON
|
||||
*/
|
||||
public function hosttemplatechoiceAction()
|
||||
public function hosttemplatechoicesAction()
|
||||
{
|
||||
$export = new ImportExport($this->db());
|
||||
echo $this->renderJson(
|
||||
|
|
|
@ -4,6 +4,7 @@ namespace Icinga\Module\Director\Clicommands;
|
|||
|
||||
use Icinga\Module\Director\Cli\Command;
|
||||
use Icinga\Module\Director\DirectorObject\Automation\ImportExport;
|
||||
use Icinga\Module\Director\Objects\ImportSource;
|
||||
|
||||
/**
|
||||
* Export Director Config Objects
|
||||
|
@ -11,44 +12,51 @@ use Icinga\Module\Director\DirectorObject\Automation\ImportExport;
|
|||
class ImportCommand extends Command
|
||||
{
|
||||
/**
|
||||
* Export all ImportSource definitions
|
||||
*
|
||||
* Use this command to delete a single Icinga object
|
||||
* Import ImportSource definitions
|
||||
*
|
||||
* USAGE
|
||||
*
|
||||
* icingacli director import importsource [options]
|
||||
* icingacli director import importsources < importsources.json
|
||||
*
|
||||
* OPTIONS
|
||||
*
|
||||
* --no-pretty JSON is pretty-printed per default
|
||||
* Use this flag to enforce unformatted JSON
|
||||
*/
|
||||
public function importsourceAction()
|
||||
public function importsourcesAction()
|
||||
{
|
||||
$json = file_get_contents('php://stdin');
|
||||
$export = new ImportExport($this->db());
|
||||
$export->unserializeImportSources(json_decode($json));
|
||||
$import = new ImportExport($this->db());
|
||||
$count = $import->unserializeImportSources(json_decode($json));
|
||||
echo "$count Import Sources have been imported\n";
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Import an ImportSource definition
|
||||
// *
|
||||
// * USAGE
|
||||
// *
|
||||
// * icingacli director import importsource < importsource.json
|
||||
// *
|
||||
// * OPTIONS
|
||||
// */
|
||||
// public function importsourcection()
|
||||
// {
|
||||
// $json = file_get_contents('php://stdin');
|
||||
// $object = ImportSource::import(json_decode($json), $this->db());
|
||||
// $object->store();
|
||||
// printf("Import Source '%s' has been imported\n", $object->getObjectName());
|
||||
// }
|
||||
|
||||
/**
|
||||
* Import SyncRule definitions
|
||||
*
|
||||
* Use this command to import ....
|
||||
*
|
||||
* USAGE
|
||||
*
|
||||
* icingacli director syncrule export [options]
|
||||
*
|
||||
* OPTIONS
|
||||
*
|
||||
* --no-pretty JSON is pretty-printed per default
|
||||
* Use this flag to enforce unformatted JSON
|
||||
* icingacli director import syncrules < syncrules.json
|
||||
*/
|
||||
public function syncruleAction()
|
||||
public function syncrulesAction()
|
||||
{
|
||||
$json = file_get_contents('php://stdin');
|
||||
$export = new ImportExport($this->db());
|
||||
$export->unserializeSyncRules(json_decode($json));
|
||||
$import = new ImportExport($this->db());
|
||||
$count = $import->unserializeSyncRules(json_decode($json));
|
||||
echo "$count Sync Rules have been imported\n";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -297,6 +297,46 @@ a good reason. The CLI allows you to issue operations that are not allowed in th
|
|||
web frontend. Do not use this unless you really understand its implications. And
|
||||
remember, with great power comes great responsibility.
|
||||
|
||||
|
||||
Import/Export Director Objects
|
||||
------------------------------
|
||||
|
||||
Some objects are not directly related to Icinga Objects but used by the Director
|
||||
to manage them. To make it easier for administrators to for example pre-fill an
|
||||
empty Director Instance with Import Sources and Sync Rules, related import/export
|
||||
commands come in handy.
|
||||
|
||||
Use `icingacli director export <type> [options]` to export objects of a specific
|
||||
type:
|
||||
|
||||
| Type | Description |
|
||||
|-----------------------|-------------------------------------------------|
|
||||
| `datafields` | Export all DataField definitions |
|
||||
| `datalists` | Export all DataList definitions |
|
||||
| `hosttemplatechoices` | Export all IcingaTemplateChoiceHost definitions |
|
||||
| `importsources` | Export all ImportSource definitions |
|
||||
| `jobs` | Export all Job definitions |
|
||||
| `syncrules` | Export all SyncRule definitions |
|
||||
|
||||
#### Options
|
||||
|
||||
| Option | Description |
|
||||
|---------------|------------------------------------------------------|
|
||||
| `--no-pretty` | JSON is pretty-printed per default. Use this flag to |
|
||||
| | enforce unformatted JSON |
|
||||
|
||||
Use `icingacli director import <type> < exported.json` to import objects of a
|
||||
specific type:
|
||||
|
||||
| Type | Description |
|
||||
|-----------------------|-------------------------------------------------|
|
||||
| `importsources` | Import ImportSource definitions from STDIN |
|
||||
| `syncrules` | Import SyncRule definitions from STDIN |
|
||||
|
||||
|
||||
This feature is available since v1.5.0.
|
||||
|
||||
|
||||
Health Check Plugin
|
||||
-------------------
|
||||
|
||||
|
|
Loading…
Reference in New Issue