Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

145

146

147

148

149

150

151

152

153

154

155

156

157

158

159

160

161

162

163

164

165

166

167

168

169

170

171

172

173

174

175

176

177

178

179

180

181

182

183

184

185

186

187

188

189

190

191

192

193

194

195

196

197

198

199

200

201

202

203

204

205

206

207

208

209

210

211

212

213

214

215

216

217

218

219

220

221

222

223

224

225

226

227

228

229

230

231

232

233

234

235

236

237

238

239

240

241

242

243

244

245

246

247

248

249

250

251

252

253

254

255

256

257

258

259

260

261

262

263

264

265

266

267

268

269

270

271

272

273

274

275

276

277

278

279

280

281

282

283

284

285

286

287

288

289

290

291

292

293

294

295

296

297

298

299

300

301

302

303

304

305

306

307

308

309

310

311

312

313

314

315

316

317

318

319

320

321

322

323

324

325

326

327

328

329

330

331

332

333

334

335

336

337

338

339

340

341

342

343

344

345

346

347

348

349

350

351

352

353

354

355

356

357

358

359

360

361

362

363

364

365

366

367

368

369

370

371

372

373

374

375

376

377

378

379

380

381

382

383

384

385

386

387

388

389

390

391

392

393

394

395

396

397

398

399

400

401

402

403

404

405

406

407

408

409

410

411

412

413

414

415

416

417

418

419

420

421

422

423

424

425

426

427

428

429

430

431

432

433

434

435

436

437

438

439

440

441

442

443

444

445

446

447

448

449

450

451

452

453

454

455

456

457

458

459

460

461

462

463

464

465

466

467

468

469

470

471

472

473

474

475

476

477

478

479

480

481

482

483

484

485

486

487

488

489

490

491

492

493

494

495

496

497

498

499

500

501

502

503

504

505

506

507

508

509

510

511

512

513

514

515

516

517

518

519

520

521

522

523

524

525

526

527

528

529

530

531

532

533

534

535

536

537

538

539

540

541

542

543

544

545

546

547

548

549

550

551

552

553

554

555

556

557

558

559

560

561

562

563

564

565

566

567

568

569

570

571

572

573

574

575

576

577

578

579

580

581

582

583

584

585

586

587

588

589

590

591

592

593

594

595

596

597

598

599

600

601

602

603

604

605

606

607

608

609

610

611

612

613

614

615

616

617

618

619

620

621

622

623

624

625

626

627

628

629

630

631

632

633

634

635

636

637

638

639

640

641

642

643

644

645

646

#!/usr/bin/python 

# 

# Copyright (C) Citrix Systems Inc. 

# 

# This program is free software; you can redistribute it and/or modify  

# it under the terms of the GNU Lesser General Public License as published  

# by the Free Software Foundation; version 2.1 only. 

# 

# This program is distributed in the hope that it will be useful,  

# but WITHOUT ANY WARRANTY; without even the implied warranty of  

# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the  

# GNU Lesser General Public License for more details. 

# 

# You should have received a copy of the GNU Lesser General Public License 

# along with this program; if not, write to the Free Software Foundation, Inc., 

# 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA 

# 

# SR: Base class for storage repositories 

# 

 

import VDI 

import xml.dom.minidom 

import errno 

import xs_errors 

import XenAPI, xmlrpclib, util 

import copy, os 

import traceback 

 

MOUNT_BASE = '/var/run/sr-mount' 

DEFAULT_TAP = 'vhd' 

TAPDISK_UTIL = '/usr/sbin/td-util' 

MASTER_LVM_CONF = '/etc/lvm/master' 

 

# LUN per VDI key for XenCenter 

LUNPERVDI = "LUNperVDI" 

 

class SRException(Exception): 

    """Exception raised by storage repository operations""" 

    errno = errno.EINVAL 

    def __init__(self, reason): 

        Exception.__init__(self, reason) 

 

    def toxml(self): 

        return xmlrpclib.dumps(xmlrpclib.Fault(int(self.errno), str(self)), "", True) 

 

class SROSError(SRException): 

    """Wrapper for OSError""" 

    def __init__(self, errno, reason): 

        self.errno = errno 

        Exception.__init__(self, reason) 

 

 

