Revision a0c3fea1 lib/cmdlib.py
b/lib/cmdlib.py | ||
---|---|---|
2253 | 2253 |
(instance.name, target_node)) |
2254 | 2254 |
|
2255 | 2255 |
|
2256 |
def _CreateBlockDevOnPrimary(cfg, node, device): |
|
2256 |
def _CreateBlockDevOnPrimary(cfg, node, device, info):
|
|
2257 | 2257 |
"""Create a tree of block devices on the primary node. |
2258 | 2258 |
|
2259 | 2259 |
This always creates all devices. |
... | ... | |
2261 | 2261 |
""" |
2262 | 2262 |
if device.children: |
2263 | 2263 |
for child in device.children: |
2264 |
if not _CreateBlockDevOnPrimary(cfg, node, child): |
|
2264 |
if not _CreateBlockDevOnPrimary(cfg, node, child, info):
|
|
2265 | 2265 |
return False |
2266 | 2266 |
|
2267 | 2267 |
cfg.SetDiskID(device, node) |
2268 |
new_id = rpc.call_blockdev_create(node, device, device.size, True) |
|
2268 |
new_id = rpc.call_blockdev_create(node, device, device.size, True, info)
|
|
2269 | 2269 |
if not new_id: |
2270 | 2270 |
return False |
2271 | 2271 |
if device.physical_id is None: |
... | ... | |
2273 | 2273 |
return True |
2274 | 2274 |
|
2275 | 2275 |
|
2276 |
def _CreateBlockDevOnSecondary(cfg, node, device, force): |
|
2276 |
def _CreateBlockDevOnSecondary(cfg, node, device, force, info):
|
|
2277 | 2277 |
"""Create a tree of block devices on a secondary node. |
2278 | 2278 |
|
2279 | 2279 |
If this device type has to be created on secondaries, create it and |
... | ... | |
2286 | 2286 |
force = True |
2287 | 2287 |
if device.children: |
2288 | 2288 |
for child in device.children: |
2289 |
if not _CreateBlockDevOnSecondary(cfg, node, child, force): |
|
2289 |
if not _CreateBlockDevOnSecondary(cfg, node, child, force, info):
|
|
2290 | 2290 |
return False |
2291 | 2291 |
|
2292 | 2292 |
if not force: |
2293 | 2293 |
return True |
2294 | 2294 |
cfg.SetDiskID(device, node) |
2295 |
new_id = rpc.call_blockdev_create(node, device, device.size, False) |
|
2295 |
new_id = rpc.call_blockdev_create(node, device, device.size, False, info)
|
|
2296 | 2296 |
if not new_id: |
2297 | 2297 |
return False |
2298 | 2298 |
if device.physical_id is None: |
... | ... | |
2394 | 2394 |
return disks |
2395 | 2395 |
|
2396 | 2396 |
|
2397 |
def _GetInstanceInfoText(instance): |
|
2398 |
return "originstname+%s" % instance.name |
|
2399 |
|
|
2400 |
|
|
2397 | 2401 |
def _CreateDisks(cfg, instance): |
2398 | 2402 |
"""Create all disks for an instance. |
2399 | 2403 |
|
... | ... | |
2406 | 2410 |
True or False showing the success of the creation process |
2407 | 2411 |
|
2408 | 2412 |
""" |
2413 |
info = _GetInstanceInfoText(instance) |
|
2414 |
|
|
2409 | 2415 |
for device in instance.disks: |
2410 | 2416 |
logger.Info("creating volume %s for instance %s" % |
2411 | 2417 |
(device.iv_name, instance.name)) |
2412 | 2418 |
#HARDCODE |
2413 | 2419 |
for secondary_node in instance.secondary_nodes: |
2414 |
if not _CreateBlockDevOnSecondary(cfg, secondary_node, device, False): |
|
2420 |
if not _CreateBlockDevOnSecondary(cfg, secondary_node, device, False, |
|
2421 |
info): |
|
2415 | 2422 |
logger.Error("failed to create volume %s (%s) on secondary node %s!" % |
2416 | 2423 |
(device.iv_name, device, secondary_node)) |
2417 | 2424 |
return False |
2418 | 2425 |
#HARDCODE |
2419 |
if not _CreateBlockDevOnPrimary(cfg, instance.primary_node, device): |
|
2426 |
if not _CreateBlockDevOnPrimary(cfg, instance.primary_node, device, info):
|
|
2420 | 2427 |
logger.Error("failed to create volume %s on primary!" % |
2421 | 2428 |
device.iv_name) |
2422 | 2429 |
return False |
... | ... | |
2854 | 2861 |
|
2855 | 2862 |
logger.Info("adding new mirror component on secondary") |
2856 | 2863 |
#HARDCODE |
2857 |
if not _CreateBlockDevOnSecondary(self.cfg, remote_node, new_drbd, False): |
|
2864 |
if not _CreateBlockDevOnSecondary(self.cfg, remote_node, new_drbd, False, |
|
2865 |
_GetInstanceInfoText(instance)): |
|
2858 | 2866 |
raise errors.OpExecError, ("Failed to create new component on secondary" |
2859 | 2867 |
" node %s" % remote_node) |
2860 | 2868 |
|
2861 | 2869 |
logger.Info("adding new mirror component on primary") |
2862 | 2870 |
#HARDCODE |
2863 |
if not _CreateBlockDevOnPrimary(self.cfg, instance.primary_node, new_drbd): |
|
2871 |
if not _CreateBlockDevOnPrimary(self.cfg, instance.primary_node, new_drbd, |
|
2872 |
_GetInstanceInfoText(instance)): |
|
2864 | 2873 |
# remove secondary dev |
2865 | 2874 |
self.cfg.SetDiskID(new_drbd, remote_node) |
2866 | 2875 |
rpc.call_blockdev_remove(remote_node, new_drbd) |
... | ... | |
3053 | 3062 |
logger.Info("adding new mirror component on secondary for %s" % |
3054 | 3063 |
dev.iv_name) |
3055 | 3064 |
#HARDCODE |
3056 |
if not _CreateBlockDevOnSecondary(cfg, remote_node, new_drbd, False): |
|
3065 |
if not _CreateBlockDevOnSecondary(cfg, remote_node, new_drbd, False, |
|
3066 |
_GetInstanceInfoText(instance)): |
|
3057 | 3067 |
raise errors.OpExecError, ("Failed to create new component on" |
3058 | 3068 |
" secondary node %s\n" |
3059 | 3069 |
"Full abort, cleanup manually!" % |
... | ... | |
3061 | 3071 |
|
3062 | 3072 |
logger.Info("adding new mirror component on primary") |
3063 | 3073 |
#HARDCODE |
3064 |
if not _CreateBlockDevOnPrimary(cfg, instance.primary_node, new_drbd): |
|
3074 |
if not _CreateBlockDevOnPrimary(cfg, instance.primary_node, new_drbd, |
|
3075 |
_GetInstanceInfoText(instance)): |
|
3065 | 3076 |
# remove secondary dev |
3066 | 3077 |
cfg.SetDiskID(new_drbd, remote_node) |
3067 | 3078 |
rpc.call_blockdev_remove(remote_node, new_drbd) |
Also available in: Unified diff