Table Of Contents

Application Packaging Standard

Last updated 18-Mar-2019

Assign Services to Users

Scenario

The services provided by the application must be assigned to service users. In the previous scenarios, you have subscribed your test customer to the application that allows creating virtual servers (VPSes) for service users. The subscription contains a limited numbers of various offers for creating VPSes. The customer already has some service users for whom the customer administrator should create VPSes.

../../../_images/sys-user-step-customer.png ../../../_images/sys-user-step-staff.png ../../../_images/sys-user-step-user.png ../../../_images/sys-user-step-subscription.png ../../../_images/sys-user-step-service-b.png

Source Data

Collect the following data before you start provisioning application resources.

  • Security token - customer admin’s token. Within the account, the account administrator must manage the subscribed services.

  • APS type of the service - http://aps-standard.org/samples/suwizard1p/vps/1.0. To be sure in correctness of the schema usage, find out the type by sending the following request:

    GET /aps/2/types
    

    In the response, find out the vps type:

    HTTP/1.1 200 OK
    
    [...{
        "aps": {
           "id": "145",
           "href": "/aps/2/types/145"
        },
        "apsVersion": "2.0",
        "name": "vps",
        "id": "http://aps-standard.org/samples/suwizard1p/vps/1.0",
        "implements": "http://aps-standard.org/types/core/user/service/1.0",
        "properties": {
           "name": {
              "type": "string",
              "title": "name",
              "description": "Server Name"
           },
           "description": {
              "type": "string",
              "title": "Description",
              "description": "Server Description"
           },
           "state": {
              "type": "string",
              "title": "state",
              "description": "Server State"
           },
           "hardware": {
              "type": "Hardware",
              "title": "Hardware",
              "description": "Server Hardware"
           },
           "platform": {
              "type": "Platform",
              "title": "Platform",
              "description": "OS Platform"
           },
           "userName": {
              "type": "string",
              "title": "User Name",
              "description": "VPS Owner Name"
           },
        },
        "operations": {
           "start": {
              "verb": "GET"
              "path": "/start"
              "response": {
                 "contentType": "text/json",
                 "type": "string",
                 "items": null
              }
           },
           "stop": {
              "verb": "GET"
              "path": "/stop"
              "response": {
                 "contentType": "text/json",
                 "type": "string",
                 "items": null
              }
           }
        },
        "structures": {
           "CPU": {
              "type": "object"
              "properties": {
                 "number": {
                    "type": "integer",
                    "title": "Number of CPUs",
                    "description": "Number of CPU cores"
                 }
              }
           },
           "OS": {
              "type": "object"
              "properties": {
                 "name": {
                    "type": "string",
                    "title": "OS Name",
                    "description": "Operating System Name"
                 },
                 "version": {
                    "type": "string",
                    "title": "OS Version",
                    "description": "Operating System version"
                 }
              }
           },
           "Hardware": {
              "type": "object"
              "properties": {
                 "memory": {
                    "type": "integer",
                    "title": "RAM Size",
                    "description": "RAM size in GB"
                 }-
                 "diskspace": {
                    "type": "integer",
                    "title": "Disk Space",
                    "description": "Disk space in GB"
                 }-
                 "CPU": {
                    "type": "CPU",
                    "title": "CPU",
                    "description": "Server CPU parameters"
                 }
              }
           },
           "Platform": {
              "type": "object"
              "properties": {
                 "arch": {
                    "type": "string"
                    "title": "Architecture"
                    "description": "Platform architecture"
                 },
                 "OS": {
                    "type": "OS"
                    "title": "OS Parameters"
                    "description": "Parameters of operating system"
                 }
              }
           }
        },
        "relations": {
           "context": {
              "type": "http://aps-standard.org/samples/suwizard1p/context/1.0",
              "required": true,
              "collection": false
           },
           "offer": {
              "type": "http://aps-standard.org/samples/suwizard1p/offer/1.0",
              "required": true,
              "collection": false
           },
           "user": {
              "type": "http://aps-standard.org/types/core/service-user/1.0",
              "required": true,
              "collection": false,
              "assign": {
                 "access": {
                    "owner": true
                 }
              }
           }
        }
    },...]
    

    Note

    A VPS must have relations with the following resources whose APS IDs you must collect before provisioning a VPS:

    • Service user
    • Offer
    • Management context in the subscription
  • APS ID of the service user:

    GET /aps/2/resources?implementing(http://parallels.com/aps/types/pa/service-user/1.2)
    

    The following response contains the APS ID of the user created earlier:

    HTTP/1.1 200 OK
    
    [{"aps":{"id":"e21e19e0-5951-43a7-8103-8c5606398379",...},...},...]
    
  • APS ID of the silver offer that will be related with the new VPS:

    GET /aps/2/resources?implementing(http://aps-standard.org/samples/suwizard1p/offer/1.0),like(name,*Silver*)
    

    The following response contains the APS ID of the silver offer created earlier:

    HTTP/1.1 200 OK
    
    [{"aps":{"id":"8c0e2f65-8968-43f6-97ca-93ed7b7df9d1",...},...}]
    
  • APS ID of the management context that will be related with the VPS:

    GET /aps/2/resources?implementing(http://aps-standard.org/samples/suwizard1p/context/1.0)
    

    The response must contain only one resource of this type, since this is a singular resource in a subscription:

    HTTP/1.1 200 OK
    
    [{"aps":{"id":"32ef5e79-1043-45db-a26d-21dcd4ef3661",...},...}]
    
  • APS ID of the subscription whose limits must allow creating the VPS:

    GET /aps/2/resources?implementing(http://parallels.com/aps/types/pa/subscription/1.0)
    

    The following response contains the APS ID of the subscription created earlier:

    HTTP/1.1 200 OK
    
    [{"aps":{"id":"c315f4a9-1e00-4458-b3e9-95de5659b3d7",...},...}]
    

Preliminary Inspection

Before you start creating a new VPS, verify if there is a VPS with similar properties and if the respective resource usage did not reach its limit in the subscription.

  • Get a list of all service VPSes:

    GET /aps/2/resources?implementing(http://aps-standard.org/samples/suwizard1p/vps/1.0)
    
  • Verify if there is a VPS with the name similar to the name of the new VPS:

    GET /aps/2/resources?implementing(http://aps-standard.org/samples/suwizard1p/vps/1.0),like(name,*VPS-101*)
    
  • Verify if the silver offer usage did not reach the limit in the subscription. Use the subscription APS ID in the following request:

    GET /aps/2/resources/c315f4a9-1e00-4458-b3e9-95de5659b3d7/resources
    

    The following response shows that only 1 VPS out of 10 allowed is used:

    HTTP/1.1 200 OK
    
    [...{
        "id": "1000053"
        "title": "User Management - Silver VPS Configuration"
        "apsId": "8c0e2f65-8968-43f6-97ca-93ed7b7df9d1"
        "apsType": "http://aps-standard.org/samples/suwizard1p/offer/1.0"
        "usage": 1
        "limit": 10
        "unit": "unit"
    },...]
    

Creating Object

A REST request for creating a new VPS must comply with the vps type investigated earlier. The most important is to specify the required links with the management context, an offer, and a user, as well as to specify the subscription APS ID in the APS-Subscription-ID header.

POST /aps/2/resources

"APS-Subscription-ID": "c315f4a9-1e00-4458-b3e9-95de5659b3d7"

{
    "aps":{
    "type":"http://aps-standard.org/samples/suwizard1p/vps/1.0"
    },
    "name":"VPS-101",
    "state":"Stopped",
    "hardware":{
        "memory": 512,
        "diskspace": 64,
        "CPU":{
         "number": 2
        }
    },
    "platform":{
      "OS":{
          "name":"CentOS",
          "version": 7
        }
    },
   "userName":"Nick Archer",
   "offer":{
      "aps":{
         "href":"aps/2/resources/8c0e2f65-8968-43f6-97ca-93ed7b7df9d1",
         "id":"8c0e2f65-8968-43f6-97ca-93ed7b7df9d1"
      }
   },
   "context":{
      "aps":{
         "href":"aps/2/resources/32ef5e79-1043-45db-a26d-21dcd4ef3661",
         "id":"32ef5e79-1043-45db-a26d-21dcd4ef3661"
      }
   },
   "user":{
      "aps":{
         "href":"aps/2/resources/e21e19e0-5951-43a7-8103-8c5606398379",
         "id":"e21e19e0-5951-43a7-8103-8c5606398379"
      }
   }
}

The response must look similar to:

HTTP/1.1 200 OK

{
  "aps": {
    "type": "http://aps-standard.org/samples/suwizard1p/vps/1.0",
    "id": "34540887-26ee-49fe-97ad-0fe067268ded",
    "status": "aps:ready",
    "revision": 3,
    "modified": "2016-09-28T09:57:55Z",
    "subscription": "c315f4a9-1e00-4458-b3e9-95de5659b3d7",
    "package": {
      "id": "0275d4b1-b8a9-4c2c-bd3c-b11fc3c45081",
      "href": "/aps/2/packages/0275d4b1-b8a9-4c2c-bd3c-b11fc3c45081"
    }
  },
  "hardware": {
    "CPU": {
      "number": 2
    },
    "diskspace": 64,
    "memory": 512
  },
  "name": "VPS-101",
  "platform": {
    "OS": {
      "name": "CentOS",
      "version": "7"
    }
  },
  "state": "Stopped",
  "userName": "Nick Archer",
  "context": {
    "aps": {
      "link": "strong",
      "href": "/aps/2/resources/32ef5e79-1043-45db-a26d-21dcd4ef3661",
      "id": "32ef5e79-1043-45db-a26d-21dcd4ef3661",
      "subscription": "c315f4a9-1e00-4458-b3e9-95de5659b3d7"
    }
  },
  "offer": {
    "aps": {
      "link": "strong",
      "href": "/aps/2/resources/8c0e2f65-8968-43f6-97ca-93ed7b7df9d1",
      "id": "8c0e2f65-8968-43f6-97ca-93ed7b7df9d1"
    }
  },
  "user": {
    "aps": {
      "link": "strong",
      "href": "/aps/2/resources/e21e19e0-5951-43a7-8103-8c5606398379",
      "id": "e21e19e0-5951-43a7-8103-8c5606398379"
    }
  }
}

Now your test user can use the newly created VPS.

Conclusion

You have successfully created a resource and assigned it to a service user. Similarly, you can create more resources and assign them to the same or other users.

You can use additional verification of the VPS existence:

  • Use the REST requests described in the Preliminary Inspection to find the difference.
  • Find the new VPS in the customer control panel (CCP). For this aim, log in to CCP and open the VPS Management item in the navigation menu. In the list of servers, find out the VPS you have just created and examine the properties you have assigned to it.
../../../_images/ccp-vps-user.png

On completion of this scenario, you have achieved the business goal.