ironic.common.cinder module¶
- ironic.common.cinder.attach_volumes(task, volume_list, connector)[source]¶
Attach volumes to a node.
Enumerate through the provided list of volumes and attach the volumes to the node defined in the task utilizing the provided connector information.
If an attachment appears to already exist, we will skip attempting to attach the volume. If use of the volume fails, a user may need to remove any lingering pre-existing/unused attachment records since we have no way to validate if the connector profile data differs from what was provided to cinder.
- Parameters:
task – TaskManager instance representing the operation.
volume_list – List of volume_id UUID values representing volumes.
connector –
Dictionary object representing the node sufficiently to attach a volume. This value can vary based upon the node’s configuration, capability, and ultimately the back-end storage driver. As cinder was designed around iSCSI, the ‘ip’ and ‘initiator’ keys are generally expected by cinder drivers. For FiberChannel, the key ‘wwpns’ can be used with a list of port addresses. Some drivers support a ‘multipath’ boolean key, although it is generally False. The ‘host’ key is generally used for logging by drivers. Example:
{ 'wwpns': ['list','of','port','wwns'], 'ip': 'ip address', 'initiator': 'initiator iqn', 'multipath': False, 'host': 'hostname', }
- Raises:
StorageError If storage subsystem exception is raised.
- Returns:
List of connected volumes, including volumes that were already connected to desired nodes. The returned list can be relatively consistent depending on the end storage driver that the volume is configured for, however the ‘driver_volume_type’ key should not be relied upon as it is a free-form value returned by the driver. The accompanying ‘data’ key contains the actual target details which will indicate either target WWNs and a LUN or a target portal and IQN. It also always contains volume ID in cinder and ironic. Except for these two IDs, each driver may return somewhat different data although the same keys are used if the target is FC or iSCSI, so any logic should be based upon the returned contents. For already attached volumes, the structure contains ‘already_attached’: True key-value pair. In such case, connection info for the node is already in the database, ‘data’ structure contains only basic info of volume ID in cinder and ironic, so any logic based on that should retrieve it from the database. Example:
[{ 'driver_volume_type': 'fibre_channel' 'data': { 'encrypted': False, 'target_lun': 1, 'target_wwn': ['1234567890123', '1234567890124'], 'volume_id': '00000000-0000-0000-0000-000000000001', 'ironic_volume_id': '11111111-0000-0000-0000-000000000001'} }, { 'driver_volume_type': 'iscsi' 'data': { 'target_iqn': 'iqn.2010-10.org.openstack:volume-000002', 'target_portal': '127.0.0.0.1:3260', 'volume_id': '00000000-0000-0000-0000-000000000002', 'ironic_volume_id': '11111111-0000-0000-0000-000000000002', 'target_lun': 2} }, { 'already_attached': True 'data': { 'volume_id': '00000000-0000-0000-0000-000000000002', 'ironic_volume_id': '11111111-0000-0000-0000-000000000002'} }]
- ironic.common.cinder.detach_volumes(task, volume_list, connector, allow_errors=False)[source]¶
Detach a list of volumes from a provided connector detail.
Enumerates through a provided list of volumes and issues detachment requests utilizing the connector information that describes the node.
- Parameters:
task – The TaskManager task representing the request.
volume_list – The list of volume id values to detach.
connector –
Dictionary object representing the node sufficiently to attach a volume. This value can vary based upon the node’s configuration, capability, and ultimately the back-end storage driver. As cinder was designed around iSCSI, the ‘ip’ and ‘initiator’ keys are generally expected. For FiberChannel, the key ‘wwpns’ can be used with a list of port addresses. Some drivers support a ‘multipath’ boolean key, although it is generally False. The ‘host’ key is generally used for logging by drivers. Example:
{ 'wwpns': ['list','of','port','wwns'] 'ip': 'ip address', 'initiator': 'initiator iqn', 'multipath': False, 'host': 'hostname' }
allow_errors – Boolean value governing if errors that are returned are treated as warnings instead of exceptions. Default False.
- Raises:
StorageError
- ironic.common.cinder.get_client(context=None, auth_from_config=False)[source]¶
Retrieve a cinder client connection.
- Parameters:
context – request context, instance of ironic.common.context.RequestContext
auth_from_config – (boolean) When True, use auth values from conf parameters
- Returns:
A cinder client.
- ironic.common.cinder.is_volume_attached(node, volume)[source]¶
Check if a volume is attached to the supplied node.
- Parameters:
node – The object representing the node.
volume – The object representing the volume from cinder.
- Returns:
Boolean indicating if the volume is attached. Returns True if cinder shows the volume as presently attached, otherwise returns False.