16.5. Adding a Resource to a Collection
The
add
method adds a resource to a collection. The resource to be added is created based on the parameters provided. Parameters are provided to the add
method using an instance of an object from the ovirtsdk.xml.params module. Selecting the specific class from the module to use varies based on the type of resource being created.
Example 16.8. Adding a Resource to a Collection
In this example, a brick is added to the
GlusterBricks
collection.
br_param = params.GlusterBrick( brick_dir='/exports/music_2', server_id='0f5a7016-bb36-4f2b-a226-3b16c3eeca0c') bricksParam = params.GlusterBricks() bricksParam.add_brick(br_param)
While the brick created in this example is not yet ready to run, it illustrates the process for creating any Red Hat Storage resource:
Procedure 16.1. Creating a Red Hat Storage Resource
- Create an instance of the parameter object for the type of resource being created.
- Identify the collection to which the resource will be added.
- Call the
add
method of the collection passing the parameter object as a parameter.
22632%2C+Console+Developer+Guide-322-09-2014+17%3A11%3A35Report a bug