Table of Contents |
---|
...
This tutorial continues on from Get Started with the Abiquo API!
Modify an entity through the API
Because the VM entity is a special case, we are going to look at two types of modifications: configuring a VM and changing the state of a VM.
...
To add a NIC to the VM, we are going to first perform the steps using the UI, in order to obtain information about the data object.
Configure the VM to add a NIC through the UI
Now we will add a network interface card (NIC) with an IP address in a private network to the first VM we created.
- If your VM is deployed and it doesn't have network hot-reconfigure, then shut it down
- Open the browser console at the Network tab and record actions
- Edit the VM, go to Network → Private → select network → drag and drop an IP, and save the VM
- Examine the PUT request and look for the link to the NIC and expand it. It It will probably be at the end of the links section.
Tip | ||
---|---|---|
| ||
If your VM is deployed, then it will already have a NIC. To work with a deployed VM, you may need to create another private network, because by default, you may not be able to add two NICs in the same private network. To edit the VM, if the VM doesn't have network hot-reconfigure, then you will need to shut it down first. |
At the top of the Request Payload section, click "view source". Copy the source, format it, and select the link to the NIC and copy it. After formatting, it will look something like this.
Code Block |
---|
{ "title":"privateip", "rel":"nic0", "type":"application/vnd.abiquo.privateip+json", "href":"https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/262/privatenetworks/345/ips/14316" }, |
We will use this type of NIC link in the next step.
Add a NIC to the VM through the API
Now we are going to add a NIC to the second VM. To do this, we need to identify the second private IP that we created for this tutorial.
...
Include Page | ||||
---|---|---|---|---|
|
Delete an entity
To delete an entity, simply perform a DELETE request to the API link. But remember that there may be restrictions on what you can delete. For example, you cannot delete a virtual datacenter that contains virtual appliances. If we delete the VM using the following query, it will be removed from the platform (and if it exists on the hypervisor, it will be destroyed). The NIC we added will be detached and released back into the virtual datacenter.
...