~ubuntu-branches/ubuntu/saucy/nova/saucy-proposed

« back to all changes in this revision

Viewing changes to nova/network/quantum/nova_ipam_lib.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short, Adam Gandelman, Chuck Short, Adam Gandleman
  • Date: 2012-02-03 09:03:12 UTC
  • mfrom: (1.1.43)
  • Revision ID: package-import@ubuntu.com-20120203090312-v0f0yt3tx1dfbd4r
Tags: 2012.1~e4~20120203.12454-0ubuntu1
[ Adam Gandelman ]
[Chuck Short]
* New upstream version.
* debian/control: Replace m2crpto with python-crypto.
  (LP: #917851)
* debian/*.upstart.in, debian/nova-common.postinst,
  debian/nova_sudoers: Change default shell to /bin/false.
  (LP: #890362)

[Adam Gandleman]
* debian/nova-common.{install, postinst}: Install policy.json on all
  Nova nodes (LP: #923817)
* debian/rules: Remove installation of policy.json (moved to nova-common),
  point to the correct upstream git repository.

Show diffs side-by-side

added added

removed removed

Lines of Context:
62
62
        networks = manager.FlatManager.create_networks(self.net_manager,
63
63
                    admin_context, label, cidr,
64
64
                    False, 1, subnet_size, cidr_v6, gateway,
65
 
                    gateway_v6, quantum_net_id, None, dns1, dns2)
 
65
                    gateway_v6, quantum_net_id, None, dns1, dns2,
 
66
                    ipam=True)
 
67
        #TODO(tr3buchet): refactor passing in the ipam key so that
 
68
        # it's no longer required. The reason it exists now is because
 
69
        # nova insists on carving up IP blocks. What ends up happening is
 
70
        # we create a v4 and an identically sized v6 block. The reason
 
71
        # the quantum tests passed previosly is nothing prevented an
 
72
        # incorrect v6 address from being assigned to the wrong subnet
66
73
 
67
74
        if len(networks) != 1:
68
75
            raise Exception(_("Error creating network entry"))
122
129
            id_priority_map[net_id] = n['priority']
123
130
        return sorted(net_list, key=lambda x: id_priority_map[x[0]])
124
131
 
125
 
    def allocate_fixed_ip(self, context, tenant_id, quantum_net_id, vif_rec):
 
132
    def allocate_fixed_ip(self, context, tenant_id, quantum_net_id,
 
133
                          network_tenant_id, vif_rec):
126
134
        """Allocates a single fixed IPv4 address for a virtual interface."""
127
135
        admin_context = context.elevated()
128
136
        network = db.network_get_by_uuid(admin_context, quantum_net_id)
147
155
           associated with a Quantum Network UUID.
148
156
        """
149
157
        n = db.network_get_by_uuid(context.elevated(), net_id)
150
 
        subnet_data_v4 = {
 
158
        subnet_v4 = {
151
159
            'network_id': n['uuid'],
152
160
            'cidr': n['cidr'],
153
161
            'gateway': n['gateway'],
154
162
            'broadcast': n['broadcast'],
155
163
            'netmask': n['netmask'],
 
164
            'version': 4,
156
165
            'dns1': n['dns1'],
157
166
            'dns2': n['dns2']}
158
 
        subnet_data_v6 = {
 
167
        #TODO(tr3buchet): I'm noticing we've assumed here that all dns is v4.
 
168
        #                 this is probably bad as there is no way to add v6
 
169
        #                 dns to nova
 
170
        subnet_v6 = {
159
171
            'network_id': n['uuid'],
160
172
            'cidr': n['cidr_v6'],
161
173
            'gateway': n['gateway_v6'],
162
174
            'broadcast': None,
163
 
            'netmask': None,
 
175
            'netmask': n['netmask_v6'],
 
176
            'version': 6,
164
177
            'dns1': None,
165
178
            'dns2': None}
166
 
        return (subnet_data_v4, subnet_data_v6)
 
179
        return [subnet_v4, subnet_v6]
 
180
 
 
181
    def get_routes_by_ip_block(self, context, block_id, project_id):
 
182
        """Returns the list of routes for the IP block"""
 
183
        return []
167
184
 
168
185
    def get_v4_ips_by_interface(self, context, net_id, vif_id, project_id):
169
186
        """Returns a list of IPv4 address strings associated with
170
187
           the specified virtual interface, based on the fixed_ips table.
171
188
        """
 
189
        # TODO(tr3buchet): link fixed_ips to vif by uuid so only 1 db call
172
190
        vif_rec = db.virtual_interface_get_by_uuid(context, vif_id)
173
191
        fixed_ips = db.fixed_ips_by_virtual_interface(context,
174
 
                                                         vif_rec['id'])
 
192
                                                      vif_rec['id'])
175
193
        return [fixed_ip['address'] for fixed_ip in fixed_ips]
176
194
 
177
195
    def get_v6_ips_by_interface(self, context, net_id, vif_id, project_id):
228
246
                    ip['virtual_interface_id'])
229
247
                allocated_ips.append((ip['address'], vif['uuid']))
230
248
        return allocated_ips
 
249
 
 
250
    def get_floating_ips_by_fixed_address(self, context, fixed_address):
 
251
        return db.floating_ip_get_by_fixed_address(context, fixed_address)