~ubuntu-branches/ubuntu/raring/cinder/raring-updates

« back to all changes in this revision

Viewing changes to cinder/scheduler/manager.py

Tags: upstream-2013.1~g2
ImportĀ upstreamĀ versionĀ 2013.1~g2

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
Scheduler Service
22
22
"""
23
23
 
24
 
import functools
25
 
 
 
24
from cinder import context
26
25
from cinder import db
27
26
from cinder import exception
28
27
from cinder import flags
32
31
from cinder.openstack.common import importutils
33
32
from cinder.openstack.common import log as logging
34
33
from cinder.openstack.common.notifier import api as notifier
 
34
from cinder.volume import rpcapi as volume_rpcapi
35
35
 
36
36
 
37
37
LOG = logging.getLogger(__name__)
38
38
 
39
39
scheduler_driver_opt = cfg.StrOpt('scheduler_driver',
40
 
        default='cinder.scheduler.simple.SimpleScheduler',
41
 
        help='Default driver to use for the scheduler')
 
40
                                  default='cinder.scheduler.filter_scheduler.'
 
41
                                          'FilterScheduler',
 
42
                                  help='Default scheduler driver to use')
42
43
 
43
44
FLAGS = flags.FLAGS
44
45
FLAGS.register_opt(scheduler_driver_opt)
45
46
 
46
47
 
47
48
class SchedulerManager(manager.Manager):
48
 
    """Chooses a host to create volumes"""
 
49
    """Chooses a host to create volumes."""
49
50
 
50
51
    RPC_API_VERSION = '1.2'
51
52
 
55
56
        self.driver = importutils.import_object(scheduler_driver)
56
57
        super(SchedulerManager, self).__init__(*args, **kwargs)
57
58
 
 
59
    def init_host(self):
 
60
        ctxt = context.get_admin_context()
 
61
        self.request_service_capabilities(ctxt)
 
62
 
58
63
    def get_host_list(self, context):
59
64
        """Get a list of hosts from the HostManager."""
60
65
        return self.driver.get_host_list()
64
69
        return self.driver.get_service_capabilities()
65
70
 
66
71
    def update_service_capabilities(self, context, service_name=None,
67
 
            host=None, capabilities=None, **kwargs):
 
72
                                    host=None, capabilities=None, **kwargs):
68
73
        """Process a capability update from a service node."""
69
74
        if capabilities is None:
70
75
            capabilities = {}
71
 
        self.driver.update_service_capabilities(service_name, host,
72
 
                capabilities)
 
76
        self.driver.update_service_capabilities(service_name,
 
77
                                                host,
 
78
                                                capabilities)
73
79
 
74
80
    def create_volume(self, context, topic, volume_id, snapshot_id=None,
75
81
                      image_id=None, request_spec=None,
86
92
                volume_properties = {'size': size,
87
93
                                     'availability_zone': availability_zone,
88
94
                                     'volume_type_id': volume_type_id}
89
 
                request_spec.update({'volume_id': volume_id,
90
 
                                 'snapshot_id': snapshot_id,
91
 
                                 'image_id': image_id,
92
 
                                 'volume_properties': volume_properties,
93
 
                                 'volume_type': dict(vol_type).iteritems()})
 
95
                request_spec.update(
 
96
                    {'volume_id': volume_id,
 
97
                     'snapshot_id': snapshot_id,
 
98
                     'image_id': image_id,
 
99
                     'volume_properties': volume_properties,
 
100
                     'volume_type': dict(vol_type).iteritems()})
94
101
 
95
102
            self.driver.schedule_create_volume(context, request_spec,
96
103
                                               filter_properties)
127
134
 
128
135
        notifier.notify(context, notifier.publisher_id("scheduler"),
129
136
                        'scheduler.' + method, notifier.ERROR, payload)
 
137
 
 
138
    def request_service_capabilities(self, context):
 
139
        volume_rpcapi.VolumeAPI().publish_service_capabilities(context)