Revision 702c3270

b/lib/storage/base.py
72 72
  after assembly we'll have our correct major/minor.
73 73

  
74 74
  """
75
  def __init__(self, unique_id, children, size, params, dyn_params):
75
  # pylint: disable=W0613
76
  def __init__(self, unique_id, children, size, params, dyn_params, *args):
76 77
    self._children = children
77 78
    self.dev_path = None
78 79
    self.unique_id = unique_id
......
111 112

  
112 113
  @classmethod
113 114
  def Create(cls, unique_id, children, size, spindles, params, excl_stor,
114
             dyn_params):
115
             dyn_params, *args):
115 116
    """Create the device.
116 117

  
117 118
    If the device cannot be created, it will return None
b/lib/storage/bdev.py
1205 1205
  handling of the externally provided block devices.
1206 1206

  
1207 1207
  """
1208
  def __init__(self, unique_id, children, size, params, dyn_params):
1208
  def __init__(self, unique_id, children, size, params, dyn_params, *args):
1209 1209
    """Attaches to an extstorage block device.
1210 1210

  
1211 1211
    """
1212 1212
    super(ExtStorageDevice, self).__init__(unique_id, children, size, params,
1213 1213
                                           dyn_params)
1214
    (self.name, self.uuid) = args
1215

  
1214 1216
    if not isinstance(unique_id, (tuple, list)) or len(unique_id) != 2:
1215 1217
      raise ValueError("Invalid configuration data %s" % str(unique_id))
1216 1218

  
......
1222 1224

  
1223 1225
  @classmethod
1224 1226
  def Create(cls, unique_id, children, size, spindles, params, excl_stor,
1225
             dyn_params):
1227
             dyn_params, *args):
1226 1228
    """Create a new extstorage device.
1227 1229

  
1228 1230
    Provision a new volume using an extstorage provider, which will
1229 1231
    then be mapped to a block device.
1230 1232

  
1231 1233
    """
1234
    (name, uuid) = args
1235

  
1232 1236
    if not isinstance(unique_id, (tuple, list)) or len(unique_id) != 2:
1233 1237
      raise errors.ProgrammerError("Invalid configuration data %s" %
1234 1238
                                   str(unique_id))
......
1239 1243
    # Call the External Storage's create script,
1240 1244
    # to provision a new Volume inside the External Storage
1241 1245
    _ExtStorageAction(constants.ES_ACTION_CREATE, unique_id,
1242
                      params, str(size))
1246
                      params, size=str(size), name=name, uuid=uuid)
1243 1247

  
1244 1248
    return ExtStorageDevice(unique_id, children, size, params, dyn_params)
1245 1249

  
......
1257 1261
    # Call the External Storage's remove script,
1258 1262
    # to remove the Volume from the External Storage
1259 1263
    _ExtStorageAction(constants.ES_ACTION_REMOVE, self.unique_id,
1260
                      self.ext_params)
1264
                      self.ext_params, name=self.name, uuid=self.uuid)
1261 1265

  
1262 1266
  def Rename(self, new_id):
1263 1267
    """Rename this device.
......
1277 1281
    # Call the External Storage's attach script,
1278 1282
    # to attach an existing Volume to a block device under /dev
1279 1283
    self.dev_path = _ExtStorageAction(constants.ES_ACTION_ATTACH,
1280
                                      self.unique_id, self.ext_params)
1284
                                      self.unique_id, self.ext_params,
1285
                                      name=self.name, uuid=self.uuid)
1281 1286

  
1282 1287
    try:
1283 1288
      st = os.stat(self.dev_path)
......
1312 1317
    # Call the External Storage's detach script,
1313 1318
    # to detach an existing Volume from it's block device under /dev
1314 1319
    _ExtStorageAction(constants.ES_ACTION_DETACH, self.unique_id,
1315
                      self.ext_params)
1320
                      self.ext_params, name=self.name, uuid=self.uuid)
1316 1321

  
1317 1322
    self.minor = None
1318 1323
    self.dev_path = None
......
1353 1358
    # Call the External Storage's grow script,
1354 1359
    # to grow an existing Volume inside the External Storage
1355 1360
    _ExtStorageAction(constants.ES_ACTION_GROW, self.unique_id,
1356
                      self.ext_params, str(self.size), grow=str(new_size))
1361
                      self.ext_params, size=str(self.size), grow=str(new_size),
1362
                      name=self.name, uuid=self.uuid)
1357 1363

  
1358 1364
  def SetInfo(self, text):
