The cinder.volume.drivers.datacore.utils Module

The cinder.volume.drivers.datacore.utils Module

Utilities and helper functions.

build_network_address(host, port)

Combines the specified host name or IP address with the specified port.

Parameters:
  • host – Host name or IP address in presentation (string) format
  • port – Port number
Returns:

The host name or IP address and port combination; IPv6 addresses are enclosed in the square brackets

get_distinct_by(key, source)

Finds distinct items for the key and returns the result in a list.

Parameters:
  • key – Function computing a key value for each item
  • source – Iterable collection of items
Returns:

The list of distinct by the key value items

get_first(predicate, source)

Searches for an item that matches the conditions.

Parameters:
  • predicate – Defines the conditions of the item to search for
  • source – Iterable collection of items
Returns:

The first item that matches the conditions defined by the specified predicate, if found; otherwise StopIteration is raised

get_first_or_default(predicate, source, default)

Searches for an item that matches the conditions.

Parameters:
  • predicate – Defines the conditions of the item to search for
  • source – Iterable collection of items
  • default – Value that is returned if the iterator is exhausted
Returns:

The first item that matches the conditions defined by the specified predicate, if found; otherwise the default value

Creative Commons Attribution 3.0 License

Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.