项目作者: ceph

项目描述 :
Python bindings for Rook-Ceph CRDs
高级语言: Python
项目地址: git://github.com/ceph/rook-client-python.git
创建时间: 2020-02-10T17:04:29Z
项目社区:https://github.com/ceph/rook-client-python

开源协议:

下载


rook-client Python API Classes

The Rook CRDs are evolving over time and to verify that clients make use of the correct definitions,
this project provides generated API classes to let users write correct clients easily.

Right now, it supports three operators:

  • Ceph
  • Edgefs
  • Cassandra

It is used to type check client code against the Rook API using mypy.

Inspired by kubernetes-client/python

Main uses case is the mgr/rook orchestrator module of the Ceph MGR

Code Generation

This project contains a generate_model_classes.py which can generate
model classes from Kubernetes CRDs and is independent of Rook.

Usage:

  1. python generate_model_classes.py <crds.yaml> <output-folder>

Installing rook-client

To install rook-client, run:

  1. pip install -e 'git+https://github.com/ceph/rook-client-python#egg=rook-client'

Usage

  1. def objectstore(api_name, name, namespace, instances):
  2. from rook_client.ceph import cephobjectstore as cos
  3. rook_os = cos.CephObjectStore(
  4. apiVersion=api_name,
  5. metadata=dict(
  6. name=name,
  7. namespace=namespace
  8. ),
  9. spec=cos.Spec(
  10. metadataPool=cos.MetadataPool(
  11. failureDomain='host',
  12. replicated=cos.Replicated(
  13. size=1
  14. )
  15. ),
  16. dataPool=cos.DataPool(
  17. failureDomain='osd',
  18. replicated=cos.Replicated(
  19. size=1
  20. )
  21. ),
  22. gateway=cos.Gateway(
  23. port=80,
  24. instances=instances
  25. )
  26. )
  27. )
  28. return rook_os.to_json()

Demo

Regenerate

To re-generate the python files, run

  1. ./generate.sh