AttachL3NetworkToVm
API Request
URLs
POST zstack/v1/vm-instances/{vmInstanceUuid}/l3-networks/{l3NetworkUuid}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.
{
"attachL3NetworkToVm": {
"driverType": "E1000"
},
"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/f526e22f739838f4bcdfdd20f0ba8a73/l3-networks/00fab8159d1d3534802c588c2bd9a28bRequest Parameters
Note:
| Name | Type | Location | Description | Valid Value | Starting Version |
|---|---|---|---|---|---|
| vmInstanceUuid | String | url | The VM instance UUID. | 0.6 | |
| l3NetworkUuid | String | url | The L3 network UUID. | 0.6 | |
| staticIp | String | body (contained in the params structure) | Optional. Specifies the IP address to be allocated to the VM instance. | 0.6 | |
| driverType | String | body | The NIC driver type. | The NIC driver type. Valid values:
|
4.0.0 |
| systemTags | List | body | Optional. The system tags. | 0.6 | |
| userTags | List | body | Optional. The user tags. | 0.6 |
Note:
- When you attach an L3 network to a VM instance in ZStack Cloud, you can enable SR-IOV by adding the
enableSRIOV option to SystemTags.
- Format of the enableSRIOV option:
enableSRIOV::{L3_NETWORK_UUID} - Example:
enableSRIOV::9e19dafe81c64fed8e34f72e27582339
- Format of the enableSRIOV option:
- When you create a VM instance in ZStack Cloud,
you can specify an IP address for the L3 network by adding the
staticIp option to SystemTags. If the network address
type is double stack (IPv4+IPv6), you can add two staticIp
options, which are IPv4 and IPv6, respectively.
- Format of the staticIp option:
staticIp::L3 network UUID::specified IP - Example:
staticIp::81a21a81cde84c1084c191354053a3b5::172.20.196.0
- Format of the staticIp option:
API Response
Sample
Response
{
"inventory": {
"uuid": "e300c6dbbaa1326ebca205a7b2a0e7ea",
"name": "Test-VM",
"description": "web server VM",
"zoneUuid": "c9b73cde21d23866802e8a5178f29f0d",
"clusterUuid": "24a72428e400344b88f8c2faa4c292bd",
"imageUuid": "5484ed82cdfc366c9657c695577bee37",
"hostUuid": "5eb00f0897603309904b418c821b1acb",
"lastHostUuid": "b2cfad47a7923346a735008c32ef0d0b",
"instanceOfferingUuid": "bbea469feb78345591cc9ac6c0ce0c5c",
"rootVolumeUuid": "fc8a81afd11136ac8a48cf458ac2945b",
"platform": "Linux",
"defaultL3NetworkUuid": "aa3e9117d9793eff81a614b0e18bade7",
"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": "458704a1654637209667e69847ee3a97",
"vmInstanceUuid": "e300c6dbbaa1326ebca205a7b2a0e7ea",
"usedIpUuid": "b6edb8e1ccc533b98cb9cc1c14baf38b",
"l3NetworkUuid": "aa3e9117d9793eff81a614b0e18bade7",
"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": "fc8a81afd11136ac8a48cf458ac2945b",
"name": "Root-Volume-For-VM-e300c6dbbaa1326ebca205a7b2a0e7ea",
"primaryStorageUuid": "91dc7f8732243262933100a509ab808a",
"vmInstanceUuid": "e300c6dbbaa1326ebca205a7b2a0e7ea",
"diskOfferingUuid": "26483e8eca413d809f4f8c6afba75ae2",
"rootImageUuid": "5484ed82cdfc366c9657c695577bee37",
"installPath": "/Cloud_ps/rootVolumes/acct-36c27e8ff05c4780bf6d2fa65700f22e/vol-fc8a81afd11136ac8a48cf458ac2945b/fc8a81afd11136ac8a48cf458ac2945b.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. | 0.6 |
| inventory | VmInstanceInventory | See inventory. | 0.6 |
#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. | 0.6 |
| description | String | The brief description of the error. | 0.6 |
| details | String | The details about the error. | 0.6 |
| elaboration | String | The reserved field. Default value: null. | 0.6 |
| opaque | LinkedHashMap | The reserved field. Default value: null. | 0.6 |
| cause | ErrorCode | The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. | 0.6 |
#inventory
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The resource UUID. | 0.6 |
| name | String | The resource name. | 0.6 |
| description | String | The detailed description of the resource. | 0.6 |
| zoneUuid | String | The zone UUID. | 0.6 |
| clusterUuid | String | The cluster UUID. | 0.6 |
| imageUuid | String | The image UUID. | 0.6 |
| hostUuid | String | The host UUID. | 0.6 |
| lastHostUuid | String | 0.6 | |
| instanceOfferingUuid | String | The instance offering UUID. | 0.6 |
| rootVolumeUuid | String | The root volume UUID. | 0.6 |
| platform | String | 0.6 | |
| defaultL3NetworkUuid | String | 0.6 | |
| type | String | 0.6 | |
| hypervisorType | String | 0.6 | |
| memorySize | Long | 0.6 | |
| cpuNum | Integer | 0.6 | |
| cpuSpeed | Long | 0.6 | |
| allocatorStrategy | String | 0.6 | |
| createDate | Timestamp | The creation date. | 0.6 |
| lastOpDate | Timestamp | The last operation date. | 0.6 |
| state | String | 0.6 | |
| vmNics | List | See vmNics. | 0.6 |
| allVolumes | List | See allVolumes. | 0.6 |
#vmNics
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The resource UUID. | 0.6 |
| vmInstanceUuid | String | The VM instance UUID. | 0.6 |
| l3NetworkUuid | String | The L3 network UUID. | 0.6 |
| ip | String | 0.6 | |
| mac | String | 0.6 | |
| netmask | String | 0.6 | |
| gateway | String | 0.6 | |
| metaData | String | 0.6 | |
| ipVersion | Integer | The IP version. | 3.1.0 |
| deviceId | Integer | 0.6 | |
| createDate | Timestamp | The creation date. | 0.6 |
| lastOpDate | Timestamp | The last operation date. | 0.6 |
| usedIps | List | See usedIps. | 0.6 |
#usedIps
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The resource UUID. | 0.6 |
| ipRangeUuid | String | The IP range UUID. | 0.6 |
| l3NetworkUuid | String | The L3 network UUID. | 0.6 |
| ipVersion | Integer | The IP version. | 3.1.0 |
| ip | String | The IP address. | 0.6 |
| netmask | String | The netmask. | 0.6 |
| gateway | String | The gateway. | 0.6 |
| usedFor | String | 0.6 | |
| ipInLong | long | 0.6 | |
| vmNicUuid | String | The VM NIC UUID. | 3.1.0 |
| createDate | Timestamp | The creation date. | 0.6 |
| lastOpDate | Timestamp | The last operation date. | 0.6 |
#allVolumes
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The resource UUID. | 0.6 |
| name | String | The resource name. | 0.6 |
| description | String | The detailed description of the resource. | 0.6 |
| primaryStorageUuid | String | The primary storage UUID. | 0.6 |
| vmInstanceUuid | String | The VM instance UUID. | 0.6 |
| diskOfferingUuid | String | The instance offering UUID. | 0.6 |
| rootImageUuid | String | 0.6 | |
| installPath | String | 0.6 | |
| type | String | 0.6 | |
| format | String | 0.6 | |
| size | Long | 0.6 | |
| actualSize | Long | 0.6 | |
| deviceId | Integer | 0.6 | |
| state | String | 0.6 | |
| status | String | 0.6 | |
| createDate | Timestamp | The creation date. | 0.6 |
| lastOpDate | Timestamp | The last operation date. | 0.6 |
| isShareable | Boolean | 0.6 |
SDK Sample
Java
SDK
AttachL3NetworkToVmAction action = new AttachL3NetworkToVmAction();
action.vmInstanceUuid = "b8755237b07a4c85923ccc96ccc0d897";
action.l3NetworkUuid = "984008169505409dbbf2bbfee9c45ffe";
action.sessionId = "46b2a5b9b4fb44268f5eb186f69c1937";
AttachL3NetworkToVmAction.Result res = action.call();Python
SDK
AttachL3NetworkToVmAction action = AttachL3NetworkToVmAction()
action.vmInstanceUuid = "aed2911fd48a4872858abe8f0bdadecf"
action.l3NetworkUuid = "0664fc2951974e338ec6266c8afcc07c"
action.sessionId = "0443d11232ae465db92eef1dcbc2a5d8"
AttachL3NetworkToVmAction.Result res = action.call()