Revision 0c3d9c7c lib/storage/drbd.py

b/lib/storage/drbd.py
163 163
  doesn't do anything to the supposed peer. If you need a fully
164 164
  connected DRBD pair, you need to use this class on both hosts.
165 165

  
166
  The unique_id for the drbd device is a (local_ip, local_port,
167
  remote_ip, remote_port, local_minor, secret) tuple, and it must have
168
  two children: the data device and the meta_device. The meta device
169
  is checked for valid size and is zeroed on create.
166
  The unique_id for the drbd device is a (pnode_uuid, snode_uuid,
167
  port, pnode_minor, lnode_minor, secret) tuple, and it must have
168
  two children: the data device and the meta_device. The meta
169
  device is checked for valid size and is zeroed on create.
170 170

  
171 171
  """
172 172
  _DRBD_MAJOR = 147
......
174 174
  # timeout constants
175 175
  _NET_RECONFIG_TIMEOUT = 60
176 176

  
177
  def __init__(self, unique_id, children, size, params):
177
  def __init__(self, unique_id, children, size, params, dyn_params):
178 178
    if children and children.count(None) > 0:
179 179
      children = []
180 180
    if len(children) not in (0, 2):
181 181
      raise ValueError("Invalid configuration data %s" % str(children))
182 182
    if not isinstance(unique_id, (tuple, list)) or len(unique_id) != 6:
183 183
      raise ValueError("Invalid configuration data %s" % str(unique_id))
184
    (self._lhost, self._lport,
185
     self._rhost, self._rport,
186
     self._aminor, self._secret) = unique_id
184
    if constants.DDP_LOCAL_IP not in dyn_params or \
185
       constants.DDP_REMOTE_IP not in dyn_params or \
186
       constants.DDP_LOCAL_MINOR not in dyn_params or \
187
       constants.DDP_REMOTE_MINOR not in dyn_params:
188
      raise ValueError("Invalid dynamic parameters %s" % str(dyn_params))
189

  
190
    self._lhost = dyn_params[constants.DDP_LOCAL_IP]
191
    self._lport = unique_id[2]
192
    self._rhost = dyn_params[constants.DDP_REMOTE_IP]
193
    self._rport = unique_id[2]
194
    self._aminor = dyn_params[constants.DDP_LOCAL_MINOR]
195
    self._secret = unique_id[5]
196

  
187 197
    if children:
188 198
      if not _CanReadDevice(children[1].dev_path):
189 199
        logging.info("drbd%s: Ignoring unreadable meta device", self._aminor)
190 200
        children = []
191
    super(DRBD8Dev, self).__init__(unique_id, children, size, params)
201
    super(DRBD8Dev, self).__init__(unique_id, children, size, params,
202
                                   dyn_params)
192 203
    self.major = self._DRBD_MAJOR
193 204

  
194 205
    info = DRBD8.GetProcInfo()
......
207 218

  
208 219
    if (self._lhost is not None and self._lhost == self._rhost and
209 220
            self._lport == self._rport):
210
      raise ValueError("Invalid configuration data, same local/remote %s" %
211
                       (unique_id,))
221
      raise ValueError("Invalid configuration data, same local/remote %s, %s" %
222
                       (unique_id, dyn_params))
212 223
    self.Attach()
213 224

  
214 225
  @staticmethod
......
1005 1016
      base.ThrowError("Can't initialize meta device: %s", result.output)
1006 1017

  
1007 1018
  @classmethod
1008
  def Create(cls, unique_id, children, size, spindles, params, excl_stor):
1019
  def Create(cls, unique_id, children, size, spindles, params, excl_stor,
1020
             dyn_params):
1009 1021
    """Create a new DRBD8 device.
1010 1022

  
1011 1023
    Since DRBD devices are not created per se, just assembled, this
......
1017 1029
    if excl_stor:
1018 1030
      raise errors.ProgrammerError("DRBD device requested with"
1019 1031
                                   " exclusive_storage")
1032
    if constants.DDP_LOCAL_MINOR not in dyn_params:
1033
      raise errors.ProgrammerError("Invalid dynamic params for drbd device %s"
1034
                                   % dyn_params)
1020 1035
    # check that the minor is unused
1021
    aminor = unique_id[4]
1036
    aminor = dyn_params[constants.DDP_LOCAL_MINOR]
1022 1037

  
1023 1038
    info = DRBD8.GetProcInfo()
1024 1039
    if info.HasMinorStatus(aminor):
......
1036 1051
                      aminor, meta)
1037 1052
    cls._CheckMetaSize(meta.dev_path)
1038 1053
    cls._InitMeta(aminor, meta.dev_path)
1039
    return cls(unique_id, children, size, params)
1054
    return cls(unique_id, children, size, params, dyn_params)
1040 1055

  
1041 1056

  
1042 1057
def _CanReadDevice(path):

Also available in: Unified diff