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.
In this document:
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 |
contexts |
Collection-Optional |
|
Offer |
cloud
vpses
|
Singular-Required
Collection-Optional
|
|
Context |
cloud
vpses
|
Singular-Required
Collection-Optional
|
|
VPS |
context
offer
|
Singular-Required
Singular-Required
|
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.
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.
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.
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;
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;
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:
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;
}
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
{
}
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;
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;
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
.