Dump the OpenManage database.
Project description
ECScmdb
Author: $Id: Thomas R. Stevenson <aa0026@wayne.edu> $
Last Changed: $Date: Wed Feb 8 18:51:00 2023 -0500 $
URL to git source: $URL: git@git.wayne.edu:ECS_Projects/ECScmdb.git $
CLI Version
cmdb: ecscmdb(1.6.27), ecspylibs(1.1.16)
cmdbdiff: ecscmdb(1.6.27), ecspylibs(1.1.16)
Summary of commands
cmdb: Download the devices in the OpenManage database into a
spreadsheet, one work sheet for each device.
cmdbdiff: Compare two cmdb spreadsheets for differences.
Assumptions
The ecscmdb user needs to know:
- how to run commands in a Linux environment.
- how to install python packages in a virtualenv.
- how to run python commands in a virtualenv.
- how to configure yaml files.
- some basic understanding of jinja2 variable used in the yaml file.
Installation
It is best to create a dedicated python virtualenv to install ecscmdb
into so as not to interfere with any other python packages installed
on your system.
# virtualenv .venv
# . .venv/bin/activate
# pip install ecscmdb
Setup
cmdb
Before cmdb can be used to gather OpenManage data, the files cmdb.yml
and cmdb.pw must be created. They are both located in the directory
etc/ecscmdb, which is relative to the virtualenv directory ecscmdb was
installed in.
cmdb.yml
cmdb.yml is a yaml file. The yaml file can have multiple "config"
sections defined within it. There must be at lease one config section.
Each config secion has the following fields:
name: The name of the config section (optional).
pw: The location of the cmdb password file relative to
virtualenv base directory cmdb was installed in.
log_level: The python log level cmdb will run at. Must be one of
DEBUG, INFO, WARNING, ERROR, CRITICAL, or TRACE.
log_dir: The location of the cmdb log directory relative to
virtualenv base directory cmdb was installed in.
OME_Login: The User ID of the OpenManage server that will be used
to gather the data.
poolsize: The number of python ProcessPoolExecutor pools that will
be used to gather the OpenManage data.
output: The location of the cmdb output file that the cmdb
spreadsheet will be written to. The name of the file can
include the jinja2 variable "{{ TOD }}" to include the
current date and time.
In addition to the config section(s), the yaml file also must include
the yaml variable "section:" which indicates which of the config sections
to process.
cmdb.yml example file
Here is an example cmdb.yml file with two config sections. Because the
"section:" variable is set to 2 in this example the second section, with
name "Configuration file Testing", will be used.
---
section: 2
config:
- name: Configuration file Production.
pw: etc/ecscmdb/cmdb.pw
log_level: warning
log_dir: log
OME_Login: CMDB
poolsize: 12
output: output/OpenManage-cmdb.{{ TOD }}.xlsx
- name: Configuration file Testing.
pw: etc/ecscmdb/cmdb.pw
log_level: TRACE
log_dir: log
OME_Login: CMDB
poolsize: 24
output: output/OpenManage-test-cmdb.{{ TOD }}.xlsx
...
cmdb.pw
cmdb.pw is a python AES encripted password file. It must contain the
following two entries:
- A key that matches the OME_Login variable from the cmdb.yml file. The value of the entry is the password for that user.
- A key named "OMEHost" (case-sensitive string). The value of the entry is the URL for the OpenManage host.
Adding or updating an entry in the cmdb.pw file
Execute "cmdb --add=STRING", where STRING is the key to be created or
updated. cmdb will then prompt for the value for the given key. The
entries are encripted and stored in the cmdb.pw file.
Example
# cmdb --add=xyzzy
Enter password for user 'xyzzy':
#
Deleting an entry from the cmdb.pw file
Execute "cmdb --delete=STRING", where STRING is the key to be deleted.
The entries will be deleted without prompting.
Example
# cmdb --delete=xyzzy
#
List the keys or keys/values stored n the cmdb.pw file
Execute "cmdb --list" to list all of the keys in the cmdb.pw file, or
"cmdb --list --verbose" to list both the keys and the values for each
key.
Examples
# cmdb --list
# cmdb --list --verbose
cmdbdiff
Before cmdbdiff can be used to compare two OpenManage spreadsheets,
created using the cmdb command, the file cmdbdiff.yml must be created.
This file is located in the directory etc/ecscmdb, which is relative
to the virtualenv directory ecscmdb was installed in.
cmdbdiff.yml
cmdbdiff.yml is a yaml file. The yaml file can have multiple "config"
sections defined within it. There must be at least one config section
in it. In addition to the config section(s), the yaml file also must
include the yaml variable "section:" which indicates which of the config
sections to process.st be at lease one config section. Each config
secion has the following fields:
name: The name of the configuration section
(optional).
admin: The Admin managing cmdbdiff.
name: The Admin name.
email: The Admin email address.
phone: The Admin phone number.
log_level: The python log level cmdb will run at.
Must be one of DEBUG, INFO, WARNING, ERROR,
CRITICAL, or TRACE.
log_dir: The location of the cmdb log directory
relative to virtualenv base directory cmdb
was installed in.
report: The location of the cmdbdiff report file
that cmdbdiff writes to. The name of the
file can include the jinja2 variable
"{{ TOD }}" to include the current date and
time.
email: The email section indicates who should
receive a copy of the cmdbdiff report.
subject: The subject line of the report email.
from: The name and email address of the user
sending the report.
name: The sending name.
email: The sending email address.
to: A list of zero or more "to" email addresses.
name: The outgoing name.
email: The outgoing email address.
cc: A list of zero or more "cc" email addresses.
name: The outgoing name.
email: The outgoing email address.
text: The text of the email that is sent.
with_changes: The text of the email being if there are
changes between the spreadsheets being
checked.
without_changes: The text of the email being if there are no
changes between the spreadsheets being
checked.
In addition to the config section(s), the yaml file also must include
the yaml variable "section:" which indicates which of the config sections
to process.
jinja2 variables used in the cmdbdiff.yml file
There are several jinja2 variables that can be used in the cmdbdiff.yml
configuration file. Here is a list with a description of their values:
TOD: The current Date and Time.
DATE: The currect Date.
TIME: The current Time.
HOST: The Host name the report was generated on.
VERSION: The Version of the cmdbdiff program.
SPREADSHEET1: The name of the first spreadsheet being checked.
WORKSHEETS1: The number of Worksheets in the spreadsheet 1.
SPREADSHEET2: The name of the second spreadsheet being checked.
WORKSHEETS2: The number of Worksheets in the spreadsheet 2.
REPORT: The name of the report file (from config.report).
ADMINNAME: The name of the cmdbdiff Admin (from config.admin.name).
ADMINEMAIL: The email address of the cmdbdiff Admin (from
config.admin.email).
ADMINPHONE: The phone number of the cmdbdiff Admin (from
config.admin.phone).
cmdbdiff.yml example file
Here is an example cmdb.yml file with one config sections. The "section:"
variable is set to 1 in this example the second section, with name
"Configuration file Production", will be used.
---
section: 1
config:
- name: Configuration file Production.
admin:
name: Bill Jones
email: BJ@example.com
phone: 999.555.1234
log_level: warning
log_dir: log
report: report/OpenManage-cmdbdiff-{{ TOD }}.xlsx
email:
subject: CMDB Diff Report generated on {{ DATE }} at {{ TIME }} on server {{ HOST }}.
from:
name: CMDB Diff Report
email: CMDB-Diff-Report@{{ HOST }}
to:
-
name: John Smith
email: JS@example.com
-
name: Steve Thomas
email: ST@example.com
cc:
-
name: Tim George
email: TG@example.com
text:
with_changes:
"\nCMDB Diff report, Version {{ VERSION }}, generated on {{ DATE
}} at {{ TIME }} on server {{ HOST }}.\n
There are three attached spreadsheets in this report:\n
1) {{ SPREADSHEET1 }}, is the previous CMDB spreadsheet with
{{ WORKSHEETS1 }} worksheets.\n
2) {{ SPREADSHEET2 }}, is an currect CMDB spreadsheet with {{
WORKSHEETS2 }} worksheets.\n
3) {{ REPORT }}, lists the changes between {{ SPREADSHEET1 }}
and {{ SPREADSHEET2 }}.\n
The first worksheet in {{ REPORT }} lists a summary of all
changes. The remaining worksheets in {{ REPORT }}, if any, are
copies of the worksheets in {{ SPREADSHEET2 }} that are
different from {{ SPREADSHEET1 }}.\n
Contact {{ ADMINNAME }} at email address {{ ADMINEMAIL }} or
phone number {{ ADMINPHONE }} if you have questions or
concerns regarding any of the spreadsheets generated in this
report.\n
Thanks!\n"
without_changes:
"\nCMDB Diff report, Version {{ VERSION }}, generated on {{ DATE
}} at {{ TIME }} on server {{ HOST }}.\n
The CMDB Diff report found no changes between {{
SPREADSHEET1 }} and {{ SPREADSHEET1 }} on {{ DATE }}.\n
There are three attached spreadsheets in this report:\n
1) {{ SPREADSHEET1 }}, is the previous CMDB spreadsheet with
{{ WORKSHEETS1 }} worksheets.\n
2) {{ SPREADSHEET2 }}, is an currect CMDB spreadsheet with {{
WORKSHEETS2 }} worksheets.\n
3) {{ REPORT }}, lists the changes between {{ SPREADSHEET1 }}
and {{ SPREADSHEET2 }}.\n
Contact {{ ADMINNAME }} at email address {{ ADMINEMAIL }} or
phone number {{ ADMINPHONE }} if you have questions or
concerns regarding any of the spreadsheets generated in this
report.\n
Thanks!\n"
CLI Help text
# cmdb --help
Program to download the data from the OpenManage DB and build a spreadsheet.
Some default option values listed below can be overridden within the
configuration file.
Usage:
cmdb [-v] [-L LEVEL] [--LOG=DIR] [-F] [-c CONFIG] [-s SECTION] [-o OUTPUT] [-p PWFILE] [-D] [-P SIZE]
cmdb [-vl] [-L LEVEL] [--LOG=DIR] [-c CONFIG] [-s SECTION] [-a ID]... [-d ID]... [-p PWFILE] [-D]
cmdb (-h | --help | -V | --version)
There are no required options.
Options:
-h, --help Show this help message and exit.
-V, --version Show version information and exit.
-F, --full Show all data, no filtering.
-c CONFIG, --config=CONFIG The configuration file.
Default: "/home/tom/Run/ECScmdb/Testing/etc/ecscmdb/cmdb.yml"
-s SECTION, --section=SECTION The configuration file version (default
defined within the configuration file).
-o OUTPUT, --output=OUTPUT Output file or directory.
Default: "/home/tom/Run/ECScmdb/Testing/output/OpenManage-cmdb.2023-02-08-18-14-30.xlsx"
-p PWFILE, --pw=PWFILE The password file. This file is used when a
login to a website or webpage is required.
Default: "/home/tom/Run/ECScmdb/Testing/etc/ecscmdb/cmdb.pw"
-l, --list List all of the IDs in the password file and
exit. If both the --list and --verbose
options are included, list both IDs and
Passwords and exit.
-a ID, --add=ID Add (or update) an ID and Password and exit.
Program will prompt for the Password to be
saved to the password file.
-d ID, --delete=ID Delete an ID (if it exists) from the
password file and exit.
-v, --verbose Print verbose messages.
-L LEVEL, --log=LEVEL Print log messages at log value LEVEL.
Valid levels are: TRACE, DEBUG, INFO, WARNING,
ERROR, and CRITICAL.
Default: WARNING
--LOG=DIR Log directory.
Default: "/home/tom/Run/ECScmdb/Testing/log/cmdb.log"
-D, --dryrun Only print out what would be done.
-P SIZE, --poolsize=SIZE Call OpenManage using pools of size SIZE.
Default: set by the OS.
# cmdbdiff --help
Program to analyze two spreadsheets for differences.
Some default option values listed below can be overridden within the initialization file.
Usage:
cmdbdiff [-v] [-L LEVEL] [--LOG=DIR] [-c CONFIG] [-s SECTION] [-r REPORT] [-D] SPREADSHEET1 SPREADSHEET2
cmdbdiff (-h | --help | -V | --version)
Variables SPREADSHEET1 and SPREADSHEET2 are required, all other parameters are optional.
Options:
-h, --help Show this help message and exit.
-V, --version Show version information and exit.
-c CONFIG, --config=CONFIG The configuration file.
Default: "/home/tom/Run/ECScmdb/Testing/etc/ecscmdb/cmdbdiff.yml"
-s SECTION, --section=SECTION The configuration file version (default
defined within the configuration file).
-r REPORT, --report=REPORT Report directory or file.
-v, --verbose Print verbose messages.
-L LEVEL, --log=LEVEL Print log messages at log value LEVEL.
Valid levels are: TRACE, DEBUG, INFO, WARNING,
ERROR, and CRITICAL.
Default: "WARNING"
--LOG=DIR Log Directory,
Default: "/home/tom/Run/ECScmdb/Testing/log/cmdbdiff.log"
-D, --dryrun Only print out what would be done.
Git information
GIT Home, README File, LICENSE File, ChangeLog File, pyproject.toml File.
About me
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
ecscmdb-1.6.28.tar.gz
(27.2 kB
view details)
Built Distribution
ecscmdb-1.6.28-py3-none-any.whl
(34.0 kB
view details)
File details
Details for the file ecscmdb-1.6.28.tar.gz
.
File metadata
- Download URL: ecscmdb-1.6.28.tar.gz
- Upload date:
- Size: 27.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.3.2 CPython/3.9.13 Linux/5.17.12-100.fc34.x86_64
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 60aa8dd25a3864b3971619b2398c28fabbe3c2b38055ada7f505d41abcaa9846 |
|
MD5 | 5cae05a51d76851f8fa7c91af49c4f7a |
|
BLAKE2b-256 | 0a20878924f89d3e80486d42255c2020c5d2905590ac719dafed170b687969e8 |
File details
Details for the file ecscmdb-1.6.28-py3-none-any.whl
.
File metadata
- Download URL: ecscmdb-1.6.28-py3-none-any.whl
- Upload date:
- Size: 34.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.3.2 CPython/3.9.13 Linux/5.17.12-100.fc34.x86_64
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a8253c76bb45ba04ac638159b9445f896014466d078397c8489b5cbbc8918d22 |
|
MD5 | 366e56d51b8c9c3b51f4291632e425e5 |
|
BLAKE2b-256 | 396d8e6bc1e95a3fab94fdd1d8aab7f0c5e173e1998ed766ebc84f84f958f320 |