Revision ee1478e5 lib/bdev.py
b/lib/bdev.py | ||
---|---|---|
290 | 290 |
raise NotImplementedError |
291 | 291 |
|
292 | 292 |
@classmethod |
293 |
def Create(cls, unique_id, children, size, params): |
|
293 |
def Create(cls, unique_id, children, size, params, excl_stor):
|
|
294 | 294 |
"""Create the device. |
295 | 295 |
|
296 | 296 |
If the device cannot be created, it will return None |
... | ... | |
524 | 524 |
self.Attach() |
525 | 525 |
|
526 | 526 |
@classmethod |
527 |
def Create(cls, unique_id, children, size, params): |
|
527 |
def Create(cls, unique_id, children, size, params, excl_stor):
|
|
528 | 528 |
"""Create a new logical volume. |
529 | 529 |
|
530 | 530 |
""" |
... | ... | |
2181 | 2181 |
self.Shutdown() |
2182 | 2182 |
|
2183 | 2183 |
@classmethod |
2184 |
def Create(cls, unique_id, children, size, params): |
|
2184 |
def Create(cls, unique_id, children, size, params, excl_stor):
|
|
2185 | 2185 |
"""Create a new DRBD8 device. |
2186 | 2186 |
|
2187 | 2187 |
Since DRBD devices are not created per se, just assembled, this |
... | ... | |
2190 | 2190 |
""" |
2191 | 2191 |
if len(children) != 2: |
2192 | 2192 |
raise errors.ProgrammerError("Invalid setup for the drbd device") |
2193 |
if excl_stor: |
|
2194 |
raise errors.ProgrammerError("DRBD device requested with" |
|
2195 |
" exclusive_storage") |
|
2193 | 2196 |
# check that the minor is unused |
2194 | 2197 |
aminor = unique_id[4] |
2195 | 2198 |
proc_info = cls._MassageProcData(cls._GetProcData()) |
... | ... | |
2355 | 2358 |
_ThrowError("Can't stat %s: %s", self.dev_path, err) |
2356 | 2359 |
|
2357 | 2360 |
@classmethod |
2358 |
def Create(cls, unique_id, children, size, params): |
|
2361 |
def Create(cls, unique_id, children, size, params, excl_stor):
|
|
2359 | 2362 |
"""Create a new file. |
2360 | 2363 |
|
2361 | 2364 |
@param size: the size of file in MiB |
... | ... | |
2364 | 2367 |
@return: an instance of FileStorage |
2365 | 2368 |
|
2366 | 2369 |
""" |
2370 |
if excl_stor: |
|
2371 |
raise errors.ProgrammerError("FileStorage device requested with" |
|
2372 |
" exclusive_storage") |
|
2367 | 2373 |
if not isinstance(unique_id, (tuple, list)) or len(unique_id) != 2: |
2368 | 2374 |
raise ValueError("Invalid configuration data %s" % str(unique_id)) |
2369 | 2375 |
|
... | ... | |
2420 | 2426 |
self.Attach() |
2421 | 2427 |
|
2422 | 2428 |
@classmethod |
2423 |
def Create(cls, unique_id, children, size, params): |
|
2429 |
def Create(cls, unique_id, children, size, params, excl_stor):
|
|
2424 | 2430 |
"""Create a new device |
2425 | 2431 |
|
2426 | 2432 |
This is a noop, we only return a PersistentBlockDevice instance |
2427 | 2433 |
|
2428 | 2434 |
""" |
2435 |
if excl_stor: |
|
2436 |
raise errors.ProgrammerError("Persistent block device requested with" |
|
2437 |
" exclusive_storage") |
|
2429 | 2438 |
return PersistentBlockDevice(unique_id, children, 0, params) |
2430 | 2439 |
|
2431 | 2440 |
def Remove(self): |
... | ... | |
2517 | 2526 |
self.Attach() |
2518 | 2527 |
|
2519 | 2528 |
@classmethod |
2520 |
def Create(cls, unique_id, children, size, params): |
|
2529 |
def Create(cls, unique_id, children, size, params, excl_stor):
|
|
2521 | 2530 |
"""Create a new rbd device. |
2522 | 2531 |
|
2523 | 2532 |
Provision a new rbd volume inside a RADOS pool. |
... | ... | |
2526 | 2535 |
if not isinstance(unique_id, (tuple, list)) or len(unique_id) != 2: |
2527 | 2536 |
raise errors.ProgrammerError("Invalid configuration data %s" % |
2528 | 2537 |
str(unique_id)) |
2538 |
if excl_stor: |
|
2539 |
raise errors.ProgrammerError("RBD device requested with" |
|
2540 |
" exclusive_storage") |
|
2529 | 2541 |
rbd_pool = params[constants.LDP_POOL] |
2530 | 2542 |
rbd_name = unique_id[1] |
2531 | 2543 |
|
... | ... | |
2810 | 2822 |
self.Attach() |
2811 | 2823 |
|
2812 | 2824 |
@classmethod |
2813 |
def Create(cls, unique_id, children, size, params): |
|
2825 |
def Create(cls, unique_id, children, size, params, excl_stor):
|
|
2814 | 2826 |
"""Create a new extstorage device. |
2815 | 2827 |
|
2816 | 2828 |
Provision a new volume using an extstorage provider, which will |
... | ... | |
2820 | 2832 |
if not isinstance(unique_id, (tuple, list)) or len(unique_id) != 2: |
2821 | 2833 |
raise errors.ProgrammerError("Invalid configuration data %s" % |
2822 | 2834 |
str(unique_id)) |
2835 |
if excl_stor: |
|
2836 |
raise errors.ProgrammerError("extstorage device requested with" |
|
2837 |
" exclusive_storage") |
|
2823 | 2838 |
|
2824 | 2839 |
# Call the External Storage's create script, |
2825 | 2840 |
# to provision a new Volume inside the External Storage |
... | ... | |
3235 | 3250 |
return device |
3236 | 3251 |
|
3237 | 3252 |
|
3238 |
def Create(disk, children): |
|
3253 |
def Create(disk, children, excl_stor):
|
|
3239 | 3254 |
"""Create a device. |
3240 | 3255 |
|
3241 | 3256 |
@type disk: L{objects.Disk} |
... | ... | |
3243 | 3258 |
@type children: list of L{bdev.BlockDev} |
3244 | 3259 |
@param children: the list of block devices that are children of the device |
3245 | 3260 |
represented by the disk parameter |
3261 |
@type excl_stor: boolean |
|
3262 |
@param excl_stor: Whether exclusive_storage is active |
|
3246 | 3263 |
|
3247 | 3264 |
""" |
3248 | 3265 |
_VerifyDiskType(disk.dev_type) |
3249 | 3266 |
_VerifyDiskParams(disk) |
3250 | 3267 |
device = DEV_MAP[disk.dev_type].Create(disk.physical_id, children, disk.size, |
3251 |
disk.params) |
|
3268 |
disk.params, excl_stor)
|
|
3252 | 3269 |
return device |
Also available in: Unified diff