Revision 26ba2bd8 lib/rpc.py
b/lib/rpc.py | ||
---|---|---|
158 | 158 |
""" |
159 | 159 |
self._cfg = cfg |
160 | 160 |
|
161 |
def _InstDict(self, instance): |
|
162 |
"""Convert the given instance to a dict. |
|
163 |
|
|
164 |
This is done via the instance's ToDict() method and additionally |
|
165 |
we fill the hvparams with the cluster defaults. |
|
166 |
|
|
167 |
@type instance: L{objects.Instance} |
|
168 |
@param instance: an Instance object |
|
169 |
@rtype: dict |
|
170 |
@return: the instance dict, with the hvparams filled with the |
|
171 |
cluster defaults |
|
172 |
|
|
173 |
""" |
|
174 |
idict = instance.ToDict() |
|
175 |
idict["hvparams"] = self._cfg.GetClusterInfo().FillHV(instance) |
|
176 |
return idict |
|
177 |
|
|
161 | 178 |
def call_volume_list(self, node_list, vg_name): |
162 | 179 |
"""Gets the logical volumes present in a given volume group. |
163 | 180 |
|
... | ... | |
201 | 218 |
This is a single-node call. |
202 | 219 |
|
203 | 220 |
""" |
204 |
c = Client("instance_start", [instance.ToDict(), extra_args])
|
|
221 |
c = Client("instance_start", [self._InstDict(instance), extra_args])
|
|
205 | 222 |
c.connect(node) |
206 | 223 |
c.run() |
207 | 224 |
return c.getresult().get(node, False) |
... | ... | |
212 | 229 |
This is a single-node call. |
213 | 230 |
|
214 | 231 |
""" |
215 |
c = Client("instance_shutdown", [instance.ToDict()])
|
|
232 |
c = Client("instance_shutdown", [self._InstDict(instance)])
|
|
216 | 233 |
c.connect(node) |
217 | 234 |
c.run() |
218 | 235 |
return c.getresult().get(node, False) |
... | ... | |
233 | 250 |
interpretation of this parameter is left to the hypervisor) |
234 | 251 |
|
235 | 252 |
""" |
236 |
c = Client("instance_migrate", [instance.ToDict(), target, live])
|
|
253 |
c = Client("instance_migrate", [self._InstDict(instance), target, live])
|
|
237 | 254 |
c.connect(node) |
238 | 255 |
c.run() |
239 | 256 |
return c.getresult().get(node, False) |
... | ... | |
244 | 261 |
This is a single-node call. |
245 | 262 |
|
246 | 263 |
""" |
247 |
c = Client("instance_reboot", [instance.ToDict(), reboot_type, extra_args]) |
|
264 |
c = Client("instance_reboot", [self._InstDict(instance), |
|
265 |
reboot_type, extra_args]) |
|
248 | 266 |
c.connect(node) |
249 | 267 |
c.run() |
250 | 268 |
return c.getresult().get(node, False) |
... | ... | |
255 | 273 |
This is a single-node call. |
256 | 274 |
|
257 | 275 |
""" |
258 |
params = [inst.ToDict(), osdev, swapdev]
|
|
276 |
params = [self._InstDict(inst), osdev, swapdev]
|
|
259 | 277 |
c = Client("instance_os_add", params) |
260 | 278 |
c.connect(node) |
261 | 279 |
c.run() |
... | ... | |
267 | 285 |
This is a single-node call. |
268 | 286 |
|
269 | 287 |
""" |
270 |
params = [inst.ToDict(), old_name, osdev, swapdev]
|
|
288 |
params = [self._InstDict(inst), old_name, osdev, swapdev]
|
|
271 | 289 |
c = Client("instance_run_rename", params) |
272 | 290 |
c.connect(node) |
273 | 291 |
c.run() |
... | ... | |
694 | 712 |
This is a single-node call. |
695 | 713 |
|
696 | 714 |
""" |
697 |
params = [snap_bdev.ToDict(), dest_node, instance.ToDict(), cluster_name] |
|
715 |
params = [snap_bdev.ToDict(), dest_node, |
|
716 |
self._InstDict(instance), cluster_name] |
|
698 | 717 |
c = Client("snapshot_export", params) |
699 | 718 |
c.connect(node) |
700 | 719 |
c.run() |
... | ... | |
711 | 730 |
flat_disks = [] |
712 | 731 |
for disk in snap_disks: |
713 | 732 |
flat_disks.append(disk.ToDict()) |
714 |
params = [instance.ToDict(), flat_disks]
|
|
733 |
params = [self._InstDict(instance), flat_disks]
|
|
715 | 734 |
c = Client("finalize_export", params) |
716 | 735 |
c.connect(node) |
717 | 736 |
c.run() |
... | ... | |
738 | 757 |
This is a single-node call. |
739 | 758 |
|
740 | 759 |
""" |
741 |
params = [inst.ToDict(), osdev, swapdev, src_node, src_image, cluster_name] |
|
760 |
params = [self._InstDict(inst), osdev, swapdev, |
|
761 |
src_node, src_image, cluster_name] |
|
742 | 762 |
c = Client("instance_os_import", params) |
743 | 763 |
c.connect(node) |
744 | 764 |
c.run() |
Also available in: Unified diff