68
69
return functools.partial(self._schedule, key)
70
71
def get_host_list(self, context):
71
"""Get a list of hosts from the HostManager."""
72
return self.driver.get_host_list()
72
"""Get a list of hosts from the HostManager.
74
Currently unused, but left for backwards compatibility.
76
raise rpc_common.RPCException(message=_('Deprecated in version 1.0'))
74
78
def get_service_capabilities(self, context):
75
"""Get the normalized set of capabilities for this zone."""
76
return self.driver.get_service_capabilities()
79
"""Get the normalized set of capabilities for this zone.
81
Has been unused since pre-essex, but remains for rpc API 1.X
84
raise rpc_common.RPCException(message=_('Deprecated in version 1.0'))
78
86
def update_service_capabilities(self, context, service_name=None,
79
87
host=None, capabilities=None, **kwargs):
102
110
return driver_method(*args, **kwargs)
103
111
except Exception as ex:
104
112
with excutils.save_and_reraise_exception():
113
request_spec = kwargs.get('request_spec', {})
105
114
self._set_vm_state_and_notify(method,
106
115
{'vm_state': vm_states.ERROR},
107
context, ex, *args, **kwargs)
116
context, ex, request_spec)
109
def run_instance(self, context, topic, *args, **kwargs):
118
def run_instance(self, context, request_spec, admin_password,
119
injected_files, requested_networks, is_first_time,
120
filter_properties, reservations, topic=None):
110
121
"""Tries to call schedule_run_instance on the driver.
111
122
Sets instance vm_state to ERROR on exceptions
113
args = (context,) + args
114
reservations = kwargs.get('reservations', None)
116
result = self.driver.schedule_run_instance(*args, **kwargs)
125
result = self.driver.schedule_run_instance(context,
126
request_spec, admin_password, injected_files,
127
requested_networks, is_first_time, filter_properties,
118
130
except exception.NoValidHost as ex:
120
132
self._set_vm_state_and_notify('run_instance',
121
133
{'vm_state': vm_states.ERROR},
122
context, ex, *args, **kwargs)
134
context, ex, request_spec)
124
136
QUOTAS.rollback(context, reservations)
125
137
except Exception as ex:
126
138
with excutils.save_and_reraise_exception():
127
139
self._set_vm_state_and_notify('run_instance',
128
140
{'vm_state': vm_states.ERROR},
129
context, ex, *args, **kwargs)
141
context, ex, request_spec)
131
143
QUOTAS.rollback(context, reservations)
133
def prep_resize(self, context, topic, *args, **kwargs):
145
# FIXME(comstud): Remove 'update_db' in a future version. It's only
146
# here for rpcapi backwards compatibility.
147
def prep_resize(self, context, image, request_spec, filter_properties,
148
update_db=None, instance=None, instance_uuid=None,
149
instance_type=None, instance_type_id=None,
150
reservations=None, topic=None):
134
151
"""Tries to call schedule_prep_resize on the driver.
135
152
Sets instance vm_state to ACTIVE on NoHostFound
136
153
Sets vm_state to ERROR on other exceptions
138
args = (context,) + args
156
instance = db.instance_get_by_uuid(context, instance_uuid)
158
if not instance_type:
159
instance_type = db.instance_type_get(context, instance_type_id)
140
return self.driver.schedule_prep_resize(*args, **kwargs)
165
'request_spec': request_spec,
166
'filter_properties': filter_properties,
167
'instance': instance,
168
'instance_type': instance_type,
169
'reservations': reservations,
171
return self.driver.schedule_prep_resize(**kwargs)
141
172
except exception.NoValidHost as ex:
142
173
self._set_vm_state_and_notify('prep_resize',
143
174
{'vm_state': vm_states.ACTIVE,
144
175
'task_state': None},
145
context, ex, *args, **kwargs)
176
context, ex, request_spec)
178
QUOTAS.rollback(context, reservations)
146
179
except Exception as ex:
147
180
with excutils.save_and_reraise_exception():
148
181
self._set_vm_state_and_notify('prep_resize',
149
182
{'vm_state': vm_states.ERROR},
150
context, ex, *args, **kwargs)
183
context, ex, request_spec)
185
QUOTAS.rollback(context, reservations)
152
187
def _set_vm_state_and_notify(self, method, updates, context, ex,
154
189
"""changes VM state and notifies"""
155
190
# FIXME(comstud): Re-factor this somehow. Not sure this belongs in the
156
191
# scheduler manager like this. We should make this easier.