Revision 4a0e011f
b/daemons/ganeti-noded | ||
---|---|---|
323 | 323 |
instance = objects.Instance.FromDict(params[2]) |
324 | 324 |
cluster_name = params[3] |
325 | 325 |
dev_idx = params[4] |
326 |
debug = params[5] |
|
326 | 327 |
return backend.ExportSnapshot(disk, dest_node, instance, |
327 |
cluster_name, dev_idx) |
|
328 |
cluster_name, dev_idx, debug)
|
|
328 | 329 |
|
329 | 330 |
@staticmethod |
330 | 331 |
def perspective_finalize_export(params): |
... | ... | |
429 | 430 |
inst_s = params[0] |
430 | 431 |
inst = objects.Instance.FromDict(inst_s) |
431 | 432 |
reinstall = params[1] |
432 |
return backend.InstanceOsAdd(inst, reinstall) |
|
433 |
debug = params[2] |
|
434 |
return backend.InstanceOsAdd(inst, reinstall, debug) |
|
433 | 435 |
|
434 | 436 |
@staticmethod |
435 | 437 |
def perspective_instance_run_rename(params): |
436 | 438 |
"""Runs the OS rename script for an instance. |
437 | 439 |
|
438 | 440 |
""" |
439 |
inst_s, old_name = params |
|
441 |
inst_s, old_name, debug = params
|
|
440 | 442 |
inst = objects.Instance.FromDict(inst_s) |
441 |
return backend.RunRenameInstance(inst, old_name) |
|
443 |
return backend.RunRenameInstance(inst, old_name, debug)
|
|
442 | 444 |
|
443 | 445 |
@staticmethod |
444 | 446 |
def perspective_instance_os_import(params): |
445 | 447 |
"""Run the import function of an OS onto a given instance. |
446 | 448 |
|
447 | 449 |
""" |
448 |
inst_s, src_node, src_images, cluster_name = params |
|
450 |
inst_s, src_node, src_images, cluster_name, debug = params
|
|
449 | 451 |
inst = objects.Instance.FromDict(inst_s) |
450 | 452 |
return backend.ImportOSIntoInstance(inst, src_node, src_images, |
451 |
cluster_name) |
|
453 |
cluster_name, debug)
|
|
452 | 454 |
|
453 | 455 |
@staticmethod |
454 | 456 |
def perspective_instance_shutdown(params): |
b/lib/backend.py | ||
---|---|---|
789 | 789 |
return output |
790 | 790 |
|
791 | 791 |
|
792 |
def InstanceOsAdd(instance, reinstall): |
|
792 |
def InstanceOsAdd(instance, reinstall, debug):
|
|
793 | 793 |
"""Add an OS to an instance. |
794 | 794 |
|
795 | 795 |
@type instance: L{objects.Instance} |
796 | 796 |
@param instance: Instance whose OS is to be installed |
797 | 797 |
@type reinstall: boolean |
798 | 798 |
@param reinstall: whether this is an instance reinstall |
799 |
@type debug: integer |
|
800 |
@param debug: debug level, passed to the OS scripts |
|
799 | 801 |
@rtype: None |
800 | 802 |
|
801 | 803 |
""" |
802 | 804 |
inst_os = OSFromDisk(instance.os) |
803 | 805 |
|
804 |
create_env = OSEnvironment(instance, inst_os) |
|
806 |
create_env = OSEnvironment(instance, inst_os, debug)
|
|
805 | 807 |
if reinstall: |
806 | 808 |
create_env['INSTANCE_REINSTALL'] = "1" |
807 | 809 |
|
... | ... | |
820 | 822 |
" log file:\n%s", result.fail_reason, "\n".join(lines), log=False) |
821 | 823 |
|
822 | 824 |
|
823 |
def RunRenameInstance(instance, old_name): |
|
825 |
def RunRenameInstance(instance, old_name, debug):
|
|
824 | 826 |
"""Run the OS rename script for an instance. |
825 | 827 |
|
826 | 828 |
@type instance: L{objects.Instance} |
827 | 829 |
@param instance: Instance whose OS is to be installed |
828 | 830 |
@type old_name: string |
829 | 831 |
@param old_name: previous instance name |
832 |
@type debug: integer |
|
833 |
@param debug: debug level, passed to the OS scripts |
|
830 | 834 |
@rtype: boolean |
831 | 835 |
@return: the success of the operation |
832 | 836 |
|
833 | 837 |
""" |
834 | 838 |
inst_os = OSFromDisk(instance.os) |
835 | 839 |
|
836 |
rename_env = OSEnvironment(instance, inst_os) |
|
840 |
rename_env = OSEnvironment(instance, inst_os, debug)
|
|
837 | 841 |
rename_env['OLD_INSTANCE_NAME'] = old_name |
838 | 842 |
|
839 | 843 |
logfile = "%s/rename-%s-%s-%s-%d.log" % (constants.LOG_OS_DIR, instance.os, |
... | ... | |
1948 | 1952 |
disk.unique_id, disk.dev_type) |
1949 | 1953 |
|
1950 | 1954 |
|
1951 |
def ExportSnapshot(disk, dest_node, instance, cluster_name, idx): |
|
1955 |
def ExportSnapshot(disk, dest_node, instance, cluster_name, idx, debug):
|
|
1952 | 1956 |
"""Export a block device snapshot to a remote node. |
1953 | 1957 |
|
1954 | 1958 |
@type disk: L{objects.Disk} |
... | ... | |
1962 | 1966 |
@type idx: int |
1963 | 1967 |
@param idx: the index of the disk in the instance's disk list, |
1964 | 1968 |
used to export to the OS scripts environment |
1969 |
@type debug: integer |
|
1970 |
@param debug: debug level, passed to the OS scripts |
|
1965 | 1971 |
@rtype: None |
1966 | 1972 |
|
1967 | 1973 |
""" |
1968 | 1974 |
inst_os = OSFromDisk(instance.os) |
1969 |
export_env = OSEnvironment(instance, inst_os) |
|
1975 |
export_env = OSEnvironment(instance, inst_os, debug)
|
|
1970 | 1976 |
|
1971 | 1977 |
export_script = inst_os.export_script |
1972 | 1978 |
|
... | ... | |
2096 | 2102 |
return config.Dumps() |
2097 | 2103 |
|
2098 | 2104 |
|
2099 |
def ImportOSIntoInstance(instance, src_node, src_images, cluster_name): |
|
2105 |
def ImportOSIntoInstance(instance, src_node, src_images, cluster_name, debug):
|
|
2100 | 2106 |
"""Import an os image into an instance. |
2101 | 2107 |
|
2102 | 2108 |
@type instance: L{objects.Instance} |
... | ... | |
2105 | 2111 |
@param src_node: source node for the disk images |
2106 | 2112 |
@type src_images: list of string |
2107 | 2113 |
@param src_images: absolute paths of the disk images |
2114 |
@type debug: integer |
|
2115 |
@param debug: debug level, passed to the OS scripts |
|
2108 | 2116 |
@rtype: list of boolean |
2109 | 2117 |
@return: each boolean represent the success of importing the n-th disk |
2110 | 2118 |
|
2111 | 2119 |
""" |
2112 | 2120 |
inst_os = OSFromDisk(instance.os) |
2113 |
import_env = OSEnvironment(instance, inst_os) |
|
2121 |
import_env = OSEnvironment(instance, inst_os, debug)
|
|
2114 | 2122 |
import_script = inst_os.import_script |
2115 | 2123 |
|
2116 | 2124 |
logfile = "%s/import-%s-%s-%s.log" % (constants.LOG_OS_DIR, instance.os, |
b/lib/cmdlib.py | ||
---|---|---|
3990 | 3990 |
_StartInstanceDisks(self, inst, None) |
3991 | 3991 |
try: |
3992 | 3992 |
feedback_fn("Running the instance OS create scripts...") |
3993 |
result = self.rpc.call_instance_os_add(inst.primary_node, inst, True) |
|
3993 |
# FIXME: pass debug option from opcode to backend |
|
3994 |
result = self.rpc.call_instance_os_add(inst.primary_node, inst, True, 0) |
|
3994 | 3995 |
result.Raise("Could not install OS for instance %s on node %s" % |
3995 | 3996 |
(inst.name, inst.primary_node)) |
3996 | 3997 |
finally: |
... | ... | |
4174 | 4175 |
_StartInstanceDisks(self, inst, None) |
4175 | 4176 |
try: |
4176 | 4177 |
result = self.rpc.call_instance_run_rename(inst.primary_node, inst, |
4177 |
old_name) |
|
4178 |
old_name, 0)
|
|
4178 | 4179 |
msg = result.fail_msg |
4179 | 4180 |
if msg: |
4180 | 4181 |
msg = ("Could not run OS rename script for instance %s on node %s" |
... | ... | |
6227 | 6228 |
if iobj.disk_template != constants.DT_DISKLESS: |
6228 | 6229 |
if self.op.mode == constants.INSTANCE_CREATE: |
6229 | 6230 |
feedback_fn("* running the instance OS create scripts...") |
6230 |
result = self.rpc.call_instance_os_add(pnode_name, iobj, False) |
|
6231 |
# FIXME: pass debug option from opcode to backend |
|
6232 |
result = self.rpc.call_instance_os_add(pnode_name, iobj, False, 0) |
|
6231 | 6233 |
result.Raise("Could not add os for instance %s" |
6232 | 6234 |
" on node %s" % (instance, pnode_name)) |
6233 | 6235 |
|
... | ... | |
6236 | 6238 |
src_node = self.op.src_node |
6237 | 6239 |
src_images = self.src_images |
6238 | 6240 |
cluster_name = self.cfg.GetClusterName() |
6241 |
# FIXME: pass debug option from opcode to backend |
|
6239 | 6242 |
import_result = self.rpc.call_instance_os_import(pnode_name, iobj, |
6240 | 6243 |
src_node, src_images, |
6241 |
cluster_name) |
|
6244 |
cluster_name, 0)
|
|
6242 | 6245 |
msg = import_result.fail_msg |
6243 | 6246 |
if msg: |
6244 | 6247 |
self.LogWarning("Error while importing the disk images for instance" |
... | ... | |
8146 | 8149 |
feedback_fn("Exporting snapshot %s from %s to %s" % |
8147 | 8150 |
(idx, src_node, dst_node.name)) |
8148 | 8151 |
if dev: |
8152 |
# FIXME: pass debug from opcode to backend |
|
8149 | 8153 |
result = self.rpc.call_snapshot_export(src_node, dev, dst_node.name, |
8150 |
instance, cluster_name, idx) |
|
8154 |
instance, cluster_name, |
|
8155 |
idx, 0) |
|
8151 | 8156 |
msg = result.fail_msg |
8152 | 8157 |
if msg: |
8153 | 8158 |
self.LogWarning("Could not export disk/%s from node %s to" |
b/lib/rpc.py | ||
---|---|---|
576 | 576 |
[self._InstDict(inst), reboot_type, |
577 | 577 |
shutdown_timeout]) |
578 | 578 |
|
579 |
def call_instance_os_add(self, node, inst, reinstall): |
|
579 |
def call_instance_os_add(self, node, inst, reinstall, debug):
|
|
580 | 580 |
"""Installs an OS on the given instance. |
581 | 581 |
|
582 | 582 |
This is a single-node call. |
583 | 583 |
|
584 | 584 |
""" |
585 | 585 |
return self._SingleNodeCall(node, "instance_os_add", |
586 |
[self._InstDict(inst), reinstall]) |
|
586 |
[self._InstDict(inst), reinstall, debug])
|
|
587 | 587 |
|
588 |
def call_instance_run_rename(self, node, inst, old_name): |
|
588 |
def call_instance_run_rename(self, node, inst, old_name, debug):
|
|
589 | 589 |
"""Run the OS rename script for an instance. |
590 | 590 |
|
591 | 591 |
This is a single-node call. |
592 | 592 |
|
593 | 593 |
""" |
594 | 594 |
return self._SingleNodeCall(node, "instance_run_rename", |
595 |
[self._InstDict(inst), old_name]) |
|
595 |
[self._InstDict(inst), old_name, debug])
|
|
596 | 596 |
|
597 | 597 |
def call_instance_info(self, node, instance, hname): |
598 | 598 |
"""Returns information about a single instance. |
... | ... | |
988 | 988 |
return self._SingleNodeCall(node, "blockdev_snapshot", [cf_bdev.ToDict()]) |
989 | 989 |
|
990 | 990 |
def call_snapshot_export(self, node, snap_bdev, dest_node, instance, |
991 |
cluster_name, idx): |
|
991 |
cluster_name, idx, debug):
|
|
992 | 992 |
"""Request the export of a given snapshot. |
993 | 993 |
|
994 | 994 |
This is a single-node call. |
... | ... | |
996 | 996 |
""" |
997 | 997 |
return self._SingleNodeCall(node, "snapshot_export", |
998 | 998 |
[snap_bdev.ToDict(), dest_node, |
999 |
self._InstDict(instance), cluster_name, idx]) |
|
999 |
self._InstDict(instance), cluster_name, |
|
1000 |
idx, debug]) |
|
1000 | 1001 |
|
1001 | 1002 |
def call_finalize_export(self, node, instance, snap_disks): |
1002 | 1003 |
"""Request the completion of an export operation. |
... | ... | |
1025 | 1026 |
return self._SingleNodeCall(node, "export_info", [path]) |
1026 | 1027 |
|
1027 | 1028 |
def call_instance_os_import(self, node, inst, src_node, src_images, |
1028 |
cluster_name): |
|
1029 |
cluster_name, debug):
|
|
1029 | 1030 |
"""Request the import of a backup into an instance. |
1030 | 1031 |
|
1031 | 1032 |
This is a single-node call. |
... | ... | |
1033 | 1034 |
""" |
1034 | 1035 |
return self._SingleNodeCall(node, "instance_os_import", |
1035 | 1036 |
[self._InstDict(inst), src_node, src_images, |
1036 |
cluster_name]) |
|
1037 |
cluster_name, debug])
|
|
1037 | 1038 |
|
1038 | 1039 |
def call_export_list(self, node_list): |
1039 | 1040 |
"""Gets the stored exports list. |
Also available in: Unified diff