Skip to content

Basic Inventory Manipulation

yangsbj edited this page Dec 28, 2018 · 1 revision

Basic Inventory Manipulation

xcat-inventory provides an object oriented view of xCAT cluster configuration in YAML/JSON format, and a set of CLIs to manipulate it. The basic cluster inventory manipulation commands include:

export

Export the cluster inventory in xCAT Database to YAML/JSON formatted objects:

  • dump cluster inventory data to screen
# xcat-inventory export
  • dump cluster inventory data to screen in yaml format
# xcat-inventory export --format yaml
  • dumo cluster inventory data to screen in json format
# xcat-inventory export --format json
  • dump cluster inventory data to a file
# xcat-inventory export -f /tmp/cluster
  • dump osimage inventory data to a file
# xcat-inventory export -t osimage -f /tmp/osimage
  • dump the inventory data of osimage "rhels6.5-x86_64-netboot-compute" to a file
# xcat-inventory export -t osimage -o rhels6.5-x86_64-netboot-compute  -f /tmp/osimage
  • export cluster inventory data to a directory
# xcat-inventory export -d /tmp/mm/
The osimage objects has been exported to directory /tmp/mm/osimage
The cluster inventory data has been dumped to /tmp/mm/cluster.json
#[root@xcatmn tmp]# tree /tmp/mm/
/tmp/mm/
├── cluster.yaml
└── osimage
    ├── xcat.redhat-alt.full.install
    │   ├── definition.yaml
    │   └── install
    │       └── xcat_clusters
    │           └── osimage
    │               └── rhels
    │                   ├── common
    │                   │   └── otherpkglist
    │                   │       └── cuda.otherpkglist
    │                   └── xcat
    │                       └── common
    │                           └── rhels.pkglist
...

the cluster configuration and non-osimage objects are exported to cluster.yaml file under target directory.

all objects except "osimage" are dumped to a file "cluster.json" or "cluster.yaml", "osimage" objects are exported to osimage directories under a subdirectory "osimage".

each osimage direcotry contains a "definition.yaml" or "definition.json", and the customized osimage files(files which are not under directory /opt/xcat/share/xcat/), such as pkglist,otherpkglist,synclists,partitionfile,template and exlists

  • export an osimage objec to a directory
# xcat-inventory export -t osimage -o rhels7.4-ppc64le-install-service  -d /tmp/mm/osimage/

import

Import the YAML/JSON formatted inventory object files into xCAT Database

  • Import cluster inventory file to xcat database
# xcat-inventory import -f /tmp/cluster
  • Import "node" and "network" objects from inventory file to xcat database
# xcat-inventory import -f /tmp/cluster  -t node,network
  • Import a network object from cluster inventory file
# xcat-inventory import -f /tmp/cluster  -t network -o 192_168_122_0-255_255_255_0
  • Import cluster inventory data from an inventory directory
# xcat-inventory import -d /tmp/mm/
  • Import an osimage object from cluster inventory directory
# xcat-inventory import -d /tmp/mm/ -t osimage -o sles12.2-ppc64le-install-compute
  • Import an osimage inventory directory
# xcat-inventory import -d /tmp/mm/osimage/rhels7.4-x86_64-netboot-compute/
  • Import osimage inventory file with variables
# xcat-inventory import -e GITREPO=/tmp/ -e SWDIR=/tmp -f /tmp/osimage/osimage.withvar.yaml
  • Import inventory file with variables, the variable values are specified in the specified variabe file. The content of variabe file is a dict in yaml format, the dict key is variable name, the dict value is the variable value.
# xcat-inventory import -f /tmp/osimage/osimage.withvar.yaml --env-file /tmp/env

The format of variables in osimage inventory file is {{<variable name>}}.

  • Builtin variables in inventory file xcat-inventory exposes several builtin variables, the values of the variables are determined during xcat-inventory import implicitly, do not need to specify with -e explicitly. Please find the description and usage of the builtin variables with:
# xcat-inventory envlist

diff

xcat-inventory diff provides object based diff view of the inventory objects from either inventory files or xCAT Database.

  • Diff the given 2 inventory files. If --filename <file name to display> option is specified, the file name in the diff header will be ""
# xcat-inventory diff --files /tmp/cluster.json /root/cluster.json [--filename cluster.json]
  • Diff the inventory objects in inventory file specified with option --source against xCAT Database
# xcat-inventory diff --source /tmp/cluster.json
  • Diff the given inventory file with whole xCAT DB
# xcat-inventory diff --source /tmp/cluster.json --all