Application Packaging Standard

Last updated 18-Mar-2019

Provisioning Logic

In this document, you will develop the APS types that will be loaded to the APS controller and the services that will function on the APS connector.

../../../../_images/offer-step-model.png ../../../../_images/offer-step-meta.png ../../../../_images/offer-step-provision-b.png ../../../../_images/offer-step-presentation.png ../../../../_images/offer-step-deploy.png ../../../../_images/offer-step-provisioning.png

Service Overview

Updates of APS Types

In this project, we have a new service offers for the new APS type offer. The latter has relationships with the other types. There must be a singular link with the application root resource cloud and a link collection with vpses, as presented in the Resource Model and in the table below.

APS Type Type ID Relation Relation parameters
Cloud http://aps-standard.org/samples/offer1p/cloud/1.0 contexts Collection-Optional
Offer http://aps-standard.org/samples/offer1p/offer/1.0
cloud
vpses
Singular-Required
Collection-Optional
Context http://aps-standard.org/samples/offer1p/context/1.0
cloud
vpses
Singular-Required
Collection-Optional
VPS http://aps-standard.org/samples/offer1p/vps/1.0
context
offer
Singular-Required
Singular-Required

New APS Type

The set of properties in the new offer APS type must be represented as structures with embedded other structures and primitive properties, as illustrated earlier for the VPS properties.

../../../../_images/demo-offer-props.png

The state property is not needed in the offer definition.

The offer APS type must have a required singular link with the cloud type and optional link collection with the vps type.

Continue Your Demo Project

This section continues the demo project from the previous step.

The provisioning logic should be modified as follows:

  • We do not need to touch contexts.php in this step. Neither the context class nor its relationship should be changed.
  • In the clouds.php file, add the relationship with offers.
  • In the vpses.php file, add the relationship with an offer.
  • Create a new offers.php file that defines the new offer APS type and the provisioning logic of the offers service.

Top Level Application Logic

In the clouds.php script, add the optional relationship with the collection of offers:

/**
 * @link("http://aps-standard.org/samples/offer1p/offer/1.0[]")
 */
public $offers;

Server Management Logic

In the vpses.php script, add the required relation to the offer type:

/**
 * @link("http://aps-standard.org/samples/offer1p/offer/1.0")
 * @required
 */
public $offer;

Offer Management Logic

When creating offers.php from scratch, follow the steps similar to those described in the Server Management Logic section of the Generic Service Management project:

  1. Declare complex properties using APS structures:

    class CPU {
            /**
            * @type("integer")
            * @title("Number of CPUs")
            * @description("Number of CPU cores")
            */
            public $number;
    }
    
    class OS {
            /**
            * @type("string")
            * @title("OS Name")
            * @description("Operating System Name")
            */
            public $name;
    
            /**
            * @type("string")
            * @title("OS Version")
            * @description("Operating System version")
            */
            public $version;
    }
    
    class Hardware {
            /**
            * @type("integer")
            * @title("RAM Size")
            * @description("RAM size in GB")
            */
            public $memory;
    
            /**
            * @type("integer")
            * @title("Disk Space")
            * @description("Disk space in GB")
            */
            public $diskspace;
    
            /**
            * @type("CPU")
            * @title("CPU")
            * @description("Server CPU parameters")
            */
            public $CPU;
    
    }
    
    class Platform {
            /**
            * @type("string")
            * @title("Architecture")
            * @description("Platform architecture")
            */
            public $arch;
    
            /**
            * @type("OS")
            * @title("OS Parameters")
            * @description("Parameters of operating system")
            */
            public $OS;
    }
    
  2. Declare the main offer class:

    /**
    * Class offer
    * @type("http://aps-standard.org/samples/offer1p/offer/1.0")
    * @implements("http://aps-standard.org/types/core/resource/1.0")
    */
    class offer extends \APS\ResourceBase
    {
    
    }
    
  3. Inside the class definition, add a relationship with the application root type called cloud and with a collection of VPSes:

    /**
    * @link("http://aps-standard.org/samples/offer1p/cloud/1.0")
    * @required
    */
    public $cloud;
    
    /**
    * @link("http://aps-standard.org/samples/offer1p/vps/1.0[]")
    */
    public $vpses;
    
  4. Inside the class definition, add all offer properties including primitives and the structures declared earlier:

    /**
    * @type(string)
    * @title("Offer Name")
    */
    public $name;
    
    /**
    * @type(string)
    * @title("Offer Description")
    */
    public $description;
    
    /**
    * @type("Hardware")
    * @title("Hardware")
    * @description("Server Hardware")
    */
    public $hardware;
    
    /**
    * @type("Platform")
    * @title("Plaform")
    * @description("OS Platform")
    */
    public $platform;
    

Conclusion

This completes the development of the provisioning logic.

The project files you have created and updated are similar to the respective files in the sample package.