目的
1. 利用 golang 调用 ceph 存储
2. 获取 ceph json 数据并进行处理
3. 利用 gjson 包对 json 数据进行处理
参考
json 处理
gjson
特点
语法简单
功能多样化
可以减少代码量
缺点
无法从代码中得知 json 结构
增加了代码维护难度
需要有完善的开发文档才行
获取
获取方法
go get -u github.com/tidwall/gjson
参考目录结构
.
├── client
├── models
└── vendor
└── github.com
├── ceph
│ └── go-ceph
│ ├── cephfs
│ ├── rados
│ └── rbd
└── tidwall <- go get 下载的 gjson 目录结构
├── gjson
└── match
json 数据参考
参考 golang ceph 连接方法 获取的 json 数据如下
{
"name": "ns-storage-020101",
"rank": 1,
"state": "peon",
"election_epoch": 52,
"quorum": [
0,
1,
2
],
"features": {
"required_con": "153140804152475648",
"required_mon": [
"kraken",
"luminous"
],
"quorum_con": "2305244844532236283",
"quorum_mon": [
"kraken",
"luminous"
]
},
"outside_quorum": [],
"extra_probe_peers": [],
"sync_provider": [],
"monmap": {
"epoch": 2,
"fsid": "8085cc2f-d5ec-48d2-b614-xxxxxxxxxxx",
"modified": "2018-12-07 20:44:56.784568",
"created": "2018-12-07 20:44:56.