def deviceCheck(op): 

    def wrapper(self, *args): 

        if 'device' not in self.dconf: 

            raise xs_errors.XenError('ConfigDeviceMissing') 

        return op(self, *args) 

    return wrapper 

 

 

backends = [] 

def registerSR(SRClass): 

    """Register SR with handler. All SR subclasses should call this in  

       the module file 

    """ 

    backends.append(SRClass) 

 

def driver(type): 

    """Find the SR for the given dconf string""" 

    for d in backends: 

        if d.handles(type): 

            return d 

    raise xs_errors.XenError('SRUnknownType') 

 

class SR(object): 

    """Semi-abstract storage repository object. 

 

    Attributes: 

      uuid: string, UUID 

      label: string 

      description: string 

      vdis: dictionary, VDI objects indexed by UUID 

      physical_utilisation: int, bytes consumed by VDIs 

      virtual_allocation: int, bytes allocated to this repository (virtual) 

      physical_size: int, bytes consumed by this repository 

      sr_vditype: string, repository type 

    """ 

    def handles(type): 

        """Returns True if this SR class understands the given dconf string""" 

        return False 

    handles = staticmethod(handles) 

 

    def __init__(self, srcmd, sr_uuid): 

        """Base class initializer. All subclasses should call SR.__init__  

           in their own 

        initializers. 

 

        Arguments: 

          srcmd: SRCommand instance, contains parsed arguments 

        """ 

        try: 

            self.srcmd = srcmd 

            self.dconf = srcmd.dconf 

            if srcmd.params.has_key('session_ref'): 

                self.session_ref = srcmd.params['session_ref'] 

                self.session = XenAPI.xapi_local() 

                self.session._session = self.session_ref 

109                if 'subtask_of' in self.srcmd.params: 

                    self.session.transport.add_extra_header('Subtask-of', self.srcmd.params['subtask_of']) 

            else: 

                self.session = None 

 

116            if 'host_ref' not in self.srcmd.params: 

                self.host_ref = "" 

            else: 

                self.host_ref = self.srcmd.params['host_ref'] 

 

            self.sr_ref = self.srcmd.params.get('sr_ref') 

 

            if 'device_config' in self.srcmd.params: 

122                if self.dconf.get("SRmaster") == "true": 

                    os.environ['LVM_SYSTEM_DIR'] = MASTER_LVM_CONF 

 

            if 'device_config' in self.srcmd.params: 

