Set lock_path correctly.
[openstack-build/neutron-build.git] / neutron / cmd / eventlet / usage_audit.py
1 # Copyright (c) 2012 New Dream Network, LLC (DreamHost)
2 # All Rights Reserved.
3 #
4 #    Licensed under the Apache License, Version 2.0 (the "License"); you may
5 #    not use this file except in compliance with the License. You may obtain
6 #    a copy of the License at
7 #
8 #         http://www.apache.org/licenses/LICENSE-2.0
9 #
10 #    Unless required by applicable law or agreed to in writing, software
11 #    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 #    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 #    License for the specific language governing permissions and limitations
14 #    under the License.
15 """Cron script to generate usage notifications for networks, ports and
16 subnets.
17
18 """
19
20 import sys
21
22 from neutron.common import config
23 from neutron.common import rpc as n_rpc
24 from neutron import context
25 from neutron import manager
26 from neutron.plugins.common import constants
27
28
29 def main():
30     config.init(sys.argv[1:])
31     config.setup_logging()
32
33     cxt = context.get_admin_context()
34     plugin = manager.NeutronManager.get_plugin()
35     l3_plugin = manager.NeutronManager.get_service_plugins().get(
36             constants.L3_ROUTER_NAT)
37     notifier = n_rpc.get_notifier('network')
38     for network in plugin.get_networks(cxt):
39         notifier.info(cxt, 'network.exists', {'network': network})
40     for subnet in plugin.get_subnets(cxt):
41         notifier.info(cxt, 'subnet.exists', {'subnet': subnet})
42     for port in plugin.get_ports(cxt):
43         notifier.info(cxt, 'port.exists', {'port': port})
44     for router in l3_plugin.get_routers(cxt):
45         notifier.info(cxt, 'router.exists', {'router': router})
46     for floatingip in l3_plugin.get_floatingips(cxt):
47         notifier.info(cxt, 'floatingip.exists', {'floatingip': floatingip})