Welcome to MCVirt’s documentation!

MCVirt - Managed Consistent Virtualisation

MCVirt (em-see-vert) - Command line virtual machine management utility.

Description

MCVirt is a utility for managing virtual machines, supporting the following technologies:

MCVirt is implemented in Python, using the the libvirt virtualisation library.

Getting started

MCVirt must currently be built from source into a deb package, using the build script. The package and dependencies can then be installed:

$ ./build.sh
$ sudo dpkg -i mcvirt_0.10_all.deb
$ sudo apt-get -f install

See the installation guide for other dependencies and system configuration.

Start the MCVirt nameserver and daemon by running:

$ sudo service mcvirt-ns start
$ sudo service mcvirtd start

Most commands require a username and password to the MCVirt daemon. During installation a superuser is created with username mjc and password pass - see permissions for information on creating new users.

Configure the volume group that MCVirt will use to store virtual machine data:

$ sudo mcvirt node --set-vm-vg <Volume Group>

See the configuration guide for further node configuration steps.

Create a VM:

$ sudo mcvirt create --cpu-count 1 --memory 512 --disk-size 8000 test-vm

See the create/remove VMs, cluster, permissions and modifying VMs guides for further administrative instructions.

Start the VM:

$ sudo mcvirt start test-vm

See the controlling VMs guide for further user instructions.

Note: Username and password can be provided on the command line with the --username and --password options to instead of typing them in after every command.

For information on developing on MCVirt, see the development documentation.

See the guide index for a full list of manuals

For more information, please feel free to contact us

LICENSE

MCVirt is licensed under GPL v2. For more information, please see LICENSE

API Documentation

Contents:

mcvirt package

Subpackages

mcvirt.auth package

Submodules
mcvirt.auth.auth module

Provide auth class for managing permissions.

class mcvirt.auth.auth.Auth[source]

Bases: mcvirt.rpc.pyro_object.PyroObject

Provides authentication and permissions for performing functions within MCVirt.

add_superuser(user_object, ignore_duplicate=False)[source]

Add a new superuser.

add_user_permission_group(*args, **kwargs)
assert_permission(permission_enum, vm_object=None)[source]

Use check_permission function to determine if a user has a given permission and throws an exception if the permission is not present.

assert_user_type(*user_type_names)[source]

Ensure that the currently logged in user is of a specified type.

check_permission(permission_enum, vm_object=None, user_object=None)[source]

Check that the user has a given permission, either globally through MCVirt or for a given VM.

check_permission_in_config(permission_config, user, permission_enum)[source]

Read permissions config and determines if a user has a given permission.

static check_root_privileges()[source]

Ensure that the user is either running as root or using sudo.

check_user_type(*user_type_names)[source]

Check that the currently logged-in user is of a specified type.

copy_permissions(source_vm, dest_vm)[source]

Copy the permissions from a given VM to this VM. This functionality is used whilst cloning a VM

delete_superuser(user_object)[source]

Remove a superuser.

delete_user_permission_group(*args, **kwargs)
get_permission_groups()[source]

Return list of user groups.

get_superusers()[source]

Return a list of superusers

get_users_in_permission_group(permission_group, vm_object=None)[source]

Obtain a list of users in a given group, either in the global permissions or for a specific VM.

is_superuser()[source]

Determine if the current user is a superuser of MCVirt.

mcvirt.auth.cluster_user module

Provide class for managing cluster users.

class mcvirt.auth.cluster_user.ClusterUser(username)[source]

Bases: mcvirt.auth.user_base.UserBase

User type for cluster daemon users.

CAN_GENERATE = True
CLUSTER_USER = True
DISTRIBUTED = False
USER_PREFIX = 'mcv-cluster-'
allow_proxy_user

Connection users can proxy for another user.

static get_default_config()[source]

Return the default user config.

node

Return the node that the user is used for

update_host(host)[source]

Update the host associated with the user.

mcvirt.auth.connection_user module

Provide class for managing connection users.

class mcvirt.auth.connection_user.ConnectionUser(username)[source]

Bases: mcvirt.auth.user_base.UserBase

User type for initial connection users

CAN_GENERATE = True
CLUSTER_USER = True
DISTRIBUTED = False
PERMISSIONS = [<Mock id='139879885448592'>]
USER_PREFIX = 'mcv-connection-'
allow_proxy_user

Connection users can proxy for another user.

create_cluster_user(host)[source]

Create a cluster user for the remote node.

mcvirt.auth.factory module

Provide factory class to create/obtain users.

class mcvirt.auth.factory.Factory[source]

Bases: mcvirt.rpc.pyro_object.PyroObject

Class for obtaining user objects

USER_CLASS

alias of UserBase

add_config(username, user_config)[source]

Add a user config to the local node.

authenticate(username, password)[source]

Attempt to authenticate a user, using username/password.

create(username, password, user_type=<class 'mcvirt.auth.user.User'>)[source]

Create a user.

ensure_valid_user_type(user_type)[source]

Ensure that a given user_type is valid.

generate_user(user_type)[source]

Remove any existing connection user and generates credentials for a new connection user.

get_all_user_objects(user_class=None)[source]

Return the user objects for all users, optionally filtered by user type.

get_all_users()[source]

Return all the users, excluding built-in users.

get_cluster_user_by_node(node)[source]

Obtain a cluster user for a given node

get_user_by_username(username)[source]

Obtain a user object for the given username.

get_user_types()[source]

Return the available user classes.

mcvirt.auth.permissions module

Provide permission enum and permission group definitions.

mcvirt.auth.session module

Provide class for managing authentication sessions.

class mcvirt.auth.session.Session[source]

Bases: object

Handle daemon user sessions.

USER_SESSIONS = {}
authenticate_session(username, session)[source]

Authenticate user session.

authenticate_user(username, password)[source]

Authenticate using username/password and store session

get_current_user_object()[source]

Return the current user object, based on pyro session.

get_proxy_user_object()[source]

Return the user that is being proxied as.

mcvirt.auth.user module

Provide class for regular MCVirt interactive users

class mcvirt.auth.user.User(username)[source]

Bases: mcvirt.auth.user_base.UserBase

Provides an interaction with the local user backend

set_password(new_password)[source]

Change the current user’s password.

mcvirt.auth.user_base module

Provide a base class for user objects.

class mcvirt.auth.user_base.UserBase(username)[source]

Bases: mcvirt.rpc.pyro_object.PyroObject

Base object for users (both user and automated).

CAN_GENERATE = False
CLUSTER_USER = False
DISTRIBUTED = True
PERMISSIONS = []
USER_PREFIX = None
allow_proxy_user

Connection users can proxy for another user.

delete(*args, **kwargs)
static generate_password(length, numeric_only=False)[source]

Return a randomly generated password

get_config()[source]

Return the configuration of the user.

static get_default_config()[source]

Return the default configuration for the user type.

get_user_type()[source]

Return the user type of the user

get_username()[source]

Return the username of the current user

Module contents

mcvirt.client package

Submodules
mcvirt.client.rpc module

Provide class for connecting to RPC daemon

class mcvirt.client.rpc.Connection(username=None, password=None, session_id=None, host=None, ignore_cluster=False)[source]

Bases: object

Connection class, providing connections to the Pyro MCVirt daemon

NS_PORT = 9090
SESSION_OBJECT = 'session'
annotate_object(object_ref)[source]

Add authentication attributes to remote object

get_connection(object_name, password=None)[source]

Obtain a connection from pyro for a given object

ignore_cluster()[source]

Set flag to ignore cluster

ignore_drbd()[source]

Set flag to ignore DRBD

session_id

Property for the session ID

Module contents

mcvirt.cluster package

Submodules
mcvirt.cluster.cluster module

Provide cluster classes

class mcvirt.cluster.cluster.Cluster[source]

Bases: mcvirt.rpc.pyro_object.PyroObject

Class to perform node management within the MCVirt cluster

add_node(*args, **kwargs)
add_node_configuration(*args, **kwargs)
check_ip_configuration()[source]

Perform various checks to ensure that the IP configuration is such that is suitable to be part of a cluster

check_node_exists(node_name)[source]

Determine if a node is already present in the cluster

check_node_versions()[source]

Ensure that all nodes in the cluster are connected and checks the node Status

check_remote_machine(remote_connection)[source]

Perform checks on the remote node to ensure that there will be no object conflicts when syncing the Network and VM configurations