126                if self.srcmd.params['device_config'].has_key('SCSIid'): 

                    dev_path = '/dev/disk/by-scsid/'+self.srcmd.params['device_config']['SCSIid'] 

                    os.environ['LVM_DEVICE'] = dev_path 

                    util.SMlog('Setting LVM_DEVICE to %s' % dev_path) 

 

        except TypeError: 

            raise Exception(traceback.format_exc()) 

        except Exception, e: 

            raise e 

            raise xs_errors.XenError('SRBadXML') 

 

        self.uuid = sr_uuid 

 

        self.label = '' 

        self.description = '' 

        self.cmd = srcmd.params['command'] 

        self.vdis = {} 

        self.physical_utilisation = 0 

        self.virtual_allocation = 0 

        self.physical_size = 0 

        self.sr_vditype = '' 

        self.passthrough = False 

        # XXX: if this is really needed then we must make a deep copy 

        self.original_srcmd = copy.deepcopy(self.srcmd) 

        self.default_vdi_visibility = True 

        self.sched = 'noop' 

        self._mpathinit() 

        self.direct = False 

        self.ops_exclusive = [] 

        self.driver_config = {} 

 

        self.load(sr_uuid) 

        self.checkroot() 

 

    @staticmethod 

    def from_uuid(session, sr_uuid): 

        import imp 

 

        _SR = session.xenapi.SR 

        sr_ref = _SR.get_by_uuid(sr_uuid) 

        sm_type = _SR.get_type(sr_ref) 

 

        # NB. load the SM driver module 

 

        _SM = session.xenapi.SM 

        sms = _SM.get_all_records_where('field "type" = "%s"' % sm_type) 

        sm_ref, sm = sms.popitem() 

        assert not sms 

 

        driver_path = _SM.get_driver_filename(sm_ref) 

        driver_real = os.path.realpath(driver_path) 

        module_name = os.path.basename(driver_path) 

 

        module = imp.load_source(module_name, driver_real) 

        target = driver(sm_type) 

 

        # NB. get the host pbd's device_config 

 

        host_ref = util.get_localhost_uuid(session) 

 

        _PBD = session.xenapi.PBD 

        pbds = _PBD.get_all_records_where('field "SR" = "%s" and' % sr_ref + 

                                          'field "host" = "%s"' % host_ref) 

        pbd_ref, pbd = pbds.popitem() 

        assert not pbds 

 

        device_config = _PBD.get_device_config(pbd_ref) 

 

        # NB. make srcmd, to please our supersized SR constructor. 

        # FIXME 

 

        from SRCommand import SRCommand 

        cmd = SRCommand(module.DRIVER_INFO) 

        cmd.dconf  = device_config 

        cmd.params = { 'session_ref'    : session._session, 

                       'host_ref'       : host_ref, 

                       'device_config'  : device_config, 

                       'sr_ref'         : sr_ref, 

                       'sr_uuid'        : sr_uuid, 

                       'command'        : 'nop' } 

 

        return target(cmd, sr_uuid) 

 

    def block_setscheduler(self, dev): 

        try: 

            realdev = os.path.realpath(dev) 

            disk    = util.diskFromPartition(realdev) 

 

            # the normal case: the sr default scheduler (typically noop), 

            # potentially overridden by SR.other_config:scheduler 

            other_config = self.session.xenapi.SR.get_other_config(self.sr_ref) 

            sched = other_config.get('scheduler') 

            if not sched: 

                sched = self.sched 

 

            # special case: CFQ if the underlying disk holds dom0's file systems. 

            if disk in util.dom0_disks(): 

                sched = 'cfq' 

 

            util.SMlog("Block scheduler: %s (%s) wants %s" % (dev, disk, sched)) 

            util.set_scheduler(realdev[5:], sched) 

 

        except Exception, e: 

            util.SMlog("Failed to set block scheduler on %s: %s" % (dev, e)) 

 

    def _addLUNperVDIkey(self): 

        try: 

            self.session.xenapi.SR.add_to_sm_config(self.sr_ref, LUNPERVDI, "true") 

        except: 

            pass 

 

    def create(self, uuid, size): 

        """Create this repository. 

        This operation may delete existing data. 

 

        The operation is NOT idempotent. The operation will fail 

        if an SR of the same UUID and driver type already exits. 

 

        Returns: 

          None 

        Raises: 

          SRUnimplementedMethod 

        """ 

        raise xs_errors.XenError('Unimplemented') 

 

    def delete(self, uuid): 

        """Delete this repository and its contents. 

 

        This operation IS idempotent -- it will succeed if the repository 

        exists and can be deleted or if the repository does not exist. 

        The caller must ensure that all VDIs are deactivated and detached 

        and that the SR itself has been detached before delete().  

        The call will FAIL if any VDIs in the SR are in use. 

 

        Returns: 

          None 

        Raises: 

          SRUnimplementedMethod 

        """ 

        raise xs_errors.XenError('Unimplemented') 

 

    def update(self, uuid): 

        """Refresh the fields in the SR object 

 

        Returns: 

          None 

        Raises: 

          SRUnimplementedMethod 

        """ 

        # no-op unless individual backends implement it 

        return 

 

    def attach(self, uuid): 

        """Initiate local access to the SR. Initialises any  

        device state required to access the substrate. 

 

        Idempotent. 

 

        Returns: 

          None 

        Raises: 

          SRUnimplementedMethod 

        """ 

        raise xs_errors.XenError('Unimplemented') 

 

    def after_master_attach(self, uuid): 

        """Perform actions required after attaching on the pool master 

        Return: 

          None 

        """ 

        try: 

            self.scan(uuid) 

        except Exception as e: 

            util.SMlog("Error in SR.after_master_attach %s" % e) 

            msg_name = "POST_ATTACH_SCAN_FAILED" 

            msg_body = "Failed to scan SR %s after attaching, " \ 

                "error %s" % (uuid, e) 

            self.session.xenapi.message.create( 

                msg_name, 2, "SR", uuid, msg_body) 

 

    def detach(self, uuid): 

        """Remove local access to the SR. Destroys any device  

        state initiated by the sr_attach() operation. 

 

        Idempotent. All VDIs must be detached in order for the operation 

        to succeed. 

 

        Returns: 

          None 

        Raises: 

          SRUnimplementedMethod 

        """ 

        raise xs_errors.XenError('Unimplemented') 

 

    def probe(self): 

        """Perform a backend-specific scan, using the current dconf.  If the 

        dconf is complete, then this will return a list of the SRs present of 

        this type on the device, if any.  If the dconf is partial, then a 

        backend-specific scan will be performed, returning results that will 

        guide the user in improving the dconf. 

 

        Idempotent. 

 

        xapi will ensure that this is serialised wrt any other probes, or 

        attach or detach operations on this host. 

 

        Returns: 

          An XML fragment containing the scan results.  These are specific 

          to the scan being performed, and the current backend. 

        Raises: 

          SRUnimplementedMethod 

        """ 

        raise xs_errors.XenError('Unimplemented') 

 

    def scan(self, uuid): 

        """ 

        Returns: 

        """ 

        # Update SR parameters 

        self._db_update() 

        # Synchronise VDI list 

        scanrecord = ScanRecord(self) 

        scanrecord.synchronise() 

 

    def replay(self, uuid): 

        """Replay a multi-stage log entry 

 

        Returns: 

          None 

        Raises: 

          SRUnimplementedMethod 

        """ 

        raise xs_errors.XenError('Unimplemented') 

 

    def content_type(self, uuid): 

        """Returns the 'content_type' of an SR as a string""" 

        return xmlrpclib.dumps((str(self.sr_vditype),), "", True) 

 

    def load(self, sr_uuid): 

        """Post-init hook""" 

        pass 

 

    def vdi(self, uuid): 

        """Return VDI object owned by this repository""" 

        if not self.vdis.has_key(uuid): 

            self.vdis[uuid] = VDI.VDI(self, uuid) 

        raise xs_errors.XenError('Unimplemented') 

        return self.vdis[uuid] 

 

    def forget_vdi(self, uuid): 

        vdi = self.session.xenapi.VDI.get_by_uuid(uuid) 

        self.session.xenapi.VDI.db_forget(vdi) 

 

    def cleanup(self): 

        # callback after the op is done 

        pass 

 

    def _db_update(self): 

        sr = self.session.xenapi.SR.get_by_uuid(self.uuid) 

        self.session.xenapi.SR.set_virtual_allocation(sr, str(self.virtual_allocation)) 

        self.session.xenapi.SR.set_physical_size(sr, str(self.physical_size)) 

        self.session.xenapi.SR.set_physical_utilisation(sr, str(self.physical_utilisation)) 

 

    def _toxml(self): 

        dom = xml.dom.minidom.Document() 

        element = dom.createElement("sr") 

        dom.appendChild(element) 

 

        #Add default uuid, physical_utilisation, physical_size and  

        # virtual_allocation entries 

        for attr in ('uuid', 'physical_utilisation', 'virtual_allocation', \ 

                     'physical_size'): 

            try: 

                aval = getattr(self, attr) 

            except AttributeError: 

                raise xs_errors.XenError('InvalidArg', \ 

                      opterr='Missing required field [%s]' % attr) 

 

            entry = dom.createElement(attr) 

            element.appendChild(entry) 

            textnode = dom.createTextNode(str(aval)) 

            entry.appendChild(textnode) 

 

        #Add the default_vdi_visibility entry 

        entry = dom.createElement('default_vdi_visibility') 

        element.appendChild(entry) 

        if not self.default_vdi_visibility: 

            textnode = dom.createTextNode('False') 

        else: 

            textnode = dom.createTextNode('True') 

        entry.appendChild(textnode) 

 

        #Add optional label and description entries 

        for attr in ('label', 'description'): 

            try: 

                aval = getattr(self, attr) 

            except AttributeError: 

                continue 

            if aval: 

                entry = dom.createElement(attr) 

                element.appendChild(entry) 

                textnode = dom.createTextNode(str(aval)) 

                entry.appendChild(textnode) 

 

        # Create VDI sub-list 

        if self.vdis: 

            for uuid in self.vdis: 

                if not self.vdis[uuid].deleted: 

                    vdinode = dom.createElement("vdi") 

                    element.appendChild(vdinode) 

                    self.vdis[uuid]._toxml(dom, vdinode) 

 

        return dom 

 

    def _fromxml(self, str, tag): 

        dom = xml.dom.minidom.parseString(str) 

        objectlist = dom.getElementsByTagName(tag)[0] 

        taglist = {} 

        for node in objectlist.childNodes: 

            taglist[node.nodeName] = "" 

            for n in node.childNodes: 

                if n.nodeType == n.TEXT_NODE: 

                    taglist[node.nodeName] += n.data 

        return taglist 

 

    def _isvalidpathstring(self, path): 

