Skip to content

xcat inventory apply design[for cluster admin]

yangsong edited this page Jan 24, 2019 · 1 revision

the workflow of xcat-inventory apply

  1. backup current cluster inventory in xCAT DB

  2. generate the inventory difference(mark as dict1) between the importing inventory file and xCAT DB with function StructureDiff().diff(d1, d2, self.isall) , the difference result will be classified with difference type,see https://github.com/seperman/deepdiff

  3. restructure dict1 to new dict (mark as dict2) structure: root[<object type>][<object>][<difference type>][<difference path>]

  4. generate the scan order list (mark as orderlist) , list of objects to process, each element is <objtype>.<objname>, should consider the order of object types, the dependency among objects, such as service nodes. compute nodes. the structure should be [[objects to process in stage1], [objects to process in stage2],[objects to process in stage3],...]

  5. generate action plan according to the orderlist in step #4.

    (1) scan dict2 according to the order based on : policy->site->passwd->route->network->zone->osimage->node

    (2) for each object difference, generate action sequence according to the action composer plugin of the object

    (3) a final action plan file(*.ap) will be generated after the iteration in step #4, the content of action plan file(*.ap) file is the xCAT commands list to finish the cluster provision

  6. import the new cluster inventory to xCAT DB

  7. action plan execution

    (1) convert the action plan file(.ap) to action file(.a) with cmd: and check: in testcase format and stop:yes

    (2) invoke the action file(*.a) with xcatttest

    (3) the result of each command will be checked and logger with xcattest(* or implement the new execution engine)

  8. rollback the backup inventory file if any fatal error in step #5

the action composer plugins

  1. the action composer plugin provides a extensible plugin to generate relevant action plan entries according to the inventory difference for each object difference

  2. each inventory object type has a composer plugin

  3. a composer plugin exposes 3 interface functions:

    on_add: actions for newly added object

    on_update: actions for updates of object attributes

    on_remove: actions for removal of object

  4. the arguments of the interface functions:

    objtype: the type of inventory object

    objname: the name of inventory object

    origdict: the original object inventory dict

    newdict: the new object inventory dict

    diffpath: the key path of the difference, such as node.node1.engines.netboot_engine.engine_info

  5. return value of interface functions: string of actions

example:

Consider the following cluster inventory:

credential:
  credential:
    CA:
      certificate: /etc/xcat/ca/ca-cert.pem
      private_key: /etc/xcat/ca/private/ca-key.pem
    client:
      root: /root/.xcat/client-cred.pem
    server: /etc/xcat/cert/server-cred.pem
network:
  10_0_0_0-255_0_0_0:
    basic_attr:
      gateway: 10.0.0.103
      mask: 255.0.0.0
      mgtifname: eth0
      mtu: '1500'
      net: 10.0.0.0
    service:
      tftpserver: <xcatmaster>