1359 1365
    """Update metadata with info text.
......
1369 1375
    # Call the External Storage's setinfo script,
1370 1376
    # to set metadata for an existing Volume inside the External Storage
1371 1377
    _ExtStorageAction(constants.ES_ACTION_SETINFO, self.unique_id,
1372
                      self.ext_params, metadata=text)
1378
                      self.ext_params, metadata=text,
1379
                      name=self.name, uuid=self.uuid)
1373 1380

  
1374 1381

  
1375 1382
def _ExtStorageAction(action, unique_id, ext_params,
1376
                      size=None, grow=None, metadata=None):
1383
                      size=None, grow=None, metadata=None,
1384
                      name=None, uuid=None):
1377 1385
  """Take an External Storage action.
1378 1386

  
1379 1387
  Take an External Storage action concerning or affecting
......
1393 1401
  @param grow: the new size in mebibytes (after grow)
1394 1402
  @type metadata: string
1395 1403
  @param metadata: metadata info of the Volume, for use by the provider
1404
  @type name: string
1405
  @param name: name of the Volume (objects.Disk.name)
1406
  @type uuid: string
1407
  @param uuid: uuid of the Volume (objects.Disk.uuid)
1396 1408
  @rtype: None or a block device path (during attach)
1397 1409

  
1398 1410
  """
......
1405 1417

  
1406 1418
  # Create the basic environment for the driver's scripts
1407 1419
  create_env = _ExtStorageEnvironment(unique_id, ext_params, size,
1408
                                      grow, metadata)
1420
                                      grow, metadata, name, uuid)
1409 1421

  
1410 1422
  # Do not use log file for action `attach' as we need
1411 1423
  # to get the output from RunResult
......
1522 1534

  
1523 1535

  
1524 1536
def _ExtStorageEnvironment(unique_id, ext_params,
1525
                           size=None, grow=None, metadata=None):
1537
                           size=None, grow=None, metadata=None,
1538
                           name=None, uuid=None):
1526 1539
  """Calculate the environment for an External Storage script.
1527 1540

  
1528 1541
  @type unique_id: tuple (driver, vol_name)
......
1535 1548
  @param grow: new size of Volume after grow (in mebibytes)
1536 1549
  @type metadata: string
1537 1550
  @param metadata: metadata info of the Volume
1551
  @type name: string
1552
  @param name: name of the Volume (objects.Disk.name)
1553
  @type uuid: string
1554
  @param uuid: uuid of the Volume (objects.Disk.uuid)
1538 1555
  @rtype: dict
1539 1556
  @return: dict of environment variables
1540 1557

  
......
1557 1574
  if metadata is not None:
1558 1575
    result["VOL_METADATA"] = metadata
1559 1576

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

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

  
1560 1583
  return result
1561 1584

  
1562 1585

  
......
1611 1634
  """
1612 1635
  _VerifyDiskType(disk.dev_type)
1613 1636
  device = DEV_MAP[disk.dev_type](disk.logical_id, children, disk.size,
1614
                                  disk.params, disk.dynamic_params)
1637
                                  disk.params, disk.dynamic_params,
1638
                                  disk.name, disk.uuid)
1615 1639
  if not device.attached:
1616 1640
    return None
1617 1641
  return device
......
1633 1657
  _VerifyDiskType(disk.dev_type)
1634 1658
  _VerifyDiskParams(disk)
1635 1659
  device = DEV_MAP[disk.dev_type](disk.logical_id, children, disk.size,
1636
                                  disk.params, disk.dynamic_params)
1660
                                  disk.params, disk.dynamic_params,
1661
                                  disk.name, disk.uuid)
1637 1662
  device.Assemble()
1638 1663
  return device
1639 1664

  
......
1656 1681
  _VerifyDiskParams(disk)
1657 1682
  device = DEV_MAP[disk.dev_type].Create(disk.logical_id, children, disk.size,
1658 1683
                                         disk.spindles, disk.params, excl_stor,
1659
                                         disk.dynamic_params)
1684
                                         disk.dynamic_params,
1685
                                         disk.name, disk.uuid)
1660 1686
  return device
1661 1687

  
1662 1688
# Please keep this at the bottom of the file for visibility.
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
VOL_CNAME
67
    The name of the Disk config object (optional).
68

  
69
VOL_UUID
70
    The uuid of the Disk config object.
71

  
66 72
EXECUTABLE SCRIPTS
67 73
------------------
68 74

  

Also available in: Unified diff