Vcloud API 整理

环境Vcloud

账户:iaasadmin 密码:passwd 租户:vsphere.local

1,获取token

curl --insecure -H "Accept: application/json" -H 'Content-Type: application/json' --data '{"username":"iaasadmin@cloud.local","password":"passwd","tenant":"vsphere.local"}' https://vra.cloud.local/identity/api/tokens

2,列出虚拟机,page指定页数,limit显示多少台,orderby以什么排序|dateCreated|id|name|status

curl --insecure -H "Content-Type: application/json" -H "Authorization: Bearer $token" https://$vRA/catalog-service/api/consumer/resources/?page=1&limit=n&$orderby=name

3,获取所有蓝图/查看所有目录项

curl --insecure -H "Accept: application/json" -H "Content-Type: application/json" -H "Authorization: Bearer $token" https://$vRA/catalog-service/api/consumer/entitledCatalogItemViews|python3 -m json.tool

4,查看某个蓝图详细信息

curl --insecure -H "Accept: application/json" -H "Content-Type: application/json" -H "Authorization: Bearer $token" https://vra.cloud.local/catalog-service/api/consumer/entitledCatalogItems/528c19ab-f9b1-4c71-ad68-cab37e8cbd6d/requests/template

5,查看某台机器的 请求的详细信息

curl --insecure -H "Content-Type: application/json" -H "Authorization: Bearer $token" https://$vRA/catalog-service/api/consumer/requests/dc9262db-29c6-4fea-ba03-b31b5fa2c34f

6,查看某台机器的详细信息(包含其他请求连接)*

curl --insecure -H "Content-Type: application/json" -H "Authorization: Bearer $token" https://$vRA/catalog-service/api/consumer/requests/499760da-efea-46f6-ac4d-e0e9fd81fc21/resourceViews

7,重新配置已有虚拟机 先获取虚拟机的Reconfigure重新配置模板json ,再携带模板json去请求重新配置

8,生成模板json文件

curl --insecure -H "Accept: application/json" -H "Content-Type: application/json" -H "Authorization: Bearer $token" https://vra.cloud.local/catalog-service/api/consumer/entitledCatalogItems/528c19ab-f9b1-4c71-ad68-cab37e8cbd6d/requests/template|python -m json.tool >Centos7_VLAN39.json

创建虚拟机

curl --insecure -H "Content-Type: application/json" -H "Authorization: Bearer $token"https://vra.cloud.local/catalog-service/api/consumer/entitledCatalogItems/528c19ab-f9b1-4c71-ad68-cab37e8cbd6d/requests --data @Centos7_VLAN39.json

检查请求状态 URL: https://<vrafqdn/catalog-service/api/consumer/requests/{requestid}

curl --insecure -H "Content-Type: application/json" -H "Authorization: Bearer $token"https://vra.cloud.local/catalog-service/api/consumer/requests/dabca9e4-42cf-466c-a497-ad8edb93d1d5

验证token状态码

    204 NO CONTENT        ##请求成功了。
    401未经授权        ##您必须具有身份验证凭据才能访问该资源。所有请求都必须经过身份验证。
    403 FORBIDDEN            ##您的身份验证凭据无法提供对资源的足够访问权限。
    404未找到        ##无法根据指定的URI找到资源。
    405方法不允许        ##资源不支持HEAD方法。
    500 SERVER ERROR    ##由于内部服务器错误,无法创建或更新资源。

官方文档:https://docs.vmware.com/en/vRealize-Automation/7.3/com.vmware.vra.programming.doc/GUID-A83C30BB-3EDD-439B-B369-A92B4992EEDD.html 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值