node:
  c910f03c09k13:
    device_info:
      arch: ppc64le
      uuid: 463e24fe-f2b2-11e8-8cea-42260a03090d
    device_type: server
    engines:
      console_engine:
        engine_info:
          serialflow: hard
          serialport: '0'
          serialspeed: '115200'
        engine_type: kvm
      hardware_mgt_engine:
        engine_info:
          id: '13'
          vmcpus: '4'
          vmhost: c910f03c09
          vmmemory: '8192'
          vmnicnicmodel: virtio-net-pci
          vmnics: br10,br50,br4093
          vmstorage: phy:/dev/mapper/vg0-vdisk00n13
        engine_type: kvm
      netboot_engine:
        engine_info:
          osimage: sles12.3-ppc64le-install-service
        engine_type: grub2
    network_info:
      primarynic:
        ip: 10.3.9.13
        mac:
        - 42:26:0a:03:09:0d
        - 42:cb:0a:03:09:0d!*NOIP*
        - 42:60:0a:03:09:0d!*NOIP*
    obj_info:
      groups: service,all
    obj_type: node
    role: compute
  c910f03c09k14:
    device_info:
      arch: ppc64le
      uuid: 396ccd7a-f2bc-11e8-8f21-420d0a03090e
    device_type: server
    engines:
      console_engine:
        engine_info:
          serialflow: hard
          serialport: '0'
          serialspeed: '115200'
        engine_type: kvm
      hardware_mgt_engine:
        engine_info:
          id: '14'
          vmcpus: '4'
          vmhost: c910f03c09
          vmmemory: '8192'
          vmnicnicmodel: virtio-net-pci
          vmnics: br10,br50,br4093
          vmstorage: phy:/dev/mapper/vg0-vdisk00n14
        engine_type: kvm
      netboot_engine:
        engine_info:
          osimage: sles12.3-ppc64le-statelite-compute
        engine_type: grub2
    network_info:
      primarynic:
        ip: 10.3.9.14
        mac:
        - 42:0d:0a:03:09:0e
        - 42:c4:0a:03:09:0e!*NOIP*
        - 42:39:0a:03:09:0e!*NOIP*
    obj_info:
      groups: all
    obj_type: node
    role: compute
    role_info:
      monserver: c910f03c09k13
      nfsserver: c910f03c09k13
      servicenode: c910f03c09k13
      tftpserver: c910f03c09k13
      xcatmaster: c910f03c09k13
  rh4.1234567890:
    device_type: server
    engines:
      hardware_mgt_engine:
        engine_type: hmc
    obj_type: group
    role: compute
  service:
    deprecated:
      noderesprimarynic: mac
    device_type: server
    engines:
      netboot_engine:
        engine_info:
          installnic: mac
          postscripts: servicenode
    obj_type: group
    role: service
    role_info:
      monserver: c910f03c09k12
      nfsserver: c910f03c09k12
      setupconserver: '1'
      setupdhcp: '1'
      setupnameserver: '1'
      setupnfs: '1'
      setupntp: '1'
      setuptftp: '1'
      tftpserver: c910f03c09k12
      xcatmaster: c910f03c09k12
  xcatdefaults:
    device_type: server
    engines:
      netboot_engine:
        engine_info:
          postbootscripts: otherpkgs
          postscripts: syslog,remoteshell,syncfiles
    obj_type: group
    role: compute
osimage:
  sles12.3-ppc64le-install-compute:
    basic_attributes:
      arch: ppc64le
      distribution: sles12.3
      osdistro: sles12.3-ppc64le
      osname: Linux
    imagetype: linux
    package_selection:
      otherpkgdir:
      - /install/post/otherpkgs/sles12.3/ppc64le
      pkgdir:
      - /install/sles12.3/ppc64le
      pkglist:
      - /opt/xcat/share/xcat/install/sles/compute.sles12.pkglist
    provision_mode: install
    role: compute
    template: /opt/xcat/share/xcat/install/sles/compute.sles12.ppc64le.tmpl
  sles12.3-ppc64le-install-service:
    basic_attributes:
      arch: ppc64le
      distribution: sles12.3
      osdistro: sles12.3-ppc64le
      osname: Linux
    imagetype: linux
    package_selection:
      otherpkgdir:
      - /install/post/otherpkgs/sles12.3/ppc64le
      otherpkglist:
      - /opt/xcat/share/xcat/install/sles/service.sles12.ppc64le.otherpkgs.pkglist
      pkgdir:
      - /install/sles12.3/ppc64le
      pkglist:
      - /opt/xcat/share/xcat/install/sles/service.sles12.pkglist
    provision_mode: install
    role: service
    scripts:
      postscripts:
      - servicenode
    template: /opt/xcat/share/xcat/install/sles/service.sles12.tmpl
  sles12.3-ppc64le-netboot-compute:
    basic_attributes:
      arch: ppc64le
      distribution: sles12.3
      osdistro: sles12.3-ppc64le
      osname: Linux
    genimgoptions:
      exlist:
      - /opt/xcat/share/xcat/netboot/sles/compute.sles12.ppc64le.exlist
      permission: '755'
      postinstall:
      - /opt/xcat/share/xcat/netboot/sles/compute.sles12.ppc64le.postinstall
      rootimgdir: /install/netboot/sles12.3/ppc64le/compute
    imagetype: linux
    package_selection:
      otherpkgdir:
      - /install/post/otherpkgs/sles12.3/ppc64le
      pkgdir:
      - /install/sles12.3/ppc64le
      pkglist:
      - /opt/xcat/share/xcat/netboot/sles/compute.sles12.ppc64le.pkglist
    provision_mode: netboot
    role: compute
  sles12.3-ppc64le-statelite-compute:
    basic_attributes:
      arch: ppc64le
      distribution: sles12.3
      osdistro: sles12.3-ppc64le
      osname: Linux
    genimgoptions:
      exlist:
      - /opt/xcat/share/xcat/netboot/sles/compute.sles12.ppc64le.exlist
      permission: '755'
      postinstall:
      - /opt/xcat/share/xcat/netboot/sles/compute.sles12.ppc64le.postinstall
      rootfstype: nfs
      rootimgdir: /install/netboot/sles12.3/ppc64le/compute
    imagetype: linux
    package_selection:
      otherpkgdir:
      - /install/post/otherpkgs/sles12.3/ppc64le
      pkgdir:
      - /install/sles12.3/ppc64le
      pkglist:
      - /opt/xcat/share/xcat/netboot/sles/compute.sles12.ppc64le.pkglist
    provision_mode: statelite
    role: compute