ensure_node_exists(node)[source]

Check if node exists and throws exception if it does not

generate_connection_info()[source]

Generate required information to connect to this node from a remote node

get_cluster_config()[source]

Get the MCVirt cluster configuration

get_cluster_ip_address()[source]

Return the cluster IP address of the local node

get_connection_string()[source]

Generate a string to connect to this node from a remote cluster

get_node_config(node)[source]

Return the configuration for a node

get_nodes(return_all=False)[source]

Return an array of node configurations

get_remote_node(node, ignore_cluster_master=False)[source]

Obtain a Remote object for a node, caching the object

print_info()[source]

Print information about the nodes in the cluster

remove_node(*args, **kwargs)
remove_node_configuration(node_name)[source]

Remove an MCVirt node from the configuration and regenerates authorized_keys file

remove_node_ssl_certificates(remote_node)[source]

Exposed method for _remove_node_ssl_certificates

run_remote_command(callback_method, nodes=None, args=[], kwargs={})[source]

Run a remote command on all (or a given list of) remote nodes

sync_networks(remote_object)[source]

Add the local networks to the remote node

sync_permissions(remote_object)[source]

Duplicate the global permissions on the local node onto the remote node

sync_users(remote_node)[source]

Synchronise the local users with the remote node

sync_virtual_machines(remote_object)[source]

Duplicate the VM configurations on the local node onto the remote node

mcvirt.cluster.remote module

Provide interface for RPC to cluster nodes

class mcvirt.cluster.remote.Node(name, node_config)[source]

Bases: mcvirt.client.rpc.Connection

A class to perform remote commands on MCVirt nodes

Module contents

mcvirt.iso package

Submodules
mcvirt.iso.factory module

Provide factory class for ISO

class mcvirt.iso.factory.Factory[source]

Bases: mcvirt.rpc.pyro_object.PyroObject

Class for obtaining ISO objects

ISO_CLASS

alias of Iso

add_from_url(*args, **kwargs)
add_iso(path)[source]

Copy an ISO to ISOs directory

add_iso_from_stream(*args, **kwargs)
get_iso_by_name(iso_name)[source]

Create and register Iso object

get_iso_list()[source]

Return a user-readable list of ISOs

get_isos()[source]

Return a list of a ISOs

class mcvirt.iso.factory.IsoWriter(temp_file, factory, temp_directory, path)[source]

Bases: mcvirt.rpc.pyro_object.PyroObject

Provide an interface for writing ISOs

write_data(data)[source]

Write data to the ISO file

write_end()[source]

End writing object, close FH and import ISO

mcvirt.iso.iso module

Provide class for managing ISO files

class mcvirt.iso.iso.Iso(name)[source]

Bases: mcvirt.rpc.pyro_object.PyroObject

Provides management of ISOs for use in MCVirt

delete()[source]

Delete an ISO

static get_filename_from_path(path, append_iso=True)[source]

Return filename part of path

get_name()[source]

Return the name of the ISO

get_path()[source]

Return the full path of the ISO

in_use

Determine if the ISO is currently in use by a VM

static overwrite_check(filename, path)[source]

Check if a file already exists at path. Ask user whether they want to overwrite. Returns True if they will overwrite, False otherwise

set_iso_permissions()[source]

Set permissions to 644

Module contents

mcvirt.node package

Subpackages
mcvirt.node.network package
Submodules
mcvirt.node.network.factory module

Provide class for generating network objects

class mcvirt.node.network.factory.Factory[source]

Bases: mcvirt.rpc.pyro_object.PyroObject

Class for obtaining network objects

OBJECT_TYPE = 'network'
check_exists(name)[source]

Check if a network exists

create(*args, **kwargs)
ensure_exists(name)[source]

Ensure network exists

get_all_network_names()[source]

Return a list of network names

get_all_network_objects()[source]

Return all network objects

get_network_by_name(network_name)[source]

Return a network object of the network for a given name.

get_network_list_table()[source]

Return a table of networks registered on the node

interface_exists(interface)[source]

Public method for to determine if an interface exists

mcvirt.node.network.network module

Provide interface to libvirt network objects

class mcvirt.node.network.network.Network(name)[source]

Bases: mcvirt.rpc.pyro_object.PyroObject

Provides an interface to LibVirt networks

delete(*args, **kwargs)
get_adapter()[source]

Return the name of the physical bridge adapter for the network

get_name()[source]

Return the name of the network

static get_network_config()[source]

Return the network configuration for the node

Module contents
Submodules
mcvirt.node.drbd module

Provides interface to mange the DRBD installation.

class mcvirt.node.drbd.Drbd[source]

Bases: mcvirt.rpc.pyro_object.PyroObject

Performs configuration of DRBD on the node

CLUSTER_SIZE = 2
CONFIG_DIRECTORY = '/etc/drbd.d'
DrbdADM = '/sbin/drbdadm'
GLOBAL_CONFIG = '/etc/drbd.d/global_common.conf'
GLOBAL_CONFIG_TEMPLATE = '/usr/lib/mcvirt/templates/drbd_global.conf'
adjust_drbd_config(resource='all')[source]

Perform a Drbd adjust, which updates the Drbd running configuration

enable(*args, **kwargs)
ensure_installed()[source]

Ensure that Drbd is installed on the node

generate_config()[source]

Generate the Drbd configuration

generate_secret()[source]

Generate a random secret for Drbd

get_all_drbd_hard_drive_object(include_remote=False)[source]

Obtain all hard drive objects that are backed by DRBD

get_config()[source]

Return the global Drbd configuration

static get_default_config()[source]

Return the default configuration for DRBD

get_used_drbd_minors()[source]

Return a list of used Drbd minor IDs

get_used_drbd_ports()[source]

Return a list of used Drbd ports

is_enabled()[source]

Determine whether Drbd is enabled on the node or not

is_installed()[source]

Determine if the ‘drbdadm’ command is present to determine if the ‘drbd8-utils’ package is installed

list()[source]

List the Drbd volumes and statuses

set_secret(secret)[source]

Set the Drbd configuration in the global MCVirt config file

mcvirt.node.libvirt_config module

Provide class to configure libvirtd

class mcvirt.node.libvirt_config.LibvirtConfig[source]

Bases: mcvirt.rpc.pyro_object.PyroObject

Provides configuration for libvirtd

CONFIG_FILE = '/etc/libvirt/libvirtd.conf'
CONFIG_TEMPLATE = '/usr/lib/mcvirt/templates/libvirtd.conf'
DEFAULT_CONFIG = '\n# Defaults for libvirtd initscript (/etc/init.d/libvirtd)\n# This is a POSIX shell fragment\n\n# Start libvirtd to handle qemu/kvm:\nstart_libvirtd="yes"\n\n# options passed to libvirtd, add "-l" to listen on tcp\nlibvirtd_opts=" --listen --verbose %s"\n'
DEFAULT_FILE = '/etc/default/%s'
generate_config()[source]

Generate the libvirtd configuration

get_config()[source]

Create the configuration for libvirt

get_service_name()[source]

Locate the libvirt service

mcvirt.node.node module

Perform configurations for local node.

class mcvirt.node.node.Node[source]

Bases: mcvirt.rpc.pyro_object.PyroObject

Provides methods to configure the local node.

clear_method_lock()[source]

Force clear a method lock to escape deadlock

get_version()[source]

Returns the version of the running daemon

is_volume_group_set()[source]

Determine if the volume group has been configured on the node

set_cluster_ip_address(*args, **kwargs)
set_storage_volume_group(*args, **kwargs)
Module contents

mcvirt.rpc package

Submodules
mcvirt.rpc.certificate_generator module

Provides class to generate and manage SSL certificates

class mcvirt.rpc.certificate_generator.CertificateGenerator(server=None, remote=False)[source]

Bases: mcvirt.rpc.pyro_object.PyroObject

Class for providing SSL socket wrappers for Pyro. Since the MCVirt isn’t available for 2/3 of the time that this is used (NS and CLI), all methods are static and paths are calculated manually. @TODO Fix this in future - create MCVirt config class.

OPENSSL = '/usr/bin/openssl'
add_public_key(key)[source]

Add the public key for a remote node

ca_key_file

Return/generate the CA prviate key.

ca_pub_file

Return/generate the CA pub file

check_certificates(check_client=True)[source]

