VM Related Interfaces

Change Virtual Machine NIC State

PUT/zstack/v1/vm-instances/nics/{vmNicUuid}/actions

Headers

Authorization: OAuth the-session-uuid

Body

{
  "changeVmNicState": {
    "state": "disable"
  },
  "systemTags": [],
  "userTags": []
}

In the example above, systemTags and userTags fields can be omitted. They are listed to indicate that the body can contain these two fields.

Curl Example

curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"changeVmNicState":{"state":"disable"}}' \
http://localhost:8080/zstack/v1/vm-instances/nics/17d47a3b35813bb5a90f9643200a0f40/actions

Parameter List

Name

Type

Location

Description

Allowed Values

Starting Version

vmNicUuid

String

url

Virtual Machine NIC UUID

 

4.6.0

state

String

body (contained in the changeVmNicState structure)

Virtual Machine NIC State

  • enable
  • disable

4.6.0

systemTags (Optional)

List

body

System Tag

 

4.6.0

userTags (Optional)

List

body

User Tag

 

4.6.0

API Response

Response Example

{
  "inventory": {
    "uuid": "11d9330dd53b3140a933afff53484a4c",
    "name": "Test-VM",
    "description": "web server VM",
    "zoneUuid": "9959e99dec6032a1b6ddc7557f33db64",
    "clusterUuid": "d1675e2a3a07326989def39ea008fc1d",
    "imageUuid": "2392ef4f86e63aaaa2b5614f6795e262",
    "hostUuid": "b1e0e26f93503ff1a36d1e52d722b9ab",
    "lastHostUuid": "799326ef34543e4d988893b236c846ce",
    "instanceOfferingUuid": "7acf02facef6324b8f5b945d920afd75",
    "rootVolumeUuid": "561bc94863f43272afb18628ff29e137",
    "platform": "Linux",
    "defaultL3NetworkUuid": "f011105734bb39189bb8105fdc081d58",
    "type": "UserVm",
    "hypervisorType": "KVM",
    "memorySize": 8589934592,
    "cpuNum": 1,
    "allocatorStrategy": "LastHostPreferredAllocatorStrategy",
    "createDate": "Nov 14, 2017 10:20:57 PM",
    "lastOpDate": "Nov 14, 2017 10:20:57 PM",
    "state": "Running",
    "vmNics": [
      {
        "uuid": "836ece7a894337b782404822f6c200bd",
        "vmInstanceUuid": "11d9330dd53b3140a933afff53484a4c",
        "usedIpUuid": "52876b0aca4936719b11959c2e53d9dc",
        "l3NetworkUuid": "f011105734bb39189bb8105fdc081d58",
        "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,
        "state": "disable",
        "createDate": "Nov 14, 2017 10:20:57 PM",
        "lastOpDate": "Nov 14, 2017 10:20:57 PM"
      }
    ],
    "allVolumes": [
      {
        "uuid": "561bc94863f43272afb18628ff29e137",
        "name": "Root-Volume-For-VM-11d9330dd53b3140a933afff53484a4c",
        "primaryStorageUuid": "75cfe252d83c3b498f8a6b00d7f03eb6",
        "vmInstanceUuid": "11d9330dd53b3140a933afff53484a4c",
        "diskOfferingUuid": "798091e2b84f30da8652329933d3bada",
        "rootImageUuid": "2392ef4f86e63aaaa2b5614f6795e262",
        "installPath": "/zstack_ps/rootVolumes/acct-36c27e8ff05c4780bf6d2fa65700f22e/vol-561bc94863f43272afb18628ff29e137/561bc94863f43272afb18628ff29e137.qcow2",
        "type": "Root",
        "format": "qcow2",
        "size": 107374182400,
        "actualSize": 21474836480,
        "deviceId": 0,
        "state": "Enabled",
        "status": "Ready",
        "createDate": "Nov 14, 2017 10:20:57 PM",
        "lastOpDate": "Nov 14, 2017 10:20:57 PM"
      }
    ]
  }
}
NameTypeDescriptionStarting Version
successboolean 4.6.0
errorErrorCodeError code. If not null, the operation failed. This field is null when the operation is successful. For details, see error4.6.0
inventoryVmInstanceInventoryFor details, see inventory4.6.0

error

NameTypeDescriptionStarting Version
codeStringError code number, a globally unique identifier for the error, for example SYS.1000, HOST.10014.6.0
descriptionStringBrief description of the error4.6.0
detailsStringDetailed error information4.6.0
elaborationStringReserved field, defaults to null4.6.0
opaqueLinkedHashMapReserved field, defaults to null4.6.0
causeErrorCodeRoot cause. The source error that caused the current error. If there is no original error, this field is null4.6.0

