change hard code wala configure path to MyDistro.getConfigurationPath() and ignore exception when get ctime of the configure file

This commit is contained in:
qingfuwang
2014-11-05 11:21:44 +08:00
parent e8263da65c
commit 6b48adeece
+8 -3
View File
@@ -5195,10 +5195,15 @@ class Agent(Util):
if provisionError == None :
provisioned = True
SetFileContents(LibDir + "/provisioned", "")
lastCtime = os.path.getctime("/etc/waagent.conf")
lastCtime = "NOTFIND"
try:
walaConfigFile = MyDistro.getConfigurationPath()
lastCtime = time.ctime(os.path.getctime(walaConfigFile))
except:
pass
#Get Ctime of wala config, can help identify the base image of this VM
AddExtensionEvent(name="WALA",op=WALAEventOperation.Provision,isSuccess=True,
message="WALA Config Ctime:"+time.ctime(lastCtime))
message="WALA Config Ctime:"+lastCtime)
#
# only one port supported
@@ -5504,7 +5509,7 @@ def Deprovision(force, deluser):
"""
#Append blank line at the end of file, so the ctime of this file is changed every time
Run("echo ''>>"+"/etc/waagent.conf")
Run("echo ''>>"+ MyDistro.getConfigurationPath())
SwitchCwd()
ovfxml = GetFileContents(LibDir+"/ovf-env.xml")