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

  1. Create an instance of the parameter object for the type of resource being created.
  2. Identify the collection to which the resource will be added.
  3. 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
Red Hat logoGithubRedditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

© 2024 Red Hat, Inc.