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.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.-
ALL_LIST_LOCATION
= None¶
-
DETAILS_VIEW_CLASS
= None¶
-
QUADICON_TYPE
= 'vm'¶
-
REMOVE_SELECTED
¶ A class that implements the version picking functionality.
Basic usage is a descriptor in which you place instances of
VersionPick
in a view. Whenever is this instance accessed from an instance, it automatically picks the correct variant based on product_version defined in thewidgetastic.browser.Browser
.You can also use this separately using the
pick()
method.Example:
class MyView(View): something_version_dependent = VersionPick({ '1.0.0': Foo('bar'), '2.5.0': Bar('baz'), })
This sample will resolve the correct (Foo or Bar) kind of item and returns it.
Parameters: version_dict – Dictionary of version_introduced: item
-
REMOVE_SINGLE
¶ A class that implements the version picking functionality.
Basic usage is a descriptor in which you place instances of
VersionPick
in a view. Whenever is this instance accessed from an instance, it automatically picks the correct variant based on product_version defined in thewidgetastic.browser.Browser
.You can also use this separately using the
pick()
method.Example:
class MyView(View): something_version_dependent = VersionPick({ '1.0.0': Foo('bar'), '2.5.0': Bar('baz'), })
This sample will resolve the correct (Foo or Bar) kind of item and returns it.
Parameters: version_dict – Dictionary of version_introduced: item
-
RETIRE_DATE_FMT
¶ A class that implements the version picking functionality.
Basic usage is a descriptor in which you place instances of
VersionPick
in a view. Whenever is this instance accessed from an instance, it automatically picks the correct variant based on product_version defined in thewidgetastic.browser.Browser
.You can also use this separately using the
pick()
method.Example:
class MyView(View): something_version_dependent = VersionPick({ '1.0.0': Foo('bar'), '2.5.0': Bar('baz'), })
This sample will resolve the correct (Foo or Bar) kind of item and returns it.
Parameters: version_dict – Dictionary of version_introduced: item
-
TO_OPEN_EDIT
= None¶
-
compliance_status
¶ Returns the title of the compliance SummaryTable. The title contains datetime so it can be compared.
Returns: NoneType
if no title is present (no compliance checks before), otherwise str
-
console_handle
¶ 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.
Parameters: - cancel – Whether to cancel the action in the alert.
- from_details – Whether to use the details view or list view.
-
exists
¶ 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 setup.py
Parameters: - 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)[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.
-
ip_address
¶ Fetches IP Address of VM
-
is_retired
¶ “Check retirement status of vm
-
is_vm
¶
-
last_analysed
¶ Returns the contents of the
Last Analysed
field in summary
-
load_details
(refresh=False, from_any_provider=False)[source]¶ Navigates to an VM’s details page.
Parameters: - refresh – Refreshes the VM page if already there
- from_any_provider – Archived/Orphaned VMs need this
-
open_console
(console='VM Console', invokes_alert=None)[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.
Parameters: - 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.
-
pretty_attrs
= ['name', 'provider', 'template_name']¶
-
quadicon_type
¶
-
rediscover_if_analysis_data_present
()[source]¶ 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.
Parameters: - from_details – Whether or not to perform action from instance details page
- cancel – Whether or not to cancel the refresh relationships action
-
set_ownership
(user=None, group=None, click_cancel=False, click_reset=False)[source]¶ Set instance ownership
Parameters:
-
smartstate_scan
(cancel=False, from_details=False, wait_for_task_result=False)[source]¶ Initiates fleecing from the UI.
Parameters: - cancel – Whether or not to cancel the refresh relationships action
- from_details – Whether or not to perform action from instance details page
-
vm_console
¶ Get the consoles window handle, and then create a VMConsole object, and store the VMConsole object aside.
-
wait_for_delete
(timeout=600)¶ 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.
-
class
cfme.common.vm.
VM
(name, provider, template_name=None, appliance=None)[source]¶ Bases:
cfme.common.vm.BaseVM
-
TO_RETIRE
= None¶
-
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
)
-
equal_drift_results
(drift_section, section, *indexes)[source]¶ Compares drift analysis results of a row specified by it’s title text.
Parameters: Note
There have to be at least 2 drift results available for this to work.
Returns: bool
-
is_pwr_option_available_in_cfme
(option, from_details=False)[source]¶ Checks to see if a power option is available on the VM
Parameters: - option – corresponds to option values under the power button,
see
EC2Instance
andOpenStackInstance
- from_details – Whether or not to perform action from instance details page
- option – corresponds to option values under the power button,
see
-
power_control_from_cfme
(option, cancel=True, from_details=False)[source]¶ Power controls a VM from within CFME
Parameters: - 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
Raises: OptionNotAvailable
– option param is not visible or enabled
-
set_retirement_date
(when=None, offset=None, warn=None)[source]¶ Overriding common method to use widgetastic views/widgets properly
Parameters: - when –
datetime.datetime
object, when to retire (date in future) - offset –
dict
with months, weeks, days, hours keys. other keys ignored - warn – When to warn, fills the select in the form in case the
when
is specified.
Note: this should be moved up to the common VM class when infra+cloud+common are all WT
If when and offset are both None, this removes retirement date
Examples
# To set a specific retirement date 2 days from today two_days_later = datetime.date.today() + datetime.timedelta(days=2) vm.set_retirement_date(when=two_days_later)
# To set a retirement offset 2 weeks from now vm.set_retirement_date(offset={weeks=2})
Offset is dict to remove ambiguity between timedelta/datetime and months/weeks/days/hours timedelta supports creation with weeks, but not months timedelta supports days attr, but not weeks or months timedelta days attr will report a total summary, not the component that was passed to it For these reasons timedelta isn’t appropriate for offset An enhancement to cfme.utils.timeutil extending timedelta would be great for making this a bit cleaner
- when –
-
wait_candu_data_available
(timeout=600)[source]¶ 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 VM to come to desired state.
This function waits just the needed amount of time thanks to wait_for.
Parameters: - desired_state – on, off, suspended... for available states, see
EC2Instance
andOpenStackInstance
- timeout – Specify amount of time (in seconds) to wait
- from_any_provider – Archived/Orphaned vms need this
Raises: TimedOutError
When instance does not come up to desired state in specified period of time.
InstanceNotFound
When unable to find the instance passed
- desired_state – on, off, suspended... for available states, see
-