452        if not path.startswith("/"): 

            return False 

        l = self._splitstring(path) 

        for char in l: 

            if char.isalpha(): 

                continue 

458            elif char.isdigit(): 

                continue 

462            elif char in ['/','-','_','.',':']: 

                continue 

            else: 

                return False 

        return True 

 

    def _splitstring(self, str): 

        elementlist = [] 

        for i in range(0, len(str)): 

            elementlist.append(str[i]) 

        return elementlist 

 

    def _mpathinit(self): 

        self.mpath = "false" 

        try: 

476            if self.dconf.has_key('multipathing') and \ 

                   self.dconf.has_key('multipathhandle'): 

                self.mpath = self.dconf['multipathing'] 

                self.mpathhandle = self.dconf['multipathhandle'] 

            else: 

                hconf = self.session.xenapi.host.get_other_config(self.host_ref) 

                self.mpath = hconf['multipathing'] 

                self.mpathhandle = hconf['multipathhandle'] 

 

487            if self.mpath != "true": 

                self.mpath = "false" 

                self.mpathhandle = "null" 

 

492            if not os.path.exists("/opt/xensource/sm/mpath_%s.py" % self.mpathhandle): 

                raise IOError("File does not exist = %s" % self.mpathhandle) 

        except: 

            self.mpath = "false" 

            self.mpathhandle = "null" 

        module_name = "mpath_%s" % self.mpathhandle 

        self.mpathmodule = __import__(module_name) 

 

    def _mpathHandle(self): 

        if self.mpath == "true": 

            self.mpathmodule.activate() 

        else: 

            self.mpathmodule.deactivate() 

 

    def checkroot(self): 

        if 'device' in self.dconf: 

            self.root = self.dconf['device'] 

