In Senlin, each node is associated with a physical object created by instantiating a profile. Profiles themselves are objects instantiated from “profile types”. In other words, a profile type provides the specification for creating profiles while a profile can be used to create multiple homogeneous objects.
Profile type implementations are managed as plugins. Users can use the built-in profile types directly and they can provide their own implementation of new profile types. The plan is to have Senlin engine support dynamical loading of plugins. Currently, this can be done by adding new senlin.profiles entry in the entry_points section in the setup.cfg file followed by a reinstall (i.e. pip install) operation.
The base class Profile provides some common logics regarding the following operations:
In addition to the above logics, the base class Profile also defines some abstract methods for a profile type implementation to implement. When invoked, these methods by default return NotImplemented, a special value that indicates the method is not implemented.
In the Profile class, there is a special property named context. This is the data structure containing all necessary information needed when the profile type implementation wants to authenticate with a cloud platform. Refer to authorization, Senlin makes use of the trust mechanism provided by the OpenStack Keystone service.
The dictionary in this context property by default contains the credentials for the Senlin service account. Using the trust built between the requesting user and the service account, a profile type implementation can authenticate itself with the backend Keystone service and then interact with the supporting service like Nova, Heat etc.
All profile type implementations can include a context key in their spec, the default value is an empty dictionary. A user may customize the contents when creating a profile object by specifying a region_name, for example, to enable a multi-region cluster deployment. They could even specify a different auth_url so that a cluster can be built across OpenStack clouds.
When released, Senlin provides some built-in profile types. However, developing new profile types for Senlin is not a difficult task.
The first step is to create a new file containing a subclass of Profile. Then you will define the spec schema for the new profile which is a python dictionary named spec_schema, with property names as keys. For each property, you will specify its value to be an object of one of the schema types listed below:
For example:
spec_schema = {
'name': schema.String('name of object'),
'capacity': schema.Integer('capacity of object', default=10),
'shared': schema.Boolean('whether object is shared', default=True)
}
If a profile property is a List, you can further define the type of elements in the list, which can be a String, a Boolean, an Integer or a Map. For example:
spec_schema = {
...
'addresses': schema.List(
'address of object on each network',
schema=schema.String('address on a network')
),
...
}
If a profile property is a Map, you can further define the “schema” of that map, which itself is another Python dictionary containing property definitions. For example:
spec_schema = {
...
'dimension': schema.Map(
'dimension of object',
schema={
'length': schema.Integer('length of object'),
'width': schema.Integer('width of object')
}
)
...
}
By default, a property is not required. If a property has to be provided, you can specify required=True in the property type constructor. For example:
spec_schema = {
...
'name_length': schema.Integer('length of name', required=True)
...
}
A property can have a default value when no value is specified. If a property has a default value, you don’t need to specify it is required. For example:
spec_schema = {
...
'min_size': schema.Integer('minimum size of object', default=0)
...
}
After the properties are defined, you can continue to work on overriding the abstract methods inherited from the base Profile type as appropriate.
For Senlin to make use of the new profile type you have just developed, you will register it to Senlin service. Currently, this is done through a manual process. In future, Senlin will provide dynamical loading support to profile type plugins.
To register a new profile type, you will add a line to the setup.cfg file that can be found at the root directory of Senlin code base. For example:
[entry_points]
senlin.profiles =
os.heat.stack = senlin.profiles.os.heat.stack:StackProfile
os.nova.server = senlin.profiles.os.nova.server:ServerProfile
my.cool.profile = <path to the profile module>:<profile class name>
Finally, save that file and do a reinstall of the Senlin service, followed by a restart of the senlin-engine process.
$ sudo pip install -e .
Now, when you do a senlin profile-type-list, you will see your profile type listed along with other existing profile types.
Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.