~ubuntu-branches/ubuntu/raring/nova/raring-proposed

« back to all changes in this revision

Viewing changes to nova/network/rpcapi.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short, Adam Gandelman, Chuck Short
  • Date: 2012-11-23 09:04:58 UTC
  • mfrom: (1.1.66)
  • Revision ID: package-import@ubuntu.com-20121123090458-91565o7aev1i1h71
Tags: 2013.1~g1-0ubuntu1
[ Adam Gandelman ]
* debian/control: Ensure novaclient is upgraded with nova,
  require python-keystoneclient >= 1:2.9.0. (LP: #1073289)
* debian/patches/{ubuntu/*, rbd-security.patch}: Dropped, applied
  upstream.
* debian/control: Add python-testtools to Build-Depends.

[ Chuck Short ]
* New upstream version.
* Refreshed debian/patches/avoid_setuptools_git_dependency.patch.
* debian/rules: FTBFS if missing binaries.
* debian/nova-scheudler.install: Add missing rabbit-queues and
  nova-rpc-zmq-receiver.
* Remove nova-volume since it doesnt exist anymore, transition to cinder-*.
* debian/rules: install apport hook in the right place.
* debian/patches/ubuntu-show-tests.patch: Display test failures.
* debian/control: Add depends on genisoimage
* debian/control: Suggest guestmount.
* debian/control: Suggest websockify. (LP: #1076442)
* debian/nova.conf: Disable nova-volume service.
* debian/control: Depend on xen-system-* rather than the hypervisor.
* debian/control, debian/mans/nova-conductor.8, debian/nova-conductor.init,
  debian/nova-conductor.install, debian/nova-conductor.logrotate
  debian/nova-conductor.manpages, debian/nova-conductor.postrm
  debian/nova-conductor.upstart.in: Add nova-conductor service.
* debian/control: Add python-fixtures as a build deps.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# vim: tabstop=4 shiftwidth=4 softtabstop=4
 
2
 
 
3
# Copyright 2012, Red Hat, Inc.
 
4
#
 
5
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
 
6
#    not use this file except in compliance with the License. You may obtain
 
7
#    a copy of the License at
 
8
#
 
9
#         http://www.apache.org/licenses/LICENSE-2.0
 
10
#
 
11
#    Unless required by applicable law or agreed to in writing, software
 
12
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 
13
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 
14
#    License for the specific language governing permissions and limitations
 
15
#    under the License.
 
16
 
 
17
"""
 
18
Client side of the network RPC API.
 
19
"""
 
20
 
 
21
from nova.openstack.common import cfg
 
22
from nova.openstack.common import jsonutils
 
23
from nova.openstack.common import rpc
 
24
from nova.openstack.common.rpc import proxy as rpc_proxy
 
25
 
 
26
CONF = cfg.CONF
 
27
CONF.import_opt('network_topic', 'nova.config')
 
28
 
 
29
 
 
30
class NetworkAPI(rpc_proxy.RpcProxy):
 
31
    '''Client side of the network rpc API.
 
32
 
 
33
    API version history:
 
34
 
 
35
        1.0 - Initial version.
 
36
        1.1 - Adds migrate_instance_[start|finish]
 
37
        1.2 - Make migrate_instance_[start|finish] a little more flexible
 
38
    '''
 
39
 
 
40
    #
 
41
    # NOTE(russellb): This is the default minimum version that the server
 
42
    # (manager) side must implement unless otherwise specified using a version
 
43
    # argument to self.call()/cast()/etc. here.  It should be left as X.0 where
 
44
    # X is the current major API version (1.0, 2.0, ...).  For more information
 
45
    # about rpc API versioning, see the docs in
 
46
    # openstack/common/rpc/dispatcher.py.
 
47
    #
 
48
    BASE_RPC_API_VERSION = '1.0'
 
49
 
 
50
    def __init__(self, topic=None):
 
51
        topic = topic if topic else CONF.network_topic
 
52
        super(NetworkAPI, self).__init__(
 
53
                topic=topic,
 
54
                default_version=self.BASE_RPC_API_VERSION)
 
55
 
 
56
    def get_all_networks(self, ctxt):
 
57
        return self.call(ctxt, self.make_msg('get_all_networks'))
 
58
 
 
59
    def get_network(self, ctxt, network_uuid):
 
60
        return self.call(ctxt, self.make_msg('get_network',
 
61
                network_uuid=network_uuid))
 
62
 
 
63
    # TODO(russellb): Convert this to named arguments.  It's a pretty large
 
64
    # list, so unwinding it all is probably best done in its own patch so it's
 
65
    # easier to review.
 
66
    def create_networks(self, ctxt, **kwargs):
 
67
        return self.call(ctxt, self.make_msg('create_networks', **kwargs))
 
68
 
 
69
    def delete_network(self, ctxt, uuid, fixed_range):
 
70
        return self.call(ctxt, self.make_msg('delete_network',
 
71
                uuid=uuid, fixed_range=fixed_range))
 
72
 
 
73
    def disassociate_network(self, ctxt, network_uuid):
 
74
        return self.call(ctxt, self.make_msg('disassociate_network',
 
75
                network_uuid=network_uuid))
 
76
 
 
77
    def get_fixed_ip(self, ctxt, id):
 
78
        return self.call(ctxt, self.make_msg('get_fixed_ip', id=id))
 
79
 
 
80
    def get_fixed_ip_by_address(self, ctxt, address):
 
81
        return self.call(ctxt, self.make_msg('get_fixed_ip_by_address',
 
82
                address=address))
 
83
 
 
84
    def get_floating_ip(self, ctxt, id):
 
85
        return self.call(ctxt, self.make_msg('get_floating_ip', id=id))
 
86
 
 
87
    def get_floating_pools(self, ctxt):
 
88
        return self.call(ctxt, self.make_msg('get_floating_pools'))
 
89
 
 
90
    def get_floating_ip_by_address(self, ctxt, address):
 
91
        return self.call(ctxt, self.make_msg('get_floating_ip_by_address',
 
92
                address=address))
 
93
 
 
94
    def get_floating_ips_by_project(self, ctxt):
 
95
        return self.call(ctxt, self.make_msg('get_floating_ips_by_project'))
 
96
 
 
97
    def get_floating_ips_by_fixed_address(self, ctxt, fixed_address):
 
98
        return self.call(ctxt, self.make_msg(
 
99
                'get_floating_ips_by_fixed_address',
 
100
                fixed_address=fixed_address))
 
101
 
 
102
    def get_instance_id_by_floating_address(self, ctxt, address):
 
103
        return self.call(ctxt, self.make_msg(
 
104
                'get_instance_id_by_floating_address',
 
105
                address=address))
 
106
 
 
107
    def get_backdoor_port(self, ctxt):
 
108
        return self.call(ctxt, self.make_msg('get_backdoor_port'))
 
109
 
 
110
    def get_vifs_by_instance(self, ctxt, instance_id):
 
111
        # NOTE(vish): When the db calls are converted to store network
 
112
        #             data by instance_uuid, this should pass uuid instead.
 
113
        return self.call(ctxt, self.make_msg('get_vifs_by_instance',
 
114
                instance_id=instance_id))
 
115
 
 
116
    def get_vif_by_mac_address(self, ctxt, mac_address):
 
117
        return self.call(ctxt, self.make_msg('get_vif_by_mac_address',
 
118
                mac_address=mac_address))
 
119
 
 
120
    def allocate_floating_ip(self, ctxt, project_id, pool, auto_assigned):
 
121
        return self.call(ctxt, self.make_msg('allocate_floating_ip',
 
122
                project_id=project_id, pool=pool, auto_assigned=auto_assigned))
 
123
 
 
124
    def deallocate_floating_ip(self, ctxt, address, affect_auto_assigned):
 
125
        return self.call(ctxt, self.make_msg('deallocate_floating_ip',
 
126
            address=address, affect_auto_assigned=affect_auto_assigned))
 
127
 
 
128
    def associate_floating_ip(self, ctxt, floating_address, fixed_address,
 
129
                              affect_auto_assigned):
 
130
        return self.call(ctxt, self.make_msg('associate_floating_ip',
 
131
                floating_address=floating_address, fixed_address=fixed_address,
 
132
                affect_auto_assigned=affect_auto_assigned))
 
133
 
 
134
    def disassociate_floating_ip(self, ctxt, address, affect_auto_assigned):
 
135
        return self.call(ctxt, self.make_msg('disassociate_floating_ip',
 
136
                address=address, affect_auto_assigned=affect_auto_assigned))
 
137
 
 
138
    def allocate_for_instance(self, ctxt, instance_id, instance_uuid,
 
139
                              project_id, host, rxtx_factor, vpn,
 
140
                              requested_networks):
 
141
        return self.call(ctxt, self.make_msg('allocate_for_instance',
 
142
                instance_id=instance_id, instance_uuid=instance_uuid,
 
143
                project_id=project_id, host=host, rxtx_factor=rxtx_factor,
 
144
                vpn=vpn, requested_networks=requested_networks))
 
145
 
 
146
    def deallocate_for_instance(self, ctxt, instance_id, project_id, host):
 
147
        return self.call(ctxt, self.make_msg('deallocate_for_instance',
 
148
                instance_id=instance_id, project_id=project_id, host=host))
 
149
 
 
150
    def add_fixed_ip_to_instance(self, ctxt, instance_id, host, network_id):
 
151
        return self.call(ctxt, self.make_msg('add_fixed_ip_to_instance',
 
152
                instance_id=instance_id, host=host, network_id=network_id))
 
153
 
 
154
    def remove_fixed_ip_from_instance(self, ctxt, instance_id, host, address):
 
155
        return self.call(ctxt, self.make_msg('remove_fixed_ip_from_instance',
 
156
                instance_id=instance_id, host=host, address=address))
 
157
 
 
158
    def add_network_to_project(self, ctxt, project_id, network_uuid):
 
159
        return self.call(ctxt, self.make_msg('add_network_to_project',
 
160
                project_id=project_id, network_uuid=network_uuid))
 
161
 
 
162
    def get_instance_nw_info(self, ctxt, instance_id, instance_uuid,
 
163
                             rxtx_factor, host, project_id):
 
164
        return self.call(ctxt, self.make_msg('get_instance_nw_info',
 
165
                instance_id=instance_id, instance_uuid=instance_uuid,
 
166
                rxtx_factor=rxtx_factor, host=host, project_id=project_id))
 
167
 
 
168
    def validate_networks(self, ctxt, networks):
 
169
        return self.call(ctxt, self.make_msg('validate_networks',
 
170
                networks=networks))
 
171
 
 
172
    def get_instance_uuids_by_ip_filter(self, ctxt, filters):
 
173
        return self.call(ctxt, self.make_msg('get_instance_uuids_by_ip_filter',
 
174
                filters=filters))
 
175
 
 
176
    def get_dns_domains(self, ctxt):
 
177
        return self.call(ctxt, self.make_msg('get_dns_domains'))
 
178
 
 
179
    def add_dns_entry(self, ctxt, address, name, dns_type, domain):
 
180
        return self.call(ctxt, self.make_msg('add_dns_entry', address=address,
 
181
                name=name, dns_type=dns_type, domain=domain))
 
182
 
 
183
    def modify_dns_entry(self, ctxt, address, name, domain):
 
184
        return self.call(ctxt, self.make_msg('modify_dns_entry',
 
185
                address=address, name=name, domain=domain))
 
186
 
 
187
    def delete_dns_entry(self, ctxt, name, domain):
 
188
        return self.call(ctxt, self.make_msg('delete_dns_entry',
 
189
                name=name, domain=domain))
 
190
 
 
191
    def delete_dns_domain(self, ctxt, domain):
 
192
        return self.call(ctxt, self.make_msg('delete_dns_domain',
 
193
                domain=domain))
 
194
 
 
195
    def get_dns_entries_by_address(self, ctxt, address, domain):
 
196
        return self.call(ctxt, self.make_msg('get_dns_entries_by_address',
 
197
                address=address, domain=domain))
 
198
 
 
199
    def get_dns_entries_by_name(self, ctxt, name, domain):
 
200
        return self.call(ctxt, self.make_msg('get_dns_entries_by_name',
 
201
                name=name, domain=domain))
 
202
 
 
203
    def create_private_dns_domain(self, ctxt, domain, av_zone):
 
204
        return self.call(ctxt, self.make_msg('create_private_dns_domain',
 
205
                domain=domain, av_zone=av_zone))
 
206
 
 
207
    def create_public_dns_domain(self, ctxt, domain, project):
 
208
        return self.call(ctxt, self.make_msg('create_public_dns_domain',
 
209
                domain=domain, project=project))
 
210
 
 
211
    def setup_networks_on_host(self, ctxt, instance_id, host, teardown):
 
212
        # NOTE(tr3buchet): the call is just to wait for completion
 
213
        return self.call(ctxt, self.make_msg('setup_networks_on_host',
 
214
                instance_id=instance_id, host=host, teardown=teardown))
 
215
 
 
216
    def set_network_host(self, ctxt, network_ref):
 
217
        network_ref_p = jsonutils.to_primitive(network_ref)
 
218
        return self.call(ctxt, self.make_msg('set_network_host',
 
219
                network_ref=network_ref_p))
 
220
 
 
221
    def rpc_setup_network_on_host(self, ctxt, network_id, teardown, host):
 
222
        # NOTE(tr3buchet): the call is just to wait for completion
 
223
        return self.call(ctxt, self.make_msg('rpc_setup_network_on_host',
 
224
                network_id=network_id, teardown=teardown),
 
225
                topic=rpc.queue_get_for(ctxt, self.topic, host))
 
226
 
 
227
    # NOTE(russellb): Ideally this would not have a prefix of '_' since it is
 
228
    # a part of the rpc API. However, this is how it was being called when the
 
229
    # 1.0 API was being documented using this client proxy class.  It should be
 
230
    # changed if there was ever a 2.0.
 
231
    def _rpc_allocate_fixed_ip(self, ctxt, instance_id, network_id, address,
 
232
                               vpn, host):
 
233
        return self.call(ctxt, self.make_msg('_rpc_allocate_fixed_ip',
 
234
                instance_id=instance_id, network_id=network_id,
 
235
                address=address, vpn=vpn),
 
236
                topic=rpc.queue_get_for(ctxt, self.topic, host))
 
237
 
 
238
    def deallocate_fixed_ip(self, ctxt, address, host):
 
239
        return self.call(ctxt, self.make_msg('deallocate_fixed_ip',
 
240
                address=address, host=host),
 
241
                topic=rpc.queue_get_for(ctxt, self.topic, host))
 
242
 
 
243
    # NOTE(russellb): Ideally this would not have a prefix of '_' since it is
 
244
    # a part of the rpc API. However, this is how it was being called when the
 
245
    # 1.0 API was being documented using this client proxy class.  It should be
 
246
    # changed if there was ever a 2.0.
 
247
    def _associate_floating_ip(self, ctxt, floating_address, fixed_address,
 
248
                               interface, host):
 
249
        return self.call(ctxt, self.make_msg('_associate_floating_ip',
 
250
                floating_address=floating_address, fixed_address=fixed_address,
 
251
                interface=interface),
 
252
                topic=rpc.queue_get_for(ctxt, self.topic, host))
 
253
 
 
254
    # NOTE(russellb): Ideally this would not have a prefix of '_' since it is
 
255
    # a part of the rpc API. However, this is how it was being called when the
 
256
    # 1.0 API was being documented using this client proxy class.  It should be
 
257
    # changed if there was ever a 2.0.
 
258
    def _disassociate_floating_ip(self, ctxt, address, interface, host):
 
259
        return self.call(ctxt, self.make_msg('_disassociate_floating_ip',
 
260
                address=address, interface=interface),
 
261
                topic=rpc.queue_get_for(ctxt, self.topic, host))
 
262
 
 
263
    def lease_fixed_ip(self, ctxt, address, host):
 
264
        self.cast(ctxt, self.make_msg('lease_fixed_ip', address=address),
 
265
                  topic=rpc.queue_get_for(ctxt, self.topic, host))
 
266
 
 
267
    def release_fixed_ip(self, ctxt, address, host):
 
268
        self.cast(ctxt, self.make_msg('release_fixed_ip', address=address),
 
269
                  topic=rpc.queue_get_for(ctxt, self.topic, host))
 
270
 
 
271
    def migrate_instance_start(self, ctxt, instance_uuid, rxtx_factor,
 
272
                               project_id, source_compute, dest_compute,
 
273
                               floating_addresses, host=None):
 
274
        topic = rpc.queue_get_for(ctxt, self.topic, host)
 
275
        return self.call(ctxt, self.make_msg(
 
276
                'migrate_instance_start',
 
277
                instance_uuid=instance_uuid,
 
278
                rxtx_factor=rxtx_factor,
 
279
                project_id=project_id,
 
280
                source=source_compute,
 
281
                dest=dest_compute,
 
282
                floating_addresses=floating_addresses),
 
283
                topic=topic,
 
284
                version='1.2')
 
285
 
 
286
    def migrate_instance_finish(self, ctxt, instance_uuid, rxtx_factor,
 
287
                                project_id, source_compute, dest_compute,
 
288
                                floating_addresses, host=None):
 
289
        topic = rpc.queue_get_for(ctxt, self.topic, host)
 
290
        return self.call(ctxt, self.make_msg(
 
291
                'migrate_instance_finish',
 
292
                instance_uuid=instance_uuid,
 
293
                rxtx_factor=rxtx_factor,
 
294
                project_id=project_id,
 
295
                source=source_compute,
 
296
                dest=dest_compute,
 
297
                floating_addresses=floating_addresses),
 
298
                topic=topic,
 
299
                version='1.2')