Skip to content

A simple inventory for registering attribute based resources

License

Notifications You must be signed in to change notification settings

cloudmesh/cloudmesh-inventory

Repository files navigation

Cloudmesh Inventory

Version License Python Format Format Travis

Introduction

Often we need a convenient way to manage inventories for Computers and Services. One way to do this is in databases or flat files, or dedicated services. Cloudmesh Inventory is designed to be at this time super simple and provides a list of computer entries that are used to document if a service is running on it. It uses a very small set of metadata to keep it extremely simple. All attribute values are strings. An example is

g001:
  cluster: gregor
  comment: test
  host: g001
  ip: 127.0.0.1
  label: g001
  metadata: None
  name: g001
  owners: gvonlasz
  project: cloudmesh
  service: compute

We explain our intended use of the attributes next

Attribute Description
cluster The name of the cluster this entry is associated with
description a description
comment a comment
host the unique name of the host
ip the ip address
name a unique hostname for the entry
label a unique label that may include more than the hostname
metadata a string in which metadata can be placed
owners a list of owners of the machine (comma separated)
project a string representiing a project name
service a string representing the service
os name of the operating system

Cloudmesh Manual

The manual for cloudmesh can be found at

Cloudmesh Inventory, however can also be used as standalone product.

Instalation and Documentation

Make sure you have a new version of python and pip. We tested with with versions greater then

  • python 3.7.3
  • pip 19.0.3

Instalation with pip

You will need the followng other cloudmesh modules before you can install via pip:

$ pip insatll cloudmesh-common
$ pip insatll cloudmesh-cmd5
$ pip insatll cloudmesh-inventory

Instalation from source

As developer we recommend yo use the instalation from source. For this we have a convenient cloudmesh installer program that outomates fetching the source and does the install for you. To install it form source use:

$ mkdir ~/cm
$ cd ~/cm

$ pip install cloudmesh-installer    
$ cloudmesh-installer git clone inventory
$ cloudmesh-installer install inventory

This will clone a number of repositories in the cm directory and install them with pip from them.

Configuration

Your inventory will be located at

~/.cloudmesh/inventory.yaml

An example file will look as follows:

g001:
  cluster: gregor
  comment: test
  host: g001
  ip: 127.0.0.1
  label: g001
  metadata: None
  name: g001
  owners: gvonlasz
  project: cloudmesh
  service: compute
  os: ubuntu20.04
g002:
  cluster: gregor
  comment: test
  host: g002
  ip: 127.0.0.1
  label: g002
  metadata: None
  name: g002
  owners: gvonlasz
  project: cloudmesh
  service: compute
  os: ubuntu20.04

BUGS

If you like to see fetures added or find bugs, please let us know.

Manual Page

Command inventory
=================

::

  Usage:
      inventory add cluster NAMES
      inventory add NAMES [--label=LABEL]
                          [--services=SERVICES]
                          [--project=PROJECT]
                          [--owners=OWNERS]
                          [--comment=COMMENT]
                          [--inventory=INVENTORY]
                          [--cluster=CLUSTER]
                          [--ip=IP]
                          [--service=SERVICE]
                          [--tag=TAG]
                          [--keyfile=KEYFILE]
                          [--router=ROUTER]
                          [--locale=LOCALE]
                          [--timezone=TIMEZONE]
      inventory create TAG [--hostnames=NAMES]
                           [--ip=IP]
                           [--inventory=INVENTORY]
                           [--keyfile=KEYFILE]
      inventory set NAMES ATTRIBUTE to VALUES [--inventory=INVENTORY] [--listvalue]
      inventory delete NAMES [--inventory=INVENTORY]
      inventory clone NAMES from SOURCE [--inventory=INVENTORY]
      inventory list [NAMES] [--format=FORMAT] [--columns=COLUMNS] [--inventory=INVENTORY]
      inventory info [--inventory=INVENTORY]
      inventory remove --inventory=INVENTORY

  Arguments:
    NAMES     Name of the resources (example i[10-20])
    FORMAT    The format of the output is either txt,
              yaml, dict, table [default: table].
    OWNERS    a comma separated list of owners for this resource
    LABEL     a unique label for this resource
    SERVICE   a string that identifies the service
    PROJECT   a string that identifies the project
    SOURCE    a single host name to clone from
    COMMENT   a comment

  Options:
     -v       verbose mode
     --keyfile=KEYFILE      Keyfile to assign [default: ~/.ssh/id_rsa.pub]

  Description:

        add -- adds a resource to the resource inventory
        list -- lists the resources in the given format
        delete -- deletes objects from the table
        clone -- copies the content of an existing object
                 and creates new once with it
        set   -- sets for the specified objects the attribute
                 to the given value or values. If multiple values
                 are used the values are assigned to the and
                 objects in order. See examples
        map   -- allows to set attributes on a set of objects
                 with a set of values

  Examples:

    cms inventory add x[0-3] --service=openstack
        adds hosts x0, x1, x2, x3 and puts the string
        openstack into the service column

    cms inventory list
        lists the repository

    cms inventory set x[3-4] temperature to 32
        sets for the resources x3, x4 the value of the
        temperature to 32

    cms inventory set x[7-8] ip to 128.0.0.[0-1]
        sets the value of x7 to 128.0.0.0
        sets the value of x8 to 128.0.0.1

    cms inventory set x1 services to bridge,kubernetes --listvalue
        sets the value of x1 to [bridge, kubernetes]
        The --listvalue option indicates the value set is a list

    cms inventory clone x[5-6] from x3
        clones the values for x5, x6 from x3

    inventory add NAMES [--label=LABEL]
                        [--services=SERVICES]
                        [--project=PROJECT]
                        [--owners=OWNERS]
                        [--comment=COMMENT]
                        [--inventory=INVENTORY]
                        [--cluster=CLUSTER]
                        [--ip=IP]
                        [--service=SERVICE]
                        [--tag=TAG]
                        [--keyfile=KEYFILE]
                        [--router=ROUTER]
                        [--locale=LOCALE]
                        [--timezone=TIMEZONE]
    inventory create TAG [--hostnames=NAMES]
                         [--ip=IP]
                         [--inventory=INVENTORY]
                         [--keyfile=KEYFILE]
    inventory set NAMES ATTRIBUTE to VALUES [--inventory=INVENTORY] [--listvalue]
    inventory delete NAMES [--inventory=INVENTORY]
    inventory clone NAMES from SOURCE [--inventory=INVENTORY]
    inventory list [NAMES] [--format=FORMAT] [--columns=COLUMNS] [--inventory=INVENTORY]
    inventory info [--inventory=INVENTORY]
    inventory remove --inventory=INVENTORY

Arguments:
  NAMES     Name of the resources (example i[10-20])
  FORMAT    The format of the output is either txt,
            yaml, dict, table [default: table].
  OWNERS    a comma separated list of owners for this resource
  LABEL     a unique label for this resource
  SERVICE   a string that identifies the service
  PROJECT   a string that identifies the project
  SOURCE    a single host name to clone from
  COMMENT   a comment

Options:
   -v       verbose mode
   --keyfile=KEYFILE      Keyfile to assign [default: ~/.ssh/id_rsa.pub]

Description:

      add -- adds a resource to the resource inventory
      list -- lists the resources in the given format
      delete -- deletes objects from the table
      clone -- copies the content of an existing object
               and creates new once with it
      set   -- sets for the specified objects the attribute
               to the given value or values. If multiple values
               are used the values are assigned to the and
               objects in order. See examples
      map   -- allows to set attributes on a set of objects
               with a set of values

Examples:

  cms inventory add x[0-3] --service=openstack
      adds hosts x0, x1, x2, x3 and puts the string
      openstack into the service column

  cms inventory list
      lists the repository

  cms inventory set x[3-4] temperature to 32
      sets for the resources x3, x4 the value of the
      temperature to 32

  cms inventory set x[7-8] ip to 128.0.0.[0-1]
      sets the value of x7 to 128.0.0.0
      sets the value of x8 to 128.0.0.1

  cms inventory set x1 services to bridge,kubernetes --listvalue
      sets the value of x1 to [bridge, kubernetes]
      The --listvalue option indicates the value set is a list

  cms inventory clone x[5-6] from x3
      clones the values for x5, x6 from x3

About

A simple inventory for registering attribute based resources

Resources

License

Stars

Watchers

Forks

Packages

No packages published