after assembly we'll have our correct major/minor.
"""
- def __init__(self, unique_id, children, size, params):
+ # pylint: disable=W0613
+ def __init__(self, unique_id, children, size, params, *args):
self._children = children
self.dev_path = None
self.unique_id = unique_id
raise NotImplementedError
@classmethod
- def Create(cls, unique_id, children, size, params, excl_stor):
+ def Create(cls, unique_id, children, size, params, excl_stor, *args):
"""Create the device.
If the device cannot be created, it will return None
handling of the externally provided block devices.
"""
- def __init__(self, unique_id, children, size, params):
+ def __init__(self, unique_id, children, size, params, *args):
"""Attaches to an extstorage block device.
"""
- super(ExtStorageDevice, self).__init__(unique_id, children, size, params)
+ super(ExtStorageDevice, self).__init__(unique_id, children, size, params,
+ *args)
+
+ (self.name, self.uuid) = args
+
if not isinstance(unique_id, (tuple, list)) or len(unique_id) != 2:
raise ValueError("Invalid configuration data %s" % str(unique_id))
self.Attach()
@classmethod
- def Create(cls, unique_id, children, size, params, excl_stor):
+ def Create(cls, unique_id, children, size, params, excl_stor, *args):
"""Create a new extstorage device.
Provision a new volume using an extstorage provider, which will
then be mapped to a block device.
"""
+ (name, uuid) = args
+
if not isinstance(unique_id, (tuple, list)) or len(unique_id) != 2:
raise errors.ProgrammerError("Invalid configuration data %s" %
str(unique_id))
# Call the External Storage's create script,
# to provision a new Volume inside the External Storage
_ExtStorageAction(constants.ES_ACTION_CREATE, unique_id,
- params, str(size))
+ params, size=str(size), name=name, uuid=uuid)
- return ExtStorageDevice(unique_id, children, size, params)
+ return ExtStorageDevice(unique_id, children, size, params, name, uuid)
def Remove(self):
"""Remove the extstorage device.
# Call the External Storage's remove script,
# to remove the Volume from the External Storage
_ExtStorageAction(constants.ES_ACTION_REMOVE, self.unique_id,
- self.ext_params)
+ self.ext_params, name=self.name, uuid=self.uuid)
def Rename(self, new_id):
"""Rename this device.
# Call the External Storage's attach script,
# to attach an existing Volume to a block device under /dev
self.dev_path = _ExtStorageAction(constants.ES_ACTION_ATTACH,
- self.unique_id, self.ext_params)
+ self.unique_id, self.ext_params,
+ name=self.name, uuid=self.uuid)
try:
st = os.stat(self.dev_path)
# Call the External Storage's detach script,
# to detach an existing Volume from it's block device under /dev
_ExtStorageAction(constants.ES_ACTION_DETACH, self.unique_id,
- self.ext_params)
+ self.ext_params, name=self.name, uuid=self.uuid)
self.minor = None
self.dev_path = None
# Call the External Storage's grow script,
# to grow an existing Volume inside the External Storage
_ExtStorageAction(constants.ES_ACTION_GROW, self.unique_id,
- self.ext_params, str(self.size), grow=str(new_size))
+ self.ext_params, size=str(self.size), grow=str(new_size),
+ name=self.name, uuid=self.uuid)
def SetInfo(self, text):
"""Update metadata with info text.
# Call the External Storage's setinfo script,
# to set metadata for an existing Volume inside the External Storage
_ExtStorageAction(constants.ES_ACTION_SETINFO, self.unique_id,
- self.ext_params, metadata=text)
+ self.ext_params, metadata=text,
+ name=self.name, uuid=self.uuid)
def Snapshot(self, snapshot_name):
"""Take a snapshot of the block device.
# Call the External Storage's setinfo script,
# to set metadata for an existing Volume inside the External Storage
_ExtStorageAction(constants.ES_ACTION_SNAPSHOT, self.unique_id,
- self.ext_params, snapshot_name=snapshot_name)
+ self.ext_params, snapshot_name=snapshot_name,
+ name=self.name, uuid=self.uuid)
def _ExtStorageAction(action, unique_id, ext_params,
size=None, grow=None, metadata=None,
- snapshot_name=None):
+ snapshot_name=None, name=None, uuid=None):
"""Take an External Storage action.
Take an External Storage action concerning or affecting
# Create the basic environment for the driver's scripts
create_env = _ExtStorageEnvironment(unique_id, ext_params, size,
- grow, metadata, snapshot_name)
+ grow, metadata, snapshot_name,
+ name, uuid)
# Do not use log file for action `attach' as we need
# to get the output from RunResult
def _ExtStorageEnvironment(unique_id, ext_params,
size=None, grow=None, metadata=None,
- snapshot_name=None):
+ snapshot_name=None, name=None, uuid=None):
"""Calculate the environment for an External Storage script.
@type unique_id: tuple (driver, vol_name)
if snapshot_name is not None:
result["VOL_SNAPSHOT_NAME"] = snapshot_name
+ if name is not None:
+ result["VOL_CNAME"] = name
+
+ if uuid is not None:
+ result["VOL_UUID"] = uuid
+
return result
"""
_VerifyDiskType(disk.dev_type)
device = DEV_MAP[disk.dev_type](disk.physical_id, children, disk.size,
- disk.params)
+ disk.params, disk.name, disk.uuid)
if not device.attached:
return None
return device
_VerifyDiskType(disk.dev_type)
_VerifyDiskParams(disk)
device = DEV_MAP[disk.dev_type](disk.physical_id, children, disk.size,
- disk.params)
+ disk.params, disk.name, disk.uuid)
device.Assemble()
return device
_VerifyDiskType(disk.dev_type)
_VerifyDiskParams(disk)
device = DEV_MAP[disk.dev_type].Create(disk.physical_id, children, disk.size,
- disk.params, excl_stor)
+ disk.params, excl_stor,
+ disk.name, disk.uuid)
return device