Revision 923ddac0 lib/cmdlib.py

b/lib/cmdlib.py
4685 4685

  
4686 4686
    """
4687 4687
    nics = [n.ToDict() for n in self.nics]
4688
    ial = IAllocator(self,
4688
    ial = IAllocator(self.cfg, self.rpc,
4689 4689
                     mode=constants.IALLOCATOR_MODE_ALLOC,
4690 4690
                     name=self.op.instance_name,
4691 4691
                     disk_template=self.op.disk_template,
......
5168 5168
    """Compute a new secondary node using an IAllocator.
5169 5169

  
5170 5170
    """
5171
    ial = IAllocator(self,
5171
    ial = IAllocator(self.cfg, self.rpc,
5172 5172
                     mode=constants.IALLOCATOR_MODE_RELOC,
5173 5173
                     name=self.op.instance_name,
5174 5174
                     relocate_from=[self.sec_node])
......
6895 6895
    "relocate_from",
6896 6896
    ]
6897 6897

  
6898
  def __init__(self, lu, mode, name, **kwargs):
6899
    self.lu = lu
6898
  def __init__(self, cfg, rpc, mode, name, **kwargs):
6899
    self.cfg = cfg
6900
    self.rpc = rpc
6900 6901
    # init buffer variables
6901 6902
    self.in_text = self.out_text = self.in_data = self.out_data = None
6902 6903
    # init all input fields so that pylint is happy
......
6934 6935
    This is the data that is independent of the actual operation.
6935 6936

  
6936 6937
    """
6937
    cfg = self.lu.cfg
6938
    cfg = self.cfg
6938 6939
    cluster_info = cfg.GetClusterInfo()
6939 6940
    # cluster data
6940 6941
    data = {
......
6956 6957
    elif self.mode == constants.IALLOCATOR_MODE_RELOC:
6957 6958
      hypervisor_name = cfg.GetInstanceInfo(self.name).hypervisor
6958 6959

  
6959
    node_data = self.lu.rpc.call_node_info(node_list, cfg.GetVGName(),
6960
                                           hypervisor_name)
6961
    node_iinfo = self.lu.rpc.call_all_instances_info(node_list,
6962
                       cluster_info.enabled_hypervisors)
6960
    node_data = self.rpc.call_node_info(node_list, cfg.GetVGName(),
6961
                                        hypervisor_name)
6962
    node_iinfo = \
6963
      self.rpc.call_all_instances_info(node_list,
6964
                                       cluster_info.enabled_hypervisors)
6963 6965
    for nname, nresult in node_data.items():
6964 6966
      # first fill in static (config-based) values
6965 6967
      ninfo = cfg.GetNodeInfo(nname)
......
7096 7098
    done.
7097 7099

  
7098 7100
    """
7099
    instance = self.lu.cfg.GetInstanceInfo(self.name)
7101
    instance = self.cfg.GetInstanceInfo(self.name)
7100 7102
    if instance is None:
7101 7103
      raise errors.ProgrammerError("Unknown instance '%s' passed to"
7102 7104
                                   " IAllocator" % self.name)
......
7138 7140

  
7139 7141
    """
7140 7142
    if call_fn is None:
7141
      call_fn = self.lu.rpc.call_iallocator_runner
7143
      call_fn = self.rpc.call_iallocator_runner
7142 7144

  
7143
    result = call_fn(self.lu.cfg.GetMasterNode(), name, self.in_text)
7145
    result = call_fn(self.cfg.GetMasterNode(), name, self.in_text)
7144 7146
    result.Raise("Failure while running the iallocator script")
7145 7147

  
7146 7148
    self.out_text = result.payload
......
7244 7246

  
7245 7247
    """
7246 7248
    if self.op.mode == constants.IALLOCATOR_MODE_ALLOC:
7247
      ial = IAllocator(self,
7249
      ial = IAllocator(self.cfg, self.rpc,
7248 7250
                       mode=self.op.mode,
7249 7251
                       name=self.op.name,
7250 7252
                       mem_size=self.op.mem_size,
......
7257 7259
                       hypervisor=self.op.hypervisor,
7258 7260
                       )
7259 7261
    else:
7260
      ial = IAllocator(self,
7262
      ial = IAllocator(self.cfg, self.rpc,
7261 7263
                       mode=self.op.mode,
7262 7264
                       name=self.op.name,
7263 7265
                       relocate_from=list(self.relocate_from),

Also available in: Unified diff