~hudson-openstack/nova/trunk

23 by Devin Carlen
Initial commit of nodemonitor
1
#!/usr/bin/env python
2
# vim: tabstop=4 shiftwidth=4 softtabstop=4
3
114 by Devin Carlen
Updated licenses
4
# Copyright 2010 United States Government as represented by the
3.1.9 by Vishvananda Ishaya
Removed trailing whitespace from header
5
# Administrator of the National Aeronautics and Space Administration.
114 by Devin Carlen
Updated licenses
6
# All Rights Reserved.
7
#
8
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
9
#    not use this file except in compliance with the License. You may obtain
10
#    a copy of the License at
11
#
12
#         http://www.apache.org/licenses/LICENSE-2.0
13
#
23 by Devin Carlen
Initial commit of nodemonitor
14
#    Unless required by applicable law or agreed to in writing, software
114 by Devin Carlen
Updated licenses
15
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
16
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
17
#    License for the specific language governing permissions and limitations
18
#    under the License.
19
23 by Devin Carlen
Initial commit of nodemonitor
20
"""
21
  Daemon for Nova RRD based instance resource monitoring.
22
"""
23
454.2.2 by jaypipes at gmail
For some reason, I forgot to commit the other endpoints...
24
import gettext
265.1.1 by Soren Hansen
Make the scripts in bin/ detect if they're being run from a bzr checkout
25
import os
26
import sys
23 by Devin Carlen
Initial commit of nodemonitor
27
from twisted.application import service
28
265.1.1 by Soren Hansen
Make the scripts in bin/ detect if they're being run from a bzr checkout
29
# If ../nova/__init__.py exists, add ../ to Python search path, so that
30
# it will override what happens to be installed in /usr/(local/)lib/python...
31
possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
32
                                   os.pardir,
33
                                   os.pardir))
34
if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')):
35
    sys.path.insert(0, possible_topdir)
36
454.2.2 by jaypipes at gmail
For some reason, I forgot to commit the other endpoints...
37
gettext.install('nova', unicode=1)
38
515.4.1 by Todd Willey
Apply logging changes as a giant patch to work around the cloudpipe delete + add issue in the original patch.
39
from nova import log as logging
411.2.1 by Soren Hansen
Unify the location of the default flagfile.
40
from nova import utils
23 by Devin Carlen
Initial commit of nodemonitor
41
from nova import twistd
42
from nova.compute import monitor
43
515.4.2 by Todd Willey
Final few log tweaks, i18n, levels, including contexts, etc.
44
LOG = logging.getLogger('nova.instancemonitor')
515.4.1 by Todd Willey
Apply logging changes as a giant patch to work around the cloudpipe delete + add issue in the original patch.
45
206.3.3 by Eric Day
Cleaned up pep8/pylint for bin/* files. I did not fix rsapi since this is already cleaned up in another branch.
46
47
if __name__ == '__main__':
430.1.1 by Michael Gundlach
Move default_flagfile() call to where it will be parsed in time to load the flagfile
48
    utils.default_flagfile()
206.3.3 by Eric Day
Cleaned up pep8/pylint for bin/* files. I did not fix rsapi since this is already cleaned up in another branch.
49
    twistd.serve(__file__)
50
51
if __name__ == '__builtin__':
515.4.1 by Todd Willey
Apply logging changes as a giant patch to work around the cloudpipe delete + add issue in the original patch.
52
    LOG.warn(_('Starting instance monitor'))
828.2.1 by Brian Lamar
disable-msg -> disable
53
    # pylint: disable=C0103
247.1.1 by Eric Day
More bin/ pep8/pylint cleanup.
54
    monitor = monitor.InstanceMonitor()
23 by Devin Carlen
Initial commit of nodemonitor
55
56
    # This is the parent service that twistd will be looking for when it
57
    # parses this file, return it so that we can get it into globals below
58
    application = service.Application('nova-instancemonitor')
247.1.1 by Eric Day
More bin/ pep8/pylint cleanup.
59
    monitor.setServiceParent(application)