exit            if self.root: 

                for dev in self.root.split(','): 

507                    if not self._isvalidpathstring(dev): 

                        raise xs_errors.XenError('ConfigDeviceInvalid', \ 

                              opterr='path is %s' % dev) 

 

    def _pathrefresh(self, obj): 

        SCSIid = getattr(self, 'SCSIid') 

        self.dconf['device'] = self.mpathmodule.path(SCSIid) 

        self.checkroot() 

        super(obj, self).load(self.uuid) 

 

    def _setMultipathableFlag(self, SCSIid=''): 

        try: 

            sm_config = self.session.xenapi.SR.get_sm_config(self.sr_ref) 

            sm_config['multipathable'] = 'true' 

            self.session.xenapi.SR.set_sm_config(self.sr_ref, sm_config) 

 

            if self.mpath == "true" and len(SCSIid): 

                cmd = ['/opt/xensource/sm/mpathcount.py',SCSIid] 

                util.pread2(cmd) 

        except: 

            pass 

 

    def check_dconf(self, key_list, raise_flag=True): 

        """ Checks if all keys in 'key_list' exist in 'self.dconf'. 

 

            Input: 

                key_list:   a list of keys to check if they exist in self.dconf 

                raise_flag: if true, raise an exception if there are 1 or more 

                            keys missing 

 

            Return: set() containing the missing keys (empty set() if all exist) 

            Raise: xs_errors.XenError('ConfigParamsMissing') 

        """ 

 

        missing_keys = {key for key in key_list if not self.dconf.has_key(key)} 

 

        if missing_keys and raise_flag: 

            errstr = 'device-config is missing the following parameters: ' + \ 

                     ', '.join([key for key in missing_keys]) 

            raise xs_errors.XenError('ConfigParamsMissing', opterr=errstr) 

 

        return missing_keys 

 

 

