summaryrefslogtreecommitdiff
path: root/azurelinuxagent/daemon/main.py
diff options
context:
space:
mode:
authorƁukasz 'sil2100' Zemczak <lukasz.zemczak@ubuntu.com>2017-03-15 10:19:34 +0100
committerusd-importer <ubuntu-server@lists.ubuntu.com>2017-03-17 13:08:24 +0000
commitc6339c307f36f77a4198d6faf1275acdf371200b (patch)
treec774046e1e30617514c09e5a2b896568706a25a8 /azurelinuxagent/daemon/main.py
parentdd73af563850762aad64e7ed2a9897377830af10 (diff)
parent2bc77af05fe602a2ba92569428c6006d1aebd19f (diff)
downloadvyos-walinuxagent-c6339c307f36f77a4198d6faf1275acdf371200b.tar.gz
vyos-walinuxagent-c6339c307f36f77a4198d6faf1275acdf371200b.zip
Import patches-applied version 2.2.6-0ubuntu1 to applied/ubuntu/zesty-proposed
Imported using git-ubuntu import. Changelog parent: dd73af563850762aad64e7ed2a9897377830af10 Unapplied parent: 2bc77af05fe602a2ba92569428c6006d1aebd19f New changelog entries: * New upstream release (LP: #1661750). * debian/control: - Change the maintainer to Ubuntu Developers (LP: #1657528). - Add the dependency of isc-dhcp-client as our maintainer scripts assume it's installed. - Add trailing commas to dependencies, add whitespaces. * Rename ephemeral-disk-warning.sh to ephemeral-disk-warning (lintian error). * debian/docs: - Remove LICENSE.txt as it's redundant. * debian/postinst: - Stop checking for update-initramfs existence using the absolute path, use the 'command' command instead to make lintian happy. * Remove debian/patches/disable-auto-update.patch: - We now ship with auto-updates enabled (LP: #1650522). * debian/maintscript: - Add a maintscript to rename the old logrotate file on upgrade from an ancient version of walinuxagent (LP: #1673152).
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()