Revision 453c5aad

b/lib/bdev.py
264 264
  after assembly we'll have our correct major/minor.
265 265

  
266 266
  """
267
  def __init__(self, unique_id, children, size, params):
267
  # pylint: disable=W0613
268
  def __init__(self, unique_id, children, size, params, *args):
268 269
    self._children = children
269 270
    self.dev_path = None
270 271
    self.unique_id = unique_id
......
301 302
    raise NotImplementedError
302 303

  
303 304
  @classmethod
304
  def Create(cls, unique_id, children, size, params, excl_stor):
305
  def Create(cls, unique_id, children, size, params, excl_stor, *args):
305 306
    """Create the device.
306 307

  
307 308
    If the device cannot be created, it will return None
......
2985 2986
  handling of the externally provided block devices.
2986 2987

  
2987 2988
  """
2988
  def __init__(self, unique_id, children, size, params):
2989
  def __init__(self, unique_id, children, size, params, *args):
2989 2990
    """Attaches to an extstorage block device.
2990 2991

  
2991 2992
    """
2992
    super(ExtStorageDevice, self).__init__(unique_id, children, size, params)
2993
    super(ExtStorageDevice, self).__init__(unique_id, children, size, params,
2994
                                           *args)
2995

  
2996
    (self.name, self.uuid) = args
2997

  
2993 2998
    if not isinstance(unique_id, (tuple, list)) or len(unique_id) != 2:
2994 2999
      raise ValueError("Invalid configuration data %s" % str(unique_id))
2995 3000

  
......
3000 3005
    self.Attach()
3001 3006

  
3002 3007
  @classmethod
3003
  def Create(cls, unique_id, children, size, params, excl_stor):
3008
  def Create(cls, unique_id, children, size, params, excl_stor, *args):
3004 3009
    """Create a new extstorage device.
3005 3010

  
3006 3011
    Provision a new volume using an extstorage provider, which will
3007 3012
    then be mapped to a block device.
3008 3013

  
3009 3014
    """
3015
    (name, uuid) = args
3016

  
3010 3017
    if not isinstance(unique_id, (tuple, list)) or len(unique_id) != 2:
3011 3018
      raise errors.ProgrammerError("Invalid configuration data %s" %
3012 3019
                                   str(unique_id))
......
3017 3024
    # Call the External Storage's create script,
3018 3025
    # to provision a new Volume inside the External Storage
3019 3026
    _ExtStorageAction(constants.ES_ACTION_CREATE, unique_id,
3020
                      params, str(size))
3027
                      params, size=str(size), name=name, uuid=uuid)
3021 3028

  
3022
    return ExtStorageDevice(unique_id, children, size, params)
3029
    return ExtStorageDevice(unique_id, children, size, params, name, uuid)
3023 3030

  
3024 3031
  def Remove(self):
3025 3032
    """Remove the extstorage device.
......
3035 3042
    # Call the External Storage's remove script,
3036 3043
    # to remove the Volume from the External Storage
3037 3044
    _ExtStorageAction(constants.ES_ACTION_REMOVE, self.unique_id,
3038
                      self.ext_params)
3045
                      self.ext_params, name=self.name, uuid=self.uuid)
3039 3046

  
3040 3047
  def Rename(self, new_id):
3041 3048
    """Rename this device.
......
3055 3062
    # Call the External Storage's attach script,
3056 3063
    # to attach an existing Volume to a block device under /dev
3057 3064
    self.dev_path = _ExtStorageAction(constants.ES_ACTION_ATTACH,
3058
                                      self.unique_id, self.ext_params)
3065
                                      self.unique_id, self.ext_params,
3066
                                      name=self.name, uuid=self.uuid)
3059 3067

  
3060 3068
    try:
3061 3069
      st = os.stat(self.dev_path)
......
3090 3098
    # Call the External Storage's detach script,
3091 3099
    # to detach an existing Volume from it's block device under /dev
3092 3100
    _ExtStorageAction(constants.ES_ACTION_DETACH, self.unique_id,
3093
                      self.ext_params)
3101
                      self.ext_params, name=self.name, uuid=self.uuid)
3094 3102

  
3095 3103
    self.minor = None
3096 3104
    self.dev_path = None
......
3131 3139
    # Call the External Storage's grow script,
3132 3140
    # to grow an existing Volume inside the External Storage
3133 3141
    _ExtStorageAction(constants.ES_ACTION_GROW, self.unique_id,
3134
                      self.ext_params, str(self.size), grow=str(new_size))
3142
                      self.ext_params, size=str(self.size), grow=str(new_size),
3143
                      name=self.name, uuid=self.uuid)
3135 3144

  
3136 3145
  def SetInfo(self, text):
3137 3146
    """Update metadata with info text.
