This Confluence has been LDAP enabled, if you are an ASF Committer, please use your LDAP Credentials to login. Any problems file an INFRA jira ticket please.

Child pages
  • 4.1.x Updating a Cartridge via REST API
Skip to end of metadata
Go to start of metadata

Overview

DescriptionUpdate a cartridge definition.
Resource Path

/cartridges

HTTP MethodPUT
Request/Response Format

application/json

Sample request

{
  "type": "php",
  "provider": "apache",
  "category": "data",
  "host": "php.stratos.org",
  "displayName": "php",
  "description": "php Cartridge",
  "version": "7",
  "multiTenant": "false",
  "portMapping": [
    {
	  "name": "http-80",
      "protocol": "http",
      "port": "80",
      "proxyPort": "8280"
    },
    {
      "name": "http-22",
      "protocol": "tcp",
      "port": "22",
      "proxyPort": "8222"
    }
  ],
  "deployment": {
    
  },
  "iaasProvider": [
    {
      "type": "mock",
      "imageId": "RegionOne/b4ca55e3-58ab-4937-82ce-817ebd10240e",
      "networkInterfaces": [
        {
          "name": "network-non-routable",
          "networkUuid": "b55f009a-1cc6-4b17-924f-4ae0ee18db5e"
        }
      ],
      "property": [
        {
          "name": "instanceType",
          "value": "RegionOne/aa5f45a2-c6d6-419d-917a-9dd2e3888594"
        },
        {
          "name": "keyPair",
          "value": "reka"
        },
        {
          "name": "securityGroups",
          "value": "default"
        }
      ]
    }
  ]
}

In Stratos 4.1.1, you can specify the kubernetesPortType as NodePort or ClusterIP in Port Mapping.

Access URLs are generated only for the NodePort service type.

{
  "type": "php",
  "category": "framework",
  "provider": "apache",
  "host": "stratos.org",
  "displayName": "PHP",
  "description": "PHP Cartridge",
  "version": "7",
  "multiTenant": true,
  "loadBalancingIPType": "private",
  "metadataKeys": [],
  "portMapping": [
    {
      "name": "http-80",
      "protocol": "http",
      "port": 80,
      "proxyPort": 8280,
      "kubernetesPortType": ""
    },
    {
      "name": "http-80",
      "protocol": "https",
      "port": 443,
      "proxyPort": 8243,
      "kubernetesPortType": ""
    }
  ],
  "iaasProvider": [
    {
      "type": "mock",
      "imageId": "ap-southeast-1/ami-2e0d5a7c",
      "property": [
        {
          "name": "instanceType",
          "value": "m1.medium"
        },
        {
          "name": "keyPair",
          "value": "xxxxxxxx"
        }
      ],
      "networkInterfaces": [
        {
          "networkUuid": "fb9c21f4-0672-48b2-8279-77334bb63a53"
        },
        {
          "networkUuid": "1e43f86f-4165-4f2e-8017-dd4cfb5548b0"
        }
      ]
    },
    {
      "type": "kubernetes",
      "imageId": "stratos/php:4.1.0",
      "property": [
        {
          "name": "KUBERNETES_CONTAINER_CPU",
          "value": "0"
        },
        {
          "name": "KUBERNETES_CONTAINER_MEMORY",
          "value": "0"
        },
        {
          "name": "KUBERNETES_SERVICE_SESSION_AFFINITY",
          "value": "ClientIP"
        },
        {
          "name": "payload_parameter.START_CMD",
          "value": "PCA"
        }
      ],
      "networkInterfaces": []
    }
  ]
}

For information on all the properties that can be used in a cartridge definition, see the Cartridge Property Definitions.

> PUT /api/cartridges HTTP/1.1
> Authorization: Basic YWRtaW46YWRtaW4=
> User-Agent: curl/7.24.0 (x86_64-apple-darwin12.0) libcurl/7.24.0 OpenSSL/0.9.8| zlib/1.2.5
> Host: localhost:9443
> Accept: */*
> Content-Type: application/json
> Content-Length: 1233
> Expect: 100-continue
>
< HTTP/1.1 100 Continue
< HTTP/1.1 200 OK
< Date: Sat, 21 Mar 2015 01:36:54 GMT
< Location: https://localhost:9443/api/cartridges/php
< Content-Type: application/json
< Transfer-Encoding: chunked
< Server: WSO2 Carbon Server
<
{"status":success,"message":"Cartridge updated successfully"}
curl -X PUT -H "Content-Type: application/json" -d @'<JSON_PAYLOAD>' -k -v -u admin:admin https://<STRATOS_HOST>:<STRATOS_HTTPS_PORT>/api/cartridges
  • The path to the JSON file that defines the cartridge needs to be defined as the <JSON_PAYLOAD> value.

  • By default, <STRATOS_HOST> is localhost. However, if you are using a public IP, the respective IP address or domain needs to be specified.
  • By default, <STRATOS_HTTPS_PORT> has been set to 9443. However, if the port offset has been incremented by n, the default port value needs to be incremented by n.

For example:

cd <STRATOS_SOURCE_HOME>/samples
curl -X PUT -H "Content-Type: application/json" -d @'cartridges/mock/php.json' -k -v -u admin:admin https://localhost:9443/api/cartridges


CLI command
update-cartridge
DescriptionUpdate a cartridge definition.
Command format
update-cartridge -p <JSON_FILE_PATH>

The path to the JSON file that defines the cartridge needs to be defined as the <JSON_FILE_PATH> value.

 

REST API response

HTTP status code

100, 200, 500
See the descriptions of the HTTP status codes here.

Location header URL

https://<STRATOS_HOST>:<STRATOS_HTTPS_PORT>/api/cartridges/<CARTRIDGE_TYPE>

  • No labels