inventory

NameTypeDescriptionStarting Version
uuidStringUUID of the resource, uniquely identifies the resource4.6.0
nameStringResource name4.6.0
descriptionStringDetailed description of the resource4.6.0
zoneUuidStringData Center UUID4.6.0
clusterUuidStringCluster UUID4.6.0
imageUuidStringImage UUID4.6.0
hostUuidStringHost UUID4.6.0
lastHostUuidString 4.6.0
instanceOfferingUuidStringCompute Offering UUID4.6.0
rootVolumeUuidStringRoot Disk UUID4.6.0
platformString 4.6.0
architectureString 4.6.0
defaultL3NetworkUuidString 4.6.0
typeString 4.6.0
hypervisorTypeString 4.6.0
memorySizeLong 4.6.0
cpuNumInteger 4.6.0
cpuSpeedLong 4.6.0
allocatorStrategyString 4.6.0
createDateTimestampCreate time4.6.0
lastOpDateTimestampLast modification time4.6.0
stateString 4.6.0
guestOsTypeString 4.1.2
vmNicsListFor details, see vmNics4.6.0
allVolumesListFor details, see allVolumes4.6.0
vmCdRomsListFor details, see vmCdRoms4.6.0

vmNics

NameTypeDescriptionStarting Version
uuidStringUUID of the resource, uniquely identifies the resource4.6.0
vmInstanceUuidStringVirtual Machine UUID4.6.0
l3NetworkUuidStringDistributed Port Group UUID4.6.0
ipString 4.6.0
macString 4.6.0
hypervisorTypeString 4.6.0
netmaskString 4.6.0
gatewayString 4.6.0
metaDataString 4.6.0
ipVersionInteger 4.6.0
driverTypeString 4.6.0
internalNameString 4.6.0
deviceIdInteger 4.6.0
typeString 4.6.0
stateStringNIC State4.6.0
createDateTimestampCreate time4.6.0
lastOpDateTimestampLast modification time4.6.0
usedIpsListFor details, see usedIps4.6.0

usedIps

NameTypeDescriptionStarting Version
uuidStringUUID of the resource, uniquely identifies the resource4.6.0
ipRangeUuidStringIP Range UUID4.6.0
l3NetworkUuidStringDistributed Port Group UUID4.6.0
ipVersionInteger 4.6.0
ipString 4.6.0
netmaskString 4.6.0
gatewayString 4.6.0
usedForString 4.6.0
ipInLonglong 4.6.0
vmNicUuidStringVirtual Machine NIC UUID4.6.0
createDateTimestampCreate time4.6.0
lastOpDateTimestampLast modification time4.6.0

allVolumes

NameTypeDescriptionStarting Version
uuidStringUUID of the resource, uniquely identifies the resource4.6.0
nameStringResource name4.6.0
descriptionStringDetailed description of the resource4.6.0
primaryStorageUuidStringData Storage UUID4.6.0
vmInstanceUuidStringVirtual Machine UUID4.6.0
diskOfferingUuidStringDisk Offering UUID4.6.0
rootImageUuidString 4.6.0
installPathString 4.6.0
typeString 4.6.0
formatString 4.6.0
sizeLong 4.6.0
actualSizeLong 4.6.0
deviceIdInteger 4.6.0
stateString 4.6.0
statusString 4.6.0
createDateTimestampCreate time4.6.0
lastOpDateTimestampLast modification time4.6.0
isShareableBoolean 4.6.0
volumeQosString 4.6.0
lastDetachDateTimestamp 4.6.0
lastVmInstanceUuidString 4.6.0

vmCdRoms

NameTypeDescriptionStarting Version
uuidStringUUID of the resource, uniquely identifies the resource4.6.0
vmInstanceUuidStringVirtual Machine UUID4.6.0
deviceIdInteger 4.6.0
isoUuidString 4.6.0
isoInstallPathString 4.6.0
nameStringResource name4.6.0
descriptionStringDetailed description of the resource4.6.0
createDateTimestampCreate time4.6.0
lastOpDateTimestampLast modification time4.6.0

SDK Examples

Java SDK

ChangeVmNicStateAction action = new ChangeVmNicStateAction();
action.vmNicUuid = "17d47a3b35813bb5a90f9643200a0f40";
action.state = "disable";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
ChangeVmNicStateAction.Result res = action.call();

Python SDK

action = ChangeVmNicStateAction()
action.vmNicUuid = "17d47a3b35813bb5a90f9643200a0f40"
action.state = "disable"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()