md format

This commit is contained in:
pycook 2023-07-12 10:14:47 +08:00
parent e45070ebdc
commit 7abc1ad581
10 changed files with 808 additions and 853 deletions

View File

@ -1,43 +1,46 @@
![基础资源视图](docs/logo.png)
[![License](https://img.shields.io/badge/License-AGPLv3-brightgreen)](https://github.com/veops/cmdb/blob/master/LICENSE)
[![UI](https://img.shields.io/badge/UI-Ant%20Design%20Pro%20Vue-brightgreen)](https://github.com/sendya/ant-design-pro-vue)
[![API](https://img.shields.io/badge/API-Flask-brightgreen)](https://github.com/pallets/flask)
[![UI](https://img.shields.io/badge/UI-Ant%20Design%20Pro%20Vue-brightgreen)](https://github.com/sendya/ant-design-pro-vue)
[![API](https://img.shields.io/badge/API-Flask-brightgreen)](https://github.com/pallets/flask)
[English](README_en.md) / [中文](README.md)
## DEMO ONLINE
- Preview online: <a href="https://cmdb.veops.cn" target="_blank">CMDB</a>
- username: demo
- password: 123456
> **ATTENTION**: branch `master` may be unstable as the result of continued development, please pull code from [releases](https://github.com/veops/cmdb/releases)
Overview
-------------
- Preview online: <a href="https://cmdb.veops.cn" target="_blank">CMDB</a>
- username: demo
- password: 123456
> **ATTENTION**: branch `master` may be unstable as the result of continued development, please pull code from [releases](https://github.com/veops/cmdb/releases)
## Overview
### Technical Architecture
<img src=docs/view.png />
### Document
- <a href="https://zhuanlan.zhihu.com/p/98453732" target="_blank">Design Document</a>
- <a href="https://github.com/veops/cmdb/tree/master/docs/cmdb_api.md" target="_blank">API Documentation</a>
- <a href="https://mp.weixin.qq.com/s/EflmmJ-qdUkddTx2hRt3pA" target="_blank">Practice of Tree View</a>
### Features
- Flexibility
1. Standardize and manage complex data assets
2. Automatically discover and inventory IT assets
- Security
1. Fine-grained access control
2. Comprehensive operation logs
2. Comprehensive operation logs
- Multi-application
1. Rich view display dimensions
2. Provide Restful API
3. Custom field triggers
### Main Features
- Model attributes support indexing, multiple values, default sorting, font color, and computed properties.
- Support automatic discovery, scheduled inspections, and file import.
- Support resource, tree view, and relationship view display.
@ -46,23 +49,27 @@ Overview
- Support cross-model search.
### System Overview
- Service Tree
![1](docs/0.png "首页展示")
![1](docs/0.png "首页展示")
[View more screenshots](docs/screenshot.md)
### More Features
> Welcome to visit VeOps official website to discover more free operations and maintenance systems.
## Recommended
[Spug - Open source lightweight automated operation and maintenance platform](https://github.com/openspug/spug)
Installation
----
### [One-Click Docker Quick Build](docs/docker_en.md)
### [Local Setup](docs/local_en.md)
### [Installation with Makefile](docs/makefile_en.md)
## Installation
### [One-Click Docker Quick Build](docs/docker_en.md)
### [Local Setup](docs/local_en.md)
### [Installation with Makefile](docs/makefile_en.md)
## Contributing
@ -72,7 +79,8 @@ Installation
1. Push to the branch (`git push origin my-feature`)
1. Create new Pull Request
-----
---
_**Welcome to join us through QQ group336164978**_
![QQgroup](docs/qr_code.jpg)
![QQgroup](docs/qr_code.jpg)

File diff suppressed because it is too large Load Diff

View File

@ -1,143 +1,133 @@
# CMDB查询 API文档
# CMDB 查询 API 文档
## 用户接口
### CI通用搜索接口
##### 搜索所有的CI实例
### CI 通用搜索接口
* GET `/api/v0.1/ci/s`
* 参数
* `string:_type` 搜索的ci_type多个用分号隔开, 例如: _type:(docker;kvm)
* `string:q` 搜索表达式, 例如`q=hostname:cmdb*`
* `string:fl` 返回字段(id, attr_name, attr_alias均可)英文半角逗号分隔
* `string:ret_key` 返回字段类型 `Enum("id", "name", "alias")` 默认 `name`
* `count` 指定一次返回CI数
* `facet` 属性字段逗号分隔返回属性字段对应的所有值
* 搜索表达式
* 简单的字符串
* `attribute:value` 指定属性搜索 `attribute`可以是`id`,`attr_name``attr_alias`
* 以上的组合逗号分隔
* 组合查询支持
* `AND`关系-`默认关系`
* `OR`关系 - eg.`-hostname:cmdb*`
* `NOT`关系-属性字段前加`~`eg. `~hostname:cmdb*`
* `IN`查询. eg. `hostname:(cmdb*;cmdb-web*)` 小括号, 分号分隔
* `RANGE`查询. eg. `hostname:[cmdb* _TO_ cmdb-web*]` `_TO_`分隔
* `COMPARISON`查询. eg. `cpu_count:>5` 支持`>, >=, <, <=`
* 返回结果
* 搜索表达式 `/api/v0.1/ci/s?q=_type:kvm,status:在线,idc:南汇,private_ip:10.1.1.1*&page=1&fl=hostname,private_ip&facet=private_ip&count=1`
* 返回数据默认json
```
{
facet: {
private_ip: [
[
"10.1.1.11",
1,
"private_ip"
],
[
"10.1.1.12",
1,
"private_ip"
],
[
"10.1.1.13",
1,
"private_ip"
]
]
},
total: 1,
numfound: 3,
result: [
{
hostname: "xxx11",
private_ip: [
"10.1.1.11"
]
}
],
counter: {
kvm: 1
},
page: 1
}
```
### CI Relation通用搜索接口
##### 搜索所有的 CI 实例
##### 搜索所有的CI之间的关系比如某一个产品线线的所有应用或者是所有服务器
- GET `/api/v0.1/ci/s`
- 参数
- `string:_type` 搜索的 ci_type多个用分号隔开, 例如: \_type:(docker;kvm)
- `string:q` 搜索表达式, 例如`q=hostname:cmdb*`
- `string:fl` 返回字段(id, attr_name, attr_alias 均可)英文半角逗号分隔
- `string:ret_key` 返回字段类型 `Enum("id", "name", "alias")` 默认 `name`
- `count` 指定一次返回 CI
- `facet` 属性字段逗号分隔返回属性字段对应的所有值
- 搜索表达式
- 简单的字符串
- `attribute:value` 指定属性搜索 `attribute`可以是`id`,`attr_name``attr_alias`
- 以上的组合逗号分隔
- 组合查询支持
- `AND`关系-`默认关系`
- `OR`关系 - eg.`-hostname:cmdb*`
- `NOT`关系-属性字段前加`~`eg. `~hostname:cmdb*`
- `IN`查询. eg. `hostname:(cmdb*;cmdb-web*)` 小括号, 分号分隔
- `RANGE`查询. eg. `hostname:[cmdb* _TO_ cmdb-web*]` `_TO_`分隔
- `COMPARISON`查询. eg. `cpu_count:>5` 支持`>, >=, <, <=`
- 返回结果
- 搜索表达式 `/api/v0.1/ci/s?q=_type:kvm,status:在线,idc:南汇,private_ip:10.1.1.1*&page=1&fl=hostname,private_ip&facet=private_ip&count=1`
- 返回数据默认 json
```
{
facet: {
private_ip: [
[
"10.1.1.11",
1,
"private_ip"
],
[
"10.1.1.12",
1,
"private_ip"
],
[
"10.1.1.13",
1,
"private_ip"
]
]
},
total: 1,
numfound: 3,
result: [
{
hostname: "xxx11",
private_ip: [
"10.1.1.11"
]
}
],
counter: {
kvm: 1
},
page: 1
}
```
* GET `/api/v0.1/ci_relations/s`
* 参数
* `int:root_id` 搜索的根节点的ci_id
* `int:level` 搜索的层级
* `string:_type` 搜索的ci_type多个用分号隔开, 例如: _type:(docker;kvm)
* `string:q` 搜索表达式, 例如`q=hostname:cmdb*`
* `string:fl` 返回字段(id, attr_name, attr_alias均可)英文半角逗号分隔
* `string:ret_key` 返回字段类型 `Enum("id", "name", "alias")` 默认 `name`
* `count` 指定一次返回CI数
* `facet` 属性字段逗号分隔返回属性字段对应的所有值
* 搜索表达式
* 简单的字符串
* `attribute:value` 指定属性搜索 `attribute`可以是`id`,`attr_name``attr_alias`
* 以上的组合逗号分隔
* 组合查询支持
* `AND`关系-`默认关系`
* `OR`关系 - eg.`-hostname:cmdb*`
* `NOT`关系-属性字段前加`~`eg. `~hostname:cmdb*`
* `IN`查询. eg. `hostname:(cmdb*;cmdb-web*)` 小括号, 分号分隔
* `RANGE`查询. eg. `hostname:[cmdb* _TO_ cmdb-web*]` `_TO_`分隔
* `COMPARISON`查询. eg. `cpu_count:>5` 支持`>, >=, <, <=`
* 返回结果
* 搜索表达式 `/api/v0.1/ci_relations/s?root_id=53&level=3&q=_type:kvm,status:在线,idc:南汇,private_ip:10.1.1.1*&page=1&fl=hostname,private_ip&facet=private_ip&count=1`
* 返回数据默认json
```
{
facet: {
private_ip: [
[
"10.1.1.11",
1,
"private_ip"
],
[
"10.1.1.12",
1,
"private_ip"
],
[
"10.1.1.13",
1,
"private_ip"
]
]
},
total: 1,
numfound: 3,
result: [
{
hostname: "xxx11",
private_ip: [
"10.1.1.11"
]
}
],
counter: {
kvm: 1
},
page: 1
}
```
### CI Relation 通用搜索接口
##### 搜索所有的 CI 之间的关系,比如某一个产品线线的所有应用或者是所有服务器
- GET `/api/v0.1/ci_relations/s`
- 参数
- `int:root_id` 搜索的根节点的 ci_id
- `int:level` 搜索的层级
- `string:_type` 搜索的 ci_type多个用分号隔开, 例如: \_type:(docker;kvm)
- `string:q` 搜索表达式, 例如`q=hostname:cmdb*`
- `string:fl` 返回字段(id, attr_name, attr_alias 均可)英文半角逗号分隔
- `string:ret_key` 返回字段类型 `Enum("id", "name", "alias")` 默认 `name`
- `count` 指定一次返回 CI
- `facet` 属性字段逗号分隔返回属性字段对应的所有值
- 搜索表达式
- 简单的字符串
- `attribute:value` 指定属性搜索 `attribute`可以是`id`,`attr_name``attr_alias`
- 以上的组合逗号分隔
- 组合查询支持
- `AND`关系-`默认关系`
- `OR`关系 - eg.`-hostname:cmdb*`
- `NOT`关系-属性字段前加`~`eg. `~hostname:cmdb*`
- `IN`查询. eg. `hostname:(cmdb*;cmdb-web*)` 小括号, 分号分隔
- `RANGE`查询. eg. `hostname:[cmdb* _TO_ cmdb-web*]` `_TO_`分隔
- `COMPARISON`查询. eg. `cpu_count:>5` 支持`>, >=, <, <=`
- 返回结果
- 搜索表达式 `/api/v0.1/ci_relations/s?root_id=53&level=3&q=_type:kvm,status:在线,idc:南汇,private_ip:10.1.1.1*&page=1&fl=hostname,private_ip&facet=private_ip&count=1`
- 返回数据默认 json
```
{
facet: {
private_ip: [
[
"10.1.1.11",
1,
"private_ip"
],
[
"10.1.1.12",
1,
"private_ip"
],
[
"10.1.1.13",
1,
"private_ip"
]
]
},
total: 1,
numfound: 3,
result: [
{
hostname: "xxx11",
private_ip: [
"10.1.1.11"
]
}
],
counter: {
kvm: 1
},
page: 1
}
```

View File

@ -1,4 +1,5 @@
- 进入主目录先安装docker环境
- 进入主目录先安装 docker 环境
```
docker-compose up -d
```

View File

@ -1,9 +1,10 @@
### Install by Docker
- Prepare: install docker and docker-compose
- In directory cmdb
```
docker-compose up -d
```
```
docker-compose up -d
```
- View: [http://127.0.0.1:8000](http://127.0.0.1:8000)
- username: demo or admin
- password: 123456
- password: 123456

View File

@ -1,32 +1,33 @@
本地搭建: 环境和依赖
----
## 本地搭建: 环境和依赖
- 存储: mysql, redis
- python版本: >=python3.8
- python 版本: >=python3.8
Install
----
- 启动mysql服务, redis服务
## Install
- 创建数据库cmdb
- 启动 mysql 服务, redis 服务
- 创建数据库 cmdb
- 拉取代码
```bash
git clone https://github.com/veops/cmdb.git
cd cmdb
cp cmdb-api/settings.example.py cmdb-api/settings.py
```
**设置cmdb-api/settings.py里的database**
**设置 cmdb-api/settings.py 里的 database**
- 安装库
- 后端: ```cd cmdb-api && pipenv run pipenv install && cd ..```
- 前端: ```cd cmdb-ui && yarn install && cd ..```
- 创建数据库表: 进入**cmdb-api**目录执行 ```pipenv run flask db-setup && pipenv run flask init-cache```
- 可以将docs/cmdb.sql导入到数据库里登录用户和密码分别是:demo/123456
- 后端: `cd cmdb-api && pipenv run pipenv install && cd ..`
- 前端: `cd cmdb-ui && yarn install && cd ..`
- 创建数据库表: 进入**cmdb-api**目录执行 `pipenv run flask db-setup && pipenv run flask init-cache`
- 可以将 docs/cmdb.sql 导入到数据库里登录用户和密码分别是:demo/123456
- 启动服务
- 后端: 进入**cmdb-api**目录执行 ```pipenv run flask run -h 0.0.0.0```
- 前端: 进入**cmdb-ui**目录执行```yarn run serve```
- worker: 进入**cmdb-api**目录执行 ```pipenv run celery worker -A celery_worker.celery -E -Q cmdb_async --concurrency=1```
- 浏览器打开: [http://127.0.0.1:8000](http://127.0.0.1:8000)
- 如果是非本机访问, 要修改**cmdb-ui/.env****VUE_APP_API_BASE_URL**里的IP地址为后端服务的ip地址
- 后端: 进入**cmdb-api**目录执行 `pipenv run flask run -h 0.0.0.0`
- 前端: 进入**cmdb-ui**目录执行`yarn run serve`
- worker: 进入**cmdb-api**目录执行 `pipenv run celery worker -A celery_worker.celery -E -Q cmdb_async --concurrency=1`
- 浏览器打开: [http://127.0.0.1:8000](http://127.0.0.1:8000)
- 如果是非本机访问, 要修改**cmdb-ui/.env****VUE_APP_API_BASE_URL**里的 IP 地址为后端服务的 ip 地址

View File

@ -1,29 +1,31 @@
### Install
- Start mysql, redis
- Create mysql database: cmdb
- Pull code
```bash
git clone https://github.com/veops/cmdb.git
cd cmdb
cp cmdb-api/settings.example.py cmdb-api/settings.py
```
**set database in config file cmdb-api/settings.py**
```bash
git clone https://github.com/veops/cmdb.git
cd cmdb
cp cmdb-api/settings.example.py cmdb-api/settings.py
```
**set database in config file cmdb-api/settings.py**
- Install library
- backend: ```cd cmdb-api && pipenv run pipenv install && cd ..```
- frontend: ```cd cmdb-ui && yarn install && cd ..```
- backend: `cd cmdb-api && pipenv run pipenv install && cd ..`
- frontend: `cd cmdb-ui && yarn install && cd ..`
- Create tables of cmdb database:
in **cmdb-api** directory: ```pipenv run flask db-setup && pipenv run flask init-cache```
- Suggest step: (default: user:demo,password:123456)
in **cmdb-api** directory: `pipenv run flask db-setup && pipenv run flask init-cache`
- Suggest step: (default: user:demo,password:123456)
``` source docs/cmdb.sql```
` source docs/cmdb.sql`
- Start service
- backend: in **cmdb-api** directory: ```pipenv run flask run -h 0.0.0.0```
- frontend: in **cmdb-ui** directory: ```yarn run serve```
- worker: in **cmdb-api** directory: ```pipenv run celery worker -A celery_worker.celery -E -Q cmdb_async --concurrency=1```
- homepage: [http://127.0.0.1:8000](http://127.0.0.1:8000)
- backend: in **cmdb-api** directory: `pipenv run flask run -h 0.0.0.0`
- frontend: in **cmdb-ui** directory: `yarn run serve`
- worker: in **cmdb-api** directory: `pipenv run celery worker -A celery_worker.celery -E -Q cmdb_async --concurrency=1`
- homepage: [http://127.0.0.1:8000](http://127.0.0.1:8000)
- if not run localhost: please change ip address(**VUE_APP_API_BASE_URL**) in config file **cmdb-ui/.env** into your backend ip address

View File

@ -1,19 +1,20 @@
Install by Makefile
----
- 启动mysql服务, redis服务
## Install by Makefile
- 创建数据库cmdb
- 启动 mysql 服务, redis 服务
- 创建数据库 cmdb
- 拉取代码
```bash
git clone https://github.com/veops/cmdb.git
cd cmdb
cp cmdb-api/settings.example.py cmdb-api/settings.py
```
**设置cmdb-api/settings.py里的database**
- 顺序在cmdb目录下执行
- 环境: ```make env```
- 启动API: ```make api```
- 启动UI: ```make ui```
- 启动worker: ```make worker```
**设置 cmdb-api/settings.py 里的 database**
- 顺序在 cmdb 目录下执行
- 环境: `make env`
- 启动 API: `make api`
- 启动 UI: `make ui`
- 启动 worker: `make worker`

View File

@ -1,16 +1,19 @@
### Install by Makefile
- Start mysql,redis
- Create mysql database: cmdb
- Pull code
```bash
git clone https://github.com/veops/cmdb.git
cd cmdb
cp cmdb-api/settings.example.py cmdb-api/settings.py
```
**set database in config file cmdb-api/settings.py**
```bash
git clone https://github.com/veops/cmdb.git
cd cmdb
cp cmdb-api/settings.example.py cmdb-api/settings.py
```
**set database in config file cmdb-api/settings.py**
- In cmdb directory,start in order as follows:
- enviroment: ```make env```
- start API: ```make api```
- start UI: ```make ui```
- start worker: ```make worker```
- enviroment: `make env`
- start API: `make api`
- start UI: `make ui`
- start worker: `make worker`

View File

@ -1,6 +1,7 @@
### 系统概览
- 服务树
![1](0.png "首页展示")
![1](0.png "首页展示")
- 资源视图
@ -29,4 +30,3 @@
- 定制仪表盘
![10](10.jpg "定制仪表盘")