tinycmdb

package module
v0.0.0-...-ab24876 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 8, 2020 License: GPL-3.0 Imports: 17 Imported by: 0

README

tinycmdb

Build status Go Report Card

About

tinycmdb is a tiny configuration management database/system.

A Configuration Management System (CMS) is a set of tools and data that is used for collecting, storing, managing, updating, analyzing and presenting data about all configuration items and their relationships.

A configuration item is (mainly) a hardware or software item and is characterized by its attributes (recorded in the ci's configuration record) and its relationship to other cis.

Get started

git clone codeberg.org/steffenfritz/tinycmdb.git
cd tinycmdb/cmd/
go build
./tinycmdb -i db

For API:
========
./tinycmdb
visit http://localhost:8000/swagger/index.html
Login with generated password and user admin via login route
Copy generated token from the response json and click "Authenticate" in Swagger
Insert "Bearer $TOKEN" where $TOKEN is the copied token from the former step

Status

  1. A very basic database schema can be generated
  2. Configuration items (CI) can be added via API
  3. CI metadata can be added via API
  4. Software, hardware, locations and simple documents can be added as CI types via API
  5. Network configurations can be added via API
  6. Systems can be created on the database level

ToDo

  1. Add searches
  2. Add updates
  3. Add adding systems via API
  4. Create a Web user interface

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddCI

func AddCI(c *gin.Context)

AddCI godoc @Summary Add a configuration item @Accept json @Produce json @Param CI body CI true "configuration item" @Success 200 {string} string "added configuration item" @Failure 400 {object} string "400" @Security ApiKeyAuth @Router /auth/addci [post]

func AddCIDB

func AddCIDB(ci CI) (string, error)

AddCIDB adds a new configuration item into the database

func AddCIMD

func AddCIMD(c *gin.Context)

AddCIMD godoc @Summary Add metadata to an existing configuration item @Accept json @Produce json @Param CIMD body CIMD true "configuration item metadata" @Success 200 {string} string "added configuration item for metadata" @Failure 400 {object} string "400" @Security ApiKeyAuth @Router /auth/addcimd [post]

func AddCIMDDB

func AddCIMDDB(cimd CIMD) error

AddCIMDDB adds new metadata for an existing configuration item

func AddDoc

func AddDoc(c *gin.Context)

AddDoc godoc @Summary Add document info to an existing configuration item @Accept json @Produce json @Param Doc body Doc true "document data" @Success 200 {string} string "added document data" @Failure 400 {object} string "400" @Security ApiKeyAuth @Router /auth/adddoc [post]

func AddDocDB

func AddDocDB(doc Doc) (string, error)

AddDocDB adds document metadata to a configuration item into the documents table

func AddHW

func AddHW(c *gin.Context)

AddHW godoc @Summary Add hardware to an existing configuration item @Accept json @Produce json @Param HW body HW true "hardware" @Success 200 {string} string "added hardware info" @Failure 400 {object} string "400" @Security ApiKeyAuth @Router /auth/addhw [post]

func AddHWDB

func AddHWDB(hw HW) (string, error)

AddHWDB adds hardware info to a configuration item

func AddLoc

func AddLoc(c *gin.Context)

AddLoc godoc @Summary Add location data @Accept json @Produce json @Param Loc body Loc true "location data" @Success 200 {string} string "added location" @Failure 400 {object} string "400" @Security ApiKeyAuth @Router /auth/addloc [post]

func AddLocDB

func AddLocDB(loc Loc) (string, error)

AddLocDB adds location info to a configuration item into the locations table

func AddNetConf

func AddNetConf(c *gin.Context)

AddNetConf godoc @Summary Add network config to an existing configuration item @Accept json @Produce json @Param Netconf body Netconf true "network configuration" @Success 200 {string} string "added network configuration" @Failure 400 {object} string "400" @Security ApiKeyAuth @Router /auth/addnetconf [post]

func AddNetConfDB

func AddNetConfDB(netconf Netconf) (string, error)

AddNetConfDB adds network configuration to a configuration item into the netconfigurations table

func AddNetSeg

func AddNetSeg(c *gin.Context)

AddNetSeg godoc @Summary Add network segment info to an existing configuration item @Accept json @Produce json @Param Netseg body Netseg true "net segment configuration" @Success 200 {string} string "added network segment configuration" @Failure 400 {object} string "400" @Security ApiKeyAuth @Router /auth/addnetseg [post]

func AddNetSegDB

func AddNetSegDB(netseg Netseg) (string, error)

AddNetSegDB adds network segment info to a configuration item into the netsegments table

func AddSW

func AddSW(c *gin.Context)

AddSW godoc @Summary Add software to an existing configuration item @Accept json @Produce json @Param SW body SW true "software" @Success 200 {string} string "added software info" @Failure 400 {object} string "400" @Security ApiKeyAuth @Router /auth/addsw [post]

func AddSWDB

func AddSWDB(sw SW) (string, error)

AddSHWDB adds software info to a configuration item

func AddUser

func AddUser(c *gin.Context)

AddUser godoc @Summary Add user @Accept json @Produce json @Param User body User true "user" @Success 200 {string} string "added user" @Failure 400 {object} string "400" @Security ApiKeyAuth @Router /auth/adduser [post]

func AddUserDB

func AddUserDB(user User) (string, error)

AddUserDB adds a new user to the users table

func CheckPasswordHash

func CheckPasswordHash(password, hash string) bool

CheckPasswordHash compares a string to its hash

func CreateDB

func CreateDB(basepath string, passwd string) error

CreateDB creates a database and sets default and technical values internally used

func CreateRandomString

func CreateRandomString() string

CreateRandomString generates a random string. Used for passwords set at installation time

func CreateUUIDString

func CreateUUIDString() (string, error)

CreateUUIDString generates a UUIDv4 string used evereywhere in tinycmdb

func HashPassword

func HashPassword(password string) (string, error)

HashPassword generates a bcrypt hash from a string

func HelloHandler

func HelloHandler(c *gin.Context)

HelloHandler godoc @Summary Show userID and put Hello World in response body when authorized @Accept json @Produce json @Success 200 {string} string "print hello world a user login" @Failure 401 {object} string "401" @Security ApiKeyAuth @Router /auth/hello [get]

func InitDB

func InitDB(dbpath string)

InitDB is an init function that makes a db connection globally available

func MyAuthenticator

func MyAuthenticator(c *gin.Context) (interface{}, error)

MyAuthenticator godoc @Summary Authenticate user @Accept json @Produce json @Param login body login true "username and password" @Success 200 {string} string "login" @Failure 401 {object} string "401" @Router /login [post]

func ReadConfig

func ReadConfig() (string, error)

ReadConfig reads the default config file that holds the database location

func Serv

func Serv()

Serv is the API server

func WriteConfig

func WriteConfig(dbinstpath string) error

WriteConfig writes the default config file that holds the database location

Types

type CI

type CI struct {
	UUID      string `json:"uuid"`
	Shortname string `json:"shortname"`
	Longdesc  string `json:"longdesc"`
	CIType    string `json:"citype"`
	Tschg     string `json:"tschg"`
}

CI type contains info for a root ci entry and maps to the database table cis

type CIMD

type CIMD struct {
	Manufacturer   string `json:"manufacturer"`
	Serialno       string `json:"serialno"`
	Productiondate string `json:"productiondate"`
	Purchasedate   string `json:"purchasedate"`
	Activefrom     string `json:"activefrom"`
	Activeto       string `json:"activeto"`
	License        string `json:"license"`
	Tschg          string `json:"tschg"`
	Ciuuid         string `json:"ciuuid"`
}

CIMD type contains metadata for a root ci entry and maps to the database table cimetadata

type Doc

type Doc struct {
	UUID    string `json:""`
	Doctype string `json:""`
	Subject string `json:""`
	Citxt   string `json:""`
	Scan    string `json:""`
	Tschg   string `json:""`
	Ciuuid  string `json:""`
}

Doc type is for simple documents and maps to the database table cidocs

type HW

type HW struct {
	UUID             string `json:"uuid"`
	Cpucount         string `json:"cpucount"`
	Cputype          string `json:"cputype"`
	Cpucores         string `json:"cpucores"`
	Memorysize       string `json:"memorysize"`
	Memorytype       string `json:"memorytype"`
	Storagesize      string `json:"storagesize"`
	Storagetype      string `json:"storagetype"`
	Powerconsumption string `json:"powercons"`
	Tschg            string `json:"tschg"`
	Ciuuid           string `json:"ciuuid"`
}

HW type is for hardware and maps to the database table hardware

type Loc

type Loc struct {
	UUID      string `json:"uuid"`
	Locname   string `json:"locname"`
	Shortdesc string `json:"shortdesc"`
	Country   string `json:"country"`
	City      string `json:"city"`
	Street    string `json:"street"`
	Number    string `json:"number"`
	Room      string `json:"room"`
	Row       string `json:"row"`
	Shelf     string `json:"shelf"`
	Rack      string `json:"rack"`
	Misc      string `json:"misc"`
	Uri       string `json:"uri"`
	Tschg     string `json:"tschg"`
	Ciuuid    string `json:"ciuuid"`
}

Loc type is for locations and maps to the database table locations

type Netconf

type Netconf struct {
	UUID       string `json:"uuid"`
	Ipaddr     string `json:"ipaddr"`
	Macaddr    string `json:"macaddr"`
	Subnet     string `json:"subnet"`
	Gateway    string `json:"gateway"`
	Dns        string `json:"dns"`
	Dhcpd      string `json:"dhcpd"`
	Ciuuid     string `json:"ciuuid"`
	Tschg      string `json:"tschg"`
	Netseguuid string `json:"netseguuid"`
}

Netconf type is for network configurations of a configuration item and maps to the database table netconfs

type Netseg

type Netseg struct {
	UUID      string `json:"uuid"`
	Netname   string `json:"netname"`
	Gateway   string `json:"gateway"`
	Firstaddr string `json:"Firstaddr"`
	Lastaddr  string `json:"Lastaddr"`
	Tschg     string `json:"Tschg"`
}

Netseg type is for network segments and maps to the database table netsegments

type SW

type SW struct {
	UUID         string `json:"uuid"`
	Shortname    string `json:"shortname"`
	Longname     string `json:"longname"`
	Manufacturer string `json:"manufacturer"`
	Version      string `json:"version"`
	Patchlevel   string `json:"patchlevel"`
	Year         string `json:"year"`
	Platform     string `json:"platform"`
	Tschg        string `json:"tschg"`
	Ciuuid       string `json:"ciuuid"`
}

SW type is for software and maps to the database table software

type User

type User struct {
	UUID       string `json:"uuid"`
	Username   string `json:"username"`
	Passwd     string `json:"passwd"`
	Firstname  string `json:"firstname"`
	Middlename string `json:"middlename"`
	Lastname   string `json:"lastname"`
	Email      string `json:"email"`
	Phone      string `json:"phone"`
	Mobile     string `json:"mobile"`
	Validfrom  string `json:"validfrom"`
	Validto    string `json:"validto"`
	Tschg      string `json:"tschg"`
}

User type contains info for a single user and maps to the database table users

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL