cfme.common.vm module

Module containing classes with common behaviour for both VMs and Instances of all types.

class cfme.common.vm.BaseVM(name, provider, template_name=None, appliance=None)[source]

Bases: cfme.utils.pretty.Pretty, cfme.utils.update.Updateable, cfme.common.PolicyProfileAssignable, cfme.common.WidgetasticTaggable, cfme.common.SummaryMixin, cfme.utils.appliance.Navigatable

Base VM and Template class that holds the largest common functionality between VMs, instances, templates and images.

In order to inherit these, you have to implement the on_details method.

REMOVE_SELECTED = {'': 'Remove selected items from the VMDB', '5.6': 'Remove selected items', '5.7': 'Remove selected items'}
REMOVE_SINGLE = {'': 'Remove from the VMDB', '5.6': 'Remove Virtual Machine', '5.7': 'Remove Virtual Machine'}
RETIRE_DATE_FMT = {Version('lowest'): '%m/%d/%y', '5.7': '%m/%d/%y %H:%M UTC'}

Initiates compliance check and waits for it to finish.

TODO This should be refactored as it’s done Host.check_compliance. It shouldn’t return anything. compliant property should use compliance_status.


Returns the title of the compliance infoblock. The title contains datetime so it can be compared.

Returns:NoneType if no title is present (no compliance checks before), otherwise str

Check if the VM is compliant

Returns:NoneType if the VM was never verified, otherwise bool

The basic algorithm for getting the consoles window handle is to get the appliances window handle and then iterate through the window_handles till we find one that is not the appliances window handle. Once we find this check that it has a canvas widget with a specific ID

delete(cancel=False, from_details=False)[source]

Deletes the VM/Instance from the VMDB.

  • cancel – Whether to cancel the action in the alert.
  • from_details – Whether to use the details view or list view.
edit_form = <cfme.web_ui.Form fields=[('custom_ident', <cfme.web_ui.Input _names=('custom_1',), _use_id=False>), ('description_tarea', "//textarea[@id='description']"), ('parent_sel', {Version('lowest'): Select("//select[@name='chosen_parent']", multi=False), '5.5': <cfme.web_ui.AngularSelect _loc="//button[@data-id='chosen_parent']", none=None, multi=False, exact=False>}), ('child_sel', Select("//select[@id='kids_chosen']", multi=True)), ('vm_sel', Select("//select[@id='choices_chosen']", multi=True)), ('add_btn', "//img[@alt='Move selected VMs to left']"), ('remove_btn', "//img[@alt='Move selected VMs to right']"), ('remove_all_btn', "//img[@alt='Move all VMs to right']")]>

Checks presence of the quadicon in the CFME.

classmethod factory(vm_name, provider, template_name=None, template=False)[source]

Factory class method that determines the correct subclass for given provider.

For reference how does that work, refer to the entrypoints in the

  • vm_name – Name of the VM/Instance as it appears in the UI
  • provider – The provider object (not the string!)
  • template_name – Source template name. Useful when the VM/Instance does not exist and you want to create it.
  • template – Whether the generated object class should be VM/Instance or a template class.
find_quadicon(from_any_provider=False, use_search=True)[source]

Find and return a quadicon belonging to a specific vm

Parameters:from_any_provider – Whether to look for it anywhere (root of the tree). Useful when looking up archived or orphaned VMs

Returns: entity of appropriate type Raises: VmOrInstanceNotFound

get_detail(properties=None, icon_href=False)[source]

Gets details from the details infoblock

The function first ensures that we are on the detail page for the specific VM/Instance.

Parameters:properties – An InfoBlock title, followed by the Key name, e.g. “Relationships”, “Images”
Returns:A string representing the contents of the InfoBlock’s value.
classmethod get_first_vm(provider)[source]

Get first VM/Instance.


Fetches IP Address of VM


“Check retirement status of vm


Returns the contents of the Last Analysed field in summary


Navigates to an VM’s details page.


refresh – Refreshes the VM page if already there



When unable to find the VM passed

open_console(console='VM Console', invokes_alert=False, cancel=False)[source]

Initiates the opening of one of the console types supported by the Access button. Presently we only support VM Console, which is the HTML5 Console. In case of VMware provider it could be VMRC, VNC/HTML5, WebMKS, but we only support VNC/HTML5. Possible values for ‘console’ could be ‘VM Console’ and ‘Web Console’, but Web Console is not supported as well.

  • console – one of the supported console types given by the Access button.
  • invokes_alert – If the particular console will invoke a CFME popup/alert setting this to true will handle this.
  • cancel – Allows one to cancel the operation if the popup/alert occurs.

Clicks on details infoblock


Loads up the edit page of the object.


Navigates to an VM’s timeline page.

