COT.ovf.hardware
module¶
Representation of OVF hardware definitions.
Classes and Exceptions
OVFHardware |
Helper class for OVF . |
OVFHardwareDataError |
The input data used to construct an OVFHardware is not sane. |
-
exception
OVFHardwareDataError
[source]¶ Bases:
exceptions.Exception
The input data used to construct an
OVFHardware
is not sane.
-
class
OVFHardware
(ovf)[source]¶ Bases:
object
Helper class for
OVF
.Represents all hardware items defined by this OVF; i.e., the contents of all Items in the VirtualHardwareSection.
Fundamentally it’s just a dict of
OVFItem
objects with a bunch of helper methods.-
__init__
(ovf)[source]¶ Construct an OVFHardware object describing all Items in the OVF.
Parameters: ovf (OVF) – OVF instance to extract hardware information from. Raises: OVFHardwareDataError
– if any data errors are seen
-
clone_item
(parent_item, profile_list)[source]¶ Clone an
OVFItem
to create a new instance.Parameters: Returns: tuple –
(instance_id, ovfitem)
-
delete_item
(item)[source]¶ Delete the given Item from the hardware.
Parameters: item (OVFItem) – Item to delete
-
find_all_items
(resource_type=None, properties=None, profile_list=None)[source]¶ Find all items matching the given type, properties, and profiles.
Parameters: Returns: list – Matching
OVFItem
instances
-
find_item
(resource_type=None, properties=None, profile=None)[source]¶ Find the only
OVFItem
of the givenresource_type
.Parameters: Returns: OVFItem – Matching instance, or None
Raises: LookupError
– if more than one such Item exists.
-
find_unused_instance_id
()[source]¶ Find the first available
InstanceID
number.Returns: str – An instance ID that is not yet in use.
-
get_item_count
(resource_type, profile)[source]¶ Wrapper for
get_item_count_per_profile()
.Parameters: Returns: int – Number of items of this type in this profile.
-
get_item_count_per_profile
(resource_type, profile_list)[source]¶ Get the number of Items of the given type per profile.
Items present under “no profile” will be counted against the total for each profile.
Parameters: Returns: dict – mapping profile strings to the number of items under each profile.
-
item_match
(item, resource_type, properties, profile_list)[source]¶ Check whether the given item matches the given filters.
Parameters: Returns: bool – True if the item matches all filters, False if not.
-
new_item
(resource_type, profile_list=None)[source]¶ Create a new
OVFItem
of the given type.Parameters: Returns: tuple –
(instance_id, ovfitem)
-
set_item_count_per_profile
(resource_type, count, profile_list)[source]¶ Set the number of items of a given type under the given profile(s).
If the new count is greater than the current count under this profile, then additional instances that already exist under another profile will be added to this profile, starting with the lowest-sequence instance not already present, and only as a last resort will new instances be created.
If the new count is less than the current count under this profile, then the highest-numbered instances will be removed preferentially.
Parameters:
-
set_item_values_per_profile
(resource_type, prop_name, value_list, profile_list, default=None)[source]¶ Set value(s) for a property of multiple items of a type.
Parameters: - resource_type (str) – Device type such as ‘harddisk’ or ‘cpu’
- prop_name (str) – Property name to update
- value_list (list) – List of values to set (one value per item of the
given
resource_type
) - profile_list (list) – List of profiles to filter on (default: apply across all profiles)
- default (str) – If there are more matching items than entries in
value_list
, set extra items to this value
-
set_value_for_all_items
(resource_type, prop_name, new_value, profile_list, create_new=False)[source]¶ Set a property to the given value for all items of the given type.
If no items of the given type exist, will create a new
Item
ifcreate_new
is set toTrue
; otherwise will log a warning and do nothing.Parameters: - resource_type (str) – Resource type such as ‘cpu’ or ‘harddisk’
- prop_name (str) – Property name to update
- new_value (str) – New value to set the property to
- profile_list (list) – List of profiles to filter on (default: apply across all profiles)
- create_new (bool) – Whether to create a new entry if no items
of this
resource_type
presently exist.
-
update_existing_item_count_per_profile
(resource_type, count, profile_list)[source]¶ Change profile membership of existing items as needed.
Helper method for
set_item_count_per_profile()
.Parameters: Returns: tuple – (count_dict, items_to_add, last_item)
-