Welcome to virt_web’s documentation!

Contents:

virt_web API

Api Controller

class virt_web.controllers.api.Api(*args, **kwargs)

The API controller for the virt_web application.

Controls and views various domain information

domain_list(filter_name='', node_hostname=None, submit=None)

Return a list of domains

If filter_name is specified it will only return names that match it.

Parameters:
  • filter_name – Filter by this name
  • node_hostname – Filter by nodes on a specific hostname
node_list(filter_name='', hostname=None, no_json=None, submit=None)

Return a list of nodes

If filter_name is specified it will only return names that match it.

Parameters:
  • filter_name – Filter by this name
  • hostname – The hostname of the node to return
  • no_json – Disable json detection
node_pool_list(filter_name='', hostname=None, no_json=None, submit=None)

Return a list of nodes with basic pool info on each node

returns a dict containing a list of all nodes that match as well as number of pools, how much total space is used, and how much of that space is free

Parameters:
  • filter_name – Filter by this name
  • hostname – The hostname of the node to return
  • no_json – Disable json detection
  • submit – Ignored
pool_list(filter_name='', hostname=None, no_json=None, submit=None)

Return a list of pools

Returns a list of pools

Parameters:
  • filter_name – Filter by this name
  • hostname – The hostname of the node to return
  • no_json – Disable json detection
  • submit – Ignored
volume_list(filter_name='', hostname=None, pool_uuid=None, no_json=None, submit=None)

Return a list of volumes

Returns a list of volumes

Parameters:
  • filter_name – Filter by this name
  • hostname – The hostname of the node to return
  • pool_uuid – If specified, will return all volumes in that pool
  • no_json – Disable json detection
  • submit – Ignored

virt_web utility

Using Virt Web Util

WebHelpers used in virt_web.

virt_web.lib.helpers.bytes_to_human(bytes)

Convert a number of bytes to a more human readable version.

The conversion will take the number of bytes and find a number of KB, MB, or GB to the nearest tenth that still has at least one non-zero number in the ones place. It appends KB, MB, or GB to the end of the number depending on what units were used.

Parameter:bytes – Number of bytes to convert to a more human readable form.
Returns:String with a more human readbale form of the number of bytes.
virt_web.lib.helpers.object_id_dict(response_list)

Creates a dict of getObjects return from amqp

This will return a dict of objects as returned by getObjects().

Parameter:response_list – A list of objects returned from getObjects
Returns:Returns a dict of the objects
virt_web.lib.helpers.qmf_jsonify(response_list)

Creates a json representation of getObjects return from amqp

This will return a list of objects as returned by getObjects(). in a json friendly format

Parameter:response_list – A list of objects returned from getObjects
Returns:Returns a list of the objects
virt_web.lib.helpers.to_bytes(amount)

Convert a string into a number of bytes.

Parameter:amount – string representing anumber of bytes. It can be all digits or have a suffix of B, K, KB, M, MB, G or GB. K and KB mean kilobytes (1024 bytes), M and MB mean megabytes (1024*1024 bytes), and G and GB mean gigabytes(1024*1024*1024 bytes). B or no suffix means bytes. Note that fractions of a byte are rounded down.
Raises ValueError:
 if the string is not in a recognized format
Returns:The number of bytes that the string represented

virt_web Globals

The application’s Globals object

class virt_web.lib.app_globals.Globals

Container for objects available throughout the life of the application.

One instance of Globals is created during application initialization and is available during requests via the ‘tg.app_globals’ variable.

amqp_session
Contains a connection to an amqp server that lets you query and
manipulate libvirt managed hosts.

virt_web validators

class virt_web.lib.validators.BytesValidator(*args, **kw)

Validator to turn a human readable byte string into a number of bytes

kwarg minimum:Number of bytes must be more than this amount
kwarg maximum:Number of bytes must be less than this amount
kwarg negative:if True the number of bytes may be negative. The default is False which disallows negative values

Messages

badType:
The input must be a string (not a %(type)s: %(value)r)
empty:
Please enter a value
invalid:
Cannot parse %(amount)s into bytes
max:
Number of bytes must be less than %(max)i
min:
Number of bytes must be more than %(min)i
negative:
Must specify a positive number of bytes
noneType:
The input must be a string (not None)
validate_python(amount, state)
Validate the amount based on variables

