~zulcss/ubuntu/precise/quantum/trunk

« back to all changes in this revision

Viewing changes to quantum/db/dhcp_rpc_base.py

  • Committer: Chuck Short
  • Date: 2012-11-26 19:51:11 UTC
  • mfrom: (26.1.1 raring-proposed)
  • Revision ID: zulcss@ubuntu.com-20121126195111-jnz2cr4xi6whemw2
* New upstream release for the Ubuntu Cloud Archive.
* debian/patches/*: Refreshed for opening of Grizzly.
* New upstream release.
* debian/rules: FTFBS if there is missing binaries.
* debian/quantum-server.install: Add quantum-debug.

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
# See the License for the specific language governing permissions and
14
14
# limitations under the License.
15
15
 
16
 
import logging
17
 
 
18
16
from sqlalchemy.orm import exc
19
17
 
20
 
from quantum import context as quantum_context
 
18
from quantum.api.v2 import attributes
21
19
from quantum import manager
22
 
from quantum.api.v2 import attributes
23
 
from quantum.openstack.common import context
 
20
from quantum.openstack.common import log as logging
24
21
 
25
22
 
26
23
LOG = logging.getLogger(__name__)
27
24
 
28
25
 
29
 
def augment_context(context):
30
 
    """Augments RPC with additional attributes, so that plugin calls work."""
31
 
    return quantum_context.Context(context.user, None, is_admin=True,
32
 
                                   roles=['admin'])
33
 
 
34
 
 
35
26
class DhcpRpcCallbackMixin(object):
36
27
    """A mix-in that enable DHCP agent support in plugin implementations."""
37
28
 
40
31
        host = kwargs.get('host')
41
32
        LOG.debug('Network list requested from %s', host)
42
33
        plugin = manager.QuantumManager.get_plugin()
43
 
        context = augment_context(context)
44
34
        filters = dict(admin_state_up=[True])
45
35
 
46
36
        return [net['id'] for net in
49
39
    def get_network_info(self, context, **kwargs):
50
40
        """Retrieve and return a extended information about a network."""
51
41
        network_id = kwargs.get('network_id')
52
 
        context = augment_context(context)
53
42
        plugin = manager.QuantumManager.get_plugin()
54
43
        network = plugin.get_network(context, network_id)
55
44
 
69
58
        host = kwargs.get('host')
70
59
        network_id = kwargs.get('network_id')
71
60
        device_id = kwargs.get('device_id')
72
 
         # There could be more than one dhcp server per network, so create
73
 
         # a device id that combines host and network ids
 
61
        # There could be more than one dhcp server per network, so create
 
62
        # a device id that combines host and network ids
74
63
 
75
64
        LOG.debug('Port %s for %s requested from %s', device_id, network_id,
76
65
                  host)
77
 
        context = augment_context(context)
78
66
        plugin = manager.QuantumManager.get_plugin()
79
67
        retval = None
80
68
 
137
125
 
138
126
        LOG.debug('DHCP port deletion for %s d request from %s', network_id,
139
127
                  host)
140
 
        context = augment_context(context)
141
128
        plugin = manager.QuantumManager.get_plugin()
142
129
        filters = dict(network_id=[network_id], device_id=[device_id])
143
130
        ports = plugin.get_ports(context, filters=filters)
155
142
        LOG.debug('DHCP port remove fixed_ip for %s d request from %s',
156
143
                  subnet_id,
157
144
                  host)
158
 
 
159
 
        context = augment_context(context)
160
145
        plugin = manager.QuantumManager.get_plugin()
161
146
        filters = dict(network_id=[network_id], device_id=[device_id])
162
147
        ports = plugin.get_ports(context, filters=filters)
180
165
 
181
166
        LOG.debug('Updating lease expiration for %s on network %s from %s.',
182
167
                  ip_address, network_id, host)
183
 
 
184
 
        context = augment_context(context)
185
168
        plugin = manager.QuantumManager.get_plugin()
186
169
 
187
170
        plugin.update_fixed_ip_lease_expiration(context, network_id,