~ubuntu-branches/debian/sid/waagent/sid

« back to all changes in this revision

Viewing changes to azurelinuxagent/distro/default/run.py

  • Committer: Package Import Robot
  • Author(s): Bastian Blank
  • Date: 2016-02-11 16:40:04 UTC
  • mfrom: (1.2.3)
  • Revision ID: package-import@ubuntu.com-20160211164004-m9chank2yihdviil
Tags: 2.1.3-1
* New upstream version.
* Only create /var/lib/waagent on initial installation

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Microsoft Azure Linux Agent
2
 
#
3
 
# Copyright 2014 Microsoft Corporation
4
 
#
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
8
 
#
9
 
#     http://www.apache.org/licenses/LICENSE-2.0
10
 
#
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.
16
 
#
17
 
# Requires Python 2.4+ and Openssl 1.0+
18
 
#
19
 
 
20
 
import os
21
 
import time
22
 
import sys
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
34
 
 
35
 
 
36
 
class MainHandler(object):
37
 
    def __init__(self, handlers):
38
 
        self.handlers = handlers
39
 
 
40
 
    def run(self):
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,
44
 
                    PY_VERSION_MICRO)
45
 
 
46
 
        event.enable_unhandled_err_dump("Azure Linux Agent")
47
 
        fileutil.write_file(OSUTIL.get_agent_pid_file_path(), text(os.getpid()))
48
 
 
49
 
        if conf.get_switch("DetectScvmmEnv", False):
50
 
            if self.handlers.scvmm_handler.detect_scvmm_env():
51
 
                return
52
 
 
53
 
        self.handlers.dhcp_handler.probe()
54
 
 
55
 
        prot.detect_default_protocol()
56
 
 
57
 
        event.EventMonitor().start()
58
 
 
59
 
        self.handlers.provision_handler.process()
60
 
 
61
 
        if conf.get_switch("ResourceDisk.Format", False):
62
 
            self.handlers.resource_disk_handler.start_activate_resource_disk()
63
 
 
64
 
        self.handlers.env_handler.start()
65
 
 
66
 
        protocol = prot.FACTORY.get_default_protocol()
67
 
        while True:
68
 
            #Handle extensions
69
 
            self.handlers.ext_handlers_handler.process()
70
 
            time.sleep(25)
71