解决了

通过REST API创建后,VM在状态下供电的VM

  • 2021年1月28日
  • 1回复
  • 413意见

徽章 +1

用于创建VM克隆的REST API工作正常,但是在VM克隆之后。它处于脱离状态。

有什么方法可以通过API 3在状态下设置权力(在API 2中,它在那里,但它的旧且弃用不起作用)

或者

创建VM或克隆的任何其他方法,以便在VM创建后它可以在状态下掌权。

图标

最好的答案Anishwalia202021年1月28日,07:03

hey\u00a0@Balram<\/user-mention>\u00a0I don\u2019t think there is any REST API v3\u00a0operation specifically related to the VM to power it on, but you can do so using PUT \/vms\/UUID v3 opeartion\u00a0<\/strong><\/a><\/p>

To update a VM's specs, we need to send an HTTP PUT request to the Prism Central IP. The request\u00a0body<\/strong>\u00a0should contain all current specs of the VM. The easiest way to get a VM's specs is to send a GET request to \/vms\/uuid<\/strong><\/a><\/p>

Now in the below output of GET operation,\u00a0Scroll down to the\u00a0Response Body<\/strong>\u00a0text box. Find the\u00a0spec\u00a0key and copy starting from \"spec<\/strong>\" down to the last closing curly brace \"}\". Paste it to a text editor.<\/p>

For eg-<\/p>

{
\"spec\": {
\"cluster_reference\": {
\"kind\": \"cluster\",
\"name\": \"Prolix\",
\"uuid\": \"00052c80-729d-8705-0000-0000000051fa\"
},
\"description\": \"v3api_vm\",
\"resources\": {
\"vnuma_config\": {
\"num_vnuma_nodes\": 0
},
\"nic_list\": [
{
\"ip_endpoint_list\": [],
\"nic_type\": \"NORMAL_NIC\",
\"subnet_reference\": {
\"kind\": \"subnet\",
\"name\": \"vlan25\",
\"uuid\": \"565784d2-7a68-4a16-a1bd-92473760f607\"
},
\"uuid\": \"4bff96c1-386e-40bb-bc5b-1dc8a85952af\",
\"mac_address\": \"50:6b:8d:b4:76:12\"
}
],
\"num_vcpus_per_socket\": 2,
\"num_sockets\": 1,
\"gpu_list\": [],
\"memory_size_mib\": 4096,
\"power_state\": \"OFF\",
\"hardware_clock_timezone\": \"UTC\",
\"power_state_mechanism\": {
\"mechanism\": \"HARD\"
},
\"vga_console_enabled\": true,
\"disk_list\": [
{
\"device_properties\": {
\"disk_address\": {
\"device_index\": 1,
\"adapter_type\": \"SCSI\"
},
\"device_type\": \"DISK\"
},
\"uuid\": \"948915d8-1f99-46f3-a249-39151f3f518a\",
\"disk_size_bytes\": 26484932608,
\"disk_size_mib\": 25258
}
]
},
\"name\": \"nuran_v3api\"
},
\"api_version\": \"3.1\",
\"metadata\": {
\"last_update_time\": \"2018-11-03T00:26:41Z\",
\"kind\": \"vm\",
\"uuid\": \"042dada0-2f55-4001-a6f1-70d7b88e323c\",
\"project_reference\": {
\"kind\": \"project\",
\"name\": \"default\",
\"uuid\": \"f86d420a-f601-4ca9-9135-082bc38554c6\"
},
\"spec_version\": 1,
\"creation_time\": \"2018-11-02T20:42:52Z\",
\"owner_reference\": {
\"kind\": \"user\",
\"uuid\": \"00000000-0000-0000-0000-000000000000\",
\"name\": \"admin\"
},
\"categories\": {}
}
}<\/code><\/pre>

\u00a0<\/p>

Now, you can update any parameter in the above, you power on a VM, update its\u00a0configuration, add new disk etc.
\u00a0<\/p>

\u00a0<\/p>

or\u00a0another way is by using the Powershell scripts:<\/p>

Here is a list of entities which you can manage using PowerShell CMDlets:\u00a0https:\/\/portal.nutanix.com\/page\/documents\/details?targetId=API_Ref-Acr_v4_6%3APowerShell_Cmdlets_Reference<\/a><\/p>

\u00a0<\/p>

Also, this\u00a0PowerShell CMDlets cheatsheet would\u00a0be useful:
\u00a0<\/p>

\"//www.jhbzcj.com/next/prism-for-infra-and-it-ops-26/\"<\/figure>