Ensure that the required certificates are available to start the daemon and connect to the local host

client_csr

Return the client CSR

client_key_file

Obtain the private key for the client key

client_pub_file

Return/generate the client public file, used for connecting to the libvirt daemon

generate_csr()[source]

Generate a certificate request for the remote server

get_ca_contents()[source]

Return the contents of the local CA certificate

is_local

Determine if the server is the local machine

remote_ssl_directory

Return the ‘remote’ subdirectory of server, used for storing certificates that are used by a remote server.

remove_certificates()[source]

Remove a certificate directory for a node

server_key_file

Obtain the server private key file

server_pub_file

Obtain the server public key file

sign_csr(csr)[source]

Sign the CSR for a remote SSL certificate.

ssl_base_directory

Return the base SSL directory for the node.

ssl_directory

Return the SSL directory for the server

ssl_dn

“Return the certificate DN is openssl argument format.

ssl_subj

Return the SSL DN in regular format

mcvirt.rpc.certificate_generator_factory module

Provides an interface to obtain certificate generator objects

class mcvirt.rpc.certificate_generator_factory.CertificateGeneratorFactory[source]

Bases: mcvirt.rpc.pyro_object.PyroObject

Provides an interface to obtain certificate generator objects

get_cert_generator(server, remote=False)[source]

Obtain a certificate generator object for a given server

mcvirt.rpc.constants module

Provides constants for the RPC daemon

class mcvirt.rpc.constants.Annotations[source]

Bases: object

Pyro annotation names @TODO Move to main MCVIrt constants class

CLUSTER_MASTER = 'CLMA'
HAS_LOCK = 'HASL'
IGNORE_CLUSTER = 'IGCL'
IGNORE_Drbd = 'IGDR'
PASSWORD = 'PASS'
PROXY_USER = 'ALTU'
SESSION_ID = 'SEID'
USERNAME = 'USER'
mcvirt.rpc.daemon_lock module

Provides a locking mechanism for the MCVirt daemon

class mcvirt.rpc.daemon_lock.DaemonLock(timeout=2)[source]

Bases: object

Provides a lock for the MCVirt daemon

LOCK = None
mcvirt.rpc.lock module

Provides classes for locking the MCVirt daemon whilst a function is being performed

class mcvirt.rpc.lock.MethodLock[source]

Bases: object

Class for storing/generating/obtaining a lock object

classmethod get_lock()[source]

Obtain the lock object and return

mcvirt.rpc.lock.locking_method(object_type=None, instance_method=True)[source]

Provide a decorator method for locking the node whilst performing the method

mcvirt.rpc.name_server module

Thread for running the name server

class mcvirt.rpc.name_server.NameServer[source]

Bases: object

Thread for running the name server

start()[source]

Start the Pyro name server

mcvirt.rpc.pyro_object module

Base class for providing Pyro-based methods for objects

class mcvirt.rpc.pyro_object.PyroObject[source]

Bases: object

Base class for providing Pyro-based methods for objects

mcvirt.rpc.rpc_daemon module

Provide class for RPC daemon.

class mcvirt.rpc.rpc_daemon.BaseRpcDaemon(*args, **kwargs)[source]

Bases: Pyro4.core.Daemon

Override Pyro daemon to add authentication checks and MCVirt integration

validateHandshake(conn, data)[source]

Perform authentication on new connections

class mcvirt.rpc.rpc_daemon.DaemonSession[source]

Bases: object

Class for allowing client to obtain the session ID

get_session_id()[source]

Return the client’s current session ID

class mcvirt.rpc.rpc_daemon.RpcNSMixinDaemon[source]

Bases: object

Wrapper for the daemon. Required since the Pyro daemon class overrides get/setattr and other built-in object methods

DAEMON = None
obtain_connection()[source]

Attempt to obtain a connection to the name server.

register(obj_or_class, objectId, *args, **kwargs)[source]

Override register to register object with NS.

register_factories()[source]

Register base MCVirt factories with RPC daemon

shutdown(signum, frame)[source]

Shutdown Pyro Daemon

start(*args, **kwargs)[source]

Start the Pyro daemon

mcvirt.rpc.ssl_socket module

Provides methods for wrapping Pyro methods with SSL

class mcvirt.rpc.ssl_socket.SSLSocket[source]

Bases: object

Provides methods for wrapping Pyro methods with SSL

static create_broadcast_ssl_socket(*args, **kwargs)[source]

Override the Pyro createBroadcastSocket method and wrap with SSL

static create_ssl_socket(*args, **kwargs)[source]

Override the Pyro createSocket method and wrap with SSL

static wrap_socket(socket_object, *args, **kwargs)[source]

Wrap a Pyro socket connection with SSL

Module contents

mcvirt.test package

Subpackages
mcvirt.test.lock package
Submodules
mcvirt.test.lock.lock_tests module
class mcvirt.test.lock.lock_tests.LockTests(methodName='runTest')[source]

Bases: mcvirt.test.test_base.TestBase

Provide unit tests for the functionality provided by the node subparser

static suite()[source]

Return a test suite

test_method_lock_escape_return()[source]

Test whether locks can be cleared and clear_method_lock returns accurateley

test_method_lock_rpc()[source]

Test whether locks can be cleared over the RPC

Module contents
mcvirt.test.node package
Submodules
mcvirt.test.node.network_tests module
class mcvirt.test.node.network_tests.NetworkTests(methodName='runTest')[source]

Bases: mcvirt.test.test_base.TestBase

Test suite for performing tests on the network class

static suite()[source]

Return a test suite of the network tests

test_create()[source]

Test the creation of network through the argument parser

test_delete()[source]

Test deleting a network through the argument parser

test_delete_non_existent()[source]

Attempt to delete a non-existent network

test_delete_utilized()[source]

Attempt to remove a network that is in use by a VM

test_duplicate_name_create()[source]

Test attempting to create a network with a duplicate name through the argument parser

test_list()[source]

Attempt to use the parser to list the networks

mcvirt.test.node.node_tests module
class mcvirt.test.node.node_tests.NodeTests(methodName='runTest')[source]

Bases: mcvirt.test.test_base.TestBase

Provide unit tests for the functionality provided by the node subparser

setUp()[source]

Create various objects and deletes any test VMs

static suite()[source]

Return a test suite

tearDown()[source]

Reset any values changed to the MCVirt config

test_set_invalid_ip_address()[source]

Test the validity checks for IP addresses

test_set_invalid_volume_group()[source]

Test the validity checks for volume group name

test_set_ip_address()[source]

Change the cluster IP address using the argument parser

test_set_volume_group()[source]

Change the cluster IP address using the argument parser

Module contents
mcvirt.test.virtual_machine package
Subpackages
mcvirt.test.virtual_machine.hard_drive package
Submodules
mcvirt.test.virtual_machine.hard_drive.drbd_tests module
class mcvirt.test.virtual_machine.hard_drive.drbd_tests.DrbdTests(methodName='runTest')[source]

Bases: mcvirt.test.test_base.TestBase

Provides unit tests for the Drbd hard drive class

static suite()[source]

Return a test suite of the Virtual Machine tests

test_verify(*args)
Module contents
Submodules
mcvirt.test.virtual_machine.online_migrate_tests module
class mcvirt.test.virtual_machine.online_migrate_tests.LibvirtConnectorUnitTest[source]

Bases: mcvirt.libvirt_connector.LibvirtConnector

Override LibvirtConnector class to provide ability to cause connection errors whilst connecting to remote libvirt instances

get_connection(server=None)[source]
exception mcvirt.test.virtual_machine.online_migrate_tests.LibvirtFailureSimulationException[source]

Bases: mcvirt.exceptions.MCVirtException

A libvirt command has been simulated to fail

class mcvirt.test.virtual_machine.online_migrate_tests.OnlineMigrateTests(methodName='runTest')[source]

Bases: mcvirt.test.test_base.TestBase

Provides unit tests for the onlineMigrate function

RPC_DAEMON = None
setUp()[source]

Create various objects and deletes any test VMs

static suite()[source]

Return a test suite of the online migrate tests

tearDown()[source]

Stops and tears down any test VMs

