You can add a deployment policy using the CLI tool, REST API or the PPaaS Console as shown below:
Adding a deployment policy via the CLI
Overview
CLI command | add-deployment-policy |
Description | Add a deployment policy definition. |
Command format | add-deployment-policy -p <JSON_FILE_PATH> The path to the JSON file that defines the deployment policy needs to be defined as the |
Parameter definition
Short option | Long option | Description | Required | Example value |
---|---|---|---|---|
-p | --resource-path | Folder path where the JSON file that defines the deployment policy is stored. | Yes | <PRIVATE_PAAS_CARTRIDGES>/wso2am/1.9.0/samples/ |
Example
Add the deployment policy that is defined in the
<PRIVATE_PAAS_CARTRIDGES>/wso2am/1.9.0/samples/deployment-policies/mock/deployment-policy-1.json
file.
add-deployment-policy -p <PRIVATE_PAAS_CARTRIDGES>/wso2am/1.9.0/samples/deployment-policies/mock/deployment-policy-1.json
Sample output
Deployment policy added successfully: [deployment-policy-id] deployment-policy-1
Adding a deployment policy via the REST API
Overview
Description | Add a deployment policy definition. |
Resource Path |
|
HTTP Method | POST |
Request/Response Format |
|
Command format | curl -X POST -H "Content-Type: application/json" -d @'<JSON_PAYLOAD>' -k -v -u <USERNAME>:<PASSWORD> https://<PRIVATE_PAAS_HOST>:<PRIVATE_PAAS_HTTPS_PORT>/api/deploymentPolicies
|
Example
Add the deployment policy that is defined in the <PRIVATE_PAAS_CARTRIDGES>/wso2am/1.9.0/samples/deployment-policies/mock/deployment-policy-1.json
file.
cd <PRIVATE_PAAS_SAMPLES>/common/samples curl -X POST -H "Content-Type: application/json" -d @'deployment-policies/deployment-policy-1.json' -k -v -u admin:admin https://localhost:9443/api/deploymentPolicies
Sample output
> POST /api/deploymentPolicies HTTP/1.1 > Host: localhost:9443 > Authorization: Basic YWRtaW46YWRtaW4= > User-Agent: curl/7.43.0 > Accept: */* > Content-Type: application/json > Content-Length: 432 > < HTTP/1.1 201 Created < Date: Mon, 05 Oct 2015 04:34:35 GMT < Location: https://localhost:9443/api/deploymentPolicies/deployment-policy-1 < Content-Type: application/json < Transfer-Encoding: chunked < Server: WSO2 Carbon Server < {"status":"success","message":"Deployment policy added successfully: [deployment-policy-id] deployment-policy-1"}
You will come across the following HTTP status codes while adding a deployment policy:
HTTP status code | 201, 400, 409, 500 See the descriptions of the HTTP status codes here. |
Location header URL | https://<STRATOS_HOST>:<STRATOS_HTTPS_PORT>/api/deploymentPolicies/<DEPLOYMENT_POLICY_ID> |
Adding a deployment policy via the PPaaS Console
Adding a deployment policy via the UI editor
Follow the instructions below to add a deployment policy:
- Click Configurations on the home page.
- Click Deployment Policies.
- Click Add New Deployment Policy.
- Enter the required details. For property definitions, see Deployment policy property definitions.
- Click SAVE DEPLOYMENT POLICY DEFINITION.
Adding a deployment policy via the JSON editor
Follow the instructions below to add a deployment policy:
- Click Configurations on the home page.
- Click Deployment Policies.
- Click ADD DEPLOYMENT POLICY.
- Click on the editor control to switch to the JSON editor. The JSON code format to add a deployment policy will appear.
- Optionally, check the Auto correct with schema option to ensure that you do not accidentally delete any mandatory fields from the deployment policy definition JSON code.
- Code the deployment policy definition using JSON. For property definitions, see Deployment Policy Resource Definition.
- Click SAVE DEPLOYMENT POLICY DEFINITION.
Sample deployment policy JSON
{ "id": "deployment-policy-1", "networkPartitions": [ { "id": "network-partition-mock", "partitionAlgo": "round-robin", "partitions": [ { "id": "partition-1", "partitionMax": 2 } ] } ] }