\u00a0<\/p>

You can check out the Powershell commands under\u00a0Acropolis Task administration(2nd column in the above screenshot)<\/strong>\u00a0to create a new VM, Power it on etc,<\/p>

\u00a0<\/p>","className":"post__content__best_answer"}">

查看原件

该主题已关闭以供评论

1回复

UserLevel 6
徽章 +5

@balram我认为没有任何与VM专门相关的REST API V3操作来供电,但是您可以使用put /vms /uuid v3 opeartion

要更新VM的规格,我们需要向Prism Central IP发送HTTP PUT请求。请求身体应包含VM的所有当前规格。获得VM规格的最简单方法是发送获取请求 /vms /uuid

现在在下面的输出中,向下滚动到响应主体文本框。从规格“直到最后一个关闭的卷发式”}“将其粘贴到文本编辑器上。

例如 -

{
“规格”:{
“ cluster_reference”:{
“ ank”:“ cluster”,
“名称”:“ Prolix”,
“ uuid”:“ 00052C80-729D-8705-0000-000000000051FA”
},,
“描述”:“ v3api_vm”,
“资源”: {
“ vnuma_config”:{
“ num_vnuma_nodes”:0
},,
“ nic_list”:[
{
“ ip_endpoint_list”:[],
“ nic_type”:“ normal_nic”,
“ subnet_reference”:{
“ ank”:“子网”,
“名称”:“ vlan25”,
“ uuid”:“ 565784D2-7A68-4A16-A1BD-9247376077”
},,
“ uuid”:“ 4BFF96C1-386E-40BB-BC5B-1DC8A85952AF”,
“ mac_address”:“ 50:6b:8d:b4:76:12”
}
],,
“ num_vcpus_per_socket”:2,
“ num_sockets”:1,
“ gpu_list”:[],
“ memory_size_mib”:4096,
“ power_state”:“关闭”,
“ hardware_clock_timezone”:“ utc”,
“ power_state_mechanism”:{
“机制”:“硬”
},,
“ vga_console_enabled”:troo,
“ disk_list”:[
{
“ device_properties”:{
“ disk_address”:{
“ device_index”:1,
“ adapter_type”:“ scsi”
},,
“ device_type”:“磁盘”
},,
“ uuid”:“ 948915D8-1F99-46F3-A249-39151F3F518A”,
“ disk_size_bytes”:26484932608,
“ disk_size_mib”:25258
}
这是给出的
},,
“名称”:“ nuran_v3api”
},,
“ api_version”:“ 3.1”,
“元数据”:{
“ last_update_time”:“ 2018-11-03T00:26:41Z”,
“友善”:“ VM”,
“ uuid”:“ 042DADA0-2F55-4001-A6F1-70D7B88E323C”,
“ Project_Reference”:{
“友善”:“项目”,
“名称”:“默认”,
“ uuid”:“ F86D420A-F601-4CA9-9135-082BC38554C6”
},,
“ spec_version”:1,
“ creation_time”:“ 2018-11-02T20:42:52Z”,
“所有者_Reference”:{
“ ank”:“用户”,
“ uuid”:“ 00000000-0000-0000-0000-0000-000000000000”,
“名称”:“ admin”
},,
“类别”:{}
}
}

现在,您可以更新以上参数,在VM上供电,更新其配置,添加新磁盘等。

或另一种方法是使用PowerShell脚本:

这是您可以使用PowerShell cmdlet管理的实体列表:https://portal.nutanix.com/page/documents/details?targetId=Api_ref-acr_v4_6%3powershell_cmdlets_reference

此外,此PowerShell CMDlets作弊表将很有用:

您可以在下面查看PowerShell命令雅典卫城任务管理(上面的屏幕截图中的第二列)要创建一个新的VM,请在等等上供电

Learn more about our cookies.<\/a>","cookiepolicy.button":"Accept cookies","cookiepolicy.button.deny":"Deny all","cookiepolicy.link":"Cookie settings","cookiepolicy.modal.title":"Cookie settings","cookiepolicy.modal.content":"We use 3 different kinds of cookies. You can choose which cookies you want to accept. We need basic cookies to make this site work, therefore these are the minimum you can select. Learn more about our cookies.<\/a>","cookiepolicy.modal.level1":"Basic
Functional","cookiepolicy.modal.level2":"Normal
Functional + analytics","cookiepolicy.modal.level3":"Complete
Functional + analytics + social media + embedded videos"}}}">
Baidu