test_migrate(*args)
test_migrate_drbd_not_connected(*args)
test_migrate_inappropriate_node(*args)
test_migrate_invalid_iso(*args)
test_migrate_invalid_network(*args)
test_migrate_invalid_node(*args)
test_migrate_libvirt_connection_failure(*args)
test_migrate_locked(*args)
test_migrate_post_migration_libvirt_failure(*args)
test_migrate_pre_migration_libvirt_failure(*args)
test_migrate_stopped_vm(*args)
test_migrate_unregistered(*args)
class mcvirt.test.virtual_machine.online_migrate_tests.VirtualMachineFactoryUnitTest[source]

Bases: mcvirt.virtual_machine.factory.Factory

getVirtualMachineByName(vm_name)[source]

Obtain a VM object, based on VM name

class mcvirt.test.virtual_machine.online_migrate_tests.VirtualMachineLibvirtFail(virtual_machine_factory, name)[source]

Bases: mcvirt.virtual_machine.virtual_machine.VirtualMachine

Override the VirtulMachine class to add overrides for simulating libvirt failures.

LIBVIRT_FAILURE_MODE
mcvirt.test.virtual_machine.virtual_machine_tests module
class mcvirt.test.virtual_machine.virtual_machine_tests.VirtualMachineTests(methodName='runTest')[source]

Bases: mcvirt.test.test_base.TestBase

Provide unit tests for the VirtualMachine class

static suite()[source]

Return a test suite of the Virtual Machine tests

test_clone_drbd(*args)
test_clone_local()[source]

Test the VM cloning in MCVirt using the argument parser

test_create(storage_type)[source]

Test the creation of VMs through the argument parser

test_create_alternative_driver()[source]

Create VMs using alternative hard drive drivers

test_create_drbd(*args)
test_create_drbd_not_enabled(*args)
test_create_duplicate()[source]

Attempt to create two VMs with the same name

test_create_local()[source]

Perform the test_create test with Local storage

test_delete(storage_type)[source]

Test the deletion of a VM through the argument parser

test_delete_drbd(*args)
test_delete_local()[source]

Perform the test_delete test with Local storage

test_duplicate(storage_type)[source]

Attempt to duplicate a VM using the argument parser and perform tests on the parent and duplicate VM

test_duplicate_drbd(*args)
test_duplicate_local()[source]

Perform test_duplicate test with Local storage

test_invalid_name()[source]

Attempt to create a virtual machine with an invalid name

test_invalid_network_name()[source]

Attempt to create a VM using a network that does not exist

test_live_iso_change()[source]

Change the ISO attached to a running VM

test_lock()[source]

Exercise VM locking

test_offline_migrate(*args)
test_reset()[source]

Reset a running VM

test_reset_stopped_vm()[source]

Attempt to reset a stopped VM

test_start(storage_type)[source]

Test starting VMs through the argument parser

test_start_drbd(*args)
test_start_local()[source]

Perform the test_start test with Local storage

test_start_running_vm()[source]

Attempt to start a running VM

test_stop(storage_type)[source]

Test stopping VMs through the argument parser

test_stop_drbd(*args)
test_stop_local()[source]

Perform the test_stop test with Local storage

test_stop_stopped_vm()[source]

Attempt to stop an already stopped VM

test_unspecified_storage_type_drbd(*args)
test_unspecified_storage_type_local(*args)
test_vm_directory_already_exists()[source]

Attempt to create a VM whilst the directory for the VM already exists

Module contents
Submodules
mcvirt.test.auth_tests module
class mcvirt.test.auth_tests.AuthTests(methodName='runTest')[source]

Bases: mcvirt.test.test_base.TestBase

Provides unit tests for the Auth class

TEST_PASSWORD = 'test-password'
TEST_USERNAME = 'test-user'
TEST_USERNAME_ALTERNATIVE = 'user-to-delete'
create_test_user(username, password)[source]

Create a test user, annotate the user object and return it

parse_command(command, username, password)[source]

Parse the specified command with the specified credentials

setUp()[source]

Set up a test user

static suite()[source]

Returns a test suite of the Auth tests

tearDown()[source]

Remove the test user

test_add_delete_superuser()[source]

Add/delete a user to/from the superuser role

test_add_duplicate_superuser()[source]

Attempts to add a superuser twice

test_add_new_user()[source]

Create a new user through the parser

test_add_remove_user_permission()[source]

Add a user to a virtual machine, using the argument parser

test_attempt_add_superuser_to_vm()[source]

Attempts to add a user as a superuser to a VM

test_change_password()[source]

Change the password of a user through the parser

test_delete_non_existant_superuser()[source]

Attempts to remove a non-existent user from the superuser group

test_remove_user_account()[source]

Delete a user through the parser

mcvirt.test.run_tests module
mcvirt.test.test_base module
class mcvirt.test.test_base.TestBase(methodName='runTest')[source]

Bases: unittest.case.TestCase

Provide base test case, with constructor/destructor for providing access to the parser and RPC

RPC_PASSWORD = 'pass'
RPC_USERNAME = 'mjc'
create_vm(vm_name, storage_type)[source]

Create a test VM, annotate object and ensure it exists

setUp()[source]

Obtain connections to the daemon and create various member variables.

stop_and_delete(vm_name)[source]

Stop and remove a virtual machine

tearDown()[source]

Destroy stored objects.

mcvirt.test.test_base.skip_drbd(required)[source]
mcvirt.test.unit_test_bootstrap module
class mcvirt.test.unit_test_bootstrap.UnitTestBootstrap[source]

Bases: object

Bootstrap daemon with unit tests

daemon_loop_condition()[source]

Provide a condition for the daemon loop

start()[source]

Start the daemon, run the unit tests and tear down

mcvirt.test.update_tests module
class mcvirt.test.update_tests.UpdateTests(methodName='runTest')[source]

Bases: mcvirt.test.test_base.TestBase

Provide unit tests for the functionality provided by the update subparser

setUp()[source]

Create network adapter factory

static suite()[source]

Return a test suite

tearDown()[source]

Tear down network adapter factory

test_remove_network()[source]

Remove a network interface from a VM, using the parser

test_remove_network_non_existant()[source]

Attempt to remove a network interface from a VM that doesn’t exist

mcvirt.test.validation_tests module
class mcvirt.test.validation_tests.ValidationTests(methodName='runTest')[source]

Bases: mcvirt.test.test_base.TestBase

Provides unit tests for validation

static suite()[source]

Return a test suite of validation tests

test_boolean()[source]

Test the validation of booleans

test_create_network()[source]

Test creating a netork with an invalid name to check that network creation uses ArgumentValidator

test_create_vm()[source]

Test an invalid VM name to check that VM creation uses ArgumentValidator

test_drbd_resource()[source]
test_hostnames()[source]

Test the validation of hostnames

test_integer()[source]

Test the validation of integers

test_network_names()[source]

Test the validation of network names

test_pos_integer()[source]

Test the validation of positive integers

test_validity(validator, valid_list, invalid_list, expected_exception=<type 'exceptions.TypeError'>)[source]

Use the provided validator function to test each string in valid_list and invalid_list, failing the test if expected_exception is raised for anything in valid_list, and failing if the exception is NOT raised for anything in invalid_list

Module contents

mcvirt.virtual_machine package

Subpackages
mcvirt.virtual_machine.hard_drive package
Submodules
mcvirt.virtual_machine.hard_drive.base module

Provide base operations to manage all hard drives, used by VMs

class mcvirt.virtual_machine.hard_drive.base.Base(vm_object, disk_id=None, driver=None)[source]

Bases: mcvirt.rpc.pyro_object.PyroObject

Provides base operations to manage all hard drives, used by VMs

DEFAULT_DRIVER
MAXIMUM_DEVICES = 1
SNAPSHOT_SIZE = '500M'
SNAPSHOT_SUFFIX = '_snapshot'
activateDisk()[source]

Activates the storage volume

activateLogicalVolume(*args, **kwargs)
addToVirtualMachine(*args, **kwargs)
clone(destination_vm_object)[source]

Clone a VM, using snapshotting, attaching it to the new VM object

config_properties

Return the disk object config items

create()[source]

Creates a new disk image, attaches the disk to the VM and records the disk in the VM configuration

createBackupSnapshot()[source]

Creates a snapshot of the logical volume for backing up and locks the VM

createLogicalVolume(*args, **kwargs)
deactivateDisk()[source]

Deactivates the storage volume

delete()[source]

Delete the logical volume for the disk

deleteBackupSnapshot()[source]

Deletes the backup snapshot for the disk and unlocks the VM

disk_id

