Pythonic Classes

VM

The top level VM object holds common methods for VMs.

It should not be instanciated directly - use the lower level TemplateVM and AppVM objects instead.

class pyqubes.vm.VM(name, proactive=False, operating_system='fedora-23')[source]

The VM object represants a QubesOS VM. Its methods are common accross both AppVMs and TemplateVMs.

VM should not be instanciated directly - use TemplateVM or AppVM.

By default, all VMs are Fedora 23 based. Other values are listed in pyqubes.constants

enact(args)[source]

Enact a list of command arguments using the VM’s enact_function

Any one of the functions in pyqubes.qubes,``pyqubes.qubesdb`` or pyqubes.qvm will return arguments in the correct format.

firewall(**kwargs)[source]

Edit the VM firewall

firewall_close()[source]

Can be explicity called to close the VM firewall to ‘deny’.

firewall_open()[source]

Can be explicity called to open the VM firewall to ‘allow’.

In most cases you should use``with vm.internet``:

vm = TemplateVM('foo')
with vm.animate:
    # Templates are offline be default
    with vm.internet:
        # Template now has unrestricted internet access
        vm.run('curl http://ipecho.net/plain')
    # Firewall is restored automatically
    # This will now fail
    vm.run('curl http://ipecho.net/plain')
info(info)[source]

Echo information from pyqubes using the VM’s enact method

remove(**kwargs)[source]

Remove the VM

run(command, quote=True, **kwargs)[source]

Run a command on the VM.

Please note: * --pass-io is always set, to run commands synchronously * Commands are automatically encapsulated in single quotes:

vm = TemplateVM('spam')
vm.run('echo "foo bar"')
# produces: qvm-run spam 'echo "foo bar"'
Parameters:quote (bool) – By default command is single quoted - set False to disable
shutdown(**kwargs)[source]

Shutdown the

Please note: * --wait is always set, to run commands synchronously

start(**kwargs)[source]

Start the VM explicitly.

In most cases you should use``with vm.animate``:

vm = TemplateVM('foo')
# Template is not started on instanciation
with vm.animate:
    # Template is now running
    vm.update()
# VM is shut down automatically

TeamplateVM & AppVM

These represent the actual VMs within QubesOS.

Methods mentioned here are specific to the VM type.

class pyqubes.vm.TemplateVM(*args, **kwargs)[source]

TemplateVM - for installing apps

clone(clone_name, **kwargs)[source]

Clone the TemplateVM and return a new TemplateVM

Parameters:clone_name (string) – Name of the new VM
Returns:The new TemplateVM instance
create_app(app_name, **kwargs)[source]

Create and return a new AppVM based on the TemplateVM.

Please note: * If label is not set, it will default to red

Parameters:app_name (string) – Name of the new VM
Returns:The new AppVM instance
update()[source]

Smartly runs the relevant package manager updates for the TemplateVM

class pyqubes.vm.AppVM(*args, **kwargs)[source]

AppVM - for running apps

Helper Classes