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.-
clone_item
(parent_item, profile_list)[source]¶ Clone an
OVFItem
to create a new instance.Parameters: - parent_item (OVFItem) – Instance to clone from
- profile_list (list) – List of profiles to clone into
Returns: (instance, ovfitem)
-
find_all_items
(resource_type=None, properties=None, profile_list=None)[source]¶ Find all items matching the given type, properties, and profiles.
Parameters: - resource_type (str) – Resource type string like ‘scsi’ or ‘serial’
- properties (dict[property, value]) – Property values to match
- profile_list (list) – List of profiles to filter on
Returns: list of
OVFItem
instances
-
find_item
(resource_type=None, properties=None, profile=None)[source]¶ Find the only
OVFItem
of the givenresource_type
.Parameters: - resource_type (str) – Resource type string like ‘scsi’ or ‘serial’
- properties (dict[property, value]) – Property values to match
- profile (str) – Single profile ID to search within
Return type: OVFItem
orNone
Raises: LookupError – if more than one such Item exists.
-
get_item_count
(resource_type, profile)[source]¶ Wrapper for
get_item_count_per_profile()
.Parameters: - resource_type (str) –
- profile (str) – Single profile identifier string to look up.
Returns: 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: - resource_type (str) –
- profile_list (list) – List of profiles to filter on (default: apply across all profiles)
Return type: dict[profile, count]
-
item_match
(item, resource_type, properties, profile_list)[source]¶ Check whether the given item matches the given filters.
-
new_item
(resource_type, profile_list=None)[source]¶ Create a new
OVFItem
of the given type.Parameters: - resource_type (str) –
- profile_list (list) – Profiles the new item should belong to
Returns: (instance, 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: - resource_type (str) – ‘cpu’, ‘harddisk’, etc.
- count (int) – Desired number of items
- profile_list (list) – List of profiles to filter on (default: apply across all profiles)
-
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 (boolean) – 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()
.Returns: (count_dict, items_to_add, last_item)
-