Projet

Général

Profil

Révision d168d49e

IDd168d49ee4647ef2b01c5341324d68e104ba4c57
Parent db7403f2
Enfant 37d81d7a

Ajouté par Lars Kruse il y a environ 5 ans

Plugin nova_floating_ips: migrate to Python3, format documentation

Voir les différences:

plugins/nova/nova_floating_ips
1
#!/usr/bin/env python
2
#
3
# Plugin to monitor status of Floating IPs in Nova
4
#
5
# To monitor a floating ips, link floating_ips to this file.
6
# E.g.
7
#    ln -s /usr/share/munin/plugins/nova_floating_ips /etc/munin/plugins/
8
#
9
# Needs following minimal configuration in plugin-conf.d/nova:
10
#   [nova_*]
11
#   user nova
12
#
13
# Magic markers
14
#%# capabilities=autoconf
15
#%# family=auto
1
#!/usr/bin/env python3
2
"""
3

  
4
=head1 NAME
5

  
6
nova_floating_ips - monitor status of Floating IPs in Nova
7

  
8

  
9
=head1 CONFIGURATION
10

  
11
To monitor a floating ips, link floating_ips to this file.
12
E.g.
13

  
14
 ln -s /usr/share/munin/plugins/nova_floating_ips /etc/munin/plugins/
15

  
16
Needs following minimal configuration in plugin-conf.d/nova:
17

  
18
 [nova_*]
19
 user nova
20

  
21

  
22
=head1 AUTHORS
23

  
24
Copyright 2012 Mehdi Abaakouk <sileht@sileht.net>
25

  
26

  
27
=head1 MAGIC MARKERS
28

  
29
 #%# capabilities=autoconf
30
 #%# family=auto
31

  
32
=cut
33
"""
16 34

  
17 35
import sys
18 36

  
......
27 45
    successful_import = True
28 46

  
29 47

  
30

  
31 48
states = ['total', 'allocated', 'associated']
32 49

  
50

  
33 51
def print_config():
34 52
    global states
35
    print 'graph_title Nova Floating IPs'
36
    print 'graph_vlabel IPs'
37
    print 'graph_args --base 1000 --lower-limit 0'
38
    print 'graph_category cloud'
39
    print 'graph_scale no'
40
    print 'graph_info This graph shows the number of Floating IPs in Nova and their status'
53
    print('graph_title Nova Floating IPs')
54
    print('graph_vlabel IPs')
55
    print('graph_args --base 1000 --lower-limit 0')
56
    print('graph_category cloud')
57
    print('graph_scale no')
58
    print('graph_info This graph shows the number of Floating IPs in Nova and their status')
41 59
    for state in states:
42
        print '%s.label %s' % (state, state)
43
        print '%s.draw LINE2' % state
44
        print '%s.info %s IPs' % (state, state)
60
        print('%s.label %s' % (state, state))
61
        print('%s.draw LINE2' % state)
62
        print('%s.info %s IPs' % (state, state))
45 63

  
46 64

  
47 65
def get_status():
......
63 81

  
64 82
def print_values():
65 83
    status = get_status()
66
    for (state, value) in status.iteritems():
67
        print "%s.value %s" % (state, value)
84
    for (state, value) in status.items():
85
        print("%s.value %s" % (state, value))
68 86

  
69 87

  
70 88
if __name__ == '__main__':
......
73 91
            print_config()
74 92
        elif sys.argv[1] == "autoconf":
75 93
            if not successful_import:
76
                print 'no (failed import nova module)'
94
                print('no (failed import nova module)')
77 95
                sys.exit(0)
78 96
            else:
79
                print 'yes'
97
                print('yes')
80 98
    elif successful_import:
81 99
        utils.default_flagfile()
82 100
        flags.FLAGS(sys.argv)
t/test-exception-wrapper.expected-failures
270 270
plugins/nginx/nginx_upstream
271 271
plugins/nginx/nginx_vhost_traffic
272 272
plugins/nginx/nginx_working_set
273
plugins/nova/nova_floating_ips
274 273
plugins/nova/nova_instance_
275 274
plugins/nova/nova_instance_launched
276 275
plugins/nova/nova_instance_timing

Formats disponibles : Unified diff