1
# Microsoft Azure Linux Agent
3
# Copyright 2014 Microsoft Corporation
5
# Licensed under the Apache License, Version 2.0 (the "License");
6
# you may not use this file except in compliance with the License.
7
# You may obtain a copy of the License at
9
# http://www.apache.org/licenses/LICENSE-2.0
11
# Unless required by applicable law or agreed to in writing, software
12
# distributed under the License is distributed on an "AS IS" BASIS,
13
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
# See the License for the specific language governing permissions and
15
# limitations under the License.
17
# Requires Python 2.4+ and Openssl 1.0+
23
import azurelinuxagent.logger as logger
24
from azurelinuxagent.future import text
25
import azurelinuxagent.conf as conf
26
from azurelinuxagent.metadata import AGENT_LONG_NAME, AGENT_VERSION, \
27
DISTRO_NAME, DISTRO_VERSION, \
28
DISTRO_FULL_NAME, PY_VERSION_MAJOR, \
29
PY_VERSION_MINOR, PY_VERSION_MICRO
30
import azurelinuxagent.event as event
31
import azurelinuxagent.protocol as prot
32
from azurelinuxagent.utils.osutil import OSUTIL
33
import azurelinuxagent.utils.fileutil as fileutil
36
class MainHandler(object):
37
def __init__(self, handlers):
38
self.handlers = handlers
41
logger.info("{0} Version:{1}", AGENT_LONG_NAME, AGENT_VERSION)
42
logger.info("OS: {0} {1}", DISTRO_NAME, DISTRO_VERSION)
43
logger.info("Python: {0}.{1}.{2}", PY_VERSION_MAJOR, PY_VERSION_MINOR,
46
event.enable_unhandled_err_dump("Azure Linux Agent")
47
fileutil.write_file(OSUTIL.get_agent_pid_file_path(), text(os.getpid()))
49
if conf.get_switch("DetectScvmmEnv", False):
50
if self.handlers.scvmm_handler.detect_scvmm_env():
53
self.handlers.dhcp_handler.probe()
55
prot.detect_default_protocol()
57
event.EventMonitor().start()
59
self.handlers.provision_handler.process()
61
if conf.get_switch("ResourceDisk.Format", False):
62
self.handlers.resource_disk_handler.start_activate_resource_disk()
64
self.handlers.env_handler.start()
66
protocol = prot.FACTORY.get_default_protocol()
69
self.handlers.ext_handlers_handler.process()