Skip to main content

数字能源 API 的 Python 包装器

项目描述

PyDigitalEnergy 是一个 Python 包,允许简单地访问数字能源虚拟化管理平台 API。

安装

Python 3.7+ 支持 PyDigitalEnergy。推荐的安装方式是通过pip

pip install pydigitalenergy

有关安装 Python 和 pip 的说明,请参阅“The Hitchhiker's Guide to Python”安装指南

结构概述

由于Digital Energy是一个虚拟化管理平台。在这里您可以看到高级结构:

└── Grid (Data Center) 		# Logical entity that defines the set of resources
  └── Grid Node(CLuster) 	# Logical grouping of hosts
    └── Stack (Host) 		# Also known as hypervisors, are the physical servers
      └── Compute (Virtual Machine)

快速开始

假设你已经有一个凭证,你可以像这样实例化一个 DigitalEnergyAPI 实例:

from pydigitalenergy import DigitalEnergyApi

api = DigitalEnergyApi(
    hostname = 'Digital Energy host',
    client_id = 'Your identifier',
    client_secret = 'Your secret key'
)

通过该api实例,您可以与 Digital Energy 进行交互。您可以在下面找到几个示例。

计算/虚拟机

在计算中,虚拟机 (VM) 是计算机系统的虚拟化/仿真。

# Get list of computes
computes = api.cloudbroker.computes.list()

# Or you can use more convenient alias
vms = api.cloudbroker.virtual_machines.list()

# To get one particular instance you should use .get() method
# For example with ID = 42
vm = api.cloudbroker.virtual_machines.get(42)

堆栈/主机

主机,也称为管理程序,是运行虚拟机的物理服务器

# Get list of stacks
stacks = api.cloudbroker.stacks.list()

# Or you can use more convenient alias
hosts = api.cloudbroker.hosts.list()

# To get one particular instance you should use .get() method
# For example with ID = 4
host = api.cloudbroker.hosts.get(4)

节点/集群

集群是共享相同存储域并具有相同类型 CPU 的主机的逻辑分组

# Get list of nodes
nodes = api.cloudbroker.nodes.list()

# Or you can use more convenient alias
clusters = api.cloudbroker.clusters.list()

# To get one particular instance you should use .get() method
# For example with ID = 10
cluster = api.cloudbroker.clusters.get(10)

网格/数据中心

数据中心是定义在特定环境中使用的资源集的逻辑实体

# Get list of stacks
grids = api.cloudbroker.grid.list()

# Or you can use more convenient alias
dcs = api.cloudbroker.data_centers.list()

# To get one particular instance you should use .get() method
# For example with ID = 1
host = api.cloudbroker.data_centers.get(1)

可用方法列表

您可以在详细文档中找到更多方法。

项目详情


下载文件

下载适用于您平台的文件。如果您不确定要选择哪个,请了解有关安装包的更多信息。

源分布

PyDigitalEnergy-0.0.3.tar.gz (18.9 kB 查看哈希

已上传 source

内置分布

PyDigitalEnergy-0.0.3-py3-none-any.whl (26.0 kB 查看哈希

已上传 py3