AttachVmNicToVm
API Request
URLs
POST zstack/v1/vm-instances/{vmInstanceUuid}/nices/{vmNicUuid}Headers
Authorization: OAuth the-session-uuidBody
Note: In
the preceding sample, both systemTags and userTags are optional.
These two fields can be included in the body structure.
{
"params": {},
"systemTags": [],
"userTags": []
}
Note: In
the preceding sample, both systemTags and userTags are optional.
These two fields can be included in the body structure.Curl Sample
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{}}' http://localhost:8080/zstack/v1/vm-instances/4fea63520ff63f5f9856acd619add4f5/nices/8b22e01e4bf43b1dab1530d2b362bbc5Request Parameters
| Name | Type | Location | Description | Valid Value | Starting Version |
|---|---|---|---|---|---|
| vmNicUuid | String | url | The NIC UUID. | 4.0.0 | |
| vmInstanceUuid | List | url | The VM UUID. | 4.0.0 | |
| systemTags | List | body | Optional. The system tags。 | 4.0.0 | |
| userTags | List | body | Optional. The user tags. | 4.0.0 |
API Response
Sample Response
{
"inventory": {
"uuid": "afbd67886d773a45af9a20071bcb09bb",
"name": "Test-VM",
"description": "web server VM",
"zoneUuid": "4b9ddab3f5f738f1a0161f5cf5f33f5c",
"clusterUuid": "d7061d85666a380cb3dda4cc7f9f16ee",
"imageUuid": "179a3412da4a32faa927eae552348907",
"hostUuid": "6ee062370eee3df58623fa99be0b2ce0",
"lastHostUuid": "09fdbebbaea73df79b744ad0d4bd7088",
"instanceOfferingUuid": "6dc0db981e68348e89ac79ed18fa4b24",
"rootVolumeUuid": "a876397202ac3d1daf9f4ea67e75e13d",
"platform": "Linux",
"defaultL3NetworkUuid": "3baaf68d632f3e9aa12be139d58d968e",
"type": "UserVm",
"hypervisorType": "KVM",
"memorySize": 8.589934592E9,
"cpuNum": 1.0,
"allocatorStrategy": "LastHostPreferredAllocatorStrategy",
"createDate": "Nov 14, 2017 10:20:57 PM",
"lastOpDate": "Nov 14, 2017 10:20:57 PM",
"state": "Running",
"vmNics": [
{
"uuid": "b9415d324b50301e923a990bf65352d0",
"vmInstanceUuid": "afbd67886d773a45af9a20071bcb09bb",
"usedIpUuid": "76a49549cb183d35865276187afb482b",
"l3NetworkUuid": "3baaf68d632f3e9aa12be139d58d968e",
"ip": "192.168.1.10",
"mac": "00:0c:29:bd:99:fc",
"hypervisorType": "KVM",
"netmask": "255.255.255.0",
"gateway": "192.168.1.1",
"deviceId": 0.0,
"createDate": "Nov 14, 2017 10:20:57 PM",
"lastOpDate": "Nov 14, 2017 10:20:57 PM"
}
],
"allVolumes": [
{
"uuid": "a876397202ac3d1daf9f4ea67e75e13d",
"name": "Root-Volume-For-VM-afbd67886d773a45af9a20071bcb09bb",
"primaryStorageUuid": "336625bac9e0326b9a9abc7801ef2c86",
"vmInstanceUuid": "afbd67886d773a45af9a20071bcb09bb",
"diskOfferingUuid": "475f8e09aae2389ea6945b46601aa683",
"rootImageUuid": "179a3412da4a32faa927eae552348907",
"installPath": "/Cloud_ps/rootVolumes/acct-36c27e8ff05c4780bf6d2fa65700f22e/vol-a876397202ac3d1daf9f4ea67e75e13d/a876397202ac3d1daf9f4ea67e75e13d.qcow2",
"type": "Root",
"format": "qcow2",
"size": 1.073741824E11,
"actualSize": 2.147483648E10,
"deviceId": 0.0,
"state": "Enabled",
"status": "Ready",
"createDate": "Nov 14, 2017 10:20:57 PM",
"lastOpDate": "Nov 14, 2017 10:20:57 PM"
}
]
}
}| Name | Type | Description | Starting Version |
|---|---|---|---|
| error | ErrorCode | The error code. If not null, the operation fails, or vice versa. For more information, see error | 4.0.0 |
| inventory | VmInstanceInventory | See inventory | 4.0.0 |
#error
| Name | Type | Description | Starting Version |
|---|---|---|---|
| code | String | The error code, which is a numbered or alphanumeric code that specifies an error. For example, SYS.1000, HOST.1001. | 4.0.0 |
| description | String | The brief description of the error. | 4.0.0 |
| details | String | The details about the error. | 4.0.0 |
| elaboration | String | The reserved field. Default value: null. | 4.0.0 |
| opaque | LinkedHashMap | The reserved field. Default value: null. | 4.0.0 |
| cause | ErrorCode | The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. | 4.0.0 |
#inventory
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The VM UUID. | 4.0.0 |
| name | String | The VM name. | 4.0.0 |
| description | String | The detailed description of the VM. | 4.0.0 |
| zoneUuid | String | The zone UUID. | 4.0.0 |
| clusterUuid | String | The cluster UUID. | 4.0.0 |
| imageUuid | String | The image UUID. | 4.0.0 |
| hostUuid | String | The host UUID. | 4.0.0 |
| lastHostUuid | String | The UUID of the host on which the VM instance was running last time. | 4.0.0 |
| instanceOfferingUuid | String | The instance offering UUID. | 4.0.0 |
| rootVolumeUuid | String | The root volume UUID. | 4.0.0 |
| platform | String | The platform on which the VM instance is running. | 4.0.0 |
| defaultL3NetworkUuid | String | The UUID of the default L3 network. | 4.0.0 |
| type | String | The VM instance type. | 4.0.0 |
| hypervisorType | String | The hypervisor type of the VM instance. | 4.0.0 |
| memorySize | Long | The memory size. | 4.0.0 |
| cpuNum | Integer | The number of CPU cores of the VM instance. | 4.0.0 |
| cpuSpeed | Long | The CPU speed. | 4.0.0 |
| allocatorStrategy | String | The allocator strategy. | 4.0.0 |
| createDate | Timestamp | The time when the VM instance was created. | 4.0.0 |
| lastOpDate | Timestamp | The time when the VM instance was last modified. | 4.0.0 |
| state | String | The state of the VM instance. | 4.0.0 |
| vmNics | List | See vmNics. | 4.0.0 |
| allVolumes | List | See allVolumes. | 4.0.0 |
#vmNics
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The UUID of the NIC. | 4.0.0 |
| vmInstanceUuid | String | The VM UUID. | 4.0.0 |
| l3NetworkUuid | String | The L3 network UUID. | 4.0.0 |
| ip | String | The IP address of the NIC. | 4.0.0 |
| mac | String | The MAC address of the NIC. | 4.0.0 |
| hypervisorType | String | The virtualization type. | 4.0.0 |
| netmask | String | The netmask of the NIC. | 4.0.0 |
| gateway | String | The gateway IP address. | 4.0.0 |
| metaData | String | 4.0.0 | |
| ipVersion | Integer | The version of the IP address. | 4.0.0 |
| deviceId | Integer | The device ID. | 4.0.0 |
| type | String | The NIC type. | 4.0.0 |
| createDate | Timestamp | The time when the NIC was added. | 4.0.0 |
| lastOpDate | Timestamp | The time when the NIC was last modified. | 4.0.0 |
| usedIps | List | See usedIps | 4.0.0 |
#usedIps
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The IP address UUID. | 4.0.0 |
| ipRangeUuid | String | The IP range UUID. | 4.0.0 |
| l3NetworkUuid | String | The L3 network UUID. | 4.0.0 |
| ipVersion | Integer | The IP version. | 4.0.0 |
| ip | String | The IP address. | 4.0.0 |
| netmask | String | The netmask. | 4.0.0 |
| gateway | String | The gateway. | 4.0.0 |
| usedFor | String | 4.0.0 | |
| ipInLong | long | 4.0.0 | |
| vmNicUuid | String | The VM NIC UUID. | 4.0.0 |
| createDate | Timestamp | The time when the IP address was used. | 4.0.0 |
| lastOpDate | Timestamp | The time when the IP address was last modified. | 4.0.0 |
#allVolumes
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The volume UUID. | 4.0.0 |
| name | String | The volume name. | 4.0.0 |
| description | String | The detailed description of the volume. | 4.0.0 |
| primaryStorageUuid | String | The primary storage UUID. | 4.0.0 |
| vmInstanceUuid | String | The bare metal instance UUID. | 4.0.0 |
| diskOfferingUuid | String | The volume offering UUID. | 4.0.0 |
| rootImageUuid | String | The root image UUID. | 4.0.0 |
| installPath | String | The installation path of the volume in the primary storage. | 4.0.0 |
| type | String | The type of the volume. | 4.0.0 |
| format | String | The format of the volume. | 4.0.0 |
| size | Long | The size of the volume. | 4.0.0 |
| actualSize | Long | The actual storage space that the volume takes up. | 4.0.0 |
| deviceId | Integer | 4.0.0 | |
| state | String | The state of the volume. | 4.0.0 |
| status | String | The status of the volume. | 4.0.0 |
| createDate | Timestamp | The time when the volume was created. | 4.0.0 |
| lastOpDate | Timestamp | The time when the volume was last modified. | 4.0.0 |
| isShareable | Boolean | Indicates whether the volume is shareable. | 4.0.0 |
| volumeQos | String | The QoS of the volume, for example, 1048576. | 4.0.0 |
SDK Sample
Java
SDK
AttachVmNicToVmAction action = new AttachVmNicToVmAction();
action.vmNicUuid = "8b22e01e4bf43b1dab1530d2b362bbc5";
action.vmInstanceUuid = "4fea63520ff63f5f9856acd619add4f5";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
AttachVmNicToVmAction.Result res = action.call();Python
SDK
AttachVmNicToVmAction action = AttachVmNicToVmAction()
action.vmNicUuid = "8b22e01e4bf43b1dab1530d2b362bbc5"
action.vmInstanceUuid = "4fea63520ff63f5f9856acd619add4f5"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
AttachVmNicToVmAction.Result res = action.call()