Revision b23c4333 lib/cmdlib.py
b/lib/cmdlib.py | ||
---|---|---|
2369 | 2369 |
inst = self.instance |
2370 | 2370 |
old_name = inst.name |
2371 | 2371 |
|
2372 |
if inst.disk_template == constants.DT_FILE: |
|
2373 |
old_file_storage_dir = os.path.dirname(inst.disks[0].logical_id[1]) |
|
2374 |
|
|
2372 | 2375 |
self.cfg.RenameInstance(inst.name, self.op.new_name) |
2373 | 2376 |
|
2374 | 2377 |
# re-read the instance from the configuration after rename |
2375 | 2378 |
inst = self.cfg.GetInstanceInfo(self.op.new_name) |
2376 | 2379 |
|
2380 |
if inst.disk_template == constants.DT_FILE: |
|
2381 |
new_file_storage_dir = os.path.dirname(inst.disks[0].logical_id[1]) |
|
2382 |
result = rpc.call_file_storage_dir_rename(inst.primary_node, |
|
2383 |
old_file_storage_dir, |
|
2384 |
new_file_storage_dir) |
|
2385 |
|
|
2386 |
if not result: |
|
2387 |
raise errors.OpExecError("Could not connect to node '%s' to rename" |
|
2388 |
" directory '%s' to '%s' (but the instance" |
|
2389 |
" has been renamed in Ganeti)" % ( |
|
2390 |
inst.primary_node, old_file_storage_dir, |
|
2391 |
new_file_storage_dir)) |
|
2392 |
|
|
2393 |
if not result[0]: |
|
2394 |
raise errors.OpExecError("Could not rename directory '%s' to '%s'" |
|
2395 |
" (but the instance has been renamed in" |
|
2396 |
" Ganeti)" % (old_file_storage_dir, |
|
2397 |
new_file_storage_dir)) |
|
2398 |
|
|
2377 | 2399 |
_StartInstanceDisks(self.cfg, inst, None) |
2378 | 2400 |
try: |
2379 | 2401 |
if not rpc.call_instance_run_rename(inst.primary_node, inst, old_name, |
Also available in: Unified diff