virt_web Node

Node Controller

class virt_web.controllers.node.FilterNodeForm(*args, **kw)
prompts user for a filter to node name
class virt_web.controllers.node.Node(*args, **kwargs)

The Domain controller for the virt_web application.

Controls and views various domain information

list(filter_name='', submit=None)
Return a list of nodes
view(hostname)

Return node, pool, volume and domain information about a host

This method returns all information known about a specific node using hostname as the identifier.

Parameter:hostname – the fqdn of a node’s hostname

The following cause problems

virt_web Volume

Volume Controller

class virt_web.controllers.volume.CreateVolumeForm(*args, **kw)
CreateVolumeForm: ToscaWidget for volume creation
class virt_web.controllers.volume.CreateVolumeFormXML(*args, **kw)
class virt_web.controllers.volume.Volume(*args, **kwargs)

The Domain controller for the virt_web application.

Controls and views various domain information

delete(volume_id)

Delete a volume name:

This method will delete a volume from the pool

Parameter:volume_id – The getObjectId id of the volume to delete.
dump(uuid)

Dump the xml contents of a volume

This will prompt the user to make edits to the raw xml configuration for a given domain

Parameter:uuid – uuid of the domain to dump
list()

Get a list of valid volumes

This method returns a list of nodes, volumes, and pools.

new(hostname, pool=None, volume_name=None, capacity=None)

Display form for creating a new volume

This method will prompt for a new volume on a given hostname and pool.

Parameters:
  • hostname – fqdn of the node where the pool should be created
  • pool – Pool name of the pool where the new volume should be created. If not specified, a list of available pools will be returned.
  • volume_name – The name of the new volume to create
  • capacity – The size of the new volume in bytes to be created
new_action(hostname, pool, volume_name, capacity)

Create a new volume

This method will create a new volume on a specified node and volume

Parameters:
  • hostname – The hostname of the node where creation happens
  • pool – Pool UUID of the pool where the new volume should be created
  • volume_name – The name of the new volume to create
  • capacity – The size of the new volume in bytes to be created
new_action_xml(hostname, pool, xml)

Create a new volume

This method will create a new volume on a specified node and volume

Parameters:
  • hostname – The hostname of the node where creation shappens
  • pool – Pool ID of the pool
  • xml – The xml file to create a volume with.

virt_web Domain

Domain Controller

class virt_web.controllers.domain.CreateDomainForm(*args, **kw)
Form for getting new domain information
class virt_web.controllers.domain.CreateDomainFormXML(*args, **kw)
CreateDomainForm: ToscaWidget for pool creation
class virt_web.controllers.domain.Domain(*args, **kwargs)

The Domain controller for the virt_web application.

Controls and views various domain information

create(domain_uuid)

Prompt user to create a new domain

This method will attempt to create (start) a new domain.

Parameter:domain_id – The uuid of the domain you want to start.
Returns:The domain name, result text and result status
create_all(node_hostname)

Create all domains on a node_hostname

This will create all domains on a given node_hostname

Parameter:node_hostname – The hostname to create all domains on
destroy(domain_uuid)

Destroy a domain

This method will destroy a domain given domain id

Parameter:domain_uuid – Domain uuid as given by string representation of the domain
destroy_all(node_hostname)

Destroy all domains on a node_hostname

This will destroy all domains on a given node_hostname

Parameter:node_hostname – The hostname to destroy all domains on
edit(uuid)

Put the xml file in a text area and prompt user for updates

This will prompt the user to make edits to the raw xml configuration for a given domain

Parameter:uuid – uuid of the domain to edit
edit_action_xml(uuid, xml)

Create a new domain

Takes all the information in required to create a new hostname.

Parameters:
  • uuid – UUID of domain to edit
  • xml – Raw XML to change domain
list(filter_name='', submit=None)

Return a list of domains and nodes

If filter_name is specified it will only return names that match it.

Parameter:filter_name – Filter by this name
new(hostname, **kw)

Prompt user for a new domain

For a given node hostname prompt user to create a new domain.

Parameter:hostname – Hostname of the node to add a new volume to
new_action(hostname, domain_name, memory, current_memory, vcpus, cmd_line, disk)

