- 12 Nov 2024
-
DarkLight
-
PDF
db import
- Updated on 12 Nov 2024
-
DarkLight
-
PDF
iagctl db import
Import resources/services from a service file
Synopsis
This command imports a service config from a file. This command is useful in cases where services and resources need to move from one gateway instance to another. The method allows a previously exported (or created) file to be imported.
Services and resources can be imported either from a local file or a repository if there is one setup. Gateway also provides tools to --validate
and --check
the import process.
Validate
Validation can be run against a file by providing the --validate
command. The flag will ensure that the resource has all required fields. If not, it will return information so the issue can be resolved.
Check
Check allows gateway to display the actions that would take place, or the results of dry-run
import without making any changes to the store. There are three states to the --check
command: conflict, add, replacement.
State | Description |
---|---|
Conflict | This state means there is a conflict and no action will take place. To override the existing resource that is flagged as a conflict use the --force flag. |
Add | This state means the resource is new and will be created on import. |
Replacement | This state means the resource will be replaced when the service is imported. You will see this state when running the check flag with --force . |
Examples
Service File
example.yml
decorators:
- name: ansible-xr
schema:
$id: https://example.com/device.schema.json
$schema: https://json-schema.org/draft/2020-12/schema
properties:
device_type:
description: The type of device
enum:
- ios
- eos
- nxos
type: string
host:
description: The hostname or IP address of the device
type: string
title: Network Device
type: object
repositories:
- name: xr-resources
description: XR Resources for testing
url: git@gitlab.com:jh/xr/resources.git
reference: main
tags:
- cisco
- xr
private-key-name: xr-gitlab-private
services:
- name: Ansible-Example
type: ansible-playbook
description: An ansible playbook to say hello-world
playbooks:
- hello-world.yml
working-directory: ./
repository: xr-resources
decorator: ansible-xr
tags:
- xr
- cisco
runtime:
check: true
diff: true
skip-tags: example-tag
inventory:
- ./inventory.ini
verbose-level: 6
- name: Hello-World
type: python-script
description: A simple hello-world playbook
filename: hello-world.yml
working-directory: ansibleplaybooks
repository: xr-resources
decorator: my-special-decorator
iagctl db import <filename> [flags]
Import Services and Resources from a Local File
iagctl db import ./file.yml
Import Services and Resources from a Repository
iagctl db import ./path/to/yaml/relative/to/repo/service.yaml --repository my-services-repo
Validate Service File
iagctl db import ./file.yml --validate
Check Service File Against Gateway Store
iagctl db import ./file.yml --check
Check Service File Against Gateway Store if Forced
iagctl db import ./file.yml --check --force
Options
--check When set gateway will perform a validation and dry-run of the service import.
--force When set gateway will override any existing service that already exists.
-h, --help Help for import
--repository string The repository name to import services from. This must be a repository already preconfigured and referenced by its name.
--validate When set gateway will only validate the service file.
Options Inherited from Parent Commands
--config string Path to the configuration file
--raw Displays the result of the command in its raw format
--verbose Enable verbose output
CLI References
See related db
commands:
For all CLI commands see → Command References Index