Return the disk ID of the current disk, generating a new one if there is not already one present

driver

Return the disk drive driver name

duplicate(destination_vm_object)[source]

Clone the hard drive and attach it to the new VM object

getDiskConfig()[source]

Returns the disk configuration for the hard drive

getDiskPath()[source]

Exposed method for _getDiskPath

getSize()[source]

Gets the size of the disk (in MB)

get_remote_object(node_name=None, remote_node=None, registered=True)[source]

Obtain an instance of the current hard drive object on a remote node

get_type()[source]

Return the type of storage for the hard drive

increaseSize(*args, **kwargs)
static isAvailable(pyro_object)[source]

Returns whether the storage type is available on the node

move(destination_node, source_node)[source]

Moves the storage to another node in the cluster

postOnlineMigration()[source]

Performs post tasks after a VM has performed an online migration

preMigrationChecks(destination_node)[source]

Determines if the disk is in a state to allow the attached VM to be migrated to another node

preOnlineMigration()[source]

Performs required tasks in order for the underlying VM to perform an online migration

removeFromVirtualMachine(*args, **kwargs)
removeLogicalVolume(*args, **kwargs)
zeroLogicalVolume(*args, **kwargs)
mcvirt.virtual_machine.hard_drive.drbd module
class mcvirt.virtual_machine.hard_drive.drbd.Drbd(drbd_minor=None, drbd_port=None, *args, **kwargs)[source]

Bases: mcvirt.virtual_machine.hard_drive.base.Base

Provides operations to manage Drbd-backed hard drives, used by VMs

CACHE_MODE = 'none'
CREATE_PROGRESS
Drbd_CONFIG_TEMPLATE = '/usr/lib/mcvirt/templates/drbd_resource.conf'
Drbd_META_SUFFIX = 'meta'
Drbd_RAW_SUFFIX = 'raw'
Drbd_STATES = {'CONNECTION': {'CONNECTED': [<Mock id='139879884454480'>, <Mock id='139879883919696'>, <Mock id='139879895072464'>, <Mock id='139879886588880'>, <Mock id='139879881399312'>, <Mock id='139879878593616'>, <Mock id='139879881478992'>, <Mock id='139879886774672'>, <Mock id='139879887715920'>, <Mock id='139879879171856'>], 'WARNING': [<Mock id='139879893623312'>, <Mock id='139879893648592'>, <Mock id='139879893653392'>, <Mock id='139879893551696'>, <Mock id='139879893478672'>, <Mock id='139879893491664'>, <Mock id='139879893566160'>], 'OK': [<Mock id='139879883844432'>, <Mock id='139879890713104'>, <Mock id='139879890534800'>, <Mock id='139879890960912'>, <Mock id='139879890612624'>, <Mock id='139879884047888'>, <Mock id='139879884675856'>, <Mock id='139879886824016'>, <Mock id='139879896450832'>]}, 'DISK': {'WARNING': [<Mock id='139879890647824'>, <Mock id='139879890705872'>], 'OK': [<Mock id='139879890597968'>]}, 'ROLE': {'WARNING': [], 'OK': [<Mock id='139879893685648'>]}}
INITIAL_MINOR = 1
INITIAL_PORT = 7789
activateDisk()[source]

Ensure that the disk is ready to be used by a VM on the local node

config_properties

Return the disk object config items

create(size)[source]

Creates a new hard drive, attaches the disk to the VM and records the disk in the VM configuration

deactivateDisk()[source]

Marks Drbd volume as secondary

drbdConnect(*args, **kwargs)
drbdDisconnect(*args, **kwargs)
drbdDown(*args, **kwargs)
drbdGetConnectionState()[source]

Provide an exposed method for _drbdGetConnectionState

drbdGetDiskState()[source]

Provide an exposed method for drbdGetDiskState

drbdSetPrimary(*args, **kwargs)
drbdSetSecondary(*args, **kwargs)
drbdUp(*args, **kwargs)
drbd_minor

Returns the Drbd port assigned to the hard drive

drbd_port

Returns the Drbd port assigned to the hard drive

generateDrbdConfig(*args, **kwargs)
getSize()[source]

Gets the size of the disk (in MB)

initialiseMetaData(*args, **kwargs)
static isAvailable(pyro_object)[source]

Determine if Drbd is available on the node

move(destination_node, source_node)[source]

Replaces a remote node for the Drbd volume with a new node and syncs the data

postOnlineMigration()[source]

Performs post tasks after a VM has performed an online migration

preMigrationChecks()[source]

Ensures that the Drbd state of the disk is in a state suitable for migration

preOnlineMigration(destination_node)[source]

Performs required tasks in order for the underlying VM to perform an online migration

removeDrbdConfig(*args, **kwargs)
resource_name

Returns the Drbd resource name for the hard drive object

setSyncState(*args, **kwargs)
setTwoPrimariesConfig(*args, **kwargs)
verify()[source]

Performs a verification of a Drbd hard drive

mcvirt.virtual_machine.hard_drive.factory module
class mcvirt.virtual_machine.hard_drive.factory.Factory[source]

Bases: mcvirt.rpc.pyro_object.PyroObject

Provides a factory for creating hard drive/hard drive config objects

DEFAULT_STORAGE_TYPE = 'Local'
HARD_DRIVE_CLASS

alias of Base

OBJECT_TYPE = 'hard disk'
STORAGE_TYPES = [<class 'mcvirt.virtual_machine.hard_drive.local.Local'>, <class 'mcvirt.virtual_machine.hard_drive.drbd.Drbd'>]
create(*args, **kwargs)
getClass(storage_type)[source]

Obtains the hard drive class for a given storage type

getDrbdObjectByResourceName(resource_name)[source]

Obtains a hard drive object for a Drbd drive, based on the resource name

getObject(vm_object, disk_id, **config)[source]

Returns the storage object for a given disk

getStorageTypes()[source]

Returns the available storage types that MCVirt provides

mcvirt.virtual_machine.hard_drive.local module
class mcvirt.virtual_machine.hard_drive.local.Local(*args, **kwargs)[source]

Bases: mcvirt.virtual_machine.hard_drive.base.Base

Provides operations to manage local hard drives, used by VMs

CACHE_MODE = 'directsync'
MAXIMUM_DEVICES = 4
activateDisk()[source]

Starts the disk logical volume

clone(destination_vm_object)[source]

Clone a VM, using snapshotting, attaching it to the new VM object

create(size)[source]

Creates a new disk image, attaches the disk to the VM and records the disk in the VM configuration

deactivateDisk()[source]

Deactivates the disk loglcal volume

getSize()[source]

Gets the size of the disk (in MB)

increaseSize(*args, **kwargs)
static isAvailable(pyro_object)[source]

Determine if local storage is available on the node

preMigrationChecks()[source]

Perform pre-migration checks

Module contents
mcvirt.virtual_machine.network_adapter package
Submodules
mcvirt.virtual_machine.network_adapter.factory module
class mcvirt.virtual_machine.network_adapter.factory.Factory[source]

Bases: mcvirt.rpc.pyro_object.PyroObject

Factory method to create/obtain network adapter instances

NETWORK_ADAPTER_CLASS

alias of NetworkAdapter

OBJECT_TYPE = 'network adapter'
create(*args, **kwargs)
getNetworkAdapterByMacAdress(virtual_machine, mac_address)[source]

Returns the network adapter by a given MAC address

getNetworkAdaptersByVirtualMachine(virtual_machine)[source]

Returns an array of network interface objects for each of the interfaces attached to the VM

mcvirt.virtual_machine.network_adapter.network_adapter module

Provide class for network adapters.

class mcvirt.virtual_machine.network_adapter.network_adapter.NetworkAdapter(mac_address, vm_object)[source]

Bases: mcvirt.rpc.pyro_object.PyroObject

Provides operations to network interfaces attached to a VM

delete(*args, **kwargs)
static generateMacAddress()[source]

Generates a random MAC address for new VM network interfaces

getConnectedNetwork()[source]

Returns the network that a given interface is connected to

getLibvirtConfig()[source]

Returns a dict of the LibVirt configuration for the network interface

getMacAddress()[source]

Returns the MAC address of the current network object

get_config()[source]

Returns a dict of the MCVirt configuration for the network interface

Module contents
Submodules
mcvirt.virtual_machine.disk_drive module
class mcvirt.virtual_machine.disk_drive.DiskDrive(vm_object)[source]

