Closed bheisig closed 5 years ago
Feature has been implemented. As you can see the usage is slightly different as specified (IMHO it's even better):
$ idoitcli save --help
Create/update CMDB objects and their category entries
USAGE
$ idoitcli save [OPTIONS] [QUERY]
ARGUMENTS
QUERY Combination of type/object/category/entry
type is the localized name of an object type,
its constant or its numeric identifier
object title of numeric identifier
category is the localized name of the category,
its contant or numeric identifier
entry is the numeric identifier
of an existing category entry
COMMAND OPTIONS
-a ATTRIBUTE=VALUE, Localized name or key of ATTRIBUTE
--attribute=ATTRIBUTE=VALUE and its VALUE
(Use only if category is set)
COMMON OPTIONS
-c FILE, Include settings stored in a JSON-formatted
--config=FILE configuration file FILE; repeat option for more
than one FILE
-s KEY=VALUE, Add runtime setting KEY with its VALUE; separate
--setting=KEY=VALUE nested keys with ".", for example "key1.key2=123";
repeat option for more than one KEY
--no-colors Do not print colored messages
-q, --quiet Do not output messages, only errors
-v, --verbose Be more verbose
-h, --help Print this help or information about a
specific command
--version Print version information
-y, --yes No user interaction required; answer questions
automatically with default values
EXAMPLES
# Create new object with type "server" and title "mylittleserver":
$ idoitcli save server/mylittleserver
# Create/update attributes in a single-value category:
$ idoitcli save server/mylittleserver/model \
-a manufacturer=VendorA -a model=ModelA
# Another one:
$ idoitcli save server/mylittleserver/location \
-a location="Data Center"
# Update attributes in a multi-value category:
$ idoitcli save server/mylittleserver/host\ address/1 \
-a ipv4_address=192.168.42.23 \
-a hostname=mylittleserver \
-a domain=example.com
# Use a template for an interactive mode:
$ cat template.json
{
"templates": {
"server": [
{
"category": "model",
"attribute": "manufacturer"
},
{
"category": "model",
"attribute": "model"
},
{
"category": "host address",
"attribute": "ipv4_address"
},
{
"category": "host address",
"attribute": "hostname"
},
{
"category": "host address",
"attribute": "domain"
},
{
"category": "location",
"attribute": "location"
}
]
}
}
# Interactive mode:
$ idoitcli save -c template.json
Create/update CMDB objects and their category entries
Type? server
Title? mylittleserver
Add more attributes? [Y/n] y
[Model] Manufacturer? VendorA
[Model] Model? ModelA
[Host address] IPv4 address? 192.168.42.23
[Host address] Hostname? mylittleserver
[Host address] Domain? example.com
[Location] Location? Data Center
Link: http://cmdb.example.com/i-doit/?objID=42
Create a new object
Create/update attributes in a single-value category
Update attributes in a multi-value category
Interactive mode
First, collect data:
Add more attributes
will be asked if template is available (see below)Templates
Based on object type specific templates in configuration file create/update objects and their attributes.
Common aspects
STDOUT
what happened exactly.