2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2024-11-24 10:30:01 +00:00
7 the mini design of xcat inventory export and import for osimage
yangsong edited this page 2018-05-08 17:31:03 +08:00

the export of osimages

xcat-inventory export -t osimage [-o <osimage name>] -f|--path <destdir>  [--format <format>] [--archive] 
  • if option -f|--path <destdir> is not specified, keep the current behavior to display the osimage definition in stdout

  • if option -f|--path <destdir> is specified, create each subdirectory <osimage name> for each osimage object under <destdir>, each subdirectory <osimage name> contains the following files:

    (1) definition.yaml: the definition of the osimage in the specified <format>

    (2) the directory hierarchy of the osimage customized files referenced in osimage definition, the osimage customized files under the path which shipped by xCAT will not be exported.

  • if --archive is specified, a tarball instead of osimage directory will be created

An example:

[root@c910f03c05k21 osimage]# xcat-inventory export -t osimage -o rhels7.4sp1-x86_64-netboot-compute --format yaml --path //opt/inventory/site/osimage/
[root@c910f03c05k21 osimage]# cat /opt/inventory/site/osimage/rhels7.4sp1-x86_64-netboot-compute/definition.yaml
osimage:
  rhels7.4sp1-x86_64-netboot-compute:
    basic_attributes:
      arch: x86_64
      distribution: rhels7.4sp1
      osdistro: rhels7.4sp1-x86_64
    genimgoptions:
      exlist: /opt/inventory/site/osimage/rhels7.4sp1-x86_64-netboot-compute/compute.rhels7.x86_64.exlist
      postinstall: /opt/inventory/site/osimage/rhels7.4sp1-x86_64-netboot-compute/compute.rhels7.x86_64.postinstall
      rootimgdir: /install/netboot/rhels7.4sp1/x86_64/compute
    imagetype: linux
    package_selection:
      otherpkgdir: /install/post/otherpkgs/rhels7.4sp1/x86_64
      otherpkglist: /opt/inventory/site/osimage/rhels7.4sp1-x86_64-netboot-compute/compute.rhels7.x86_64.otherpkglist
      pkgdir: /install/rhels7.4sp1/x86_64
      pkglist: /opt/inventory/site/osimage/rhels7.4sp1-x86_64-netboot-compute/compute.rhels7.x86_64.pkglist
    provision_mode: netboot
    role: compute
    scripts:
      postbootscripts: config_cuda
      postscripts: confignetwork
schema_version: '1.0'

[root@c910f03c05k21 osimage]# tree /opt/inventory/site/osimage/rhels7.4sp1-x86_64-netboot-compute
/opt/inventory/site/osimage/rhels7.4sp1-x86_64-netboot-compute
├── config_cuda
├── confignetwork
├── definition.yaml
└── opt
    └── inventory
        └── site
            └── osimage
                └── rhels7.4sp1-x86_64-netboot-compute
                    ├── compute.rhels7.x86_64.exlist
                    ├── compute.rhels7.x86_64.otherpkglist
                    ├── compute.rhels7.x86_64.pkglist
                    └── compute.rhels7.x86_64.postinstall

5 directories, 7 files

the import of osimages

xcat-inventory import [-t osimage] [-o <osimage name>] -f|--path <srcdir> 
  • if <srcdir> is a flat text file, keep the current behavior of xcat-inventory import
  • if <srcdir> is a directory, check whether the file "definition.yaml" exists under <srcdir>
    • if yes, <srcdir> is an osimage directory
      • if [-o <osimage name>] is specified, compare the specified osimage name <osimage name> and the osimage name in definition.yaml
        • if the specified osimage name matches the osimage name in definition.yaml, import osimage definition into xCAT DB,insert the git commit id into osimage.usercomments, copy the customized osimage files referenced in osimage definition to the destination path in osimage definition; otherwise, complain the specified osimage does not exist under <srcdir>. If the destination file is exactly the same as the source file, just import osimage definition into xCAT DB, skip file copy.
      • if [-o <osimage name>] is not specified, import the osimage definition and customized osimage files under <srcdir>
    • if no, <srcdir> might be an directory holding osimage directories
      • if [-o <osimage name>] is specified, find the directory <osimage name> under <srcdir>, import <osimage name> if it is a valid osimage directory
      • if [-o <osimage name>] is not specified, import all the valid osimage directories under <srcdir>
  • if <srcdir> is a tarball file, extract the tarball first and import the unarchived file/directory