Revision 6aa7a354 lib/backend.py
b/lib/backend.py | ||
---|---|---|
925 | 925 |
return output |
926 | 926 |
|
927 | 927 |
|
928 |
def _InstanceLogName(kind, os_name, instance): |
|
928 |
def _InstanceLogName(kind, os_name, instance, component):
|
|
929 | 929 |
"""Compute the OS log filename for a given instance and operation. |
930 | 930 |
|
931 | 931 |
The instance name and os name are passed in as strings since not all |
... | ... | |
937 | 937 |
@param os_name: the os name |
938 | 938 |
@type instance: string |
939 | 939 |
@param instance: the name of the instance being imported/added/etc. |
940 |
@type component: string or None |
|
941 |
@param component: the name of the component of the instance being |
|
942 |
transferred |
|
940 | 943 |
|
941 | 944 |
""" |
942 | 945 |
# TODO: Use tempfile.mkstemp to create unique filename |
943 |
base = ("%s-%s-%s-%s.log" % |
|
944 |
(kind, os_name, instance, utils.TimestampForFilename())) |
|
946 |
if component: |
|
947 |
assert "/" not in component |
|
948 |
c_msg = "-%s" % component |
|
949 |
else: |
|
950 |
c_msg = "" |
|
951 |
base = ("%s-%s-%s%s-%s.log" % |
|
952 |
(kind, os_name, instance, c_msg, utils.TimestampForFilename())) |
|
945 | 953 |
return utils.PathJoin(constants.LOG_OS_DIR, base) |
946 | 954 |
|
947 | 955 |
|
... | ... | |
963 | 971 |
if reinstall: |
964 | 972 |
create_env["INSTANCE_REINSTALL"] = "1" |
965 | 973 |
|
966 |
logfile = _InstanceLogName("add", instance.os, instance.name) |
|
974 |
logfile = _InstanceLogName("add", instance.os, instance.name, None)
|
|
967 | 975 |
|
968 | 976 |
result = utils.RunCmd([inst_os.create_script], env=create_env, |
969 | 977 |
cwd=inst_os.path, output=logfile, reset_env=True) |
... | ... | |
996 | 1004 |
rename_env["OLD_INSTANCE_NAME"] = old_name |
997 | 1005 |
|
998 | 1006 |
logfile = _InstanceLogName("rename", instance.os, |
999 |
"%s-%s" % (old_name, instance.name)) |
|
1007 |
"%s-%s" % (old_name, instance.name), None)
|
|
1000 | 1008 |
|
1001 | 1009 |
result = utils.RunCmd([inst_os.rename_script], env=rename_env, |
1002 | 1010 |
cwd=inst_os.path, output=logfile, reset_env=True) |
... | ... | |
3077 | 3085 |
# Overall timeout for establishing connection while listening |
3078 | 3086 |
cmd.append("--connect-timeout=%s" % opts.connect_timeout) |
3079 | 3087 |
|
3080 |
logfile = _InstanceLogName(prefix, instance.os, instance.name) |
|
3088 |
logfile = _InstanceLogName(prefix, instance.os, instance.name, component)
|
|
3081 | 3089 |
|
3082 | 3090 |
# TODO: Once _InstanceLogName uses tempfile.mkstemp, StartDaemon has |
3083 | 3091 |
# support for receiving a file descriptor for output |
Also available in: Unified diff