def metadata_from_config_drive(config_drive_label=CONFIG_DRIVE_LABEL):
 try:
  mounted_fs = temporary_mount(LabelledFilesystem(label=config_drive_label), options=['ro'])
 except MountError as e:
  Message.new(message_type=u'flocker:node:agents:blockdevice:openstack:compute_instance_id:configdrive_not_available', error_message=unicode(e)).write()
  return None
 with mounted_fs as mountpoint:
  metadata_file = mountpoint.descendant(METADATA_RELATIVE_PATH)
  try:
   content = metadata_file.getContent()
  except IOError as e:
   Message.new(message_type=u'flocker:node:agents:blockdevice:openstack:compute_instance_id:metadata_file_not_found', error_message=unicode(e)).write()
   return
  try:
   return json.loads(content)
  except ValueError as e:
   Message.new(message_type=u'flocker:node:agents:blockdevice:openstack:compute_instance_id:metadata_file_not_json', error_message=unicode(e)).write()
   return

def metadata_from_config_drive ( config_drive_label = CONFIG_DRIVE_LABEL ) : try : mounted_fs = temporary_mount ( LabelledFilesystem ( label = config_drive_label ) , options = [ 'ro' ] ) except MountError as e : Message . new ( message_type = u'flocker:node:agents:blockdevice:openstack:compute_instance_id:configdrive_not_available' , error_message = unicode ( e ) ) . write ( ) return None with mounted_fs as mountpoint : metadata_file = mountpoint . descendant ( METADATA_RELATIVE_PATH ) try : content = metadata_file . getContent ( ) except IOError as e : Message . new ( message_type = u'flocker:node:agents:blockdevice:openstack:compute_instance_id:metadata_file_not_found' , error_message = unicode ( e ) ) . write ( ) return try : return json . loads ( content ) except ValueError as e : Message . new ( message_type = u'flocker:node:agents:blockdevice:openstack:compute_instance_id:metadata_file_not_json' , error_message = unicode ( e ) ) . write ( ) return
attempt to retrieve metadata from config drive .