Revision cfefe007

b/lib/cmdlib.py
4305 4305
                                   " like a valid IP address" %
4306 4306
                                   self.op.vnc_bind_address)
4307 4307

  
4308
    self.instance = self.cfg.GetInstanceInfo(self.op.instance_name)
4308
    instance = self.instance = self.cfg.GetInstanceInfo(self.op.instance_name)
4309 4309
    assert self.instance is not None, \
4310 4310
      "Cannot retrieve locked instance %s" % self.op.instance_name
4311
    self.warn = []
4312
    if self.mem is not None and not self.force:
4313
      pnode = self.instance.primary_node
4314
      nodelist = [pnode]
4315
      nodelist.extend(instance.secondary_nodes)
4316
      instance_info = rpc.call_instance_info(pnode, instance.name)
4317
      nodeinfo = rpc.call_node_info(nodelist, self.cfg.GetVGName())
4318

  
4319
      if pnode not in nodeinfo or not isinstance(nodeinfo[pnode], dict):
4320
        # Assume the primary node is unreachable and go ahead
4321
        self.warn.append("Can't get info from primary node %s" % pnode)
4322
      else:
4323
        if instance_info:
4324
          current_mem = instance_info['memory']
4325
        else:
4326
          # Assume instance not running
4327
          # (there is a slight race condition here, but it's not very probable,
4328
          # and we have no other way to check)
4329
          current_mem = 0
4330
        miss_mem = self.mem - current_mem - nodeinfo[pnode]['memory_free']
4331
        if miss_mem > 0:
4332
          raise errors.OpPrereqError("This change will prevent the instance"
4333
                                     " from starting, due to %d MB of memory"
4334
                                     " missing on its primary node" % miss_mem)
4335

  
4336
      for node in instance.secondary_nodes:
4337
        if node not in nodeinfo or not isinstance(nodeinfo[node], dict):
4338
          self.warn.append("Can't get info from secondary node %s" % node)
4339
        elif self.mem > nodeinfo[node]['memory_free']:
4340
          self.warn.append("Not enough memory to failover instance to secondary"
4341
                           " node %s" % node)
4342

  
4311 4343
    return
4312 4344

  
4313 4345
  def Exec(self, feedback_fn):
......
4315 4347

  
4316 4348
    All parameters take effect only at the next restart of the instance.
4317 4349
    """
4350
    # Process here the warnings from CheckPrereq, as we don't have a
4351
    # feedback_fn there.
4352
    for warn in self.warn:
4353
      feedback_fn("WARNING: %s" % warn)
4354

  
4318 4355
    result = []
4319 4356
    instance = self.instance
4320 4357
    if self.mem:

Also available in: Unified diff