跳转到主要内容

Fabric Orchestrator API

项目描述

PyPI

Fabric Orchestrator swagger-client

这是Fabric Orchestrator API

此Python包是由Swagger Codegen项目自动生成的

  • API版本:1.0.1
  • 包版本:1.0.0
  • 构建包:io.swagger.codegen.v3.generators.python.PythonClientCodegen

生成客户端代码

由于swagger-code-gen中的BUG,请按照以下步骤操作

话虽如此,Swagger Codegen 3.x的Python生成器中存在一个BUG,它不会在OpenAPI 3.0定义中生成Bearer身份验证的代码。作为一个解决方案,编辑您的OpenAPI YAML文件,并将这部分

  securitySchemes:
    bearerAuth:     
      type: http
      scheme: bearer
      bearerFormat: JWT  

替换为

  securitySchemes:
    sso_auth:
      type: apiKey
      in: header
      name: Authorization

然后从修改后的API定义中生成新的Python客户端。

更多详情请参考 这里

需求。

Python 3.9+

安装 & 使用

pip install

如果Python包托管在GitHub上,您可以直接从GitHub安装

pip install git+https://github.com/fabric-testbed/OrchestratorClient.git

(可能需要使用root权限运行pipsudo pip install git+https://github.com/fabric-testbed/OrchestratorClient.git

然后导入包

import fabric_cf.orchestrator.swagger_client 

Setuptools

通过Setuptools安装。

python setup.py install --user

(或使用sudo python setup.py install为所有用户安装包)

然后导入包

import fabric_cf.orchestrator.swagger_client

入门指南

请遵循安装程序,然后运行以下命令

from __future__ import print_function
import time
from fabric_cf.orchestrator.swagger_client.api.version_api import VersionApi
from fabric_cf.orchestrator.swagger_client import Configuration, ApiClient
from fabric_cf.orchestrator.swagger_client.rest import ApiException
from pprint import pprint

# Configure API key authorization: bearerAuth
configuration = Configuration()
configuration.api_key['Authorization'] = 'YOUR_API_KEY'
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['Authorization'] = 'Bearer'

# create_slices an instance of the API class
api_instance = VersionApi(ApiClient(configuration))

try:
    # version
    api_response = api_instance.version_get()
    pprint(api_response)
except ApiException as e:
    print("Exception when calling VersionApi->version_get: %s\n" % e)

API端点文档

所有URI均相对于http://127.0.0.1:8700/

方法 HTTP请求 描述
PoasApi poas_create_sliver_id_post POST /poas/create/{sliver_id} 对sliver执行操作。
PoasApi poas_get GET /poas/ 请求获取POAs的状态。
PoasApi poas_poa_id_get GET /poas/{poa_id} 对sliver执行操作。
ResourcesApi portalresources_get GET /portalresources 检索门户可用资源的列表和描述。
ResourcesApi resources_get GET /resources 检索可用资源的列表和描述。默认情况下,返回缓存的可用资源信息。用户可以强制请求当前可用资源。
SlicesApi slices_create_post POST /slices/create 创建切片
SlicesApi slices_creates_post POST /slices/creates 创建切片
SlicesApi slices_delete_delete DELETE /slices/delete 删除项目中的所有用户切片。
SlicesApi slices_delete_slice_id_delete DELETE /slices/delete/{slice_id} 删除切片。
SlicesApi slices_get GET /slices 检索用户切片列表。
SlicesApi slices_modify_slice_id_accept_post POST /slices/modify/{slice_id}/accept 接受对现有切片的最后修改。
SlicesApi slices_modify_slice_id_put PUT /slices/modify/{slice_id} 修改现有切片。
SlicesApi slices_renew_slice_id_post POST /slices/renew/{slice_id} 更新切片。
SlicesApi slices_slice_id_get GET /slices/{slice_id} 切片属性
SliversApi slivers_get GET /slivers 检索用户slivers列表。
SliversApi slivers_sliver_id_get GET /slivers/{sliver_id} slivers属性
VersionApi version_get GET /version 版本

模型文档

授权文档

bearerAuth

  • 类型:API密钥
  • API密钥参数名:Authorization
  • 位置:HTTP头

Orchestrator代理文档

建议用户使用Orchestrator代理类进行任何编排操作。以下是一些示例。

获取资源

orchestrator_host = "dev-3.fabric-testbed.net"
proxy = OrchestratorProxy(orchestrator_host=orchestrator_host)
resources = proxy.resources(token=token)

创建切片

 import fim.user as fu
 t = fu.ExperimentTopology()
 n1 = t.add_node(name='n1', site='RENC')
 cap = fu.Capacities()
 cap.set_fields(core=4, ram=64, disk=500)
 n1.set_properties(capacities=cap, image_type='qcow2', image_ref='default_centos_8')
 n1.add_component(ctype=fu.ComponentType.SmartNIC, model='ConnectX-6', name='nic1')

 n2 = t.add_node(name='n2', site='RENC')
 n2.set_properties(capacities=cap, image_type='qcow2', image_ref='default_centos_8')
 n2.add_component(ctype=fu.ComponentType.GPU, model='Tesla T4', name='nic2')

 slice_graph = t.serialize()
 sss_key = "<user public key>"
 orchestrator_host = "dev-3.fabric-testbed.net"
 proxy = OrchestratorProxy(orchestrator_host=orchestrator_host)
 status, reservation_list = proxy.create(token=token, slice_name=name, slice_graph=slice_graph, ssh_key=ssh_key)

获取切片

orchestrator_host = "dev-3.fabric-testbed.net"
proxy = OrchestratorProxy(orchestrator_host=orchestrator_host)
status, slice_list = proxy.slices(token=token)

获取切片

orchestrator_host = "dev-3.fabric-testbed.net"
proxy = OrchestratorProxy(orchestrator_host=orchestrator_host)
status, slice_topology = proxy.get_slice(token=token, slice_id=slice_id)

获取slivers

orchestrator_host = "dev-3.fabric-testbed.net"
proxy = OrchestratorProxy(orchestrator_host=orchestrator_host)
status, reservation_list = proxy.slivers(token=token, slice_id=slice_id)

获取slivers

orchestrator_host = "dev-3.fabric-testbed.net"
proxy = OrchestratorProxy(orchestrator_host=orchestrator_host)
status, reservation = proxy.slivers(token=token, slice_id=slice_id, sliver_id=sliver_id)

通过slice_id删除切片

orchestrator_host = "dev-3.fabric-testbed.net"
proxy = OrchestratorProxy(orchestrator_host=orchestrator_host)
status, result = proxy.delete(token=token, slice_id=slice_id)

通过电子邮件删除切片

orchestrator_host = "dev-3.fabric-testbed.net"
proxy = OrchestratorProxy(orchestrator_host=orchestrator_host)
status, result = proxy.delete(token=token, email=email)

更新切片

now = datetime.now(timezone.utc)
new_time = now + timedelta(days=2)
orchestrator_host = "dev-3.fabric-testbed.net"
proxy = OrchestratorProxy(orchestrator_host=orchestrator_host)
status, reservation = proxy.renew_slice(token=token, slice_id=slice_id,
                                        new_lease_end_time=new_time.strftime('%Y-%m-%d %H:%M:%S %z'))

作者

kthare10@unc.edu

项目详情


发布历史 发布通知 | RSS源

下载文件

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

源分发

fabric-orchestrator-client-1.7.3.tar.gz (49.4 kB 查看哈希值)

上传时间 源代码

构建分发

fabric_orchestrator_client-1.7.3-py3-none-any.whl (82.0 kB 查看哈希值)

上传时间 Python 3

由以下机构支持

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF 赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误日志 StatusPage StatusPage 状态页面