summaryrefslogtreecommitdiff
path: root/azurelinuxagent/daemon/main.py
diff options
context:
space:
mode:
Diffstat (limited to 'azurelinuxagent/daemon/main.py')
-rw-r--r--azurelinuxagent/daemon/main.py31
1 files changed, 14 insertions, 17 deletions
diff --git a/azurelinuxagent/daemon/main.py b/azurelinuxagent/daemon/main.py
index d3185a1..b0da02a 100644
--- a/azurelinuxagent/daemon/main.py
+++ b/azurelinuxagent/daemon/main.py
@@ -23,34 +23,32 @@ import time
import traceback
import azurelinuxagent.common.conf as conf
-import azurelinuxagent.common.event as event
-import azurelinuxagent.common.utils.fileutil as fileutil
import azurelinuxagent.common.logger as logger
-
-from azurelinuxagent.common.future import ustr
+import azurelinuxagent.common.utils.fileutil as fileutil
from azurelinuxagent.common.event import add_event, WALAEventOperation
-from azurelinuxagent.common.exception import ProtocolError
+from azurelinuxagent.common.future import ustr
from azurelinuxagent.common.osutil import get_osutil
from azurelinuxagent.common.protocol import get_protocol_util
-from azurelinuxagent.common.rdma import RDMADeviceHandler, setup_rdma_device
-from azurelinuxagent.common.utils.textutil import parse_doc, find, getattrib
+from azurelinuxagent.common.rdma import setup_rdma_device
from azurelinuxagent.common.version import AGENT_LONG_NAME, AGENT_VERSION, \
- DISTRO_NAME, DISTRO_VERSION, \
- DISTRO_FULL_NAME, PY_VERSION_MAJOR, \
- PY_VERSION_MINOR, PY_VERSION_MICRO
+ DISTRO_NAME, DISTRO_VERSION, PY_VERSION_MAJOR, PY_VERSION_MINOR, \
+ PY_VERSION_MICRO
from azurelinuxagent.daemon.resourcedisk import get_resourcedisk_handler
from azurelinuxagent.daemon.scvmm import get_scvmm_handler
+from azurelinuxagent.ga.update import get_update_handler
from azurelinuxagent.pa.provision import get_provision_handler
from azurelinuxagent.pa.rdma import get_rdma_handler
-from azurelinuxagent.ga.update import get_update_handler
+
def get_daemon_handler():
return DaemonHandler()
+
class DaemonHandler(object):
"""
Main thread of daemon. It will invoke other threads to do actual work
"""
+
def __init__(self):
self.running = True
self.osutil = get_osutil()
@@ -59,7 +57,7 @@ class DaemonHandler(object):
logger.info("{0} Version:{1}", AGENT_LONG_NAME, AGENT_VERSION)
logger.info("OS: {0} {1}", DISTRO_NAME, DISTRO_VERSION)
logger.info("Python: {0}.{1}.{2}", PY_VERSION_MAJOR, PY_VERSION_MINOR,
- PY_VERSION_MICRO)
+ PY_VERSION_MICRO)
self.check_pid()
@@ -68,12 +66,11 @@ class DaemonHandler(object):
self.daemon()
except Exception as e:
err_msg = traceback.format_exc()
- add_event("WALA", is_success=False, message=ustr(err_msg),
+ add_event("WALA", is_success=False, message=ustr(err_msg),
op=WALAEventOperation.UnhandledError)
logger.info("Sleep 15 seconds and restart daemon")
time.sleep(15)
-
def check_pid(self):
"""Check whether daemon is already running"""
pid = None
@@ -84,11 +81,11 @@ class DaemonHandler(object):
if self.osutil.check_pid_alive(pid):
logger.info("Daemon is already running: {0}", pid)
sys.exit(0)
-
+
fileutil.write_file(pid_file, ustr(os.getpid()))
def daemon(self):
- logger.info("Run daemon")
+ logger.info("Run daemon")
self.protocol_util = get_protocol_util()
self.scvmm_handler = get_scvmm_handler()
@@ -125,6 +122,6 @@ class DaemonHandler(object):
logger.error("Error setting up rdma device: %s" % e)
else:
logger.info("RDMA capabilities are not enabled, skipping")
-
+
while self.running:
self.update_handler.run_latest()