Bases: mcvirt.rpc.pyro_object.PyroObject

Provides operations to manage the disk drive attached to a VM

attachISO(iso_object, live=False)[source]

Attaches an ISO image to the disk drive of the VM

getCurrentDisk()[source]

Returns the path of the disk currently attached to the VM

preOnlineMigrationChecks(destination_node_name)[source]

Performs pre-online-migration checks

removeISO()[source]

Removes ISO attached to the disk drive of a VM

mcvirt.virtual_machine.factory module
class mcvirt.virtual_machine.factory.Factory[source]

Bases: mcvirt.rpc.pyro_object.PyroObject

Class for obtaining virtual machine objects

OBJECT_TYPE = 'virtual machine'
VIRTUAL_MACHINE_CLASS

alias of VirtualMachine

checkName(name, ignore_exists=False)[source]
check_exists(vm_name)[source]

Determines if a VM exists, given a name

create(*args, **kwargs)
getAllVirtualMachines()[source]

Return objects for all virtual machines

getAllVmNames(node=None)[source]

Returns a list of all VMs within the cluster or those registered on a specific node

getVirtualMachineByName(vm_name)[source]

Obtain a VM object, based on VM name

listVms(*args, **kwargs)
mcvirt.virtual_machine.virtual_machine module

Provides virtual machine class.

class mcvirt.virtual_machine.virtual_machine.VirtualMachine(virtual_machine_factory, name)[source]

Bases: mcvirt.rpc.pyro_object.PyroObject

Provides operations to manage a LibVirt virtual machine.

OBJECT_TYPE = 'virtual machine'
clone(*args, **kwargs)
delete(*args, **kwargs)
duplicate(*args, **kwargs)
editConfig(*args, **kwargs)
ensureRegistered()[source]

Ensures that the VM is registered

ensureRegisteredLocally()[source]

Ensures that the VM is registered locally, otherwise an exception is thrown

ensureUnlocked()[source]

Ensures that the VM is in an unlocked state

getAvailableNodes()[source]

Returns the nodes that the VM can be run on

getCPU()[source]

Returns the number of CPU cores attached to the VM

getCloneChildren()[source]

Returns the VMs that have been cloned from the VM

getCloneParent()[source]

Determines if a VM is a clone of another VM

getHardDriveObjects()[source]

Returns an array of disk objects for the disks attached to the VM

getInfo()[source]

Gets information about the current VM

getLibvirtConfig()[source]

Returns an XML object of the libvirt configuration for the domain

getLockState()[source]
getNode()[source]

Returns the node that the VM is registered on

getPowerState()[source]
getRAM()[source]

Returns the amount of memory attached the VM

getStorageType()[source]

Returns the storage type of the VM

getVncPort()[source]

Returns the port used by the VNC display for the VM

get_config_object()[source]

Return the configuration object for the VM

get_disk_drive()[source]

Returns a disk drive object for the VM

get_libvirt_xml()[source]

Obtain domain XML from libvirt

get_name()[source]

Return the name of the VM

get_remote_object()[source]

Return a instance of the virtual machine object on the machine that the VM is registered

isRegistered()[source]

Returns true if the VM is registered on a node

isRegisteredLocally()[source]

Returns true if the VM is registered on the local node

isRegisteredRemotely()[source]

Returns true if the VM is registered on a remote node

move(*args, **kwargs)
offlineMigrate(*args, **kwargs)
onlineMigrate(*args, **kwargs)
register(*args, **kwargs)
reset(*args, **kwargs)
setBootOrder(boot_devices)[source]

Sets the boot devices and the order in which devices are booted from

setLockState(lock_status)[source]
setNode(node)[source]
setNodeRemote(*args, **kwargs)
start(*args, **kwargs)
stop(*args, **kwargs)
unregister(*args, **kwargs)
updateCPU(*args, **kwargs)
updateRAM(*args, **kwargs)
update_config(attribute_path, value, reason)[source]

Updates a VM configuration attribute and replicates change across all nodes

mcvirt.virtual_machine.virtual_machine_config module
class mcvirt.virtual_machine.virtual_machine_config.VirtualMachineConfig(vm_object)[source]

Bases: mcvirt.config_file.ConfigFile

Provides operations to obtain and set the MCVirt configuration for a VM

static create(vm_name, available_nodes, cpu_cores, memory_allocation)[source]

Creates a basic VM configuration for new VMs

static get_config_path(vm_name)[source]

Provides the path of the VM-spefic configuration file

Module contents

Submodules

mcvirt.argument_validator module

Argument validators.

class mcvirt.argument_validator.ArgumentValidator[source]

Bases: object

Provide methods to validate argument values

static validate_boolean(variable)[source]

Ensure variable is a boolean

static validate_drbd_resource(variable)[source]

Validate DRBD resource name

static validate_hostname(hostname)[source]

Validate a hostname

static validate_integer(value)[source]

Validate integer

static validate_network_name(name)[source]

Validate the name of a network

static validate_positive_integer(value)[source]

Validate that a given variable is a positive integer

mcvirt.bash-complete module

mcvirt.config_file module

Provide base class for configuration files

class mcvirt.config_file.ConfigFile[source]

Bases: object

Provides operations to obtain and set the MCVirt configuration for a VM

CURRENT_VERSION = 4
GIT = '/usr/bin/git'
static create()[source]

Creates a basic VM configuration for new VMs

getPermissionConfig()[source]
get_config()[source]

Load the VM configuration from disk and returns the parsed JSON.

static get_config_path(vm_name)[source]

Provide the path of the VM-specific configuration file

gitAdd(message='')[source]

Commits changes to an added or modified configuration file

gitRemove(message='')[source]

Removes and commits a configuration file

setConfigPermissions()[source]

Sets file permissions for config directories

update_config(callback_function, reason='')[source]

Write a provided configuration back to the configuration file.

upgrade()[source]

Performs an upgrade of the config file

mcvirt.constants module

Provide constants used throughout MCVirt.

class mcvirt.constants.DirectoryLocation[source]

Bases: object

Provides directory/file path constants.

BASE_STORAGE_DIR = '/var/lib/mcvirt'
BASE_VM_STORAGE_DIR = '/var/lib/mcvirt/build-4189623-project-52530-mcvirt/vm'
ISO_STORAGE_DIR = '/var/lib/mcvirt/build-4189623-project-52530-mcvirt/iso'
LOCK_FILE = '/var/run/lock/mcvirt/lock'
LOCK_FILE_DIR = '/var/run/lock/mcvirt'
LOG_FILE = '/var/log/mcvirt.log'
NODE_STORAGE_DIR = '/var/lib/mcvirt/build-4189623-project-52530-mcvirt'
TEMPLATE_DIR = '/usr/lib/mcvirt/templates'

mcvirt.exceptions module

Provide access to all MCVirt exceptions.

exception mcvirt.exceptions.ArgumentParserException[source]

Bases: mcvirt.exceptions.MCVirtException

An invalid argument was provided

exception mcvirt.exceptions.AttributeAlreadyChanged[source]

Bases: mcvirt.exceptions.MCVirtException

Attribute, user is trying to change, has already changed

exception mcvirt.exceptions.AuthenticationError[source]

Bases: mcvirt.exceptions.MCVirtException

Incorrect credentials

exception mcvirt.exceptions.BackupSnapshotAlreadyExistsException[source]

Bases: mcvirt.exceptions.MCVirtException

The backup snapshot for the logical volume already exists

exception mcvirt.exceptions.BackupSnapshotDoesNotExistException[source]

Bases: mcvirt.exceptions.MCVirtException

The backup snapshot for the logical volume does not exist

exception mcvirt.exceptions.BlankPasswordException[source]

Bases: mcvirt.exceptions.MCVirtException

The provided password is blank

exception mcvirt.exceptions.CACertificateAlreadyExists[source]

Bases: mcvirt.exceptions.MCVirtException

CA file for server already exists

exception mcvirt.exceptions.CACertificateNotFoundException[source]

Bases: mcvirt.exceptions.MCVirtException

CA certificate for host could not be found

exception mcvirt.exceptions.CAFileAlreadyExists[source]

Bases: mcvirt.exceptions.MCVirtException

The CA file already exists.

exception mcvirt.exceptions.CannotCloneDrbdBasedVmsException[source]

Bases: mcvirt.exceptions.MCVirtException

