~0x44/nova/bug838466

« back to all changes in this revision

Viewing changes to bin/nova-instancemonitor

  • Committer: Brian Waldon
  • Date: 2011-07-29 19:58:41 UTC
  • mto: This revision was merged to the branch mainline in revision 1364.
  • Revision ID: brian.waldon@rackspace.com-20110729195841-9gotdic0qhazqkpy
typo

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
# vim: tabstop=4 shiftwidth=4 softtabstop=4
 
3
 
 
4
# Copyright 2010 United States Government as represented by the
 
5
# Administrator of the National Aeronautics and Space Administration.
 
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
#
 
14
#    Unless required by applicable law or agreed to in writing, software
 
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
 
 
20
"""
 
21
  Daemon for Nova RRD based instance resource monitoring.
 
22
"""
 
23
 
 
24
import gettext
 
25
import os
 
26
import sys
 
27
from twisted.application import service
 
28
 
 
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
 
 
37
gettext.install('nova', unicode=1)
 
38
 
 
39
from nova import log as logging
 
40
from nova import utils
 
41
from nova import twistd
 
42
from nova.compute import monitor
 
43
 
 
44
LOG = logging.getLogger('nova.instancemonitor')
 
45
 
 
46
 
 
47
if __name__ == '__main__':
 
48
    utils.default_flagfile()
 
49
    twistd.serve(__file__)
 
50
 
 
51
if __name__ == '__builtin__':
 
52
    LOG.warn(_('Starting instance monitor'))
 
53
    # pylint: disable=C0103
 
54
    monitor = monitor.InstanceMonitor()
 
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')
 
59
    monitor.setServiceParent(application)