passwd:
  omapi:
    password: MVBSZnhQang1d1p6cjZ1ZmxaaVlWczBWc2FFajhxM0s=
    username: xcat_key
  system:
    password: cluster
    username: root
policy:
  '1':
    name: root
    rule: allow
  '1.2':
    name: c910f03c09k12
    rule: trusted
  '2':
    commands: getbmcconfig
    rule: allow
  '2.1':
    commands: remoteimmsetup
    rule: allow
  '2.3':
    commands: lsxcatd
    rule: allow
  '3':
    commands: nextdestiny
    rule: allow
  '4':
    commands: getdestiny
    rule: allow
  '4.4':
    commands: getpostscript
    rule: allow
  '4.5':
    commands: getcredentials
    rule: allow
  '4.6':
    commands: syncfiles
    rule: allow
  '4.7':
    commands: litefile
    rule: allow
  '4.8':
    commands: litetree
    rule: allow
  '4.9':
    commands: getadapter
    rule: allow
route: {}
schema_version: '2.0'
site:
  clustersite:
    SNsyncfiledir: /var/xcat/syncfiles
    auditnosyslog: '0'
    auditskipcmds: ALL
    blademaxp: '64'
    cleanupxcatpost: 'no'
    consoleondemand: 'no'
    databaseloc: /var/lib
    db2installloc: /mntdb2
    dhcplease: '43200'
    disjointdhcps: '0'
    dnshandler: ddns
    domain: pok.stglabs.ibm.com
    enableASMI: 'no'
    forwarders: 10.0.0.103
    fsptimeout: '0'
    installdir: /install
    installloc: /install
    ipmimaxp: '64'
    ipmiretries: '3'
    ipmitimeout: '2'
    master: 10.3.9.12
    maxssh: '8'
    nameservers: <xcatmaster>
    nodesyncfiledir: /var/xcat/node/syncfiles
    ntpservers: <xcatmaster>
    powerinterval: '0'
    ppcmaxp: '64'
    ppcretry: '3'
    ppctimeout: '0'
    sharedtftp: '1'
    sshbetweennodes: ALLGROUPS
    syspowerinterval: '0'
    tftpdir: /tftpboot
    timezone: America/New_York
    useNmapfromMN: 'no'
    vsftp: n
    xcatconfdir: /etc/xcat
    xcatdport: '3001'
    xcatiport: '3002'
    xcatsslversion: TLSv1
zone: {}