Cannot clone Drbd-based VMs

exception mcvirt.exceptions.CannotDeleteClonedVmException[source]

Bases: mcvirt.exceptions.MCVirtException

Cannot delete a cloned VM

exception mcvirt.exceptions.CannotMigrateLocalDiskException[source]

Bases: mcvirt.exceptions.MCVirtException

Local disks cannot be migrated

exception mcvirt.exceptions.CannotStartClonedVmException[source]

Bases: mcvirt.exceptions.MCVirtException

Cloned VMs cannot be started

exception mcvirt.exceptions.ClusterNotInitialisedException[source]

Bases: mcvirt.exceptions.MCVirtException

The cluster has not been initialised, so cannot connect to the remote node

exception mcvirt.exceptions.ConfigFileCouldNotBeFoundException[source]

Bases: mcvirt.exceptions.MCVirtException

Config file could not be found

exception mcvirt.exceptions.ConnectionFailureToRemoteLibvirtInstance[source]

Bases: mcvirt.exceptions.MCVirtException

Connection failure whilst attempting to obtain a remote libvirt connection

exception mcvirt.exceptions.CouldNotConnectToNodeException[source]

Bases: mcvirt.exceptions.MCVirtException

Could not connect to remove cluster node

exception mcvirt.exceptions.CurrentUserError[source]

Bases: mcvirt.exceptions.MCVirtException

Error whilst obtaining current pyro user

exception mcvirt.exceptions.DiskAlreadyExistsException[source]

Bases: mcvirt.exceptions.MCVirtException

The disk already exists

exception mcvirt.exceptions.DrbdAlreadyEnabled[source]

Bases: mcvirt.exceptions.MCVirtException

Drbd has already been enabled on this node

exception mcvirt.exceptions.DrbdBlockDeviceDoesNotExistException[source]

Bases: mcvirt.exceptions.MCVirtException

Drbd block device does not exist

exception mcvirt.exceptions.DrbdNotEnabledOnNode[source]

Bases: mcvirt.exceptions.MCVirtException

Drbd volumes cannot be created on a node that has not been configured to use Drbd

exception mcvirt.exceptions.DrbdNotInstalledException[source]

Bases: mcvirt.exceptions.MCVirtException

Drbd is not installed

exception mcvirt.exceptions.DrbdStateException[source]

Bases: mcvirt.exceptions.MCVirtException

The Drbd state is not OK

exception mcvirt.exceptions.DrbdVolumeNotInSyncException[source]

Bases: mcvirt.exceptions.MCVirtException

The last Drbd verification of the volume failed

exception mcvirt.exceptions.DuplicatePermissionException[source]

Bases: mcvirt.exceptions.MCVirtException

User already exists in group

exception mcvirt.exceptions.ExternalStorageCommandErrorException[source]

Bases: mcvirt.exceptions.MCVirtException

An error occurred whilst performing an external command

exception mcvirt.exceptions.FailedToRemoveFileException[source]

Bases: mcvirt.exceptions.MCVirtException

A failure occurred whilst trying to remove an ISO

exception mcvirt.exceptions.HardDriveDoesNotExistException[source]

Bases: mcvirt.exceptions.MCVirtException

The given hard drive does not exist

exception mcvirt.exceptions.InaccessibleNodeException[source]

Bases: mcvirt.exceptions.MCVirtException, Pyro4.errors.SecurityError

Unable to connect to node in the cluster

exception mcvirt.exceptions.IncorrectCredentials[source]

Bases: mcvirt.exceptions.MCVirtException

The supplied credentials are incorrect

exception mcvirt.exceptions.InsufficientPermissionsException[source]

Bases: mcvirt.exceptions.MCVirtException

User does not have the required permission

exception mcvirt.exceptions.InterfaceDoesNotExist[source]

Bases: mcvirt.exceptions.MCVirtException

Physical interface does not exist

exception mcvirt.exceptions.InvalidArgumentException[source]

Bases: mcvirt.exceptions.MCVirtException

Argument given is not valid

exception mcvirt.exceptions.InvalidConnectionString[source]

Bases: mcvirt.exceptions.MCVirtException

Connection string is invalid

exception mcvirt.exceptions.InvalidIPAddressException[source]

Bases: mcvirt.exceptions.MCVirtException

The specified IP address is invalid

exception mcvirt.exceptions.InvalidISOPathException[source]

Bases: mcvirt.exceptions.MCVirtException

ISO to add does not exist

exception mcvirt.exceptions.InvalidNodesException[source]

Bases: mcvirt.exceptions.MCVirtException

The nodes passed is invalid

exception mcvirt.exceptions.InvalidPermissionGroupException[source]

Bases: mcvirt.exceptions.MCVirtException

Attempted to perform actions on an invalid permission group

exception mcvirt.exceptions.InvalidUserTypeException[source]

Bases: mcvirt.exceptions.MCVirtException

An invalid user type was specified.

exception mcvirt.exceptions.InvalidUsernameException[source]

Bases: mcvirt.exceptions.MCVirtException

Username is within a reserved namespace

exception mcvirt.exceptions.InvalidVirtualMachineNameException[source]

Bases: mcvirt.exceptions.MCVirtException

VM is being created with an invalid name

exception mcvirt.exceptions.InvalidVolumeGroupNameException[source]

Bases: mcvirt.exceptions.MCVirtException

The specified name of the volume group is invalid

exception mcvirt.exceptions.IsoAlreadyExistsException[source]

Bases: mcvirt.exceptions.MCVirtException

An ISO with the same name already exists

exception mcvirt.exceptions.IsoInUseException[source]

Bases: mcvirt.exceptions.MCVirtException

The ISO is in use, so cannot be removed

exception mcvirt.exceptions.IsoNotPresentOnDestinationNodeException[source]

Bases: mcvirt.exceptions.MCVirtException

ISO attached to VM does not exist on destination node whilst performing a migration]

exception mcvirt.exceptions.LibVirtConnectionException[source]

Bases: mcvirt.exceptions.MCVirtException

An error ocurred whilst connecting to LibVirt

exception mcvirt.exceptions.LibvirtException[source]

Bases: mcvirt.exceptions.MCVirtException

Issue with performing libvirt command

exception mcvirt.exceptions.LibvirtNotInstalledException[source]

Bases: mcvirt.exceptions.MCVirtException

Libvirt does not appear to be installed

exception mcvirt.exceptions.LogicalVolumeDoesNotExistException[source]

Bases: mcvirt.exceptions.MCVirtException

A required logical volume does not exist

exception mcvirt.exceptions.MCVirtCommandException[source]

Bases: mcvirt.exceptions.MCVirtException

Provides an exception to be thrown after errors whilst calling external commands

exception mcvirt.exceptions.MCVirtException[source]

Bases: exceptions.Exception

Provides an exception to be thrown for errors in MCVirt

exception mcvirt.exceptions.MCVirtLockException[source]

Bases: mcvirt.exceptions.MCVirtException

A lock has already been found

exception mcvirt.exceptions.MigrationFailureExcpetion[source]

Bases: mcvirt.exceptions.MCVirtException

A Libvirt Exception occurred whilst performing a migration

exception mcvirt.exceptions.MissingConfigurationException[source]

Bases: mcvirt.exceptions.MCVirtException

Configuration is missing

exception mcvirt.exceptions.MustGenerateCertificateException[source]

Bases: mcvirt.exceptions.MCVirtException

The certificate cannot be manually added and must be generated

exception mcvirt.exceptions.NameNotSpecifiedException[source]

Bases: mcvirt.exceptions.MCVirtException

A name has not been specified and cannot be determined by the path/URL

exception mcvirt.exceptions.NetworkAdapterDoesNotExistException[source]

Bases: mcvirt.exceptions.MCVirtException

The network adapter does not exist

exception mcvirt.exceptions.NetworkAlreadyExistsException[source]

Bases: mcvirt.exceptions.MCVirtException

Network already exists with the same name

exception mcvirt.exceptions.NetworkDoesNotExistException[source]

Bases: mcvirt.exceptions.MCVirtException

Network does not exist

exception mcvirt.exceptions.NetworkUtilizedException[source]

Bases: mcvirt.exceptions.MCVirtException

Network is utilized by virtual machines

exception mcvirt.exceptions.NodeAlreadyPresent[source]

Bases: mcvirt.exceptions.MCVirtException

