Setting Port Range On Your Agent

When using Service Virtualization or the proxy recorder on a Private Location, sometimes limiting the port range that is open to the virtual service or proxy recorder is necessary. Every virtual service uses its own port, so consider that defining a port range limits the number of virtual services that you can create and run on a particular agent.

Static Endpoints for Service Virtualization

This behavior only applies to transaction based virtual services on Docker-based agents.

If a transactional virtual service is stopped and re-deployed on a Docker Private Location, the same port number will be reused when possible. If the port is not available and taken by another process on the Agent host, the virtual service finds a new port from the allowed port range of the Agent and uses that. In this case, the notification message indicates that the end point has changed.

endpoint-port-change-message.png

Set a Custom Port Range

The following API lets you to limit the range of ports available on a specific agent:

URL

https://a.blazemeter.com/api/v4/private-locations/<LOCATION_ID>/ships/<AGENT_ID>

Request Parameters

Parameter Description
API Key Identifies the user (--user 'id:secret' ). How to get the API Key?
Patch Body "portRange" is the only parameter needed.
LOCATION_ID The ID of the Private Location.How to get I get the Harbor ID?
AGENT_ID The ID of the agent within the Private Location. How to get the Ship ID?

cURL

curl -X PATCH https://a.blazemeter.com/api/v4/private-locations/<LOCATION_ID>/ships/<AGENT_ID> -H "Content-Type: application/json" --user 'id:secret' -d '{"portRange":"2000-2500"}'

Example PATCH Body

{
	"portRange":"2000-2500"
}

Example Response

{
    "api_version": 4,
    "error": null,
    "result": {
        "id": "5abe9cde63cb0e3e0a7b24ca",
        "name": "My OPL",
        "address": "1.1.1.1",
        "publicIpAddress": "2.2.2.2",
        "state": "idle",
        "lastHeartBeat": 1534529255,
        "lastCommandOutput": "",
        "isLocked": false,
        "hostInfo": {
            "containerManager": {
                "type": "DockerManager",
                "info": {
                    "operatingSystem": "Ubuntu 16.04.4 LTS",
                    "operatingSystemType": "linux",
                    "memory": 8370008064,
                    "cpus": 2,
                    "dockerRootDir": "/var/lib/docker",
                    "dockerVersion": "18.03.0-ce",
                    "images": [
                        {
                            "Created": 1533577200,
                            "Labels": null,
                            "VirtualSize": 3875773553,
                            "SharedSize": -1,
                            "ParentId": "",
                            "Size": 3875773553,
                            "RepoDigests": null,
                            "Id": "sha256:777390077be6370e1ac1d5426a6f208a8f7244357a3439ca758e20341309e081",
                            "Containers": -1,
                            "RepoTags": [
                                "taurus-cloud:1.0.12-413",
                                "taurus-cloud:latest"
                            ]
                        },
                        {
                            "Created": 1532378534,
                            "Labels": null,
                            "VirtualSize": 1126812353,
                            "SharedSize": -1,
                            "ParentId": "",
                            "Size": 1126812353,
                            "RepoDigests": null,
                            "Id": "sha256:2b188b359b0aedcc33c2f4ded7e85934ca86db97a21b50ce9a66cd65f9db52ea",
                            "Containers": -1,
                            "RepoTags": [
                                "blazemeter/proxy-recorder:1.3.3-345",
                                "blazemeter/proxy-recorder:latest"
                            ]
                        },
                        {
                            "Created": 1530052739,
                            "Labels": null,
                            "VirtualSize": 256493329,
                            "SharedSize": -1,
                            "ParentId": "",
                            "Size": 256493329,
                            "RepoDigests": null,
                            "Id": "sha256:ca5cc016dcf11c4b702eb3780d199b5bd27ce42178b65be0aeb36c9a8036e560",
                            "Containers": -1,
                            "RepoTags": [
                                "blazemeter/crane:2.0.10-307",
                                "blazemeter/crane:latest"
                            ]
                        },
                        {
                            "Created": 1526891640,
                            "Labels": null,
                            "VirtualSize": 282881488,
                            "SharedSize": -1,
                            "ParentId": "",
                            "Size": 282881488,
                            "RepoDigests": null,
                            "Id": "sha256:8f5ec4edbf9f891d68031a4456fed401179ef68b907ae3cf52f5f7664d1fd499",
                            "Containers": -1,
                            "RepoTags": [
                                "apm-image:1.1.0-154",
                                "apm-image:latest"
                            ]
                        },
                        {
                            "Created": 1522443674,
                            "Labels": null,
                            "VirtualSize": 98099521,
                            "SharedSize": -1,
                            "ParentId": "",
                            "Size": 98099521,
                            "RepoDigests": null,
                            "Id": "sha256:df3cce743a98d60e3ebab387a374829abe72cb0f5f766eb1fab03c16988fbd8f",
                            "Containers": -1,
                            "RepoTags": [
                                "blazemeter-quicktest:1.0.2",
                                "blazemeter-quicktest:latest"
                            ]
                        },
                        {
                            "Created": 1522443581,
                            "Labels": null,
                            "VirtualSize": 5457394747,
                            "SharedSize": -1,
                            "ParentId": "",
                            "Size": 5457394747,
                            "RepoDigests": null,
                            "Id": "sha256:74bfdc5600d05aeb99717755c24411509bd081cbc188de8354ec583fe45a98be",
                            "Containers": -1,
                            "RepoTags": [
                                "blazemeter:1.0.16",
                                "blazemeter:latest"
                            ]
                        }
                    ]
                }
            },
            "diskSpace": {
                "/var/lib/docker": {
                    "present": false
                },
                "/home/blazemeter": {
                    "present": false
                },
                "/tmp": {
                    "freeSpace": 26885898240,
                    "present": true
                }
            }
        },
        "isAutoUpdate": true,
        "uptime": 607952,
        "portRange": "2000-2500",
        "created": 0,
        "updated": 1534794529,
        "updaterStatus": {
            "status": "success",
            "lastUpdateCheck": 1534529254,
            "nextUpdateCheck": 1534532854
        },
        "ts": 1534529255
    }
}