Create a new domain

Takes all the information in required to create a new hostname.

Parameters:
  • hostname – Hostname of the node to create this new domain
  • domain_name – Name of the new domain.
  • memory – Maximum memory to allocate to guest.
  • current_memory – Memory to boot guest with.
  • vcpus – Number of cpus for domain to use.
  • cmd_line – Kernel args to boot with.
  • disk – Path to volume.
new_action_xml(hostname, xml)

Create a new domain

Takes all the information in required to create a new hostname.

Parameters:
  • hostname – The hostname of the node where creation shappens
  • xml – The xml file to create a volume with.
resume(domain_uuid)

Resume a domain

This method will resume a suspended domain and resume it’s function

Parameter:domain_uuid – Domain uuid as given by a string representation of the domain
resume_all(node_hostname)

resume all domains on a node_hostname

This will resume all domains on a given node_hostname

Parameter:node_hostname – The hostname to pause all domains on
shutdown(domain_uuid)

Shutdown a domain

This method will attempt to gracefully shutdown a domain

Parameter:domain_uuid – Domain uuid as given by a string representation of the domain
shutdown_all(node_hostname)

Shutdown all domains on a node_hostname

This will shutdown all domains on a given node_hostname

Parameter:node_hostname – The hostname to pause all domains on
suspend(domain_uuid)

Suspend or pause a domain

This method will suspend a domain and stop it’s function until it is resumed

Parameter:domain_uuid – domain_uuid as given by a string representation of the domain
suspend_all(node_hostname)

Suspend all domains on a node_hostname

This will suspend all domains on a given node_hostname

Parameter:node_hostname – The hostname to pause all domains on
undefine(domain_uuid)

Undefine or delete a domain

This method will undefine or delete a domain.

Parameter:domain_id – Domain uuid as given by a string representation of the domain
class virt_web.controllers.domain.EditDomainXML(*args, **kw)
Prompts user for the xml file to edit a domain
class virt_web.controllers.domain.FilterDomainForm(*args, **kw)
prompts user for a filter to domain name

virt_web Pools

Pool Controller

class virt_web.controllers.pool.CreatePoolForm(*args, **kw)
CreatePoolForm: ToscaWidget for pool creation
class virt_web.controllers.pool.CreatePoolFormXML(*args, **kw)
CreatePoolForm: ToscaWidget for pool creation
class virt_web.controllers.pool.EditPoolXML(*args, **kw)
class virt_web.controllers.pool.Pool(*args, **kwargs)

The Domain controller for the virt_web application.

Controls and views various domain information

create(pool_uuid)

Create (starts) a running pool

Given pool id, this will start a libvirt storage pool

Parameter:pool_uuid – UUID of the pool being enabled
destroy(pool_uuid)

Destroy (disables) a running pool

Given pool id, this will disable a libvirt storage pool

Parameter:pool_uuid – UUID of the pool being disabled
edit(uuid)

Put the xml file in a text area and prompt user for updates

This will prompt the user to make edits to the raw xml configuration for a given domain

Parameter:uuid – uuid of the domain to edit
edit_action_xml(uuid, xml)

Edit a pool

Takes all the information in required to create a new hostname.

Parameters:
  • uuid – UUID of pool to edit
  • xml – Raw XML to change domain
list(filter_name='')

Return a list of all pools and nodes

Parameter:filter_name – Filters the pools by hostname
new(hostname)

Prompt user to create a new pool

This will display a form to users and get information back to then create a pool.

Parameter:hostname – The hostname to create a new pool on
Returns:node
new_action(type, pool_name, path, hostname)

Creates (enables) an already defined pool.

Given pool id, this will enable a libvirt storage pool

Parameters:
  • type – Type of pool to make
  • pool_name – Name of the pool to create
  • path – Path to new pool
  • hostname – Host that does the creation
new_action_xml(hostname, xml)

Creates (enables) an already defined pool.

Given pool id, this will enable a libvirt storage pool

Parameters:
  • hostname – Host that does the creation
  • xml – XML to do the creation
undefine(pool_uuid)

Undefine a destroyed pool

Once a pool has been stopped, this will undefine it.

Parameter:pool_uuid – UUID of the pool to be removed

Indices and tables