Node being added is already connected to cluster

exception mcvirt.exceptions.NodeAuthenticationException[source]

Bases: mcvirt.exceptions.MCVirtException

Incorrect password supplied for remote node

exception mcvirt.exceptions.NodeDoesNotExistException[source]

Bases: mcvirt.exceptions.MCVirtException

The node does not exist

exception mcvirt.exceptions.NodeVersionMismatch[source]

Bases: Pyro4.errors.SecurityError

A node is running a different version of MCVirt

exception mcvirt.exceptions.OpenSSLNotFoundException[source]

Bases: mcvirt.exceptions.MCVirtException

The OpenSSL executable could not be found

exception mcvirt.exceptions.PasswordsDoNotMatchException[source]

Bases: mcvirt.exceptions.MCVirtException

The new passwords do not match

exception mcvirt.exceptions.ReachedMaximumStorageDevicesException[source]

Bases: mcvirt.exceptions.MCVirtException

Reached the limit to number of hard disks attached to VM

exception mcvirt.exceptions.RemoteCommandExecutionFailedException[source]

Bases: mcvirt.exceptions.MCVirtException

A remote command execution fails

exception mcvirt.exceptions.RemoteNodeLockedException[source]

Bases: mcvirt.exceptions.MCVirtException

Remote node is locked

exception mcvirt.exceptions.RemoteObjectConflict[source]

Bases: mcvirt.exceptions.MCVirtException

The remote node contains an object that will cause conflict when syncing

exception mcvirt.exceptions.StorageTypeNotSpecified[source]

Bases: mcvirt.exceptions.MCVirtException

Storage type has not been specified

exception mcvirt.exceptions.StorageTypesCannotBeMixedException[source]

Bases: mcvirt.exceptions.MCVirtException

Storage types cannot be mixed within a single VM

exception mcvirt.exceptions.UnknownRemoteCommandException[source]

Bases: mcvirt.exceptions.MCVirtException

An unknown command was passed to the remote machine

exception mcvirt.exceptions.UnknownStorageTypeException[source]

Bases: mcvirt.exceptions.MCVirtException

An hard drive object with an unknown disk type has been initialised

exception mcvirt.exceptions.UnprivilegedUserException[source]

Bases: mcvirt.exceptions.MCVirtException

Unprivileged user running executable

exception mcvirt.exceptions.UnsuitableNodeException[source]

Bases: mcvirt.exceptions.MCVirtException

The node is unsuitable to run the VM

exception mcvirt.exceptions.UserAlreadyExistsException[source]

Bases: mcvirt.exceptions.MCVirtException

The given user already exists.

exception mcvirt.exceptions.UserDoesNotExistException[source]

Bases: mcvirt.exceptions.MCVirtException

The specified user does not exist

exception mcvirt.exceptions.UserNotPresentInGroup[source]

Bases: mcvirt.exceptions.MCVirtException

User to be removed from group is not in the group

exception mcvirt.exceptions.VirtualMachineDoesNotExistException[source]

Bases: mcvirt.exceptions.MCVirtException

Virtual machine does not exist

exception mcvirt.exceptions.VirtualMachineLockException[source]

Bases: mcvirt.exceptions.MCVirtException

Lock cannot be set to the current lock state

exception mcvirt.exceptions.VmAlreadyExistsException[source]

Bases: mcvirt.exceptions.MCVirtException

VM is being created with a duplicate name

exception mcvirt.exceptions.VmAlreadyRegisteredException[source]

Bases: mcvirt.exceptions.MCVirtException

VM is already registered on a node

exception mcvirt.exceptions.VmAlreadyStartedException[source]

Bases: mcvirt.exceptions.MCVirtException

VM is already started when attempting to start it

exception mcvirt.exceptions.VmAlreadyStoppedException[source]

Bases: mcvirt.exceptions.MCVirtException

VM is already stopped when attempting to stop it

exception mcvirt.exceptions.VmDirectoryAlreadyExistsException[source]

Bases: mcvirt.exceptions.MCVirtException

Directory for a VM already exists

exception mcvirt.exceptions.VmIsCloneException[source]

Bases: mcvirt.exceptions.MCVirtException

VM is a clone

exception mcvirt.exceptions.VmNotRegistered[source]

Bases: mcvirt.exceptions.MCVirtException

The virtual machine is not currently registered on a node

exception mcvirt.exceptions.VmRegisteredElsewhereException[source]

Bases: mcvirt.exceptions.MCVirtException

Attempt to perform an action on a VM registered on another node

exception mcvirt.exceptions.VmRunningException[source]

Bases: mcvirt.exceptions.MCVirtException

An offline migration can only be performed on a powered off VM

exception mcvirt.exceptions.VmStoppedException[source]

Bases: mcvirt.exceptions.MCVirtException

An online migraiton can only be performed on a powered on VM

exception mcvirt.exceptions.VncNotEnabledException[source]

Bases: mcvirt.exceptions.MCVirtException

VNC is not enabled on the VM

mcvirt.exceptions.exception_class

alias of InaccessibleNodeException

mcvirt.libvirt_connector module

class mcvirt.libvirt_connector.LibvirtConnector[source]

Bases: mcvirt.rpc.pyro_object.PyroObject

Obtains/manages Libvirt connections

get_connection(server=None)[source]

Obtains a Libvirt connection for a given server

mcvirt.logger module

class mcvirt.logger.LogItem(method, user, object_name, object_type)[source]

Bases: object

description
finish_error(exception)[source]
finish_error_unknown(exception)[source]
finish_success()[source]
start()[source]
class mcvirt.logger.LogState[source]

Bases: object

FAILED = {'status': 3, 'name': 'FAILED'}
QUEUED = {'status': 0, 'name': 'QUEUED'}
RUNNING = {'status': 1, 'name': 'RUNNING'}
SUCCESS = {'status': 2, 'name': 'SUCCESS'}
class mcvirt.logger.Logger[source]

Bases: mcvirt.rpc.pyro_object.PyroObject

LOGS = []
create_log(method, user, object_name, object_type)[source]
get_logs(start_log=None, back=0, newer=False)[source]
mcvirt.logger.getLogNames(callback, instance_method, object_type, args, kwargs)[source]

Attempts to determine object name and object type, based on method

mcvirt.mcvirt-drbd module

mcvirt.mcvirt_config module

class mcvirt.mcvirt_config.MCVirtConfig[source]

Bases: mcvirt.config_file.ConfigFile

Provides operations to obtain and set the MCVirt configuration for a VM

create()[source]

Create a basic VM configuration for new VMs

getListenAddress()[source]

Return the address that should be used for listening for connections - the stored IP address, if configured, else all interfaces

mcvirt.parser module

Provides argument parser.

class mcvirt.parser.Parser(verbose=True)[source]

Bases: object

Provides an argument parser for MCVirt.

parse_arguments(script_args=None)[source]

Parse arguments and performs actions based on the arguments.

print_status(status)[source]

Print if the user has specified that the parser should print statuses.

class mcvirt.parser.ThrowingArgumentParser(prog=None, usage=None, description=None, epilog=None, version=None, parents=[], formatter_class=<class 'argparse.HelpFormatter'>, prefix_chars='-', fromfile_prefix_chars=None, argument_default=None, conflict_handler='error', add_help=True)[source]

Bases: argparse.ArgumentParser

Override the ArgumentParser class, in order to change the handling of errors.

error(message)[source]

Override the error function.

mcvirt.syslogger module

class mcvirt.syslogger.Syslogger[source]

Bases: object

Provide interface for logging to log file

LOGGER_INSTANCE = None
static get_log_level()[source]

Return the log level, set either by environmental variable or configuration in MCVirt config

static logger()[source]

Obtain logger instance if not already create, else return cached object

mcvirt.system module

class mcvirt.system.System[source]

Bases: object

static getNewPassword()[source]

Prompts the user for a new password, throwing an exception is the password is not repeated correctly

static getUserInput(display_text, password=False)[source]

Prompts the user for input

static runCommand(command_args, raise_exception_on_failure=True, cwd=None)[source]

Runs system command, throwing an exception if the exit code is not 0

mcvirt.utils module

mcvirt.utils.get_all_submodules(target_class)[source]

Returns all inheriting classes, recursively

mcvirt.utils.get_hostname()[source]

Returns the hostname of the system

mcvirt.version module

Module contents

Indices and tables