Search

3.2. Resources

download PDF

3.2.1. List Resources in a Collection (list)

Use the list command to display all resources of a specific type. Lists also include optional search queries to filter results.
Syntax

list [collection] [options]

Table 3.2. list standard options
Option Description
--show-all Displays all non-empty properties for each listed resource. Without this option, only the id, name and description properties display.
--query [QUERY] Filters the list using a server-side query based upon Red Hat Virtualization Manager query language.
--kwargs [QUERY] Filters the list using a client-side query.
--case_sensitive true|false Match search queries using case sensitivity.
--max Maximum number of results for display.

Note

Options specific to resource types are listed in the definition pages for each resource type.

Example 3.3. Examples for list

List virtual machines:
[RHEVM shell (connected)]# list vms
List virtual machines with all properties listed:
[RHEVM shell (connected)]# list vms --show-all
List virtual machines with a status of 'up':
[RHEVM shell (connected)]# list vms --query "status=up"
List users that match the specified user name across all domains with the use of a wildcard:
[RHEVM shell (connected)]# list users --query "usrname=jsmith@*"  --case_sensitive false
Get help with list search syntax:
[RHEVM shell (connected)]# list --help

3.2.2. Show a Resource (show)

Use the show command to display resource properties.
Syntax

show [resource] [id|name] [options]

Note

Options specific to resource types are listed in the definition pages for each resource type.

Example 3.4. Examples for show

Show virtual machines based upon id:
[RHEVM shell (connected)]# show vm fcadfd5f-9a12-4a1e-bb9b-2b9d5c2e04c3
Show virtual machines based upon name:
[RHEVM shell (connected)]# show vm RHEL6-Server

3.2.3. Add a Resource (add)

Use the add command to add a new resource.
Syntax

add [resource] [options]

Note

Options specific to resource types are listed in the definition pages for each resource type.

Example 3.5. Examples for add

Create a virtual machine:
[RHEVM shell (connected)]# add vm [vm-options]
Create a user:
[RHEVM shell (connected)]# add user [user-options]
The add command can be made synchronous (if supported) by using the expect option:
[RHEVM shell (connected)]# add vm [vm-options] --expect '201-created'

3.2.4. Update a Resource (update)

Use the update command to modify an existing resource.
Syntax

update [resource] [id|name] [options]

Note

Options specific to resource types are listed in the definition pages for each resource type.

Example 3.6. Examples for update

Update a virtual machine:
[RHEVM shell (connected)]# update vm RHEL6-Server [vm-options]

3.2.5. Remove a Resource (remove)

Use the remove command to remove a resource.
Syntax

remove [resource] [id|name] [options]

Table 3.3. remove standard options
Option Description
--async Perform an asynchronous removal of the resource.
--force Perform a force remove of the resource. This removes all database entries and associations for a particular resource. This action applies only to datacenter and vm resources.

Note

Options specific to resource types are listed in the definition pages for each resource type.

Example 3.7. Examples for remove

Remove a virtual machine:
[RHEVM shell (connected)]# remove vm RHEL6-Server
Asynchronous removal of a virtual machine:
[RHEVM shell (connected)]# remove vm RHEL6-Server --async true
Force remove virtual machine:
[RHEVM shell (connected)]# remove vm RHEL6-Server --force

3.2.6. Perform Action on a Resource (action)

Use the action command to perform a special function relevant to resource type.
Syntax

action [resource] [id|name] [action] [options]

Note

Options specific to resource actions are listed in the definition pages for each resource type.

Example 3.8. Examples for action

Start a virtual machine
[RHEVM shell (connected)]# action vm RHEL6-Server start
Stop a virtual machine:
[RHEVM shell (connected)]# action vm RHEL6-Server stop
The action command can be made synchronous (if supported) by using the async option:
[RHEVM shell (connected)]# action vm [vm-options] --async false

3.2.7. Using Sub-Resources (--RESOURCE-identifier)

Certain resources act as sub-resources of other resources. This means there is a dependent relationship between the sub-resource and its parent resource. Use the --RESOURCE-identifier [name] option, where RESOURCE is the parent resource type, to target a sub-resource part of a parent resource.

Example 3.9. Examples for creating sub-resources with add

Create a NIC on a virtual machine:
[RHEVM shell (connected)]# add nic --vm-identifier RHEL6-Server [nic-options]
Note the use of the --vm-identifier RHEL6-Server option. This adds a NIC on the RHEL6-Server virtual machine.
Create a storage disk on a virtual machine:
[RHEVM shell (connected)]# add disk --vm-identifier RHEL6-Server [user-options]
Note the use of the --vm-identifier RHEL6-Server option. This adds a storage disk on the RHEL6-Server virtual machine.
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.