Revision 81a3406c lib/backend.py
b/lib/backend.py | ||
---|---|---|
799 | 799 |
return output |
800 | 800 |
|
801 | 801 |
|
802 |
def _InstanceLogName(kind, os_name, instance): |
|
803 |
"""Compute the OS log filename for a given instance and operation. |
|
804 |
|
|
805 |
The instance name and os name are passed in as strings since not all |
|
806 |
operations have these as part of an instance object. |
|
807 |
|
|
808 |
@type kind: string |
|
809 |
@param kind: the operation type (e.g. add, import, etc.) |
|
810 |
@type os_name: string |
|
811 |
@param os_name: the os name |
|
812 |
@type instance: string |
|
813 |
@param instance: the name of the instance being imported/added/etc. |
|
814 |
|
|
815 |
""" |
|
816 |
base = "%s-%s-%s-%d.log" % (kind, os_name, instance, int(time.time())) |
|
817 |
return utils.PathJoin(constants.LOG_OS_DIR, base) |
|
818 |
|
|
819 |
|
|
802 | 820 |
def InstanceOsAdd(instance, reinstall, debug): |
803 | 821 |
"""Add an OS to an instance. |
804 | 822 |
|
... | ... | |
817 | 835 |
if reinstall: |
818 | 836 |
create_env['INSTANCE_REINSTALL'] = "1" |
819 | 837 |
|
820 |
logfile = "%s/add-%s-%s-%d.log" % (constants.LOG_OS_DIR, instance.os, |
|
821 |
instance.name, int(time.time())) |
|
838 |
logfile = _InstanceLogName("add", instance.os, instance.name) |
|
822 | 839 |
|
823 | 840 |
result = utils.RunCmd([inst_os.create_script], env=create_env, |
824 | 841 |
cwd=inst_os.path, output=logfile,) |
... | ... | |
850 | 867 |
rename_env = OSEnvironment(instance, inst_os, debug) |
851 | 868 |
rename_env['OLD_INSTANCE_NAME'] = old_name |
852 | 869 |
|
853 |
logfile = "%s/rename-%s-%s-%s-%d.log" % (constants.LOG_OS_DIR, instance.os, |
|
854 |
old_name, |
|
855 |
instance.name, int(time.time())) |
|
870 |
logfile = _InstanceLogName("rename", instance.os, |
|
871 |
"%s-%s" % (old_name, instance.name)) |
|
856 | 872 |
|
857 | 873 |
result = utils.RunCmd([inst_os.rename_script], env=rename_env, |
858 | 874 |
cwd=inst_os.path, output=logfile) |
... | ... | |
1982 | 1998 |
|
1983 | 1999 |
export_script = inst_os.export_script |
1984 | 2000 |
|
1985 |
logfile = "%s/exp-%s-%s-%s.log" % (constants.LOG_OS_DIR, inst_os.name, |
|
1986 |
instance.name, int(time.time())) |
|
2001 |
logfile = _InstanceLogName("export", inst_os.name, instance.name) |
|
1987 | 2002 |
if not os.path.exists(constants.LOG_OS_DIR): |
1988 | 2003 |
os.mkdir(constants.LOG_OS_DIR, 0750) |
1989 | 2004 |
real_disk = _RecursiveFindBD(disk) |
... | ... | |
2127 | 2142 |
import_env = OSEnvironment(instance, inst_os, debug) |
2128 | 2143 |
import_script = inst_os.import_script |
2129 | 2144 |
|
2130 |
logfile = "%s/import-%s-%s-%s.log" % (constants.LOG_OS_DIR, instance.os, |
|
2131 |
instance.name, int(time.time())) |
|
2145 |
logfile = _InstanceLogName("import", instance.os, instance.name) |
|
2132 | 2146 |
if not os.path.exists(constants.LOG_OS_DIR): |
2133 | 2147 |
os.mkdir(constants.LOG_OS_DIR, 0750) |
2134 | 2148 |
|
Also available in: Unified diff