~ubuntu-branches/ubuntu/quantal/nova/quantal-proposed

« back to all changes in this revision

Viewing changes to nova/scheduler/rpcapi.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2012-08-16 14:04:11 UTC
  • mto: This revision was merged to the branch mainline in revision 84.
  • Revision ID: package-import@ubuntu.com-20120816140411-0mr4n241wmk30t9l
Tags: upstream-2012.2~f3
ImportĀ upstreamĀ versionĀ 2012.2~f3

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
"""
20
20
 
21
21
from nova import flags
 
22
from nova.openstack.common import jsonutils
22
23
import nova.openstack.common.rpc.proxy
23
24
 
24
25
 
31
32
    API version history:
32
33
 
33
34
        1.0 - Initial version.
 
35
        1.1 - Changes to prep_resize():
 
36
                - remove instance_uuid, add instance
 
37
                - remove instance_type_id, add instance_type
 
38
                - remove topic, it was unused
 
39
        1.2 - Remove topic from run_instance, it was unused
 
40
        1.3 - Remove instance_id, add instance to live_migration
 
41
        1.4 - Remove update_db from prep_resize
 
42
        1.5 - Add reservations argument to prep_resize()
34
43
    '''
35
44
 
36
 
    RPC_API_VERSION = '1.0'
 
45
    BASE_RPC_API_VERSION = '1.0'
37
46
 
38
47
    def __init__(self):
39
48
        super(SchedulerAPI, self).__init__(topic=FLAGS.scheduler_topic,
40
 
                default_version=self.RPC_API_VERSION)
 
49
                default_version=self.BASE_RPC_API_VERSION)
41
50
 
42
 
    def run_instance(self, ctxt, topic, request_spec, admin_password,
 
51
    def run_instance(self, ctxt, request_spec, admin_password,
43
52
            injected_files, requested_networks, is_first_time,
44
53
            filter_properties, reservations, call=True):
45
54
        rpc_method = self.call if call else self.cast
46
 
        return rpc_method(ctxt, self.make_msg('run_instance', topic=topic,
 
55
        return rpc_method(ctxt, self.make_msg('run_instance',
47
56
                request_spec=request_spec, admin_password=admin_password,
48
57
                injected_files=injected_files,
49
58
                requested_networks=requested_networks,
50
59
                is_first_time=is_first_time,
51
60
                filter_properties=filter_properties,
52
 
                reservations=reservations))
 
61
                reservations=reservations), version='1.2')
53
62
 
54
 
    def prep_resize(self, ctxt, topic, instance_uuid, instance_type_id, image,
55
 
            update_db, request_spec, filter_properties):
56
 
        self.cast(ctxt, self.make_msg('prep_resize', topic=topic,
57
 
                instance_uuid=instance_uuid, instance_type_id=instance_type_id,
58
 
                image=image, update_db=update_db, request_spec=request_spec,
59
 
                filter_properties=filter_properties))
 
63
    def prep_resize(self, ctxt, instance, instance_type, image,
 
64
            request_spec, filter_properties, reservations):
 
65
        instance_p = jsonutils.to_primitive(instance)
 
66
        instance_type_p = jsonutils.to_primitive(instance_type)
 
67
        self.cast(ctxt, self.make_msg('prep_resize',
 
68
                instance=instance_p, instance_type=instance_type_p,
 
69
                image=image, request_spec=request_spec,
 
70
                filter_properties=filter_properties,
 
71
                reservations=reservations), version='1.5')
60
72
 
61
73
    def show_host_resources(self, ctxt, host):
62
74
        return self.call(ctxt, self.make_msg('show_host_resources', host=host))
63
75
 
64
76
    def live_migration(self, ctxt, block_migration, disk_over_commit,
65
 
            instance_id, dest, topic):
 
77
            instance, dest, topic):
66
78
        # NOTE(comstud): Call vs cast so we can get exceptions back, otherwise
67
79
        # this call in the scheduler driver doesn't return anything.
 
80
        instance_p = jsonutils.to_primitive(instance)
68
81
        return self.call(ctxt, self.make_msg('live_migration',
69
82
                block_migration=block_migration,
70
 
                disk_over_commit=disk_over_commit, instance_id=instance_id,
71
 
                dest=dest, topic=topic))
 
83
                disk_over_commit=disk_over_commit, instance=instance_p,
 
84
                dest=dest, topic=topic), version='1.3')
72
85
 
73
86
    def update_service_capabilities(self, ctxt, service_name, host,
74
87
            capabilities):
75
88
        self.fanout_cast(ctxt, self.make_msg('update_service_capabilities',
76
89
                service_name=service_name, host=host,
77
90
                capabilities=capabilities))
78
 
 
79
 
    def get_host_list(self, ctxt):
80
 
        return self.call(ctxt, self.make_msg('get_host_list'))