...
From the link to the NIC in the previous step, get only the networks IPs link
Code Block https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/privatenetworks/53/ips
Use a GET request to obtain the first 3 IP addresses in this network, with the parameter "limit=3".
Code Block curl --verbose 'href":"https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/privatenetworks/53/ips?limit=3' \ -H 'Accept: application/vnd.abiquo.privateips+json; version=5.2' \ -u user:password -k | jq .
Tip To only retrieve IPs that are available for use, you can use the query parameter "free=true".
The response has 3 IP addresses: the gateway and the IP addresses we created specifically for this exercise.
Expand Code Block √ Abiquo % curl --verbose 'https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/privatenetworks/53/ips?limit=3' \ -H 'Accept: application/vnd.abiquo.privateips+json; version=5.2' \ -u user:password -k | jq . > GET /api/cloud/virtualdatacenters/42/privatenetworks/53/ips?limit=3 HTTP/1.1 > Host: linatest.bcn.abiquo.com > Authorization: Basic XXXXXXX > User-Agent: curl/7.64.1 > Accept: application/vnd.abiquo.privateips+json; version=5.2 > < HTTP/1.1 200 200 < Date: Fri, 16 Apr 2021 19:00:47 GMT < Server: Apache < Set-Cookie: ABQSESSIONID=3701578778846185265; Max-Age=1800; Expires=Fri, 16-Apr-2021 19:30:48 GMT; Path=/; Secure; HttpOnly; SameSite=strict < X-Abiquo-TracerContext: aff6905e-3a00-47e5-a640-e70556ab7ffc < X-Abiquo-Token: a2e19816735381c1d074441cbd002aa0b2dfac898841de657740584d88f344f6868d440ef8c65b7687ac23cb388ca40e78f93c9d3156bff79e474f6222358857 < Cache-Control: no-cache, no-store, max-age=0, must-revalidate < Pragma: no-cache < Expires: 0 < Strict-Transport-Security: max-age=31536000 ; includeSubDomains < X-XSS-Protection: 1; mode=block < X-Frame-Options: DENY < X-Content-Type-Options: nosniff < Content-Type: application/vnd.abiquo.privateips+json; version=5.2 < Transfer-Encoding: chunked < { "totalSize": 10, "links": [ { "rel": "first", "href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/privatenetworks/53/ips?limit=3&by=ip&asc=true" }, { "rel": "next", "href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/privatenetworks/53/ips?startwith=3&limit=3&by=ip&asc=true" }, { "rel": "last", "href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/privatenetworks/53/ips?startwith=7&limit=3&by=ip&asc=true" } ], "collection": [ { "id": 324, "ip": "192.168.0.1", "mac": "00:50:56:2B:4D:8D", "name": "0050562B4D8D_host", "networkName": "default_private_network", "ipv6": false, "quarantine": false, "available": true, "links": [ { "title": "default_private_network", "rel": "privatenetwork", "type": "application/vnd.abiquo.vlan+json", "href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/privatenetworks/53" }, { "title": "privateip", "rel": "self", "type": "application/vnd.abiquo.privateip+json", "href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/privatenetworks/53/ips/324" }, { "title": "vdc_ESXI_vCenter", "rel": "virtualdatacenter", "type": "application/vnd.abiquo.virtualdatacenter+json", "href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42" } ] }, { "id": 326, "ip": "192.168.0.2", "mac": "00:50:56:05:FE:8F", "name": "00505605FE8F_host", "networkName": "default_private_network", "ipv6": false, "usedBy": "ABQ_039b03e9-1639-4c46-a915-b53af7ea3445", "quarantine": false, "available": true, "links": [ { "title": "default_private_network", "rel": "privatenetwork", "type": "application/vnd.abiquo.vlan+json", "href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/privatenetworks/53" }, { "title": "privateip", "rel": "self", "type": "application/vnd.abiquo.privateip+json", "href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/privatenetworks/53/ips/326" }, { "title": "vdc_ESXI_vCenter", "rel": "virtualdatacenter", "type": "application/vnd.abiquo.virtualdatacenter+json", "href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42" }, { "title": "vapp_web", "rel": "virtualappliance", "type": "application/vnd.abiquo.virtualappliance+json", "href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/virtualappliances/110" }, { "title": "ABQ_039b03e9-1639-4c46-a915-b53af7ea3445", "rel": "virtualmachine", "type": "application/vnd.abiquo.virtualmachine+json", "href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/virtualappliances/110/virtualmachines/1918" } ] }, { "id": 335, "ip": "192.168.0.3", "mac": "00:50:56:0D:BE:B9", "name": "0050560DBEB9_host", "networkName": "default_private_network", "ipv6": false, "quarantine": false, "available": true, "links": [ { "title": "default_private_network", "rel": "privatenetwork", "type": "application/vnd.abiquo.vlan+json", "href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/privatenetworks/53" }, { "title": "privateip", "rel": "self", "type": "application/vnd.abiquo.privateip+json", "href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/privatenetworks/53/ips/335" }, { "title": "vdc_ESXI_vCenter", "rel": "virtualdatacenter", "type": "application/vnd.abiquo.virtualdatacenter+json", "href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42" } ] } ] }
In the above example, the IP that is being used on a VM has a link to the VM.
...
This is an example of the modified VM object, with the nic0 link at the end of the links section.
...
Code Block |
---|
{
"id": 1920,
"uuid": "6b2d0d93-7f23-4a78-af5f-a9398be58773",
"fqdn": "box.localdomain",
"description": "A virtual machine",
"coresPerSocket": 1,
"idState": 1,
"idType": 0,
"type": "MANAGED",
"highDisponibility": 0,
"monitored": true,
"monitoringLevel": "DEFAULT",
"protected": false,
"variables": {},
"backuppolicies": [],
"lastSynchronize": 1618592955000,
"generateGuestInitialPassword": false,
"natrules": [],
"vdrpEnabled": true,
"vdrpPort": 0,
"password": "xPUOwNxb",
"deallocated": false,
"name": "ABQ_6b2d0d93-7f23-4a78-af5f-a9398be58773",
"label": "yVM_mj_2",
"ram": 48,
"cpu": 1,
"state": "NOT_ALLOCATED",
"creationTimestamp": 1618588107000,
"links": [
{
"title": "Abiquo",
"rel": "enterprise",
"type": "application/vnd.abiquo.enterprise+json",
"href": "https://linatest.bcn.abiquo.com:443/api/admin/enterprises/1"
},
{
"title": "ABQ_6b2d0d93-7f23-4a78-af5f-a9398be58773",
"rel": "edit",
"type": "application/vnd.abiquo.virtualmachine+json",
"href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/virtualappliances/110/virtualmachines/1920"
},
{
"rel": "asynctasks",
"type": "application/vnd.abiquo.asynctasks+json",
"href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/virtualappliances/110/virtualmachines/1920/asynctasks"
},
{
"title": "send mail",
"rel": "sendmail",
"type": "application/vnd.abiquo.mail+json",
"href": "https://linatest.bcn.abiquo.com:443/api/admin/publiccloudregions/7/enterprises/1/virtualmachines/1920/action/sendmail"
},
{
"title": "cloudadmin",
"rel": "user",
"type": "application/vnd.abiquo.user+json",
"href": "https://linatest.bcn.abiquo.com:443/api/admin/enterprises/1/users/10"
},
{
"title": "vdc_ESXI_vCenter",
"rel": "virtualdatacenter",
"type": "application/vnd.abiquo.virtualdatacenter+json",
"href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42"
},
{
"title": "vapp_web",
"rel": "virtualappliance",
"type": "application/vnd.abiquo.virtualappliance+json",
"href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/virtualappliances/110"
},
{
"title": "metadata",
"rel": "metadata",
"type": "application/vnd.abiquo.metadata+json",
"href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/virtualappliances/110/virtualmachines/1920/metadata"
},
{
"title": "vlan network configurations",
"rel": "configurations",
"type": "application/vnd.abiquo.virtualmachinenetworkconfigurations+json",
"href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/virtualappliances/110/virtualmachines/1920/network/configurations"
},
{
"title": "nics",
"rel": "nics",
"type": "application/vnd.abiquo.nics+json",
"href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/virtualappliances/110/virtualmachines/1920/network/nics"
},
{
"title": "disks",
"rel": "harddisks",
"type": "application/vnd.abiquo.harddisks+json",
"href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/virtualappliances/110/virtualmachines/1920/storage/disks"
},
{
"title": "NOT_ALLOCATED",
"rel": "state",
"type": "application/vnd.abiquo.virtualmachinestate+json",
"href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/virtualappliances/110/virtualmachines/1920/state"
},
{
"title": "virtual machine undeploy",
"rel": "undeploy",
"type": "application/vnd.abiquo.acceptedrequest+json",
"href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/virtualappliances/110/virtualmachines/1920/action/undeploy"
},
{
"title": "virtual machine deploy",
"rel": "deploy",
"type": "application/vnd.abiquo.acceptedrequest+json",
"href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/virtualappliances/110/virtualmachines/1920/action/deploy"
},
{
"title": "virtual machine reset",
"rel": "reset",
"type": "application/vnd.abiquo.acceptedrequest+json",
"href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/virtualappliances/110/virtualmachines/1920/action/reset"
},
{
"title": "virtual machine snapshot",
"rel": "instance",
"type": "application/vnd.abiquo.acceptedrequest+json",
"href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/virtualappliances/110/virtualmachines/1920/action/instance"
},
{
"title": "remote access",
"rel": "rdpaccess",
"type": "application/vnd.abiquo.virtualmachineconsole+json",
"href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/virtualappliances/110/virtualmachines/1920/config/rdpaccess"
},
{
"title": "tasks",
"rel": "tasks",
"type": "application/vnd.abiquo.tasks+json",
"href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/virtualappliances/110/virtualmachines/1920/tasks"
},
{
"title": "firewalls",
"rel": "firewalls",
"type": "application/vnd.abiquo.links+json",
"href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/virtualappliances/110/virtualmachines/1920/firewalls"
},
{
"title": "load balancers",
"rel": "loadbalancers",
"type": "application/vnd.abiquo.loadbalancers+json",
"href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/virtualappliances/110/virtualmachines/1920/loadbalancers"
},
{
"title": "request on demand backup",
"rel": "requestbackup",
"type": "application/vnd.abiquo.ondemandbackup+json",
"href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/virtualappliances/110/virtualmachines/1920/backup/action/request"
},
{
"title": "request a restore of a backup",
"rel": "requestrestore",
"type": "application/vnd.abiquo.restore+json",
"href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/virtualappliances/110/virtualmachines/1920/backup/action/restore"
},
{
"title": "move VM to a virtual appliance",
"rel": "vappmove",
"type": "application/vnd.abiquo.links+json",
"href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/virtualappliances/110/virtualmachines/1920/action/vappmove"
},
{
"title": "move VM to another virtual datacenter",
"rel": "move",
"type": "application/vnd.abiquo.movevm+json",
"href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/virtualappliances/110/virtualmachines/1920/action/move"
},
{
"title": "volumes",
"rel": "volumes",
"type": "application/vnd.abiquo.volumes+json",
"href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/virtualappliances/110/virtualmachines/1920/storage/volumes"
},
{
"diskAllocation": "THIN",
"diskControllerType": "IDE",
"diskLabel": "Hard disk 1",
"length": "64",
"title": "4166504b-d350-439e-adcb-1bc2b57814e0",
"rel": "disk0",
"type": "application/vnd.abiquo.harddisk+json",
"href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/disks/1896"
},
{
"title": "dstier_shared",
"rel": "datastoretier0",
"type": "application/vnd.abiquo.datastoretier+json",
"href": "https://linatest.bcn.abiquo.com:443/api/cloud/locations/7/datastoretiers/9"
},
{
"title": "protect",
"rel": "protect",
"type": "text/plain",
"href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/virtualappliances/110/virtualmachines/1920/action/protect"
},
{
"title": "unprotect",
"rel": "unprotect",
"type": "text/plain",
"href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/virtualappliances/110/virtualmachines/1920/action/unprotect"
},
{
"title": "metricsmetadata",
"rel": "metricsmetadata",
"type": "application/vnd.abiquo.metricsmetadata+json",
"href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/virtualappliances/110/virtualmachines/1920/metrics"
},
{
"title": "disablemonitoring",
"rel": "disablemonitoring",
"type": "",
"href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/virtualappliances/110/virtualmachines/1920/disablemonitoring"
},
{
"title": "collectd",
"rel": "collectd",
"type": "application/json",
"href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/virtualappliances/110/virtualmachines/1920/metrics/collectd"
},
{
"title": "alarmssearch",
"rel": "alarmssearch",
"type": "application/vnd.abiquo.alarms+json",
"href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/virtualappliances/110/virtualmachines/1920/alarms"
},
{
"title": "clone",
"rel": "clone",
"type": "application/vnd.abiquo.virtualmachinecloneoptions+json",
"href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/virtualappliances/110/virtualmachines/1920/action/clone"
},
{
"rel": "tags",
"type": "application/vnd.abiquo.resourcetags+json",
"href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/virtualappliances/110/virtualmachines/1920/tags"
},
{
"rel": "tags-update",
"type": "application/vnd.abiquo.tags+json",
"href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/virtualappliances/110/virtualmachines/1920/tags"
},
{
"rel": "tags-format",
"type": "application/vnd.abiquo.tagformatrestrictions+json",
"href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/virtualappliances/110/virtualmachines/1920/tags"
},
{
"rel": "tags-create",
"type": "application/vnd.abiquo.tags+json",
"href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/virtualappliances/110/virtualmachines/1920/tags/action/create"
},
{
"rel": "tags-delete",
"type": "application/vnd.abiquo.tagkeys+json",
"href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/virtualappliances/110/virtualmachines/1920/tags/action/delete"
},
{
"rel": "tags-edit",
"type": "application/vnd.abiquo.tags+json",
"href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/virtualappliances/110/virtualmachines/1920/tags/action/edit"
},
{
"rel": "tags-sync",
"type": "",
"href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/virtualappliances/110/virtualmachines/1920/tags/action/sync"
},
{
"title": "VMware vCenter",
"rel": "hypervisortype",
"type": "application/vnd.abiquo.hypervisortype+json",
"href": "https://linatest.bcn.abiquo.com:443/api/config/hypervisortypes/VMX_04"
},
{
"title": "yVM_mj",
"rel": "virtualmachinetemplate",
"type": "application/vnd.abiquo.virtualmachinetemplate+json",
"href": "https://linatest.bcn.abiquo.com:443/api/admin/enterprises/1/datacenterrepositories/7/virtualmachinetemplates/520"
},
{
"title": "Others",
"rel": "category",
"type": "application/vnd.abiquo.category+json",
"href": "https://linatest.bcn.abiquo.com:443/api/config/categories/1"
},
{
"title": "privateip",
"rel": "nic0",
"type": "application/vnd.abiquo.privateip+json",
"href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/privatenetworks/53/ips/335"
}
],
"usageStatistics": []
} |
...
Update the VM to add the NIC
...
The example request is given here.
...
Code Block |
---|
√ Abiquo % curl --verbose -X PUT 'https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/virtualappliances/110/virtualmachines/1920' \
-H 'Content-Type: application/vnd.abiquo.virtualmachine+json; version=5.2' \
-H 'Accept: application/vnd.abiquo.acceptedrequest+json; version=5.2' \
-u user:password \
-d @VMwithNIC.json -k
> PUT /api/cloud/virtualdatacenters/42/virtualappliances/110/virtualmachines/1920 HTTP/1.1
> Host: linatest.bcn.abiquo.com
> Authorization: Basic XXXXXX
> User-Agent: curl/7.64.1
> Content-Type: application/vnd.abiquo.virtualmachine+json; version=5.2
> Accept: application/vnd.abiquo.acceptedrequest+json; version=5.2
> Content-Length: 11899
> Expect: 100-continue
>
< HTTP/1.1 100 Continue
< HTTP/1.1 204 204
< Date: Fri, 16 Apr 2021 19:19:17 GMT
< Server: Apache
< Set-Cookie: ABQSESSIONID=8608303820936303687; Max-Age=1800; Expires=Fri, 16-Apr-2021 19:49:17 GMT; Path=/; Secure; HttpOnly; SameSite=strict
< X-Abiquo-TracerContext: 93272692-df60-4efa-a478-a4fcfd3a859b
< X-Abiquo-Token: a2e19816735381c1d074441cbd002aa06429084b01dc4d254adc14535eae44c5c3f4ad90e8e51aabe5134b3d3b841586306916bfe4fdcb486f331e2501f490c0
< Cache-Control: no-cache, no-store, max-age=0, must-revalidate
< Pragma: no-cache
< Expires: 0
< Strict-Transport-Security: max-age=31536000 ; includeSubDomains
< X-XSS-Protection: 1; mode=block
< X-Frame-Options: DENY
< X-Content-Type-Options: nosniff
<
|
...
Check your VM in the UI
In the UI, when you select the VM, and open the control panel in the Network tab, the NIC should display.
...