def _ExtStorageEnvironment(unique_id, ext_params,
                           size=None, grow=None, metadata=None,
                           name=None, uuid=None,
                           snap_name=None, snap_size=None,
                           exclusive=None):
  """Calculate the environment for an External Storage script.

  @type unique_id: tuple (driver, vol_name)
  @param unique_id: ExtStorage pool and name of the Volume
  @type ext_params: dict
  @param ext_params: the EXT parameters
  @type size: integer
  @param size: size of the Volume (in mebibytes)
  @type grow: integer
  @param grow: new size of Volume after grow (in mebibytes)
  @type metadata: string
  @param metadata: metadata info of the Volume
  @type name: string
  @param name: name of the Volume (objects.Disk.name)
  @type uuid: string
  @param uuid: uuid of the Volume (objects.Disk.uuid)
  @type snap_size: integer
  @param snap_size: the size of the snapshot
  @type snap_name: string
  @param snap_name: the name of the snapshot
  @type exclusive: boolean
  @param exclusive: Whether the Volume will be opened exclusively or not
  @rtype: dict
  @return: dict of environment variables

  """
  vol_name = unique_id[1]

  result = {}
  result["VOL_NAME"] = vol_name

  # EXT params
  for pname, pvalue in ext_params.items():
    result["EXTP_%s" % pname.upper()] = str(pvalue)

  if size is not None:
    result["VOL_SIZE"] = str(size)

  if grow is not None:
    result["VOL_NEW_SIZE"] = str(grow)

  if metadata is not None:
    result["VOL_METADATA"] = metadata

  if name is not None:
    result["VOL_CNAME"] = name

  if uuid is not None:
    result["VOL_UUID"] = uuid

  if snap_name is not None:
    result["VOL_SNAPSHOT_NAME"] = snap_name

  if snap_size is not None:
    result["VOL_SNAPSHOT_SIZE"] = str(snap_size)

  if exclusive is not None:
    result["VOL_OPEN_EXCLUSIVE"] = str(exclusive)

  return result