API reconfigures VM's Networks
- Tran Dai Quan
- Tran Khanh Ngoc
Overview
In this manual, you will find detailed information on how to prepare information, get VM’s network information, and reconfigure VM’s networks.
Procedure
Step 1: Prepare Information
Login IAM portal -> vCD portal: collect the information
{{vcd_url}}
{{vm-uuid}}: select VM -> take a look vm uuid on url
{{network_name}}: Select Networking -> Networks -> Copy the Network name
{{Bearer Token}}: Please follow the “API token login” document
Step 2: Get VM’s network information
GET https://{{vcd_url}}/api/vApp/{{vm-uuid}}/virtualHardwareSection/networkCards
Authorization: {{Bearer Token}}
Headers:
- ‘Accept’: */*;version=37.2
- ‘Content-type’: application/vnd.vmware.vcloud.rasdItem+xml
SEND request.
Copy Response Body
Step 3: Reconfig VM’s networks
PUT https//{{vcd_url}}/api/vApp/{{vm-uuid}}/virtualHardwareSection/networkCards
Authorization: {{Bearer Token }}
Headers:
- 'Accept’: */*;version=37.2
- ‘Content-type’: application/vnd.vmware.vcloud.rasdItemsList+xml; charset=ISO-8859-1
Body: {{select raw -> copy and paste response body from Get VM’s networks information }}
Ex:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<RasdItemsList xmlns="http://www.vmware.com/vcloud/v1.5" xmlns:vmext="http://www.vmware.com/vcloud/extension/v1.5" xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1" xmlns:vssd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData"
…………………………………..
………………………………….
<Link rel="edit" href="https://iaas-hcmc02.higiocloud.vn/api/vApp/vm-6cc0d2ef-6823-421a-bed5-8bb0f92a7bca/virtualHardwareSection/networkCards" type="application/vnd.vmware.vcloud.rasdItemsList+json"/>
<Item>
<rasd:Address>00:50:56:02:10:2c</rasd:Address>
<rasd:AddressOnParent>0</rasd:AddressOnParent>
<rasd:AllocationUnits xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
<rasd:AutomaticAllocation>true</rasd:AutomaticAllocation>
<rasd:AutomaticDeallocation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
<rasd:ConfigurationName xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
<rasd:Connection xmlns:ns10="http://www.vmware.com/vcloud/v1.5" ns10:ipAddressingMode="Manual" ns10:ipAddress="10.10.11.20" ns10:primaryNetworkConnection="true">10.10.11.0/24</rasd:Connection>
<rasd:ConsumerVisibility xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
…………………………………………………………………….
<rasd:ResourceSubType>VMXNET3</rasd:ResourceSubType>
<rasd:ResourceType>10</rasd:ResourceType>
<rasd:VirtualQuantity xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
<rasd:Weight xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
</Item>
</RasdItemsList>
=====================================================================
Find word :
ns10:ipAddressingMode and edit the value in “ ” (network mode: “DHCP”, “Pool”, “Manual”)
+ DHCP: Please setup DHCP pool on your network -> The P Management
+ Pool: Please setup Static IP pools on yoursetork -> IP Management
ns10:ipAddress and edit the value in “” (“VM ipv4 address”) – no need if using DHCP or Pool
ns10:primaryNetworkConnection and edit the value in “” (paste network name {{netwok_name}} )
SEND request.
Step 4: Verify
Get VM’s network information.
GET https://{{vcd_url}}/api/vApp/{{vm-uuid}}/virtualHardwareSection/networkCards
Check on the vCD portal
Login IAM -> vCD portal-> select VM-> NICs