def _parse_glance_iso8601_timestamp(timestamp):
    """Parse a subset of iso8601 timestamps into datetime objects."""
    iso_formats = ['%Y-%m-%dT%H:%M:%S.%f', '%Y-%m-%dT%H:%M:%S']

    for iso_format in iso_formats:
        try:
            return datetime.datetime.strptime(timestamp, iso_format)
        except __HOLE__:
            pass

    raise ValueError(_('%(timestamp)s does not follow any of the '
                       'signatures: %(ISO_FORMATS)s') % locals())


# TODO(yamahata): use block-device-mapping extension to glance
dataset/ETHPy150Open nii-cloud/dodai-compute/nova/image/glance.py/_parse_glance_iso8601_timestamp