......
3147 3156
    # Call the External Storage's setinfo script,
3148 3157
    # to set metadata for an existing Volume inside the External Storage
3149 3158
    _ExtStorageAction(constants.ES_ACTION_SETINFO, self.unique_id,
3150
                      self.ext_params, metadata=text)
3159
                      self.ext_params, metadata=text,
3160
                      name=self.name, uuid=self.uuid)
3151 3161

  
3152 3162
  def Snapshot(self, snapshot_name):
3153 3163
    """Take a snapshot of the block device.
......
3156 3166
    # Call the External Storage's setinfo script,
3157 3167
    # to set metadata for an existing Volume inside the External Storage
3158 3168
    _ExtStorageAction(constants.ES_ACTION_SNAPSHOT, self.unique_id,
3159
                      self.ext_params, snapshot_name=snapshot_name)
3169
                      self.ext_params, snapshot_name=snapshot_name,
3170
                      name=self.name, uuid=self.uuid)
3160 3171

  
3161 3172

  
3162 3173
def _ExtStorageAction(action, unique_id, ext_params,
3163 3174
                      size=None, grow=None, metadata=None,
3164
                      snapshot_name=None):
3175
                      snapshot_name=None, name=None, uuid=None):
3165 3176
  """Take an External Storage action.
3166 3177

  
3167 3178
  Take an External Storage action concerning or affecting
......
3193 3204

  
3194 3205
  # Create the basic environment for the driver's scripts
3195 3206
  create_env = _ExtStorageEnvironment(unique_id, ext_params, size,
3196
                                      grow, metadata, snapshot_name)
3207
                                      grow, metadata, snapshot_name,
3208
                                      name, uuid)
3197 3209

  
3198 3210
  # Do not use log file for action `attach' as we need
3199 3211
  # to get the output from RunResult
......
3312 3324

  
3313 3325
def _ExtStorageEnvironment(unique_id, ext_params,
3314 3326
                           size=None, grow=None, metadata=None,
3315
                           snapshot_name=None):
3327
                           snapshot_name=None, name=None, uuid=None):
3316 3328
  """Calculate the environment for an External Storage script.
3317 3329

  
3318 3330
  @type unique_id: tuple (driver, vol_name)
......
3350 3362
  if snapshot_name is not None:
3351 3363
    result["VOL_SNAPSHOT_NAME"] = snapshot_name
3352 3364

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

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

  
3353 3371
  return result
3354 3372

  
3355 3373

  
......
3416 3434
  """
3417 3435
  _VerifyDiskType(disk.dev_type)
3418 3436
  device = DEV_MAP[disk.dev_type](disk.physical_id, children, disk.size,
3419
                                  disk.params)
3437
                                  disk.params, disk.name, disk.uuid)
3420 3438
  if not device.attached:
3421 3439
    return None
3422 3440
  return device
......
3438 3456
  _VerifyDiskType(disk.dev_type)
3439 3457
  _VerifyDiskParams(disk)
3440 3458
  device = DEV_MAP[disk.dev_type](disk.physical_id, children, disk.size,
3441
                                  disk.params)
3459
                                  disk.params, disk.name, disk.uuid)
3442 3460
  device.Assemble()
3443 3461
  return device
3444 3462

  
......
3458 3476
  _VerifyDiskType(disk.dev_type)
3459 3477
  _VerifyDiskParams(disk)
3460 3478
  device = DEV_MAP[disk.dev_type].Create(disk.physical_id, children, disk.size,
3461
                                         disk.params, excl_stor)
3479
                                         disk.params, excl_stor,
3480
                                         disk.name, disk.uuid)
3462 3481
  return device
b/man/ganeti-extstorage-interface.rst
63 63
    metadata to be associated with the volume. Currently, Ganeti sets
64 64
    this value to ``originstname+X`` where ``X`` is the instance's name.
65 65

  
66
SNAPSHOT_NAME
67
    Available only to the **snapshot** script. This is the name of the
68
    snapshot requested by the user.
69

  
70
VOL_CNAME
71
    The name of the Disk config object (optional)
72

  
73
VOL_UUID
74
    The uuid of the Disk config object.
75

  
66 76
EXECUTABLE SCRIPTS
67 77
------------------
68 78

  

Also available in: Unified diff