Returns:TimelinesView object
pretty_attrs = ['name', 'provider', 'template_name']

Deletes the VM from the provider and lets it discover again


Rediscovers the object if it has some analysis data present.

Returns:Boolean if the rediscovery happened.
refresh_relationships(from_details=False, cancel=False, from_any_provider=False)[source]

Executes a refresh of relationships.

  • from_details – Whether or not to perform action from instance details page
  • cancel – Whether or not to cancel the refresh relationships action

Returns the retirement date of the selected machine, or ‘Never’

Returns:str object
set_ownership(user=None, group=None, click_cancel=False, click_reset=False)[source]

Set ownership of the VM/Instance or Template/Image

smartstate_scan(cancel=False, from_details=False)[source]

Initiates fleecing from the UI.

  • cancel – Whether or not to cancel the refresh relationships action
  • from_details – Whether or not to perform action from instance details page

Unset ownership of the VM/Instance or Template/Image


Get the consoles window handle, and then create a VMConsole object, and store the VMConsole object aside.

wait_for_delete(timeout=600, load_details=True)

Wait for a VM to disappear within CFME

Parameters:timeout – time (in seconds) to wait for it to appear
wait_to_appear(timeout=600, load_details=True)[source]

Wait for a VM to appear within CFME

  • timeout – time (in seconds) to wait for it to appear
  • load_details – when found, should it load the vm details
wait_to_disappear(timeout=600, load_details=True)[source]

Wait for a VM to disappear within CFME

Parameters:timeout – time (in seconds) to wait for it to appear
class cfme.common.vm.Template(name, provider, template_name=None)[source]

Bases: cfme.common.vm.BaseVM, cfme.common.vm._TemplateMixin

A base class for all templates. The constructor is a bit different, it scraps template_name.


Check if template exists on provider itself


Check if template exists on provider itself

class cfme.common.vm.VM(name, provider, template_name=None, appliance=None)[source]

Bases: cfme.common.vm.BaseVM

create_on_provider(timeout=900, find_in_cfme=False, **kwargs)[source]

Create the VM on the provider

Parameters:timeout – Number of seconds to wait for the VM to appear in CFME Will not wait at all, if set to 0 (Defaults to 900)

Check if VM exists on provider itself

equal_drift_results(row_text, section, *indexes)[source]

Compares drift analysis results of a row specified by it’s title text

  • row_text – Title text of the row to compare
  • section – Accordion section where the change happened; this section will be activated
  • indexes – Indexes of results to compare starting with 0 for first row (latest result). Compares all available drifts, if left empty (default).


There have to be at least 2 drift results available for this to work.

Returns:True if equal, False otherwise.
is_pwr_option_available_in_cfme(option, from_details=False)[source]

Checks to see if a power option is available on the VM

  • option – corresponds to option values under the power button, see EC2Instance and OpenStackInstance
  • from_details – Whether or not to perform action from instance details page
power_control_from_cfme(option, cancel=True, from_details=False)[source]

Power controls a VM from within CFME

  • option – corresponds to option values under the power button
  • cancel – Whether or not to cancel the power operation on confirmation
  • from_details – Whether or not to perform action from instance details page

OptionNotAvailable – option param is not visible or enabled

retire_form = <cfme.web_ui.Form fields=[('date_retire', <cfme.web_ui.AngularCalendarInput input_name='retirement_date', click_away_element="//label[contains(normalize-space(.), 'Retirement Date')]">), ('warn', <cfme.web_ui.AngularSelect _loc="//button[@data-id='retirementWarning']", none=None, multi=False, exact=False>)]>
set_retirement_date(when, warn=None)[source]

Sets the retirement date for this Vm object.

It incorporates some magic to make it work reliably since the retirement form is not very pretty and it can’t be just “done”.

  • when – When to retire. str in format mm/dd/yyyy of datetime.datetime or utils.timeutil.parsetime.
  • warn – When to warn, fills the select in the form in case the when is specified.

Waits until C&U data are available for this VM/Instance

Parameters:timeout – Timeout passed to utils.wait.wait_for()
wait_for_vm_state_change(desired_state=None, timeout=300, from_details=False, with_relationship_refresh=True, from_any_provider=False)[source]

Wait for M to come to desired state.

This function waits just the needed amount of time thanks to wait_for.

  • desired_state – on, off, suspended... for available states, see EC2Instance and OpenStackInstance
  • timeout – Specify amount of time (in seconds) to wait
  • from_any_provider – Archived/Orphaned vms need this
  • TimedOutError

    When instance does not come up to desired state in specified period of time.

  • InstanceNotFound

    When unable to find the instance passed


We need to call this function that will mimic clicking the calendar, picking the date and the subsequent callbacks from the server

cfme.common.vm.instance_types(category, template=False)[source]