vSphere Automation SDK for Python 使用教程

vSphere Automation SDK for Python 使用教程

vsphere-automation-sdk-pythonvmware/vsphere-automation-sdk-python: VMware 开发的 vSphere 自动化工件(SDK),用于编写 Python 程序以管理 VMware vSphere 环境。适合 DevOps 和 VMware 管理员使用,可以大大提高管理和配置 vSphere 环境的效率。项目地址:https://gitcode.com/gh_mirrors/vs/vsphere-automation-sdk-python

1. 项目的目录结构及介绍

vsphere-automation-sdk-python/
├── lib/
│   ├── vapi-client-bindings/
│   ├── vapi-common-client/
│   ├── vapi-runtime/
│   ├── vmomi-bindings/
│   ├── vsphere-automation-sdk/
│   └── ...
├── samples/
│   ├── vcenter/
│   ├── nsx-t/
│   ├── vmware-cloud-aws/
│   └── ...
├── test-requirements.txt
├── README.md
├── CODE_OF_CONDUCT.md
├── LICENSE
└── ...
  • lib/: 包含 SDK 所需的所有依赖库。
  • samples/: 包含各种示例代码,如 vCenter、NSX-T 和 VMware Cloud on AWS 的示例。
  • test-requirements.txt: 测试所需的依赖项。
  • README.md: 项目介绍和基本使用说明。
  • CODE_OF_CONDUCT.md: 行为准则。
  • LICENSE: 项目许可证。

2. 项目的启动文件介绍

项目中没有明确的“启动文件”,因为这是一个 SDK,而不是一个独立的应用程序。通常,用户会根据需要选择并运行 samples/ 目录下的示例代码来开始使用 SDK。

例如,要运行 vCenter 的示例代码,可以导航到 samples/vcenter/ 目录并运行相应的 Python 脚本。

3. 项目的配置文件介绍

项目中没有明确的“配置文件”,因为配置通常在代码中进行。用户需要在代码中设置连接到 vCenter Server 的参数,例如:

import requests
import urllib3
from vmware.vapi.vsphere.client import create_vsphere_client

session = requests.session()
# Disable cert verification for demo purpose
# This is not recommended in a production environment
session.verify = False
# Disable the secure connection warning for demo purpose
# This is not recommended in a production environment
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

# Connect to a vCenter Server using the session
vsphere_client = create_vsphere_client(server='vcenter-server-address', username='your-username', password='your-password', session=session)

在这个示例中,用户需要提供 vCenter Server 的地址、用户名和密码。这些参数通常在代码中硬编码,或者从环境变量或配置文件中读取。

vsphere-automation-sdk-pythonvmware/vsphere-automation-sdk-python: VMware 开发的 vSphere 自动化工件(SDK),用于编写 Python 程序以管理 VMware vSphere 环境。适合 DevOps 和 VMware 管理员使用,可以大大提高管理和配置 vSphere 环境的效率。项目地址:https://gitcode.com/gh_mirrors/vs/vsphere-automation-sdk-python

  • 3
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

褚铃尤Kerwin

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值