1 # Copyright (c) 2012 New Dream Network, LLC (DreamHost)
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
8 # http://www.apache.org/licenses/LICENSE-2.0
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
15 """Cron script to generate usage notifications for networks, ports and
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
30 config.init(sys.argv[1:])
31 config.setup_logging()
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})