Revision 0bbec3af
b/lib/backend.py | ||
---|---|---|
1273 | 1273 |
return results |
1274 | 1274 |
|
1275 | 1275 |
|
1276 |
def GetInstanceInfo(instance, hname): |
|
1276 |
def GetInstanceInfo(instance, hname, hvparams=None):
|
|
1277 | 1277 |
"""Gives back the information about an instance as a dictionary. |
1278 | 1278 |
|
1279 | 1279 |
@type instance: string |
1280 | 1280 |
@param instance: the instance name |
1281 | 1281 |
@type hname: string |
1282 | 1282 |
@param hname: the hypervisor type of the instance |
1283 |
@type hvparams: dict of strings |
|
1284 |
@param hvparams: the instance's hvparams |
|
1283 | 1285 |
|
1284 | 1286 |
@rtype: dict |
1285 | 1287 |
@return: dictionary with the following keys: |
... | ... | |
1291 | 1293 |
""" |
1292 | 1294 |
output = {} |
1293 | 1295 |
|
1294 |
iinfo = hypervisor.GetHypervisor(hname).GetInstanceInfo(instance) |
|
1296 |
iinfo = hypervisor.GetHypervisor(hname).GetInstanceInfo(instance, |
|
1297 |
hvparams=hvparams) |
|
1295 | 1298 |
if iinfo is not None: |
1296 | 1299 |
output["memory"] = iinfo[2] |
1297 | 1300 |
output["vcpus"] = iinfo[3] |
b/lib/cmdlib/instance.py | ||
---|---|---|
2704 | 2704 |
if (self.op.pnode is not None and self.op.pnode != pnode and |
2705 | 2705 |
not self.op.force): |
2706 | 2706 |
# verify that the instance is not up |
2707 |
instance_info = self.rpc.call_instance_info(pnode, instance.name,
|
|
2708 |
instance.hypervisor)
|
|
2707 |
instance_info = self.rpc.call_instance_info( |
|
2708 |
pnode, instance.name, instance.hypervisor, instance.hvparams)
|
|
2709 | 2709 |
if instance_info.fail_msg: |
2710 | 2710 |
self.warn.append("Can't get instance runtime information: %s" % |
2711 | 2711 |
instance_info.fail_msg) |
... | ... | |
2820 | 2820 |
# either we changed auto_balance to yes or it was from before |
2821 | 2821 |
mem_check_list.extend(instance.secondary_nodes) |
2822 | 2822 |
instance_info = self.rpc.call_instance_info( |
2823 |
pnode, instance.name, instance.hypervisor, |
|
2824 |
cluster.hvparams[instance.hypervisor]) |
|
2823 |
pnode, instance.name, instance.hypervisor, instance.hvparams) |
|
2825 | 2824 |
hvspecs = [(instance.hypervisor, cluster.hvparams[instance.hypervisor])] |
2826 | 2825 |
nodeinfo = self.rpc.call_node_info(mem_check_list, None, |
2827 | 2826 |
hvspecs, False) |
... | ... | |
2876 | 2875 |
errors.ECODE_STATE) |
2877 | 2876 |
|
2878 | 2877 |
if self.op.runtime_mem: |
2879 |
remote_info = self.rpc.call_instance_info(instance.primary_node,
|
|
2880 |
instance.name,
|
|
2881 |
instance.hypervisor)
|
|
2878 |
remote_info = self.rpc.call_instance_info( |
|
2879 |
instance.primary_node, instance.name, instance.hypervisor,
|
|
2880 |
instance.hvparams)
|
|
2882 | 2881 |
remote_info.Raise("Error checking node %s" % instance.primary_node) |
2883 | 2882 |
if not remote_info.payload: # not running already |
2884 | 2883 |
raise errors.OpPrereqError("Instance %s is not running" % |
b/lib/cmdlib/instance_migration.py | ||
---|---|---|
427 | 427 |
self.live = False |
428 | 428 |
|
429 | 429 |
if not (self.failover or self.cleanup): |
430 |
remote_info = self.rpc.call_instance_info(instance.primary_node,
|
|
431 |
instance.name,
|
|
432 |
instance.hypervisor)
|
|
430 |
remote_info = self.rpc.call_instance_info( |
|
431 |
instance.primary_node, instance.name, instance.hypervisor,
|
|
432 |
cluster.hvparams[instance.hypervisor])
|
|
433 | 433 |
remote_info.Raise("Error checking instance on node %s" % |
434 | 434 |
instance.primary_node) |
435 | 435 |
instance_running = bool(remote_info.payload) |
b/lib/cmdlib/instance_operation.py | ||
---|---|---|
98 | 98 |
assert self.instance is not None, \ |
99 | 99 |
"Cannot retrieve locked instance %s" % self.op.instance_name |
100 | 100 |
|
101 |
cluster = self.cfg.GetClusterInfo() |
|
101 | 102 |
# extra hvparams |
102 | 103 |
if self.op.hvparams: |
103 | 104 |
# check hypervisor parameter syntax (locally) |
104 |
cluster = self.cfg.GetClusterInfo() |
|
105 | 105 |
utils.ForceDictType(self.op.hvparams, constants.HVS_PARAMETER_TYPES) |
106 | 106 |
filled_hvp = cluster.FillHV(instance) |
107 | 107 |
filled_hvp.update(self.op.hvparams) |
... | ... | |
127 | 127 |
# check bridges existence |
128 | 128 |
CheckInstanceBridgesExist(self, instance) |
129 | 129 |
|
130 |
remote_info = self.rpc.call_instance_info(instance.primary_node,
|
|
131 |
instance.name,
|
|
132 |
instance.hypervisor)
|
|
130 |
remote_info = self.rpc.call_instance_info( |
|
131 |
instance.primary_node, instance.name, instance.hypervisor,
|
|
132 |
cluster.hvparams[instance.hypervisor])
|
|
133 | 133 |
remote_info.Raise("Error checking node %s" % instance.primary_node, |
134 | 134 |
prereq=True, ecode=errors.ECODE_ENVIRON) |
135 | 135 |
if not remote_info.payload: # not running already |
... | ... | |
392 | 392 |
reboot_type = self.op.reboot_type |
393 | 393 |
reason = self.op.reason |
394 | 394 |
|
395 |
remote_info = self.rpc.call_instance_info(instance.primary_node, |
|
396 |
instance.name, |
|
397 |
instance.hypervisor) |
|
395 |
cluster = self.cfg.GetClusterInfo() |
|
396 |
remote_info = self.rpc.call_instance_info( |
|
397 |
instance.primary_node, instance.name, instance.hypervisor, |
|
398 |
cluster.hvparams[instance.hypervisor]) |
|
398 | 399 |
remote_info.Raise("Error checking node %s" % instance.primary_node) |
399 | 400 |
instance_running = bool(remote_info.payload) |
400 | 401 |
|
b/lib/cmdlib/instance_query.py | ||
---|---|---|
383 | 383 |
" information only for instance %s" % |
384 | 384 |
(pnode.name, instance.name)) |
385 | 385 |
else: |
386 |
remote_info = self.rpc.call_instance_info(instance.primary_node,
|
|
387 |
instance.name,
|
|
388 |
instance.hypervisor)
|
|
386 |
remote_info = self.rpc.call_instance_info( |
|
387 |
instance.primary_node, instance.name, instance.hypervisor,
|
|
388 |
cluster.hvparams[instance.hypervisor])
|
|
389 | 389 |
remote_info.Raise("Error checking node %s" % instance.primary_node) |
390 | 390 |
remote_info = remote_info.payload |
391 | 391 |
if remote_info and "state" in remote_info: |
b/lib/hypervisor/hv_base.py | ||
---|---|---|
210 | 210 |
"""Get the list of running instances.""" |
211 | 211 |
raise NotImplementedError |
212 | 212 |
|
213 |
def GetInstanceInfo(self, instance_name): |
|
213 |
def GetInstanceInfo(self, instance_name, hvparams=None):
|
|
214 | 214 |
"""Get instance properties. |
215 | 215 |
|
216 | 216 |
@type instance_name: string |
217 | 217 |
@param instance_name: the instance name |
218 |
@type hvparams: dict of strings |
|
219 |
@param hvparams: hvparams to be used with this instance |
|
218 | 220 |
|
219 | 221 |
@return: tuple (name, id, memory, vcpus, state, times) |
220 | 222 |
|
... | ... | |
371 | 373 |
""" |
372 | 374 |
raise NotImplementedError |
373 | 375 |
|
374 |
def _InstanceStartupMemory(self, instance): |
|
376 |
def _InstanceStartupMemory(self, instance, hvparams=None):
|
|
375 | 377 |
"""Get the correct startup memory for an instance |
376 | 378 |
|
377 | 379 |
This function calculates how much memory an instance should be started |
... | ... | |
384 | 386 |
@return: memory the instance should be started with |
385 | 387 |
|
386 | 388 |
""" |
387 |
free_memory = self.GetNodeInfo()["memory_free"] |
|
389 |
free_memory = self.GetNodeInfo(hvparams=hvparams)["memory_free"]
|
|
388 | 390 |
max_start_mem = min(instance.beparams[constants.BE_MAXMEM], free_memory) |
389 | 391 |
start_mem = max(instance.beparams[constants.BE_MINMEM], max_start_mem) |
390 | 392 |
return start_mem |
b/lib/hypervisor/hv_chroot.py | ||
---|---|---|
109 | 109 |
return [name for name in os.listdir(self._ROOT_DIR) |
110 | 110 |
if self._IsDirLive(utils.PathJoin(self._ROOT_DIR, name))] |
111 | 111 |
|
112 |
def GetInstanceInfo(self, instance_name): |
|
112 |
def GetInstanceInfo(self, instance_name, hvparams=None):
|
|
113 | 113 |
"""Get instance properties. |
114 | 114 |
|
115 | 115 |
@type instance_name: string |
116 | 116 |
@param instance_name: the instance name |
117 |
@type hvparams: dict of strings |
|
118 |
@param hvparams: hvparams to be used with this instance |
|
117 | 119 |
|
118 | 120 |
@return: (name, id, memory, vcpus, stat, times) |
119 | 121 |
|
b/lib/hypervisor/hv_fake.py | ||
---|---|---|
56 | 56 |
""" |
57 | 57 |
return os.listdir(self._ROOT_DIR) |
58 | 58 |
|
59 |
def GetInstanceInfo(self, instance_name): |
|
59 |
def GetInstanceInfo(self, instance_name, hvparams=None):
|
|
60 | 60 |
"""Get instance properties. |
61 | 61 |
|
62 |
@type instance_name: string |
|
62 | 63 |
@param instance_name: the instance name |
64 |
@type hvparams: dict of strings |
|
65 |
@param hvparams: hvparams to be used with this instance |
|
63 | 66 |
|
64 | 67 |
@return: tuple of (name, id, memory, vcpus, stat, times) |
65 | 68 |
|
b/lib/hypervisor/hv_kvm.py | ||
---|---|---|
974 | 974 |
result.append(name) |
975 | 975 |
return result |
976 | 976 |
|
977 |
def GetInstanceInfo(self, instance_name): |
|
977 |
def GetInstanceInfo(self, instance_name, hvparams=None):
|
|
978 | 978 |
"""Get instance properties. |
979 | 979 |
|
980 | 980 |
@type instance_name: string |
981 | 981 |
@param instance_name: the instance name |
982 |
@type hvparams: dict of strings |
|
983 |
@param hvparams: hvparams to be used with this instance |
|
982 | 984 |
@rtype: tuple of strings |
983 | 985 |
@return: (name, id, memory, vcpus, stat, times) |
984 | 986 |
|
b/lib/hypervisor/hv_lxc.py | ||
---|---|---|
163 | 163 |
""" |
164 | 164 |
return [iinfo[0] for iinfo in self.GetAllInstancesInfo()] |
165 | 165 |
|
166 |
def GetInstanceInfo(self, instance_name): |
|
166 |
def GetInstanceInfo(self, instance_name, hvparams=None):
|
|
167 | 167 |
"""Get instance properties. |
168 | 168 |
|
169 | 169 |
@type instance_name: string |
170 | 170 |
@param instance_name: the instance name |
171 |
@type hvparams: dict of strings |
|
172 |
@param hvparams: hvparams to be used with this instance |
|
171 | 173 |
@rtype: tuple of strings |
172 | 174 |
@return: (name, id, memory, vcpus, stat, times) |
173 | 175 |
|
b/lib/hypervisor/hv_xen.py | ||
---|---|---|
453 | 453 |
names = [info[0] for info in instance_list] |
454 | 454 |
return names |
455 | 455 |
|
456 |
def GetInstanceInfo(self, instance_name): |
|
456 |
def GetInstanceInfo(self, instance_name, hvparams=None):
|
|
457 | 457 |
"""Get instance properties. |
458 | 458 |
|
459 |
@type instance_name: string |
|
459 | 460 |
@param instance_name: the instance name |
461 |
@type hvparams: dict of strings |
|
462 |
@param hvparams: the instance's hypervisor params |
|
460 | 463 |
|
461 | 464 |
@return: tuple (name, id, memory, vcpus, stat, times) |
462 | 465 |
|
463 | 466 |
""" |
464 |
instance_list = self._GetInstanceList(instance_name == _DOM0_NAME) |
|
467 |
instance_list = self._GetInstanceList(instance_name == _DOM0_NAME, |
|
468 |
hvparams=hvparams) |
|
465 | 469 |
result = None |
466 | 470 |
for data in instance_list: |
467 | 471 |
if data[0] == instance_name: |
... | ... | |
495 | 499 |
"""Start an instance. |
496 | 500 |
|
497 | 501 |
""" |
498 |
startup_memory = self._InstanceStartupMemory(instance) |
|
502 |
startup_memory = self._InstanceStartupMemory(instance, |
|
503 |
hvparams=instance.hvparams) |
|
499 | 504 |
|
500 | 505 |
self._MakeConfigFile(instance, startup_memory, block_devices) |
501 | 506 |
|
... | ... | |
551 | 556 |
"""Reboot an instance. |
552 | 557 |
|
553 | 558 |
""" |
554 |
ini_info = self.GetInstanceInfo(instance.name) |
|
559 |
ini_info = self.GetInstanceInfo(instance.name, hvparams=instance.hvparams)
|
|
555 | 560 |
|
556 | 561 |
if ini_info is None: |
557 | 562 |
raise errors.HypervisorError("Failed to reboot instance %s," |
... | ... | |
564 | 569 |
result.output)) |
565 | 570 |
|
566 | 571 |
def _CheckInstance(): |
567 |
new_info = self.GetInstanceInfo(instance.name) |
|
572 |
new_info = self.GetInstanceInfo(instance.name, hvparams=instance.hvparams)
|
|
568 | 573 |
|
569 | 574 |
# check if the domain ID has changed or the run time has decreased |
570 | 575 |
if (new_info is not None and |
b/lib/rpc_defs.py | ||
---|---|---|
218 | 218 |
("instance_info", SINGLE, None, constants.RPC_TMO_URGENT, [ |
219 | 219 |
("instance", None, "Instance name"), |
220 | 220 |
("hname", None, "Hypervisor type"), |
221 |
("hvparams", None, "Hypervisor parameters"), |
|
221 | 222 |
], None, None, "Returns information about a single instance"), |
222 | 223 |
("all_instances_info", MULTI, None, constants.RPC_TMO_URGENT, [ |
223 | 224 |
("hypervisor_list", None, "Hypervisors to query for instances"), |
b/lib/server/noded.py | ||
---|---|---|
682 | 682 |
"""Query instance information. |
683 | 683 |
|
684 | 684 |
""" |
685 |
return backend.GetInstanceInfo(params[0], params[1]) |
|
685 |
(instance_name, hypervisor_name, hvparams) = params |
|
686 |
return backend.GetInstanceInfo(instance_name, hypervisor_name, hvparams) |
|
686 | 687 |
|
687 | 688 |
@staticmethod |
688 | 689 |
def perspective_instance_migratable(params): |
Also available in: Unified diff