Revision 5e26c4d9

b/lib/masterd/instance.py
92 92
  """Callbacks for disk import/export.
93 93

  
94 94
  """
95
  def ReportListening(self, ie, private):
95
  def ReportListening(self, ie, private, component):
96 96
    """Called when daemon started listening.
97 97

  
98 98
    @type ie: Subclass of L{_DiskImportExportBase}
99 99
    @param ie: Import/export object
100 100
    @param private: Private data passed to import/export object
101
    @param component: transfer component name
101 102

  
102 103
    """
103 104

  
......
140 141
  MODE_TEXT = None
141 142

  
142 143
  def __init__(self, lu, node_name, opts,
143
               instance, timeouts, cbs, private=None):
144
               instance, component, timeouts, cbs, private=None):
144 145
    """Initializes this class.
145 146

  
146 147
    @param lu: Logical unit instance
......
150 151
    @param opts: Import/export daemon options
151 152
    @type instance: L{objects.Instance}
152 153
    @param instance: Instance object
154
    @type component: string
155
    @param component: which part of the instance is being imported
153 156
    @type timeouts: L{ImportExportTimeouts}
154 157
    @param timeouts: Timeouts for this import
155 158
    @type cbs: L{ImportExportCbBase}
......
163 166
    self.node_name = node_name
164 167
    self._opts = opts.Copy()
165 168
    self._instance = instance
169
    self._component = component
166 170
    self._timeouts = timeouts
167 171
    self._cbs = cbs
168 172
    self._private = private
......
485 489
class DiskImport(_DiskImportExportBase):
486 490
  MODE_TEXT = "import"
487 491

  
488
  def __init__(self, lu, node_name, opts, instance,
492
  def __init__(self, lu, node_name, opts, instance, component,
489 493
               dest, dest_args, timeouts, cbs, private=None):
490 494
    """Initializes this class.
491 495

  
......
496 500
    @param opts: Import/export daemon options
497 501
    @type instance: L{objects.Instance}
498 502
    @param instance: Instance object
503
    @type component: string
504
    @param component: which part of the instance is being imported
499 505
    @param dest: I/O destination
500 506
    @param dest_args: I/O arguments
501 507
    @type timeouts: L{ImportExportTimeouts}
......
505 511
    @param private: Private data for callback functions
506 512

  
507 513
    """
508
    _DiskImportExportBase.__init__(self, lu, node_name, opts,
509
                                   instance, timeouts, cbs, private)
514
    _DiskImportExportBase.__init__(self, lu, node_name, opts, instance,
515
                                   component, timeouts, cbs, private)
510 516
    self._dest = dest
511 517
    self._dest_args = dest_args
512 518

  
......
550 556
      logging.debug("Import '%s' on %s is now listening on port %s",
551 557
                    self._daemon_name, self.node_name, port)
552 558

  
553
      self._cbs.ReportListening(self, self._private)
559
      self._cbs.ReportListening(self, self._private, self._component)
554 560

  
555 561
      return True
556 562

  
......
574 580
class DiskExport(_DiskImportExportBase):
575 581
  MODE_TEXT = "export"
576 582

  
577
  def __init__(self, lu, node_name, opts,
578
               dest_host, dest_port, instance, source, source_args,
583
  def __init__(self, lu, node_name, opts, dest_host, dest_port,
584
               instance, component, source, source_args,
579 585
               timeouts, cbs, private=None):
580 586
    """Initializes this class.
581 587

  
......
590 596
    @param dest_port: Destination port number
591 597
    @type instance: L{objects.Instance}
592 598
    @param instance: Instance object
599
    @type component: string
600
    @param component: which part of the instance is being imported
593 601
    @param source: I/O source
594 602
    @param source_args: I/O source
595 603
    @type timeouts: L{ImportExportTimeouts}
......
599 607
    @param private: Private data for callback functions
600 608

  
601 609
    """
602
    _DiskImportExportBase.__init__(self, lu, node_name, opts,
603
                                   instance, timeouts, cbs, private)
610
    _DiskImportExportBase.__init__(self, lu, node_name, opts, instance,
611
                                   component, timeouts, cbs, private)
604 612
    self._dest_host = dest_host
605 613
    self._dest_port = dest_port
606 614
    self._source = source
......
885 893

  
886 894

  
887 895
class _TransferInstDestCb(_TransferInstCbBase):
888
  def ReportListening(self, ie, dtp):
896
  def ReportListening(self, ie, dtp, component):
889 897
    """Called when daemon started listening.
890 898

  
891 899
    """
......
898 906

  
899 907
    # Start export on source node
900 908
    de = DiskExport(self.lu, self.src_node, dtp.export_opts,
901
                    self.dest_ip, ie.listen_port,
902
                    self.instance, dtp.data.src_io, dtp.data.src_ioargs,
909
                    self.dest_ip, ie.listen_port, self.instance,
910
                    component, dtp.data.src_io, dtp.data.src_ioargs,
903 911
                    self.timeouts, self.src_cbs, private=dtp)
904 912
    ie.loop.Add(de)
905 913

  
......
1049 1057

  
1050 1058
        dtp = _DiskTransferPrivate(transfer, True, opts)
1051 1059

  
1052
        di = DiskImport(lu, dest_node, opts, instance,
1060
        di = DiskImport(lu, dest_node, opts, instance, "disk%d" % idx,
1053 1061
                        transfer.dest_io, transfer.dest_ioargs,
1054 1062
                        timeouts, dest_cbs, private=dtp)
1055 1063
        ieloop.Add(di)
......
1286 1294
        self._feedback_fn("Sending disk %s to %s:%s" % (idx, host, port))
1287 1295
        finished_fn = compat.partial(self._TransferFinished, idx)
1288 1296
        ieloop.Add(DiskExport(self._lu, instance.primary_node,
1289
                              opts, host, port, instance,
1297
                              opts, host, port, instance, "disk%d" % idx,
1290 1298
                              constants.IEIO_SCRIPT, (dev, idx),
1291 1299
                              timeouts, cbs, private=(idx, finished_fn)))
1292 1300

  
......
1372 1380
      "x509_ca": self._x509_cert_pem,
1373 1381
      })
1374 1382

  
1375
  def ReportListening(self, ie, private):
1383
  def ReportListening(self, ie, private, _):
1376 1384
    """Called when daemon started listening.
1377 1385

  
1378 1386
    """
......
1468 1476
                                           magic=magic, ipv6=ipv6)
1469 1477

  
1470 1478
        ieloop.Add(DiskImport(lu, instance.primary_node, opts, instance,
1479
                              "disk%d" % idx,
1471 1480
                              constants.IEIO_SCRIPT, (dev, idx),
1472 1481
                              timeouts, cbs, private=(idx, )))
1473 1482

  

Also available in: Unified diff