How to connect to VM in its region thru API

Hello,

We use MIQ multiregion setup. When accessing VM from global region I see “Connect to VM in its Region” button. How can I get the link to VM’s home region thru API?

UPD: alternatively is it possible to get href for service catalog on its region?

WBR,
Viacheslav Medvedev

@pemcg @agrare please help. How can I get VM home region through API?

This will get you the VM’s region number:

/api/vms?filter[]=name=test-rhel8&attributes=name,region_number&expand=resources

{
    "name": "vms",
    "count": 182,
    "subcount": 1,
    "subquery_count": 1,
    "pages": 1,
    "resources": [
        {
            "href": "https://x.x.x.x/api/vms/64",
            "name": "test-rhel8",
            "id": "64",
            "region_number": 0
        }
    ],
...

You can then follow this up to get more details on the region if you need:

/api/regions?filter[]=region=0&expand=resources

To find MIQ servers in that region, use something like:

api/servers?filter[]=region_number=0&expand=resources

Hope this helps,
pemcg

1 Like

Thank you! It works.