class ScanRecord: 

    def __init__(self, sr): 

        self.sr = sr 

        self.__xenapi_locations = {} 

        self.__xenapi_records = util.list_VDI_records_in_sr(sr) 

        for vdi in self.__xenapi_records.keys(): 

            self.__xenapi_locations[util.to_plain_string(self.__xenapi_records[vdi]['location'])] = vdi 

        self.__sm_records = {} 

        for vdi in sr.vdis.values(): 

            # We initialise the sm_config field with the values from the database 

            # The sm_config_overrides contains any new fields we want to add to 

            # sm_config, and also any field to delete (by virtue of having  

            # sm_config_overrides[key]=None) 

            try: 

                if not hasattr(vdi, "sm_config"): 

                    vdi.sm_config = self.__xenapi_records[self.__xenapi_locations[vdi.location]]['sm_config'].copy() 

            except: 

                util.SMlog("missing config for vdi: %s" % vdi.location) 

                vdi.sm_config = {} 

 

            vdi._override_sm_config(vdi.sm_config) 

 

            self.__sm_records[vdi.location] = vdi 

 

        xenapi_locations = set(self.__xenapi_locations.keys()) 

        sm_locations = set(self.__sm_records.keys()) 

 

        # These ones are new on disk 

        self.new = sm_locations.difference(xenapi_locations) 

        # These have disappeared from the disk 

        self.gone = xenapi_locations.difference(sm_locations) 

        # These are the ones which are still present but might have changed... 

        existing = sm_locations.intersection(xenapi_locations) 

        # Synchronise the uuid fields using the location as the primary key 

        # This ensures we know what the UUIDs are even though they aren't stored 

        # in the storage backend. 

        for location in existing: 

            sm_vdi = self.get_sm_vdi(location) 

            xenapi_vdi = self.get_xenapi_vdi(location) 

            sm_vdi.uuid = util.default(sm_vdi, "uuid", lambda: xenapi_vdi['uuid']) 

 

        # Only consider those whose configuration looks different 

        self.existing = filter(lambda x:not(self.get_sm_vdi(x).in_sync_with_xenapi_record(self.get_xenapi_vdi(x))), existing) 

 

        if len(self.new) <> 0: 

            util.SMlog("new VDIs on disk: " + repr(self.new)) 

        if len(self.gone) <> 0: 

            util.SMlog("VDIs missing from disk: " + repr(self.gone)) 

        if len(self.existing) <> 0: 

            util.SMlog("VDIs changed on disk: " + repr(self.existing)) 

 

    def get_sm_vdi(self, location): 

        return self.__sm_records[location] 

 

    def get_xenapi_vdi(self, location): 

        return self.__xenapi_records[self.__xenapi_locations[location]] 

 

    def all_xenapi_locations(self): 

        return set(self.__xenapi_locations.keys()) 

 

    def synchronise_new(self): 

        """Add XenAPI records for new disks""" 

        for location in self.new: 

            vdi = self.get_sm_vdi(location) 

            util.SMlog("Introducing VDI with location=%s" % (vdi.location)) 

            vdi._db_introduce() 

 

    def synchronise_gone(self): 

        """Delete XenAPI record for old disks""" 

        for location in self.gone: 

            vdi = self.get_xenapi_vdi(location) 

            util.SMlog("Forgetting VDI with location=%s uuid=%s" % (util.to_plain_string(vdi['location']), vdi['uuid'])) 

            try: 

                self.sr.forget_vdi(vdi['uuid']) 

            except XenAPI.Failure, e: 

                if util.isInvalidVDI(e): 

                   util.SMlog("VDI %s not found, ignoring exception" \ 

                           % vdi['uuid']) 

                else: 

                   raise 

 

    def synchronise_existing(self): 

        """Update existing XenAPI records""" 

        for location in self.existing: 

            vdi = self.get_sm_vdi(location) 

 

            util.SMlog("Updating VDI with location=%s uuid=%s" % (vdi.location, vdi.uuid)) 

            vdi._db_update() 

 

    def synchronise(self): 

        """Perform the default SM -> xenapi synchronisation; ought to be good enough 

        for most plugins.""" 

        self.synchronise_new() 

        self.synchronise_gone() 

        self.synchronise_existing()